mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-27 16:07:22 +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>
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "Entity.h"
|
|
#include "Component.h"
|
|
#include "eReplicaComponentType.h"
|
|
|
|
/**
|
|
* Component that handles player forced movement
|
|
*
|
|
*/
|
|
class PlayerForcedMovementComponent : public Component {
|
|
public:
|
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PLAYER_FORCED_MOVEMENT;
|
|
|
|
/**
|
|
* Constructor for this component
|
|
* @param parent parent that contains this component
|
|
*/
|
|
PlayerForcedMovementComponent(Entity* parent);
|
|
~PlayerForcedMovementComponent() override;
|
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
|
|
|
/**
|
|
* @brief Set the Player On Rail object
|
|
*
|
|
* @param value if the player is on a rail
|
|
*/
|
|
void SetPlayerOnRail(bool value) { m_PlayerOnRail = value; m_DirtyInfo = true; }
|
|
|
|
/**
|
|
* @brief Set the Show Billboard object
|
|
*
|
|
* @param value if the billboard should be shown
|
|
*/
|
|
void SetShowBillboard(bool value) { m_ShowBillboard = value; m_DirtyInfo = true; }
|
|
|
|
/**
|
|
* @brief Get the Player On Rail object
|
|
*
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
|
|
/**
|
|
* @brief Get the Player On Rail object
|
|
*
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
bool GetPlayerOnRail() { return m_PlayerOnRail; }
|
|
bool GetShowBillboard() { return m_ShowBillboard; }
|
|
|
|
private:
|
|
/**
|
|
* whether the info is dirty
|
|
*/
|
|
bool m_DirtyInfo = false;
|
|
|
|
/**
|
|
* whether the player is on a rail
|
|
*/
|
|
bool m_PlayerOnRail = false;
|
|
|
|
/**
|
|
* whether the billboard should be showing
|
|
*/
|
|
bool m_ShowBillboard = false;
|
|
|
|
};
|