diff --git a/dCommon/dCommonVars.h b/dCommon/dCommonVars.h index f6efdcf8..9f62eaa4 100644 --- a/dCommon/dCommonVars.h +++ b/dCommon/dCommonVars.h @@ -366,53 +366,54 @@ enum eNotifyType { }; enum eReplicaComponentType : int32_t { - COMPONENT_TYPE_CONTROLLABLE_PHYSICS = 1, //!< The ControllablePhysics Component - COMPONENT_TYPE_RENDER = 2, //!< The Render Component - COMPONENT_TYPE_SIMPLE_PHYSICS = 3, //!< The SimplePhysics Component - COMPONENT_TYPE_CHARACTER = 4, //!< The Character Component - COMPONENT_TYPE_SCRIPT = 5, //!< The Script Component - COMPONENT_TYPE_BOUNCER = 6, //!< The Bouncer Component - COMPONENT_TYPE_BUFF = 7, //!< The Buff Component - COMPONENT_TYPE_SKILL = 9, //!< The Skill Component - COMPONENT_TYPE_ITEM = 11, //!< The Item Component - COMPONENT_TYPE_VENDOR = 16, //!< The Vendor Component - COMPONENT_TYPE_INVENTORY = 17, //!< The Inventory Component - COMPONENT_TYPE_SHOOTING_GALLERY = 19, //!< The Shooting Gallery Component - COMPONENT_TYPE_RIGID_BODY_PHANTOM_PHYSICS = 20, //!< The RigidBodyPhantomPhysics Component - COMPONENT_TYPE_COLLECTIBLE = 23, //!< The Collectible Component - COMPONENT_TYPE_MOVING_PLATFORM = 25, //!< The MovingPlatform Component - COMPONENT_TYPE_PET = 26, //!< The Pet Component - COMPONENT_TYPE_VEHICLE_PHYSICS = 30, //!< The VehiclePhysics Component - COMPONENT_TYPE_MOVEMENT_AI = 31, //!< The MovementAI Component - COMPONENT_TYPE_PROPERTY = 36, //!< The Property Component - COMPONENT_TYPE_SCRIPTED_ACTIVITY = 39, //!< The ScriptedActivity Component - COMPONENT_TYPE_PHANTOM_PHYSICS = 40, //!< The PhantomPhysics Component - COMPONENT_TYPE_MODEL = 42, //!< The Model Component - COMPONENT_TYPE_PROPERTY_ENTRANCE = 43, //!< The PhantomPhysics Component - COMPONENT_TYPE_PROPERTY_MANAGEMENT = 45, //!< The PropertyManagement Component - COMPONENT_TYPE_REBUILD = 48, //!< The Rebuild Component - COMPONENT_TYPE_SWITCH = 49, //!< The Switch Component - COMPONENT_TYPE_ZONE_CONTROL = 50, //!< The ZoneControl Component - COMPONENT_TYPE_PACKAGE = 53, //!< The Package Component - COMPONENT_TYPE_PLAYER_FLAG = 58, //!< The PlayerFlag Component - COMPONENT_TYPE_BASE_COMBAT_AI = 60, //!< The BaseCombatAI Component - COMPONENT_TYPE_MODULE_ASSEMBLY = 61, //!< The ModuleAssembly Component - COMPONENT_TYPE_PROPERTY_VENDOR = 65, //!< The PropertyVendor Component - COMPONENT_TYPE_ROCKET_LAUNCH = 67, //!< The RocketLaunch Component - COMPONENT_TYPE_RACING_CONTROL = 71, //!< The RacingControl Component - COMPONENT_TYPE_MISSION_OFFER = 73, //!< The MissionOffer Component - COMPONENT_TYPE_EXHIBIT = 75, //!< The Exhibit Component - COMPONENT_TYPE_RACING_STATS = 74, //!< The Racing Stats Component - COMPONENT_TYPE_SOUND_TRIGGER = 77, //!< The Sound Trigger Component - 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_POSSESSABLE = 108, //!< The Possessable Component - COMPONENT_TYPE_LEVEL_PROGRESSION = 109, //!< The Level Progression Component - COMPONENT_TYPE_POSSESSOR = 110, //!< The Possessor Component - COMPONENT_TYPE_BUILD_BORDER = 114, //!< The Build Border Component - COMPONENT_TYPE_DESTROYABLE = 1000, //!< The Destroyable Component + COMPONENT_TYPE_CONTROLLABLE_PHYSICS = 1, //!< The ControllablePhysics Component + COMPONENT_TYPE_RENDER = 2, //!< The Render Component + COMPONENT_TYPE_SIMPLE_PHYSICS = 3, //!< The SimplePhysics Component + COMPONENT_TYPE_CHARACTER = 4, //!< The Character Component + COMPONENT_TYPE_SCRIPT = 5, //!< The Script Component + COMPONENT_TYPE_BOUNCER = 6, //!< The Bouncer Component + COMPONENT_TYPE_BUFF = 7, //!< The Buff Component + COMPONENT_TYPE_SKILL = 9, //!< The Skill Component + COMPONENT_TYPE_ITEM = 11, //!< The Item Component + COMPONENT_TYPE_VENDOR = 16, //!< The Vendor Component + COMPONENT_TYPE_INVENTORY = 17, //!< The Inventory Component + COMPONENT_TYPE_SHOOTING_GALLERY = 19, //!< The Shooting Gallery Component + COMPONENT_TYPE_RIGID_BODY_PHANTOM_PHYSICS = 20, //!< The RigidBodyPhantomPhysics Component + COMPONENT_TYPE_COLLECTIBLE = 23, //!< The Collectible Component + COMPONENT_TYPE_MOVING_PLATFORM = 25, //!< The MovingPlatform Component + COMPONENT_TYPE_PET = 26, //!< The Pet Component + COMPONENT_TYPE_VEHICLE_PHYSICS = 30, //!< The VehiclePhysics Component + COMPONENT_TYPE_MOVEMENT_AI = 31, //!< The MovementAI Component + COMPONENT_TYPE_PROPERTY = 36, //!< The Property Component + COMPONENT_TYPE_SCRIPTED_ACTIVITY = 39, //!< The ScriptedActivity Component + COMPONENT_TYPE_PHANTOM_PHYSICS = 40, //!< The PhantomPhysics Component + COMPONENT_TYPE_MODEL = 42, //!< The Model Component + COMPONENT_TYPE_PROPERTY_ENTRANCE = 43, //!< The PhantomPhysics Component + COMPONENT_TYPE_PROPERTY_MANAGEMENT = 45, //!< The PropertyManagement Component + COMPONENT_TYPE_REBUILD = 48, //!< The Rebuild Component + COMPONENT_TYPE_SWITCH = 49, //!< The Switch Component + COMPONENT_TYPE_ZONE_CONTROL = 50, //!< The ZoneControl Component + COMPONENT_TYPE_PACKAGE = 53, //!< The Package Component + COMPONENT_TYPE_PLAYER_FLAG = 58, //!< The PlayerFlag Component + COMPONENT_TYPE_BASE_COMBAT_AI = 60, //!< The BaseCombatAI Component + COMPONENT_TYPE_MODULE_ASSEMBLY = 61, //!< The ModuleAssembly Component + COMPONENT_TYPE_PROPERTY_VENDOR = 65, //!< The PropertyVendor Component + COMPONENT_TYPE_ROCKET_LAUNCH = 67, //!< The RocketLaunch Component + COMPONENT_TYPE_RACING_CONTROL = 71, //!< The RacingControl Component + COMPONENT_TYPE_MISSION_OFFER = 73, //!< The MissionOffer Component + COMPONENT_TYPE_EXHIBIT = 75, //!< The Exhibit Component + COMPONENT_TYPE_RACING_STATS = 74, //!< The Racing Stats Component + COMPONENT_TYPE_SOUND_TRIGGER = 77, //!< The Sound Trigger Component + 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, //!< 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 + COMPONENT_TYPE_BUILD_BORDER = 114, //!< The Build Border Component + COMPONENT_TYPE_DESTROYABLE = 1000, //!< The Destroyable Component }; enum class UseItemResponse : uint32_t { diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 45287bd8..32fa7d5b 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -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); } diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index ebf93dde..0995428b 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -17,6 +17,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "MovingPlatformComponent.cpp" "PetComponent.cpp" "PhantomPhysicsComponent.cpp" + "PlayerForcedMovementComponent.cpp" "PossessableComponent.cpp" "PossessorComponent.cpp" "PropertyComponent.cpp" diff --git a/dGame/dComponents/PlayerForcedMovementComponent.cpp b/dGame/dComponents/PlayerForcedMovementComponent.cpp new file mode 100644 index 00000000..94b79188 --- /dev/null +++ b/dGame/dComponents/PlayerForcedMovementComponent.cpp @@ -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; +} \ No newline at end of file diff --git a/dGame/dComponents/PlayerForcedMovementComponent.h b/dGame/dComponents/PlayerForcedMovementComponent.h new file mode 100644 index 00000000..5745a42f --- /dev/null +++ b/dGame/dComponents/PlayerForcedMovementComponent.h @@ -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; + +};