mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-26 23:43:34 +00:00
ae349d6b15
* Components: Make ComponentType inline Prevents the next commits ODR violation * Components: Add new components * Entity: Add headers inline script component ComponentType * Components: Flip constructor argument order Entity comes first always * Entity: Add generic AddComponent Allows for much easier adding of components and is error proof by not allowing the user to add more than 1 of a specific component type to an Entity. * Entity: Migrate all component constructors Move all to the new variadic templates AddComponent function to reduce clutter and ways the component map is modified. The new function makes no assumptions. Component is assumed to not exist and is checked for with operator[]. This will construct a null component which will then be newed if the component didnt exist, or it will just get the current component if it does already exist. No new component will be allocated or constructed if the component already exists and the already existing pointer is returned instead. * Entity: Add placement new For the case where the component may already exist, use a placement new to construct the component again, it would be constructed again, but would not need to go through the allocator. * Entity: Add comments on likely new code * Tests: Fix tests * Update Entity.cpp * Update SGCannon.cpp * Entity: call destructor when re-constructing * Update Entity.cpp Update Entity.cpp --------- Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
146 lines
3.0 KiB
C++
146 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include "dCommonVars.h"
|
|
#include "Component.h"
|
|
#include "eReplicaComponentType.h"
|
|
|
|
/**
|
|
* Component that handles the traveling using rails, e.g. the ninjago posts that can be used to travel using Spinjitzu.
|
|
* Credits to https://github.com/UchuServer/Uchu/blob/dev/Uchu.World/Objects/Components/ReplicaComponents/RailActivatorComponent.cs
|
|
*/
|
|
class RailActivatorComponent final : public Component {
|
|
public:
|
|
explicit RailActivatorComponent(Entity* parent, int32_t componentID);
|
|
~RailActivatorComponent() override;
|
|
|
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RAIL_ACTIVATOR;
|
|
|
|
/**
|
|
* Handles the OnUse event from some entity, initiates the rail movement
|
|
* @param originator the entity that triggered the event
|
|
*/
|
|
void OnUse(Entity* originator) override;
|
|
|
|
/**
|
|
* Event handler that's called when some entity has played the start animation for rail movement and now wants to
|
|
* start the actual movement.
|
|
* @param originator the entity that triggered the event
|
|
*/
|
|
void OnRailMovementReady(Entity* originator) const;
|
|
|
|
/**
|
|
* Event handler that's called when some entity has finished traversing the rail and wants to end its interaction
|
|
* with it
|
|
* @param originator the entity that triggered the event
|
|
*/
|
|
void OnCancelRailMovement(Entity* originator);
|
|
private:
|
|
|
|
/**
|
|
* The ID of this component in the components database
|
|
*/
|
|
int32_t m_ComponentID;
|
|
|
|
/**
|
|
* The entities that are currently traversing the rail
|
|
*/
|
|
std::vector<LWOOBJID> m_EntitiesOnRail{};
|
|
|
|
/**
|
|
* The path the entities will follow when traversing the rail
|
|
*/
|
|
std::u16string m_Path;
|
|
|
|
/**
|
|
* The index of the path that is the start
|
|
*/
|
|
uint32_t m_PathStart;
|
|
|
|
/**
|
|
* The direction on the path
|
|
*/
|
|
bool m_PathDirection;
|
|
|
|
/**
|
|
* The animation that plays when starting the rail
|
|
*/
|
|
std::u16string m_StartAnimation;
|
|
|
|
/**
|
|
* The animation that plays during the rail
|
|
*/
|
|
std::u16string m_LoopAnimation;
|
|
|
|
/**
|
|
* The animation that plays after the rail
|
|
*/
|
|
std::u16string m_StopAnimation;
|
|
|
|
/**
|
|
* The sound that plays at the start of the rail
|
|
*/
|
|
std::u16string m_StartSound;
|
|
|
|
/**
|
|
* The sound that plays during the rail
|
|
*/
|
|
std::u16string m_loopSound;
|
|
|
|
/**
|
|
* The sound that plays at the end of the rail
|
|
*/
|
|
std::u16string m_StopSound;
|
|
|
|
/**
|
|
* The effects that play at the start of the rail
|
|
*/
|
|
std::pair<uint32_t, std::u16string> m_StartEffect;
|
|
|
|
/**
|
|
* The effects that play during the rail
|
|
*/
|
|
std::pair<uint32_t, std::u16string> m_LoopEffect;
|
|
|
|
/**
|
|
* The effects that play at the end of the rail
|
|
*/
|
|
std::pair<uint32_t, std::u16string> m_StopEffect;
|
|
|
|
/**
|
|
* Client flag
|
|
*/
|
|
bool m_DamageImmune;
|
|
|
|
/**
|
|
* Client flag
|
|
*/
|
|
bool m_NoAggro;
|
|
|
|
/**
|
|
* Client flag
|
|
*/
|
|
bool m_UseDB;
|
|
|
|
/**
|
|
* Client flag
|
|
*/
|
|
bool m_CameraLocked;
|
|
|
|
/**
|
|
* Client flag
|
|
*/
|
|
bool m_CollisionEnabled;
|
|
|
|
/**
|
|
* Client flag, notifies the server when the player finished the rail
|
|
*/
|
|
bool m_NotifyArrived;
|
|
|
|
/**
|
|
* Client flag
|
|
*/
|
|
bool m_ShowNameBillboard;
|
|
};
|