DarkflameServer/dGame/dComponents/RailActivatorComponent.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

146 lines
3.0 KiB
C
Raw Permalink Normal View History

#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;
2022-07-28 13:39:57 +00:00
feat: Add isolated and simplified path to add components (#1204) * 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>
2023-10-23 01:08:49 +00:00
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RAIL_ACTIVATOR;
2022-07-28 13:39:57 +00:00
/**
* Handles the OnUse event from some entity, initiates the rail movement
* @param originator the entity that triggered the event
*/
void OnUse(Entity* originator) override;
2022-07-28 13:39:57 +00:00
/**
* 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;
2022-07-28 13:39:57 +00:00
/**
* 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;
2022-07-28 13:39:57 +00:00
/**
* The entities that are currently traversing the rail
*/
std::vector<LWOOBJID> m_EntitiesOnRail{};
2022-07-28 13:39:57 +00:00
/**
* The path the entities will follow when traversing the rail
*/
std::u16string m_Path;
2022-07-28 13:39:57 +00:00
/**
* The index of the path that is the start
*/
uint32_t m_PathStart;
2022-07-28 13:39:57 +00:00
/**
* The direction on the path
*/
bool m_PathDirection;
2022-07-28 13:39:57 +00:00
/**
* The animation that plays when starting the rail
*/
std::u16string m_StartAnimation;
2022-07-28 13:39:57 +00:00
/**
* The animation that plays during the rail
*/
std::u16string m_LoopAnimation;
2022-07-28 13:39:57 +00:00
/**
* The animation that plays after the rail
*/
std::u16string m_StopAnimation;
2022-07-28 13:39:57 +00:00
/**
* The sound that plays at the start of the rail
*/
std::u16string m_StartSound;
2022-07-28 13:39:57 +00:00
/**
* The sound that plays during the rail
*/
std::u16string m_loopSound;
2022-07-28 13:39:57 +00:00
/**
* The sound that plays at the end of the rail
*/
std::u16string m_StopSound;
2022-07-28 13:39:57 +00:00
/**
* The effects that play at the start of the rail
*/
std::pair<uint32_t, std::u16string> m_StartEffect;
2022-07-28 13:39:57 +00:00
/**
* The effects that play during the rail
*/
std::pair<uint32_t, std::u16string> m_LoopEffect;
2022-07-28 13:39:57 +00:00
/**
* The effects that play at the end of the rail
*/
std::pair<uint32_t, std::u16string> m_StopEffect;
2022-07-28 13:39:57 +00:00
/**
* Client flag
*/
bool m_DamageImmune;
2022-07-28 13:39:57 +00:00
/**
* Client flag
*/
bool m_NoAggro;
2022-07-28 13:39:57 +00:00
/**
* Client flag
*/
bool m_UseDB;
2022-07-28 13:39:57 +00:00
/**
* Client flag
*/
bool m_CameraLocked;
2022-07-28 13:39:57 +00:00
/**
* Client flag
*/
bool m_CollisionEnabled;
2022-07-28 13:39:57 +00:00
/**
* Client flag, notifies the server when the player finished the rail
*/
bool m_NotifyArrived;
2022-07-28 13:39:57 +00:00
/**
* Client flag
*/
bool m_ShowNameBillboard;
};