mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
Player forced movement component (#672)
* Split out Level progression component from Character Component This is to get to the Player forced movement Comp in a sane way * move XML to component insted of abusing charComp * use overrides should probably make everything that calls that call it correctly * fix linking issue * Add proper Player Force movement component Not used, yet
This commit is contained in:
parent
f2d1c5d26d
commit
b57cacc676
@ -407,7 +407,8 @@ enum eReplicaComponentType : int32_t {
|
||||
COMPONENT_TYPE_PROXIMITY_MONITOR = 78, //!< The Proximity Monitor Component
|
||||
COMPONENT_TYPE_MISSION = 84, //!< The Mission Component
|
||||
COMPONENT_TYPE_ROCKET_LAUNCH_LUP = 97, //!< The LUP Launchpad Componen
|
||||
COMPONENT_TYPE_RAIL_ACTIVATOR = 104,
|
||||
COMPONENT_TYPE_RAIL_ACTIVATOR = 104, //!< The Rail Activator Component
|
||||
COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT = 106, //!< The Player Forced Movement Component
|
||||
COMPONENT_TYPE_POSSESSABLE = 108, //!< The Possessable Component
|
||||
COMPONENT_TYPE_LEVEL_PROGRESSION = 109, //!< The Level Progression Component
|
||||
COMPONENT_TYPE_POSSESSOR = 110, //!< The Possessor Component
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "BouncerComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "PlayerForcedMovementComponent.h"
|
||||
#include "ScriptComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "SimplePhysicsComponent.h"
|
||||
@ -436,14 +437,8 @@ void Entity::Initialize()
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_DESTROYABLE, comp));
|
||||
}
|
||||
|
||||
/*if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_DESTROYABLE) > 0 || m_Character) {
|
||||
DestroyableComponent* comp = new DestroyableComponent();
|
||||
if (m_Character) comp->LoadFromXML(m_Character->GetXMLDoc());
|
||||
m_Components.push_back(std::make_pair(COMPONENT_TYPE_DESTROYABLE, comp));
|
||||
}*/
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_CHARACTER) > 0 || m_Character) {
|
||||
// Character Component always has a possessor and level components
|
||||
// Character Component always has a possessor, level, and forced movement components
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_POSSESSOR, new PossessorComponent(this)));
|
||||
|
||||
// load in the xml for the level
|
||||
@ -451,6 +446,8 @@ void Entity::Initialize()
|
||||
levelComp->LoadFromXml(m_Character->GetXMLDoc());
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_LEVEL_PROGRESSION, levelComp));
|
||||
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT, new PlayerForcedMovementComponent(this)));
|
||||
|
||||
CharacterComponent* comp = new CharacterComponent(this, m_Character);
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_CHARACTER, comp));
|
||||
}
|
||||
@ -1103,6 +1100,14 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
outBitStream->Write0();
|
||||
}
|
||||
|
||||
PlayerForcedMovementComponent* playerForcedMovementComponent;
|
||||
if (TryGetComponent(COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) {
|
||||
playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
} else {
|
||||
// Should never happen, but just to be safe
|
||||
outBitStream->Write0();
|
||||
}
|
||||
|
||||
characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp"
|
||||
"MovingPlatformComponent.cpp"
|
||||
"PetComponent.cpp"
|
||||
"PhantomPhysicsComponent.cpp"
|
||||
"PlayerForcedMovementComponent.cpp"
|
||||
"PossessableComponent.cpp"
|
||||
"PossessorComponent.cpp"
|
||||
"PropertyComponent.cpp"
|
||||
|
16
dGame/dComponents/PlayerForcedMovementComponent.cpp
Normal file
16
dGame/dComponents/PlayerForcedMovementComponent.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "PlayerForcedMovementComponent.h"
|
||||
|
||||
PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : Component(parent) {
|
||||
m_Parent = parent;
|
||||
}
|
||||
|
||||
PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {}
|
||||
|
||||
void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags){
|
||||
outBitStream->Write(m_DirtyInfo);
|
||||
if (m_DirtyInfo) {
|
||||
outBitStream->Write(m_PlayerOnRail);
|
||||
outBitStream->Write(m_ShowBillboard);
|
||||
}
|
||||
m_DirtyInfo = false;
|
||||
}
|
70
dGame/dComponents/PlayerForcedMovementComponent.h
Normal file
70
dGame/dComponents/PlayerForcedMovementComponent.h
Normal file
@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Component.h"
|
||||
|
||||
/**
|
||||
* Component that handles player forced movement
|
||||
*
|
||||
*/
|
||||
class PlayerForcedMovementComponent : public Component {
|
||||
public:
|
||||
static const uint32_t ComponentType = eReplicaComponentType::COMPONENT_TYPE_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, unsigned int& flags);
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user