From c168f6c97023ef01ac8ca94a8ddae692f872e384 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Fri, 10 Feb 2023 21:33:30 -0600 Subject: [PATCH 001/111] Break out the model component into the model, item, and mutable model behaviors --- dCommon/dEnums/ePhysicsBehaviorType.h | 14 +++++ dCommon/dEnums/eUgcModerationStatus.h | 13 +++++ dGame/Entity.cpp | 14 ++--- dGame/dComponents/CMakeLists.txt | 2 + dGame/dComponents/ItemComponent.cpp | 33 ++++++++++++ dGame/dComponents/ItemComponent.h | 49 +++++++++++++++++ dGame/dComponents/ModelComponent.cpp | 32 +++++------- dGame/dComponents/ModelComponent.h | 24 ++++++--- .../MutableModelBehaviorComponent.cpp | 30 +++++++++++ .../MutableModelBehaviorComponent.h | 52 +++++++++++++++++++ 10 files changed, 231 insertions(+), 32 deletions(-) create mode 100644 dCommon/dEnums/ePhysicsBehaviorType.h create mode 100644 dCommon/dEnums/eUgcModerationStatus.h create mode 100644 dGame/dComponents/ItemComponent.cpp create mode 100644 dGame/dComponents/ItemComponent.h create mode 100644 dGame/dComponents/MutableModelBehaviorComponent.cpp create mode 100644 dGame/dComponents/MutableModelBehaviorComponent.h diff --git a/dCommon/dEnums/ePhysicsBehaviorType.h b/dCommon/dEnums/ePhysicsBehaviorType.h new file mode 100644 index 000000000..52862daa1 --- /dev/null +++ b/dCommon/dEnums/ePhysicsBehaviorType.h @@ -0,0 +1,14 @@ +#ifndef __EPHYSICSBEHAVIORTYPE__H__ +#define __EPHYSICSBEHAVIORTYPE__H__ + +#include + +enum class ePhysicsBehaviorType : int32_t { + INVALID = -1, + GROUND, + FLYING, + STANDARD, + DYNAMIC +}; + +#endif //!__EPHYSICSBEHAVIORTYPE__H__ diff --git a/dCommon/dEnums/eUgcModerationStatus.h b/dCommon/dEnums/eUgcModerationStatus.h new file mode 100644 index 000000000..ae289b74a --- /dev/null +++ b/dCommon/dEnums/eUgcModerationStatus.h @@ -0,0 +1,13 @@ + +#ifndef __EUGCMODERATIONSTATUS__H__ +#define __EUGCMODERATIONSTATUS__H__ + +#include + +enum class eUgcModerationStatus : uint32_t { + NoStatus, + Approved, + Rejected, +}; + +#endif //!__EUGCMODERATIONSTATUS__H__ diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index eefa51075..ae70c8928 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -68,6 +68,7 @@ #include "ShootingGalleryComponent.h" #include "RailActivatorComponent.h" #include "LUPExhibitComponent.h" +#include "ItemComponent.h" Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity) { m_ObjectID = objectID; @@ -618,7 +619,7 @@ void Entity::Initialize() { m_Components.insert(std::make_pair(COMPONENT_TYPE_SCRIPTED_ACTIVITY, new ScriptedActivityComponent(this, scriptedActivityID))); } - if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_MODEL, -1) != -1 && !GetComponent()) { + if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_MODEL, -1) != -1 && !(petComponentId > 0)) { m_Components.insert(std::make_pair(COMPONENT_TYPE_MODEL, new ModelComponent(this))); if (m_Components.find(COMPONENT_TYPE_DESTROYABLE) == m_Components.end()) { auto destroyableComponent = new DestroyableComponent(this); @@ -630,9 +631,9 @@ void Entity::Initialize() { } } - PetComponent* petComponent; - if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ITEM) > 0 && !TryGetComponent(COMPONENT_TYPE_PET, petComponent) && !HasComponent(COMPONENT_TYPE_MODEL)) { - m_Components.insert(std::make_pair(COMPONENT_TYPE_ITEM, nullptr)); + + if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ITEM) > 0 && !(petComponentId > 0)) { + m_Components.emplace(COMPONENT_TYPE_ITEM, new ItemComponent(this)); } // Shooting gallery component @@ -1103,8 +1104,9 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags); } - if (HasComponent(COMPONENT_TYPE_ITEM)) { - outBitStream->Write0(); + ItemComponent* itemComponent; + if (TryGetComponent(COMPONENT_TYPE_ITEM, itemComponent)) { + itemComponent->Serialize(outBitStream, bIsInitialUpdate, flags); } InventoryComponent* inventoryComponent; diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index 0995428b9..e237ccaf0 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -7,6 +7,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "ControllablePhysicsComponent.cpp" "DestroyableComponent.cpp" "InventoryComponent.cpp" + "ItemComponent.cpp" "LevelProgressionComponent.cpp" "LUPExhibitComponent.cpp" "MissionComponent.cpp" @@ -15,6 +16,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "ModuleAssemblyComponent.cpp" "MovementAIComponent.cpp" "MovingPlatformComponent.cpp" + "MutableModelBehaviorCoponent.cpp" "PetComponent.cpp" "PhantomPhysicsComponent.cpp" "PlayerForcedMovementComponent.cpp" diff --git a/dGame/dComponents/ItemComponent.cpp b/dGame/dComponents/ItemComponent.cpp new file mode 100644 index 000000000..fcfb37213 --- /dev/null +++ b/dGame/dComponents/ItemComponent.cpp @@ -0,0 +1,33 @@ +#include "ItemComponent.h" +#include "Entity.h" +#include "eUgcModerationStatus.h" + + +ItemComponent::ItemComponent(Entity* parent) : Component(parent) { + m_Parent = parent; + + m_DirtyItemInfo = false; + + m_UgId = m_Parent->GetVarAs(u"userModelID"); + if (m_UgId == LWOOBJID_EMPTY) m_UgId = m_Parent->GetObjectID(); + + m_UgModerationStatus = eUgcModerationStatus::NoStatus; + + m_UgDescription = u""; +} + +void ItemComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { + + outBitStream->Write(m_DirtyItemInfo || bIsInitialUpdate); + if (m_DirtyItemInfo || bIsInitialUpdate){ + outBitStream->Write(m_UgId); + outBitStream->Write(m_UgModerationStatus); + outBitStream->Write(m_UgDescription != u""); + if (m_UgDescription != u""){ + outBitStream->Write(m_UgDescription.length()); + for (uint16_t character : m_UgDescription) outBitStream->Write(character); + } + m_DirtyItemInfo = false; + } + +} diff --git a/dGame/dComponents/ItemComponent.h b/dGame/dComponents/ItemComponent.h new file mode 100644 index 000000000..ca5cbfeb5 --- /dev/null +++ b/dGame/dComponents/ItemComponent.h @@ -0,0 +1,49 @@ +#pragma once +#include "dCommonVars.h" +#include "RakNetTypes.h" +#include "NiPoint3.h" +#include "NiQuaternion.h" +#include "Component.h" + +class Entity; +enum class eUgcModerationStatus : uint32_t; + +class ItemComponent : public Component { +public: + static const uint32_t ComponentType = COMPONENT_TYPE_ITEM; + + ItemComponent(Entity* parent); + + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + + void SetUgId(LWOOBJID id) { m_UgId = id; m_DirtyItemInfo = true; }; + LWOOBJID GetUgId() { return m_UgId; }; + + void SetUgModerationStatus(eUgcModerationStatus status) { m_UgModerationStatus = status; m_DirtyItemInfo = true; }; + eUgcModerationStatus GetUgModerationStatus() { return m_UgModerationStatus; }; + + void SetUgDescription(std::u16string description) { m_UgDescription = description; m_DirtyItemInfo = true; }; + std::u16string GetUgDescription() { return m_UgDescription;}; + +private: + + /** + * If we have change the item info + */ + bool m_DirtyItemInfo; + + /** + * The ID of the user that made the model + */ + LWOOBJID m_UgId; + + /** + * + */ + eUgcModerationStatus m_UgModerationStatus; + + /** + * The user generated description + */ + std::u16string m_UgDescription; +}; diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 8fa085f25..9e53a05d4 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -1,31 +1,23 @@ #include "ModelComponent.h" #include "Entity.h" +#include "ePhysicsBehaviorType.h" ModelComponent::ModelComponent(Entity* parent) : Component(parent) { + m_DirtyModelInfo = false; + m_IsPickable = false; + m_PhysicsType = ePhysicsBehaviorType::STANDARD; m_OriginalPosition = m_Parent->GetDefaultPosition(); m_OriginalRotation = m_Parent->GetDefaultRotation(); - - m_userModelID = m_Parent->GetVarAs(u"userModelID"); } void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { - // ItemComponent Serialization. Pets do not get this serialization. - if (!m_Parent->HasComponent(COMPONENT_TYPE_PET)) { - outBitStream->Write1(); - outBitStream->Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID()); - outBitStream->Write(0); - outBitStream->Write0(); + outBitStream->Write(m_DirtyModelInfo || bIsInitialUpdate); + if (m_DirtyModelInfo || bIsInitialUpdate) { + outBitStream->Write(m_IsPickable); + outBitStream->Write(m_PhysicsType); + outBitStream->Write(m_OriginalPosition); + outBitStream->Write(m_OriginalRotation); + m_DirtyModelInfo = false; } - - //actual model component: - outBitStream->Write1(); // Yes we are writing model info - outBitStream->Write0(); // Is pickable - outBitStream->Write(2); // Physics type - outBitStream->Write(m_OriginalPosition); // Original position - outBitStream->Write(m_OriginalRotation); // Original rotation - - outBitStream->Write1(); // We are writing behavior info - outBitStream->Write(0); // Number of behaviors - outBitStream->Write1(); // Is this model paused - if (bIsInitialUpdate) outBitStream->Write0(); // We are not writing model editing info } + diff --git a/dGame/dComponents/ModelComponent.h b/dGame/dComponents/ModelComponent.h index 813420592..8f4911687 100644 --- a/dGame/dComponents/ModelComponent.h +++ b/dGame/dComponents/ModelComponent.h @@ -6,6 +6,7 @@ #include "Component.h" class Entity; +enum class ePhysicsBehaviorType : int32_t; /** * Component that represents entities that are a model, e.g. collectible models and BBB models. @@ -28,7 +29,7 @@ class ModelComponent : public Component { * Sets the original position of the model * @param pos the original position to set */ - void SetPosition(const NiPoint3& pos) { m_OriginalPosition = pos; } + void SetPosition(const NiPoint3& pos) { m_OriginalPosition = pos; m_DirtyModelInfo = true; } /** * Returns the original rotation of the model @@ -40,10 +41,25 @@ class ModelComponent : public Component { * Sets the original rotation of the model * @param rot the original rotation to set */ - void SetRotation(const NiQuaternion& rot) { m_OriginalRotation = rot; } + void SetRotation(const NiQuaternion& rot) { m_OriginalRotation = rot; m_DirtyModelInfo = true; } private: + /** + * if the model info has changed + */ + bool m_DirtyModelInfo; + + /** + * If the model is pickable + */ + bool m_IsPickable; + + /** + * the phsyics type of the model + */ + ePhysicsBehaviorType m_PhysicsType; + /** * The original position of the model */ @@ -54,8 +70,4 @@ class ModelComponent : public Component { */ NiQuaternion m_OriginalRotation; - /** - * The ID of the user that made the model - */ - LWOOBJID m_userModelID; }; diff --git a/dGame/dComponents/MutableModelBehaviorComponent.cpp b/dGame/dComponents/MutableModelBehaviorComponent.cpp new file mode 100644 index 000000000..9dfd041c6 --- /dev/null +++ b/dGame/dComponents/MutableModelBehaviorComponent.cpp @@ -0,0 +1,30 @@ +#include "MutableModelBehaviorComponent.h" +#include "Entity.h" + +MutableModelBehaviorComponent::MutableModelBehaviorComponent(Entity* parent) : Component(parent) { + m_DirtyModelBehaviorInfo = false; + m_BehaviorCount = 0; + m_IsPaused = true; + + m_DirtyModelEditingInfo = false; + m_OldObjId = LWOOBJID_EMPTY; + m_Editor = LWOOBJID_EMPTY; + +} + +void MutableModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { + outBitStream->Write(m_DirtyModelBehaviorInfo || bIsInitialUpdate); + if (m_DirtyModelBehaviorInfo){ + outBitStream->Write(m_BehaviorCount); + outBitStream->Write(m_IsPaused); + m_DirtyModelBehaviorInfo = false; + } + + outBitStream->Write(m_DirtyModelEditingInfo && bIsInitialUpdate); + if (m_DirtyModelEditingInfo && bIsInitialUpdate) { + outBitStream->Write(m_OldObjId); + outBitStream->Write(m_Editor); + m_DirtyModelEditingInfo = false; + } +} + diff --git a/dGame/dComponents/MutableModelBehaviorComponent.h b/dGame/dComponents/MutableModelBehaviorComponent.h new file mode 100644 index 000000000..42187818f --- /dev/null +++ b/dGame/dComponents/MutableModelBehaviorComponent.h @@ -0,0 +1,52 @@ +#pragma once +#include "dCommonVars.h" +#include "RakNetTypes.h" +#include "NiPoint3.h" +#include "NiQuaternion.h" +#include "Component.h" + +class Entity; + +/** + * Component that represents entities that are a model, e.g. collectible models and BBB models. + */ +class MutableModelBehaviorComponent : public Component { +public: + static const uint32_t ComponentType = COMPONENT_TYPE_MODEL; + + MutableModelBehaviorComponent(Entity* parent); + + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + +private: + + /** + * if the behavior info has changed + */ + bool m_DirtyModelBehaviorInfo; + + /** + * The number of behaviors on the model + */ + uint32_t m_BehaviorCount; + + /** + * if the models behaviors are paused + */ + bool m_IsPaused; + + /** + * if the editing info is dirty + */ + bool m_DirtyModelEditingInfo; + + /** + * The old ID of the model + */ + LWOOBJID m_OldObjId; + + /** + * The ID of the editor of the model + */ + LWOOBJID m_Editor; +}; From 2ae9a92b553f3d646ebb0afa67ce044081f13ccf Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Fri, 10 Feb 2023 21:43:39 -0600 Subject: [PATCH 002/111] fix cmake --- dGame/dComponents/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index 18fbe19a4..7e10b586e 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -16,7 +16,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "ModuleAssemblyComponent.cpp" "MovementAIComponent.cpp" "MovingPlatformComponent.cpp" - "MutableModelBehaviorCoponent.cpp" + "MutableModelBehaviorComponent.cpp" "PetComponent.cpp" "PhantomPhysicsComponent.cpp" "PlayerForcedMovementComponent.cpp" From c2d5be0e5ddf83d9c109446d14b9d76025726625 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 20 Mar 2023 20:59:11 -0500 Subject: [PATCH 003/111] include --- dGame/Entity.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 3707e5db5..49f8a9d26 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -71,6 +71,7 @@ #include "LUPExhibitComponent.h" #include "TriggerComponent.h" #include "ItemComponent.h" +#include "MutableModelBehaviorComponent.h" Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity) { m_ObjectID = objectID; From 15988afb4ce5ed26c65383153f677b7291b8fef6 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 20 Mar 2023 21:14:52 -0500 Subject: [PATCH 004/111] hey it compiles --- dGame/dComponents/ItemComponent.h | 3 ++- dGame/dComponents/MutableModelBehaviorComponent.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dGame/dComponents/ItemComponent.h b/dGame/dComponents/ItemComponent.h index ca5cbfeb5..ccfa63a8f 100644 --- a/dGame/dComponents/ItemComponent.h +++ b/dGame/dComponents/ItemComponent.h @@ -4,13 +4,14 @@ #include "NiPoint3.h" #include "NiQuaternion.h" #include "Component.h" +#include "eReplicaComponentType.h" class Entity; enum class eUgcModerationStatus : uint32_t; class ItemComponent : public Component { public: - static const uint32_t ComponentType = COMPONENT_TYPE_ITEM; + static const eReplicaComponentType ComponentType = eReplicaComponentType::ITEM; ItemComponent(Entity* parent); diff --git a/dGame/dComponents/MutableModelBehaviorComponent.h b/dGame/dComponents/MutableModelBehaviorComponent.h index 42187818f..2256fa31b 100644 --- a/dGame/dComponents/MutableModelBehaviorComponent.h +++ b/dGame/dComponents/MutableModelBehaviorComponent.h @@ -4,6 +4,7 @@ #include "NiPoint3.h" #include "NiQuaternion.h" #include "Component.h" +#include "eReplicaComponentType.h" class Entity; @@ -12,7 +13,7 @@ class Entity; */ class MutableModelBehaviorComponent : public Component { public: - static const uint32_t ComponentType = COMPONENT_TYPE_MODEL; + static const eReplicaComponentType ComponentType = eReplicaComponentType::MODEL; MutableModelBehaviorComponent(Entity* parent); From 716a5fcf37d3b595026f782e3fbbcf75cd709a34 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Tue, 6 Jun 2023 18:59:53 -0700 Subject: [PATCH 005/111] Rename some variables in Component And add more virtuals --- CMakeVariables.txt | 2 +- dGame/dBehaviors/BasicAttackBehavior.cpp | 2 +- dGame/dComponents/BaseCombatAIComponent.cpp | 62 ++++----- dGame/dComponents/BouncerComponent.cpp | 22 +-- dGame/dComponents/BuffComponent.cpp | 26 ++-- dGame/dComponents/BuffComponent.h | 2 +- dGame/dComponents/BuildBorderComponent.cpp | 4 +- dGame/dComponents/CharacterComponent.cpp | 6 +- dGame/dComponents/Component.cpp | 23 +++- dGame/dComponents/Component.h | 37 +++-- .../ControllablePhysicsComponent.cpp | 16 +-- dGame/dComponents/DestroyableComponent.cpp | 128 +++++++++--------- dGame/dComponents/InventoryComponent.cpp | 108 +++++++-------- dGame/dComponents/LUPExhibitComponent.cpp | 2 +- .../dComponents/LevelProgressionComponent.cpp | 12 +- dGame/dComponents/MissionComponent.cpp | 4 +- dGame/dComponents/MissionOfferComponent.cpp | 12 +- dGame/dComponents/ModelComponent.cpp | 10 +- dGame/dComponents/MovementAIComponent.cpp | 24 ++-- dGame/dComponents/MovingPlatformComponent.cpp | 62 ++++----- dGame/dComponents/PetComponent.cpp | 124 ++++++++--------- dGame/dComponents/PhantomPhysicsComponent.cpp | 64 ++++----- .../PlayerForcedMovementComponent.cpp | 2 +- dGame/dComponents/PossessableComponent.cpp | 6 +- dGame/dComponents/PossessorComponent.cpp | 22 +-- .../dComponents/PropertyEntranceComponent.cpp | 6 +- .../PropertyManagementComponent.cpp | 8 +- dGame/dComponents/PropertyVendorComponent.cpp | 8 +- .../dComponents/ProximityMonitorComponent.cpp | 10 +- dGame/dComponents/RacingControlComponent.cpp | 46 +++---- dGame/dComponents/RailActivatorComponent.cpp | 10 +- dGame/dComponents/RebuildComponent.cpp | 100 +++++++------- dGame/dComponents/RenderComponent.cpp | 4 +- .../RigidbodyPhantomPhysicsComponent.cpp | 4 +- .../dComponents/RocketLaunchLupComponent.cpp | 8 +- .../RocketLaunchpadControlComponent.cpp | 6 +- .../dComponents/ScriptedActivityComponent.cpp | 18 +-- dGame/dComponents/ScriptedActivityComponent.h | 4 +- .../dComponents/ShootingGalleryComponent.cpp | 2 +- dGame/dComponents/SimplePhysicsComponent.cpp | 6 +- dGame/dComponents/SkillComponent.cpp | 26 ++-- dGame/dComponents/SoundTriggerComponent.cpp | 4 +- dGame/dComponents/SwitchComponent.cpp | 28 ++-- dGame/dComponents/TriggerComponent.cpp | 24 ++-- dGame/dComponents/VehiclePhysicsComponent.cpp | 2 +- dGame/dComponents/VendorComponent.cpp | 16 +-- dGame/dGameMessages/GameMessages.cpp | 2 +- dGame/dInventory/Inventory.cpp | 2 +- dGame/dInventory/Item.cpp | 26 ++-- dGame/dInventory/Item.h | 2 +- dGame/dInventory/ItemSet.cpp | 12 +- dGame/dMission/Mission.cpp | 2 +- dGame/dPropertyBehaviors/ControlBehaviors.cpp | 10 +- dScripts/ScriptComponent.cpp | 4 +- 54 files changed, 602 insertions(+), 580 deletions(-) diff --git a/CMakeVariables.txt b/CMakeVariables.txt index d3c8b36f2..647f43c68 100644 --- a/CMakeVariables.txt +++ b/CMakeVariables.txt @@ -17,7 +17,7 @@ __dynamic=1 # Set __compile_backtrace__ to 1 to compile the backtrace library instead of using system libraries. # __compile_backtrace__=1 # Set to the number of jobs (make -j equivalent) to compile the mariadbconn files with. -__maria_db_connector_compile_jobs__=1 +__maria_db_connector_compile_jobs__= # When set to 1 and uncommented, compiling and linking testing folders and libraries will be done. __enable_testing__=1 # The path to OpenSSL. Change this if your OpenSSL install path is different than the default. diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index f86937953..08d468ef9 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -162,7 +162,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet } auto* destroyableComponent = targetEntity->GetComponent(); - if (!destroyableComponent || !destroyableComponent->GetParent()) { + if (!destroyableComponent || !destroyableComponent->GetOwningEntity()) { Game::logger->Log("BasicAttackBehavior", "No destroyable component on %llu", branch.target); return; } diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index cccaad230..4e6dc0928 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -65,10 +65,10 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): // Get aggro and tether radius from settings and use this if it is present. Only overwrite the // radii if it is greater than the one in the database. - if (m_Parent) { - auto aggroRadius = m_Parent->GetVar(u"aggroRadius"); + if (m_OwningEntity) { + auto aggroRadius = m_OwningEntity->GetVar(u"aggroRadius"); m_AggroRadius = aggroRadius != 0 ? aggroRadius : m_AggroRadius; - auto tetherRadius = m_Parent->GetVar(u"tetherRadius"); + auto tetherRadius = m_OwningEntity->GetVar(u"tetherRadius"); m_HardTetherRadius = tetherRadius != 0 ? tetherRadius : m_HardTetherRadius; } @@ -120,14 +120,14 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): } //Create a phantom physics volume so we can detect when we're aggro'd. - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), m_AggroRadius); - m_dpEntityEnemy = new dpEntity(m_Parent->GetObjectID(), m_AggroRadius, false); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius); + m_dpEntityEnemy = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius, false); m_dpEntity->SetCollisionGroup(collisionGroup); m_dpEntityEnemy->SetCollisionGroup(collisionGroup); - m_dpEntity->SetPosition(m_Parent->GetPosition()); - m_dpEntityEnemy->SetPosition(m_Parent->GetPosition()); + m_dpEntity->SetPosition(m_OwningEntity->GetPosition()); + m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition()); dpWorld::Instance().AddEntity(m_dpEntity); dpWorld::Instance().AddEntity(m_dpEntityEnemy); @@ -146,17 +146,17 @@ void BaseCombatAIComponent::Update(const float deltaTime) { //First, we need to process physics: if (!m_dpEntity) return; - m_dpEntity->SetPosition(m_Parent->GetPosition()); //make sure our position is synced with our dpEntity - m_dpEntityEnemy->SetPosition(m_Parent->GetPosition()); + m_dpEntity->SetPosition(m_OwningEntity->GetPosition()); //make sure our position is synced with our dpEntity + m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition()); //Process enter events for (auto en : m_dpEntity->GetNewObjects()) { - m_Parent->OnCollisionPhantom(en->GetObjectID()); + m_OwningEntity->OnCollisionPhantom(en->GetObjectID()); } //Process exit events for (auto en : m_dpEntity->GetRemovedObjects()) { - m_Parent->OnCollisionLeavePhantom(en->GetObjectID()); + m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID()); } // Check if we should stop the tether effect @@ -165,31 +165,31 @@ void BaseCombatAIComponent::Update(const float deltaTime) { const auto& info = m_MovementAI->GetInfo(); if (m_Target != LWOOBJID_EMPTY || (NiPoint3::DistanceSquared( m_StartPosition, - m_Parent->GetPosition()) < 20 * 20 && m_TetherTime <= 0) + m_OwningEntity->GetPosition()) < 20 * 20 && m_TetherTime <= 0) ) { - GameMessages::SendStopFXEffect(m_Parent, true, "tether"); + GameMessages::SendStopFXEffect(m_OwningEntity, true, "tether"); m_TetherEffectActive = false; } } if (m_SoftTimer <= 0.0f) { - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); m_SoftTimer = 5.0f; } else { m_SoftTimer -= deltaTime; } - if (m_Disabled || m_Parent->GetIsDead()) + if (m_Disabled || m_OwningEntity->GetIsDead()) return; bool stunnedThisFrame = m_Stunned; CalculateCombat(deltaTime); // Putting this here for now if (m_StartPosition == NiPoint3::ZERO) { - m_StartPosition = m_Parent->GetPosition(); + m_StartPosition = m_OwningEntity->GetPosition(); } - m_MovementAI = m_Parent->GetComponent(); + m_MovementAI = m_OwningEntity->GetComponent(); if (m_MovementAI == nullptr) { return; @@ -243,7 +243,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { bool hadRemainingDowntime = m_SkillTime > 0.0f; if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime; - auto* rebuild = m_Parent->GetComponent(); + auto* rebuild = m_OwningEntity->GetComponent(); if (rebuild != nullptr) { const auto state = rebuild->GetState(); @@ -253,7 +253,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { } } - auto* skillComponent = m_Parent->GetComponent(); + auto* skillComponent = m_OwningEntity->GetComponent(); if (skillComponent == nullptr) { return; @@ -287,7 +287,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { } if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) { - auto* destroyableComponent = m_Parent->GetComponent(); + auto* destroyableComponent = m_OwningEntity->GetComponent(); if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) { auto serilizationRequired = false; @@ -305,10 +305,10 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { } if (serilizationRequired) { - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } - GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 6270, u"tether", "tether"); + GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 6270, u"tether", "tether"); m_TetherEffectActive = true; @@ -496,10 +496,10 @@ LWOOBJID BaseCombatAIComponent::FindTarget() { std::vector BaseCombatAIComponent::GetTargetWithinAggroRange() const { std::vector targets; - for (auto id : m_Parent->GetTargetsInPhantom()) { + for (auto id : m_OwningEntity->GetTargetsInPhantom()) { auto* other = EntityManager::Instance()->GetEntity(id); - const auto distance = Vector3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition()); + const auto distance = Vector3::DistanceSquared(m_OwningEntity->GetPosition(), other->GetPosition()); if (distance > m_AggroRadius * m_AggroRadius) continue; @@ -510,7 +510,7 @@ std::vector BaseCombatAIComponent::GetTargetWithinAggroRange() const { } bool BaseCombatAIComponent::IsMech() { - switch (m_Parent->GetLOT()) { + switch (m_OwningEntity->GetLOT()) { case 6253: return true; @@ -535,7 +535,7 @@ void BaseCombatAIComponent::SetAiState(AiState newState) { if (newState == this->m_State) return; this->m_State = newState; m_DirtyStateOrTarget = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { @@ -553,10 +553,10 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { return false; } - auto* referenceDestroyable = m_Parent->GetComponent(); + auto* referenceDestroyable = m_OwningEntity->GetComponent(); if (referenceDestroyable == nullptr) { - Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_Parent->GetObjectID()); + Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID()); return false; } @@ -588,7 +588,7 @@ void BaseCombatAIComponent::SetTarget(const LWOOBJID target) { if (this->m_Target == target) return; m_Target = target; m_DirtyStateOrTarget = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } Entity* BaseCombatAIComponent::GetTargetEntity() const { @@ -597,7 +597,7 @@ Entity* BaseCombatAIComponent::GetTargetEntity() const { void BaseCombatAIComponent::Taunt(LWOOBJID offender, float threat) { // Can't taunt self - if (offender == m_Parent->GetObjectID()) + if (offender == m_OwningEntity->GetObjectID()) return; m_ThreatEntries[offender] += threat; @@ -788,7 +788,7 @@ void BaseCombatAIComponent::LookAt(const NiPoint3& point) { return; } - m_Parent->SetRotation(NiQuaternion::LookAt(m_Parent->GetPosition(), point)); + m_OwningEntity->SetRotation(NiQuaternion::LookAt(m_OwningEntity->GetPosition(), point)); } void BaseCombatAIComponent::SetDisabled(bool value) { diff --git a/dGame/dComponents/BouncerComponent.cpp b/dGame/dComponents/BouncerComponent.cpp index f6a532615..e26e23a83 100644 --- a/dGame/dComponents/BouncerComponent.cpp +++ b/dGame/dComponents/BouncerComponent.cpp @@ -30,28 +30,28 @@ void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia } Entity* BouncerComponent::GetParentEntity() const { - return m_Parent; + return m_OwningEntity; } void BouncerComponent::SetPetEnabled(bool value) { m_PetEnabled = value; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void BouncerComponent::SetPetBouncerEnabled(bool value) { m_PetBouncerEnabled = value; - GameMessages::SendBouncerActiveStatus(m_Parent->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendBouncerActiveStatus(m_OwningEntity->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); if (value) { - m_Parent->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_Parent); - GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 1513, u"create", "PetOnSwitch", LWOOBJID_EMPTY, 1, 1, true); + m_OwningEntity->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_OwningEntity); + GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 1513, u"create", "PetOnSwitch", LWOOBJID_EMPTY, 1, 1, true); } else { - m_Parent->TriggerEvent(eTriggerEventType::PET_OFF_SWITCH, m_Parent); - GameMessages::SendStopFXEffect(m_Parent, true, "PetOnSwitch"); + m_OwningEntity->TriggerEvent(eTriggerEventType::PET_OFF_SWITCH, m_OwningEntity); + GameMessages::SendStopFXEffect(m_OwningEntity, true, "PetOnSwitch"); } } @@ -65,7 +65,7 @@ bool BouncerComponent::GetPetBouncerEnabled() const { } void BouncerComponent::LookupPetSwitch() { - const auto& groups = m_Parent->GetGroups(); + const auto& groups = m_OwningEntity->GetGroups(); for (const auto& group : groups) { const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group); @@ -79,7 +79,7 @@ void BouncerComponent::LookupPetSwitch() { m_PetSwitchLoaded = true; m_PetEnabled = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); Game::logger->Log("BouncerComponent", "Loaded pet bouncer"); } @@ -89,7 +89,7 @@ void BouncerComponent::LookupPetSwitch() { if (!m_PetSwitchLoaded) { Game::logger->Log("BouncerComponent", "Failed to load pet bouncer"); - m_Parent->AddCallbackTimer(0.5f, [this]() { + m_OwningEntity->AddCallbackTimer(0.5f, [this]() { LookupPetSwitch(); }); } diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index 68b5182c7..3a10c3c3c 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -64,7 +64,7 @@ void BuffComponent::Update(float deltaTime) { buff.second.tickTime = buff.second.tick; buff.second.stacks--; - SkillComponent::HandleUnmanaged(buff.second.behaviorID, m_Parent->GetObjectID(), buff.second.source); + SkillComponent::HandleUnmanaged(buff.second.behaviorID, m_OwningEntity->GetObjectID(), buff.second.source); } } @@ -91,7 +91,7 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO return; } - GameMessages::SendAddBuff(const_cast(m_Parent->GetObjectID()), source, (uint32_t)id, + GameMessages::SendAddBuff(const_cast(m_OwningEntity->GetObjectID()), source, (uint32_t)id, (uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath, cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone); @@ -132,7 +132,7 @@ void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity return; } - GameMessages::SendRemoveBuff(m_Parent, fromUnEquip, removeImmunity, id); + GameMessages::SendRemoveBuff(m_OwningEntity, fromUnEquip, removeImmunity, id); m_Buffs.erase(iter); @@ -149,7 +149,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { if (parameter.name == "max_health") { const auto maxHealth = parameter.value; - auto* destroyable = this->GetParent()->GetComponent(); + auto* destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -157,7 +157,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { } else if (parameter.name == "max_armor") { const auto maxArmor = parameter.value; - auto* destroyable = this->GetParent()->GetComponent(); + auto* destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -165,13 +165,13 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { } else if (parameter.name == "max_imagination") { const auto maxImagination = parameter.value; - auto* destroyable = this->GetParent()->GetComponent(); + auto* destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination); } else if (parameter.name == "speed") { - auto* controllablePhysicsComponent = this->GetParent()->GetComponent(); + auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); if (!controllablePhysicsComponent) return; const auto speed = parameter.value; controllablePhysicsComponent->AddSpeedboost(speed); @@ -185,7 +185,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { if (parameter.name == "max_health") { const auto maxHealth = parameter.value; - auto* destroyable = this->GetParent()->GetComponent(); + auto* destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -193,7 +193,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { } else if (parameter.name == "max_armor") { const auto maxArmor = parameter.value; - auto* destroyable = this->GetParent()->GetComponent(); + auto* destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -201,13 +201,13 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { } else if (parameter.name == "max_imagination") { const auto maxImagination = parameter.value; - auto* destroyable = this->GetParent()->GetComponent(); + auto* destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination); } else if (parameter.name == "speed") { - auto* controllablePhysicsComponent = this->GetParent()->GetComponent(); + auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); if (!controllablePhysicsComponent) return; const auto speed = parameter.value; controllablePhysicsComponent->RemoveSpeedboost(speed); @@ -233,8 +233,8 @@ void BuffComponent::ReApplyBuffs() { } } -Entity* BuffComponent::GetParent() const { - return m_Parent; +Entity* BuffComponent::GetOwningEntity() const { + return m_OwningEntity; } void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { diff --git a/dGame/dComponents/BuffComponent.h b/dGame/dComponents/BuffComponent.h index d91758835..af961ba3a 100644 --- a/dGame/dComponents/BuffComponent.h +++ b/dGame/dComponents/BuffComponent.h @@ -48,7 +48,7 @@ class BuffComponent : public Component { ~BuffComponent(); - Entity* GetParent() const; + Entity* GetOwningEntity() const; void LoadFromXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/BuildBorderComponent.cpp b/dGame/dComponents/BuildBorderComponent.cpp index f9ead9e4d..5b46d5731 100644 --- a/dGame/dComponents/BuildBorderComponent.cpp +++ b/dGame/dComponents/BuildBorderComponent.cpp @@ -19,7 +19,7 @@ void BuildBorderComponent::OnUse(Entity* originator) { if (originator->GetCharacter()) { const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque"); - auto buildArea = m_Parent->GetObjectID(); + auto buildArea = m_OwningEntity->GetObjectID(); if (!entities.empty()) { buildArea = entities[0]->GetObjectID(); @@ -63,7 +63,7 @@ void BuildBorderComponent::OnUse(Entity* originator) { GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition()); } - InventoryComponent* inv = m_Parent->GetComponent(); + InventoryComponent* inv = m_OwningEntity->GetComponent(); if (!inv) return; inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here } diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 32fe564c7..7bd4cc192 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -491,7 +491,7 @@ void CharacterComponent::TrackRaceCompleted(bool won) { } void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) { - const auto distance = NiPoint3::Distance(newPosition, m_Parent->GetPosition()); + const auto distance = NiPoint3::Distance(newPosition, m_OwningEntity->GetPosition()); if (m_IsRacing) { UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance); @@ -732,8 +732,8 @@ void CharacterComponent::RemoveVentureVisionEffect(std::string ventureVisionType } void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const { - if (!m_Parent) return; + if (!m_OwningEntity) return; AMFArrayValue arrayToSend; arrayToSend.Insert(ventureVisionType, showFaction); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend); + GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity ? m_OwningEntity->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend); } diff --git a/dGame/dComponents/Component.cpp b/dGame/dComponents/Component.cpp index ca018c29c..d04397f47 100644 --- a/dGame/dComponents/Component.cpp +++ b/dGame/dComponents/Component.cpp @@ -1,18 +1,15 @@ #include "Component.h" +#include "DluAssert.h" - -Component::Component(Entity* parent) { - m_Parent = parent; +Component::Component(Entity* owningEntity) { + DluAssert(owningEntity != nullptr); + m_OwningEntity = owningEntity; } Component::~Component() { } -Entity* Component::GetParent() const { - return m_Parent; -} - void Component::Update(float deltaTime) { } @@ -28,3 +25,15 @@ void Component::UpdateXml(tinyxml2::XMLDocument* doc) { void Component::LoadFromXml(tinyxml2::XMLDocument* doc) { } + +void Component::Startup() { + +} + +void Component::LoadConfigData() { + +} + +void Component::LoadTemplateData() { + +} diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index 9b0df9fdf..25df2d878 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -1,29 +1,22 @@ #pragma once -#include "../thirdparty/tinyxml2/tinyxml2.h" +#include "tinyxml2.h" class Entity; /** * Component base class, provides methods for game loop updates, usage events and loading and saving to XML. */ -class Component -{ +class Component { public: - Component(Entity* parent); + Component(Entity* owningEntity); virtual ~Component(); /** * Gets the owner of this component * @return the owner of this component */ - Entity* GetParent() const; - - /** - * Updates the component in the game loop - * @param deltaTime time passed since last update - */ - virtual void Update(float deltaTime); + Entity* GetOwningEntity() const { return m_OwningEntity; }; /** * Event called when this component is being used, e.g. when some entity interacted with it @@ -43,10 +36,30 @@ class Component */ virtual void LoadFromXml(tinyxml2::XMLDocument* doc); + /** + * Call after you have newed the component to initialize it + */ + virtual void Startup(); + + /** + * Updates the component in the game loop + * @param deltaTime time passed since last update + */ + virtual void Update(float deltaTime); + + /** + * Loads the data of this component from the luz/lvl configuration + */ + virtual void LoadConfigData(); + + /** + * Loads the data of this component from the cdclient database + */ + virtual void LoadTemplateData(); protected: /** * The entity that owns this component */ - Entity* m_Parent; + Entity* m_OwningEntity; }; diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index d1b442001..04f627e72 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -58,7 +58,7 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics"); float radius = 1.5f; - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), radius, false); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), radius, false); m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY); dpWorld::Instance().AddEntity(m_dpEntity); } @@ -168,7 +168,7 @@ void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { return; } - m_Parent->GetCharacter()->LoadXmlRespawnCheckpoints(); + m_OwningEntity->GetCharacter()->LoadXmlRespawnCheckpoints(); character->QueryAttribute("lzx", &m_Position.x); character->QueryAttribute("lzy", &m_Position.y); @@ -300,7 +300,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) { auto candidateRadius = m_ActivePickupRadiusScales[i]; if (m_PickupRadius < candidateRadius) m_PickupRadius = candidateRadius; } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void ControllablePhysicsComponent::AddSpeedboost(float value) { @@ -321,13 +321,13 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) { // Recalculate speedboost since we removed one m_SpeedBoost = 0.0f; if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed - auto* levelProgressionComponent = m_Parent->GetComponent(); + auto* levelProgressionComponent = m_OwningEntity->GetComponent(); if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase(); } else { // Used the last applied speedboost m_SpeedBoost = m_ActiveSpeedBoosts.back(); } SetSpeedMultiplier(m_SpeedBoost / 500.0f); // 500 being the base speed - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){ @@ -339,13 +339,13 @@ void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bo m_IsInBubble = true; m_DirtyBubble = true; m_SpecialAnims = specialAnims; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void ControllablePhysicsComponent::DeactivateBubbleBuff(){ m_DirtyBubble = true; m_IsInBubble = false; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); }; void ControllablePhysicsComponent::SetStunImmunity( @@ -378,7 +378,7 @@ void ControllablePhysicsComponent::SetStunImmunity( } GameMessages::SendSetStunImmunity( - m_Parent->GetObjectID(), state, m_Parent->GetSystemAddress(), originator, + m_OwningEntity->GetObjectID(), state, m_OwningEntity->GetSystemAddress(), originator, bImmuneToStunAttack, bImmuneToStunEquip, bImmuneToStunInteract, diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 01ebf5c10..bb47ce32f 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -185,7 +185,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { return; } - auto* buffComponent = m_Parent->GetComponent(); + auto* buffComponent = m_OwningEntity->GetComponent(); if (buffComponent != nullptr) { buffComponent->LoadFromXml(doc); @@ -207,7 +207,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) { return; } - auto* buffComponent = m_Parent->GetComponent(); + auto* buffComponent = m_OwningEntity->GetComponent(); if (buffComponent != nullptr) { buffComponent->UpdateXml(doc); @@ -224,7 +224,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) { void DestroyableComponent::SetHealth(int32_t value) { m_DirtyHealth = true; - auto* characterComponent = m_Parent->GetComponent(); + auto* characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackHealthDelta(value - m_iHealth); } @@ -244,16 +244,16 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) { if (playAnim) { // Now update the player bar - if (!m_Parent->GetParentUser()) return; + if (!m_OwningEntity->GetParentUser()) return; AMFArrayValue args; args.Insert("amount", std::to_string(difference)); args.Insert("type", "health"); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); + GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void DestroyableComponent::SetArmor(int32_t value) { @@ -262,14 +262,14 @@ void DestroyableComponent::SetArmor(int32_t value) { // If Destroyable Component already has zero armor do not trigger the passive ability again. bool hadArmor = m_iArmor > 0; - auto* characterComponent = m_Parent->GetComponent(); + auto* characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackArmorDelta(value - m_iArmor); } m_iArmor = value; - auto* inventroyComponent = m_Parent->GetComponent(); + auto* inventroyComponent = m_OwningEntity->GetComponent(); if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) { inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor); } @@ -285,29 +285,29 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) { if (playAnim) { // Now update the player bar - if (!m_Parent->GetParentUser()) return; + if (!m_OwningEntity->GetParentUser()) return; AMFArrayValue args; args.Insert("amount", std::to_string(value)); args.Insert("type", "armor"); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); + GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void DestroyableComponent::SetImagination(int32_t value) { m_DirtyHealth = true; - auto* characterComponent = m_Parent->GetComponent(); + auto* characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackImaginationDelta(value - m_iImagination); } m_iImagination = value; - auto* inventroyComponent = m_Parent->GetComponent(); + auto* inventroyComponent = m_OwningEntity->GetComponent(); if (m_iImagination == 0 && inventroyComponent != nullptr) { inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination); } @@ -325,15 +325,15 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) { if (playAnim) { // Now update the player bar - if (!m_Parent->GetParentUser()) return; + if (!m_OwningEntity->GetParentUser()) return; AMFArrayValue args; args.Insert("amount", std::to_string(difference)); args.Insert("type", "imagination"); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); + GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void DestroyableComponent::SetDamageToAbsorb(int32_t value) { @@ -455,8 +455,8 @@ bool DestroyableComponent::IsImmune() const { } bool DestroyableComponent::IsKnockbackImmune() const { - auto* characterComponent = m_Parent->GetComponent(); - auto* inventoryComponent = m_Parent->GetComponent(); + auto* characterComponent = m_OwningEntity->GetComponent(); + auto* inventoryComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) { const auto hasPassive = inventoryComponent->HasAnyPassive({ @@ -532,7 +532,7 @@ void DestroyableComponent::Heal(const uint32_t health) { SetHealth(current); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } @@ -550,7 +550,7 @@ void DestroyableComponent::Imagine(const int32_t deltaImagination) { SetImagination(current); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } @@ -564,7 +564,7 @@ void DestroyableComponent::Repair(const uint32_t armor) { SetArmor(current); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } @@ -616,13 +616,13 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 SetIsShielded(absorb > 0); // Dismount on the possessable hit - auto possessable = m_Parent->GetComponent(); + auto possessable = m_OwningEntity->GetComponent(); if (possessable && possessable->GetDepossessOnHit()) { possessable->Dismount(); } // Dismount on the possessor hit - auto possessor = m_Parent->GetComponent(); + auto possessor = m_OwningEntity->GetComponent(); if (possessor) { auto possessableId = possessor->GetPossessable(); if (possessableId != LWOOBJID_EMPTY) { @@ -633,17 +633,17 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 } } - if (m_Parent->GetLOT() != 1) { + if (m_OwningEntity->GetLOT() != 1) { echo = true; } if (echo) { - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } auto* attacker = EntityManager::Instance()->GetEntity(source); - m_Parent->OnHit(attacker); - m_Parent->OnHitOrHealResult(attacker, sourceDamage); + m_OwningEntity->OnHit(attacker); + m_OwningEntity->OnHitOrHealResult(attacker, sourceDamage); NotifySubscribers(attacker, sourceDamage); for (const auto& cb : m_OnHitCallbacks) { @@ -651,7 +651,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 } if (health != 0) { - auto* combatComponent = m_Parent->GetComponent(); + auto* combatComponent = m_OwningEntity->GetComponent(); if (combatComponent != nullptr) { combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary @@ -670,7 +670,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) { m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd)); - Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_Parent->GetObjectID()); + Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_OwningEntity->GetObjectID()); Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); } @@ -678,16 +678,16 @@ void DestroyableComponent::Unsubscribe(LWOOBJID scriptObjId) { auto foundScript = m_SubscribedScripts.find(scriptObjId); if (foundScript != m_SubscribedScripts.end()) { m_SubscribedScripts.erase(foundScript); - Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_Parent->GetObjectID()); + Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_OwningEntity->GetObjectID()); } else { - Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_Parent->GetObjectID(), scriptObjId); + Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_OwningEntity->GetObjectID(), scriptObjId); } Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); } void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) { for (auto script : m_SubscribedScripts) { - script.second->NotifyHitOrHealResult(m_Parent, attacker, damage); + script.second->NotifyHitOrHealResult(m_OwningEntity, attacker, damage); } } @@ -696,7 +696,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType SetArmor(0); SetHealth(0); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } m_KillerID = source; @@ -708,12 +708,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID()); - const auto isEnemy = m_Parent->GetComponent() != nullptr; + const auto isEnemy = m_OwningEntity->GetComponent() != nullptr; auto* inventoryComponent = owner->GetComponent(); if (inventoryComponent != nullptr && isEnemy) { - inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_Parent); + inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_OwningEntity); } auto* missions = owner->GetComponent(); @@ -729,28 +729,28 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType if (memberMissions == nullptr) continue; - memberMissions->Progress(eMissionTaskType::SMASH, m_Parent->GetLOT()); - memberMissions->Progress(eMissionTaskType::USE_SKILL, m_Parent->GetLOT(), skillID); + memberMissions->Progress(eMissionTaskType::SMASH, m_OwningEntity->GetLOT()); + memberMissions->Progress(eMissionTaskType::USE_SKILL, m_OwningEntity->GetLOT(), skillID); } } else { - missions->Progress(eMissionTaskType::SMASH, m_Parent->GetLOT()); - missions->Progress(eMissionTaskType::USE_SKILL, m_Parent->GetLOT(), skillID); + missions->Progress(eMissionTaskType::SMASH, m_OwningEntity->GetLOT()); + missions->Progress(eMissionTaskType::USE_SKILL, m_OwningEntity->GetLOT(), skillID); } } } - const auto isPlayer = m_Parent->IsPlayer(); + const auto isPlayer = m_OwningEntity->IsPlayer(); - GameMessages::SendDie(m_Parent, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1); + GameMessages::SendDie(m_OwningEntity, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1); //NANI?! if (!isPlayer) { if (owner != nullptr) { auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID()); - if (team != nullptr && m_Parent->GetComponent() != nullptr) { + if (team != nullptr && m_OwningEntity->GetComponent() != nullptr) { LWOOBJID specificOwner = LWOOBJID_EMPTY; - auto* scriptedActivityComponent = m_Parent->GetComponent(); + auto* scriptedActivityComponent = m_OwningEntity->GetComponent(); uint32_t teamSize = team->members.size(); uint32_t lootMatrixId = GetLootMatrixID(); @@ -763,24 +763,24 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType auto* member = EntityManager::Instance()->GetEntity(specificOwner); - if (member) LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins()); + if (member) LootGenerator::Instance().DropLoot(member, m_OwningEntity, lootMatrixId, GetMinCoins(), GetMaxCoins()); } else { for (const auto memberId : team->members) { // Free for all auto* member = EntityManager::Instance()->GetEntity(memberId); if (member == nullptr) continue; - LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins()); + LootGenerator::Instance().DropLoot(member, m_OwningEntity, lootMatrixId, GetMinCoins(), GetMaxCoins()); } } } else { // drop loot for non team user - LootGenerator::Instance().DropLoot(owner, m_Parent, GetLootMatrixID(), GetMinCoins(), GetMaxCoins()); + LootGenerator::Instance().DropLoot(owner, m_OwningEntity, GetLootMatrixID(), GetMinCoins(), GetMaxCoins()); } } } else { //Check if this zone allows coin drops if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) { - auto* character = m_Parent->GetCharacter(); + auto* character = m_OwningEntity->GetCharacter(); uint64_t coinsTotal = character->GetCoins(); const uint64_t minCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMin; if (coinsTotal >= minCoinsToLose) { @@ -792,27 +792,27 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType coinsTotal -= coinsToLose; - LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLose, coinsToLose); + LootGenerator::Instance().DropLoot(m_OwningEntity, m_OwningEntity, -1, coinsToLose, coinsToLose); character->SetCoins(coinsTotal, eLootSourceType::PICKUP); } } Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity(); for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { - script->OnPlayerDied(zoneControl, m_Parent); + script->OnPlayerDied(zoneControl, m_OwningEntity); } std::vector scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); for (Entity* scriptEntity : scriptedActs) { if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) { - script->OnPlayerDied(scriptEntity, m_Parent); + script->OnPlayerDied(scriptEntity, m_OwningEntity); } } } } - m_Parent->Kill(owner); + m_OwningEntity->Kill(owner); } void DestroyableComponent::SetFaction(int32_t factionID, bool ignoreChecks) { @@ -858,7 +858,7 @@ void DestroyableComponent::SetStatusImmunity( } GameMessages::SendSetStatusImmunity( - m_Parent->GetObjectID(), state, m_Parent->GetSystemAddress(), + m_OwningEntity->GetObjectID(), state, m_OwningEntity->GetSystemAddress(), bImmuneToBasicAttack, bImmuneToDamageOverTime, bImmuneToKnockback, @@ -872,7 +872,7 @@ void DestroyableComponent::SetStatusImmunity( } void DestroyableComponent::FixStats() { - auto* entity = GetParent(); + auto* entity = GetOwningEntity(); if (entity == nullptr) return; @@ -974,19 +974,19 @@ void DestroyableComponent::AddOnHitCallback(const std::function& void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ //check if this is a player: - if (m_Parent->IsPlayer()) { + if (m_OwningEntity->IsPlayer()) { //remove hardcore_lose_uscore_on_death_percent from the player's uscore: - auto* character = m_Parent->GetComponent(); + auto* character = m_OwningEntity->GetComponent(); auto uscore = character->GetUScore(); auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100); character->SetUScore(uscore - uscoreToLose); - GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION); + GameMessages::SendModifyLEGOScore(m_OwningEntity, m_OwningEntity->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION); if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) { //drop all items from inventory: - auto* inventory = m_Parent->GetComponent(); + auto* inventory = m_OwningEntity->GetComponent(); if (inventory) { //get the items inventory: auto items = inventory->GetInventory(eInventoryType::ITEMS); @@ -998,17 +998,17 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ if (!item.second) continue; // don't drop the thinkng cap if (item.second->GetLot() == 6086) continue; - GameMessages::SendDropClientLoot(m_Parent, source, item.second->GetLot(), 0, m_Parent->GetPosition(), item.second->GetCount()); + GameMessages::SendDropClientLoot(m_OwningEntity, source, item.second->GetLot(), 0, m_OwningEntity->GetPosition(), item.second->GetCount()); item.second->SetCount(0, false, false); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } } } //get character: - auto* chars = m_Parent->GetCharacter(); + auto* chars = m_OwningEntity->GetCharacter(); if (chars) { auto coins = chars->GetCoins(); @@ -1016,13 +1016,13 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ chars->SetCoins(0, eLootSourceType::NONE); //drop all coins: - GameMessages::SendDropClientLoot(m_Parent, source, LOT_NULL, coins, m_Parent->GetPosition()); + GameMessages::SendDropClientLoot(m_OwningEntity, source, LOT_NULL, coins, m_OwningEntity->GetPosition()); } // Reload the player since we can't normally reduce uscore from the server and we want the UI to update // do this last so we don't get killed.... again - EntityManager::Instance()->DestructEntity(m_Parent); - EntityManager::Instance()->ConstructEntity(m_Parent); + EntityManager::Instance()->DestructEntity(m_OwningEntity); + EntityManager::Instance()->ConstructEntity(m_OwningEntity); return; } @@ -1039,7 +1039,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ playerStats->SetUScore(playerStats->GetUScore() + uscore); GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } } diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 907356ce0..28294dbf3 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -189,7 +189,7 @@ void InventoryComponent::AddItem( inventoryType = Inventory::FindInventoryTypeForLot(lot); } - auto* missions = static_cast(this->m_Parent->GetComponent(eReplicaComponentType::MISSION)); + auto* missions = static_cast(this->m_OwningEntity->GetComponent(eReplicaComponentType::MISSION)); auto* inventory = GetInventory(inventoryType); @@ -261,7 +261,7 @@ void InventoryComponent::AddItem( } if (slot == -1) { - auto* player = dynamic_cast(GetParent()); + auto* player = dynamic_cast(GetOwningEntity()); if (player == nullptr) { return; @@ -276,7 +276,7 @@ void InventoryComponent::AddItem( case 1: for (size_t i = 0; i < size; i++) { - GameMessages::SendDropClientLoot(this->m_Parent, this->m_Parent->GetObjectID(), lot, 0, this->m_Parent->GetPosition(), 1); + GameMessages::SendDropClientLoot(this->m_OwningEntity, this->m_OwningEntity->GetObjectID(), lot, 0, this->m_OwningEntity->GetPosition(), 1); } break; @@ -378,7 +378,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in item->SetCount(item->GetCount() - delta, false, false); } - auto* missionComponent = m_Parent->GetComponent(); + auto* missionComponent = m_OwningEntity->GetComponent(); if (missionComponent != nullptr) { if (IsTransferInventory(inventory)) { @@ -479,7 +479,7 @@ bool InventoryComponent::HasSpaceForLoot(const std::unordered_map& } if (slotsNeeded > 0) { - GameMessages::SendNotifyNotEnoughInvSpace(m_Parent->GetObjectID(), slotsNeeded, ITEMS, m_Parent->GetSystemAddress()); + GameMessages::SendNotifyNotEnoughInvSpace(m_OwningEntity->GetObjectID(), slotsNeeded, ITEMS, m_OwningEntity->GetSystemAddress()); return false; } @@ -687,7 +687,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { itemElement->SetAttribute("sk", item->GetSubKey()); // Begin custom xml - itemElement->SetAttribute("parent", item->GetParent()); + itemElement->SetAttribute("parent", item->GetOwningEntity()); // End custom xml for (auto* data : item->GetConfig()) { @@ -821,23 +821,23 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) { return; } - auto* character = m_Parent->GetCharacter(); + auto* character = m_OwningEntity->GetCharacter(); if (character != nullptr && !skipChecks) { // Hacky proximity rocket if (item->GetLot() == 6416) { const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCH); - const auto position = m_Parent->GetPosition(); + const auto position = m_OwningEntity->GetPosition(); for (auto* lauchPad : rocketLauchPads) { if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue; - auto* characterComponent = m_Parent->GetComponent(); + auto* characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId()); - lauchPad->OnUse(m_Parent); + lauchPad->OnUse(m_OwningEntity); break; } @@ -853,7 +853,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) { if (!building && (item->GetLot() == 6086 || type == eItemType::LOOT_MODEL || type == eItemType::VEHICLE)) return; if (type != eItemType::LOOT_MODEL && type != eItemType::MODEL) { - if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_Parent)) { + if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_OwningEntity)) { return; } } @@ -879,7 +879,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) { EquipScripts(item); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void InventoryComponent::UnEquipItem(Item* item) { @@ -909,12 +909,12 @@ void InventoryComponent::UnEquipItem(Item* item) { UnequipScripts(item); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); // Trigger property event if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) { - PropertyManagementComponent::Instance()->GetParent()->OnZonePropertyModelRemovedWhileEquipped(m_Parent); - dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_Parent); + PropertyManagementComponent::Instance()->GetOwningEntity()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity); + dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity); } } @@ -926,11 +926,11 @@ void InventoryComponent::EquipScripts(Item* equippedItem) { if (scriptComponentID > -1) { CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable(); CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID); - auto* itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name); + auto* itemScript = CppScripts::GetScript(m_OwningEntity, scriptCompData.script_name); if (!itemScript) { Game::logger->Log("InventoryComponent", "null script?"); } - itemScript->OnFactionTriggerItemEquipped(m_Parent, equippedItem->GetId()); + itemScript->OnFactionTriggerItemEquipped(m_OwningEntity, equippedItem->GetId()); } } @@ -941,19 +941,19 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) { if (scriptComponentID > -1) { CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable(); CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID); - auto* itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name); + auto* itemScript = CppScripts::GetScript(m_OwningEntity, scriptCompData.script_name); if (!itemScript) { Game::logger->Log("InventoryComponent", "null script?"); } - itemScript->OnFactionTriggerItemUnequipped(m_Parent, unequippedItem->GetId()); + itemScript->OnFactionTriggerItemUnequipped(m_OwningEntity, unequippedItem->GetId()); } } void InventoryComponent::HandlePossession(Item* item) { - auto* characterComponent = m_Parent->GetComponent(); + auto* characterComponent = m_OwningEntity->GetComponent(); if (!characterComponent) return; - auto* possessorComponent = m_Parent->GetComponent(); + auto* possessorComponent = m_OwningEntity->GetComponent(); if (!possessorComponent) return; // Don't do anything if we are busy dismounting @@ -968,22 +968,22 @@ void InventoryComponent::HandlePossession(Item* item) { return; } - GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStateChangeType::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true); + GameMessages::SendSetStunned(m_OwningEntity->GetObjectID(), eStateChangeType::PUSH, m_OwningEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true); // Set the mount Item ID so that we know what were handling possessorComponent->SetMountItemID(item->GetId()); - GameMessages::SendSetMountInventoryID(m_Parent, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendSetMountInventoryID(m_OwningEntity, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS); // Create entity to mount - auto startRotation = m_Parent->GetRotation(); + auto startRotation = m_OwningEntity->GetRotation(); EntityInfo info{}; info.lot = item->GetLot(); - info.pos = m_Parent->GetPosition(); + info.pos = m_OwningEntity->GetPosition(); info.rot = startRotation; - info.spawnerID = m_Parent->GetObjectID(); + info.spawnerID = m_OwningEntity->GetObjectID(); - auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); + auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity); // Check to see if the mount is a vehicle, if so, flip it auto* vehicleComponent = mount->GetComponent(); @@ -1010,29 +1010,29 @@ void InventoryComponent::HandlePossession(Item* item) { auto* possessableComponent = mount->GetComponent(); if (possessableComponent) { possessableComponent->SetIsItemSpawned(true); - possessableComponent->SetPossessor(m_Parent->GetObjectID()); + possessableComponent->SetPossessor(m_OwningEntity->GetObjectID()); // Possess it possessorComponent->SetPossessable(mount->GetObjectID()); possessorComponent->SetPossessableType(possessableComponent->GetPossessionType()); } - GameMessages::SendSetJetPackMode(m_Parent, false); + GameMessages::SendSetJetPackMode(m_OwningEntity, false); // Make it go to the client EntityManager::Instance()->ConstructEntity(mount); // Update the possessor - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); // have to unlock the input so it vehicle can be driven - if (vehicleComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress()); - GameMessages::SendMarkInventoryItemAsActive(m_Parent->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_Parent->GetSystemAddress()); + if (vehicleComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress()); + GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_OwningEntity->GetSystemAddress()); } void InventoryComponent::ApplyBuff(Item* item) const { const auto buffs = FindBuffs(item, true); for (const auto buff : buffs) { - SkillComponent::HandleUnmanaged(buff, m_Parent->GetObjectID()); + SkillComponent::HandleUnmanaged(buff, m_OwningEntity->GetObjectID()); } } @@ -1041,7 +1041,7 @@ void InventoryComponent::RemoveBuff(Item* item) const { const auto buffs = FindBuffs(item, false); for (const auto buff : buffs) { - SkillComponent::HandleUnCast(buff, m_Parent->GetObjectID()); + SkillComponent::HandleUnCast(buff, m_OwningEntity->GetObjectID()); } } @@ -1076,14 +1076,14 @@ void InventoryComponent::PopEquippedItems() { m_Pushed.clear(); - auto destroyableComponent = m_Parent->GetComponent(); + auto destroyableComponent = m_OwningEntity->GetComponent(); // Reset stats to full if (destroyableComponent) { destroyableComponent->SetHealth(static_cast(destroyableComponent->GetMaxHealth())); destroyableComponent->SetArmor(static_cast(destroyableComponent->GetMaxArmor())); destroyableComponent->SetImagination(static_cast(destroyableComponent->GetMaxImagination())); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } m_Dirty = true; @@ -1169,10 +1169,10 @@ void InventoryComponent::AddItemSkills(const LOT lot) { if (index != m_Skills.end()) { const auto old = index->second; - GameMessages::SendRemoveSkill(m_Parent, old); + GameMessages::SendRemoveSkill(m_OwningEntity, old); } - GameMessages::SendAddSkill(m_Parent, skill, static_cast(slot)); + GameMessages::SendAddSkill(m_OwningEntity, skill, static_cast(slot)); m_Skills.insert_or_assign(slot, skill); } @@ -1194,14 +1194,14 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) { const auto old = index->second; - GameMessages::SendRemoveSkill(m_Parent, old); + GameMessages::SendRemoveSkill(m_OwningEntity, old); m_Skills.erase(slot); if (slot == BehaviorSlot::Primary) { m_Skills.insert_or_assign(BehaviorSlot::Primary, 1); - GameMessages::SendAddSkill(m_Parent, 1, static_cast(BehaviorSlot::Primary)); + GameMessages::SendAddSkill(m_OwningEntity, 1, static_cast(BehaviorSlot::Primary)); } } @@ -1227,7 +1227,7 @@ bool InventoryComponent::HasAnyPassive(const std::vectorGetObjectID()); + auto* current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); if (current != nullptr) { current->Deactivate(); @@ -1235,7 +1235,7 @@ void InventoryComponent::DespawnPet() { } void InventoryComponent::SpawnPet(Item* item) { - auto* current = PetComponent::GetActivePet(m_Parent->GetObjectID()); + auto* current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); if (current != nullptr) { current->Deactivate(); @@ -1246,18 +1246,18 @@ void InventoryComponent::SpawnPet(Item* item) { } // First check if we can summon the pet. You need 1 imagination to do so. - auto destroyableComponent = m_Parent->GetComponent(); + auto destroyableComponent = m_OwningEntity->GetComponent(); if (Game::config->GetValue("pets_take_imagination") == "1" && destroyableComponent && destroyableComponent->GetImagination() <= 0) { - GameMessages::SendUseItemRequirementsResponse(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), eUseItemResponse::NoImaginationForPet); + GameMessages::SendUseItemRequirementsResponse(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet); return; } EntityInfo info{}; info.lot = item->GetLot(); - info.pos = m_Parent->GetPosition(); + info.pos = m_OwningEntity->GetPosition(); info.rot = NiQuaternion::IDENTITY; - info.spawnerID = m_Parent->GetObjectID(); + info.spawnerID = m_OwningEntity->GetObjectID(); auto* pet = EntityManager::Instance()->CreateEntity(info); @@ -1339,7 +1339,7 @@ std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip return entry.objectTemplate == static_cast(item->GetLot()); }); - auto* missions = static_cast(m_Parent->GetComponent(eReplicaComponentType::MISSION)); + auto* missions = static_cast(m_OwningEntity->GetComponent(eReplicaComponentType::MISSION)); for (const auto& result : results) { if (result.castOnType == 1) { @@ -1356,7 +1356,7 @@ std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip } // If item is not a proxy, add its buff to the added buffs. - if (item->GetParent() == LWOOBJID_EMPTY) buffs.push_back(static_cast(entry.behaviorID)); + if (item->GetOwningEntity() == LWOOBJID_EMPTY) buffs.push_back(static_cast(entry.behaviorID)); } } @@ -1376,7 +1376,7 @@ void InventoryComponent::SetNPCItems(const std::vector& items) { UpdateSlot(info.equipLocation, { id, static_cast(item), 1, slot++ }, true); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } InventoryComponent::~InventoryComponent() { @@ -1442,7 +1442,7 @@ std::vector InventoryComponent::FindProxies(const LWOOBJID parent) { for (const auto& pair : inventory->GetItems()) { auto* item = pair.second; - if (item->GetParent() == parent) { + if (item->GetOwningEntity() == parent) { proxies.push_back(item); } } @@ -1479,7 +1479,7 @@ bool InventoryComponent::IsParentValid(Item* root) { for (const auto& candidate : items) { auto* item = candidate.second; - if (item->GetParent() == id) { + if (item->GetOwningEntity() == id) { return true; } } @@ -1497,7 +1497,7 @@ void InventoryComponent::CheckProxyIntegrity() { for (const auto& candidate : items) { auto* item = candidate.second; - const auto parent = item->GetParent(); + const auto parent = item->GetOwningEntity(); if (parent == LWOOBJID_EMPTY) { continue; @@ -1526,7 +1526,7 @@ void InventoryComponent::CheckProxyIntegrity() { { auto* item = candidate.second; - const auto parent = item->GetParent(); + const auto parent = item->GetOwningEntity(); if (parent != LWOOBJID_EMPTY) { @@ -1555,7 +1555,7 @@ void InventoryComponent::CheckProxyIntegrity() { } void InventoryComponent::PurgeProxies(Item* item) { - const auto root = item->GetParent(); + const auto root = item->GetOwningEntity(); if (root != LWOOBJID_EMPTY) { item = FindItemById(root); diff --git a/dGame/dComponents/LUPExhibitComponent.cpp b/dGame/dComponents/LUPExhibitComponent.cpp index 7b8c85ba7..5a98d2ab3 100644 --- a/dGame/dComponents/LUPExhibitComponent.cpp +++ b/dGame/dComponents/LUPExhibitComponent.cpp @@ -35,7 +35,7 @@ void LUPExhibitComponent::NextExhibit() { m_Exhibit = m_Exhibits[m_ExhibitIndex]; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index 8163e7363..682b9ac39 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -7,7 +7,7 @@ #include "CDRewardsTable.h" LevelProgressionComponent::LevelProgressionComponent(Entity* parent) : Component(parent) { - m_Parent = parent; + m_OwningEntity = parent; m_Level = 1; m_SpeedBase = 500.0f; m_CharacterVersion = eCharacterVersion::LIVE; @@ -49,12 +49,12 @@ void LevelProgressionComponent::HandleLevelUp() { const auto& rewards = rewardsTable->GetByLevelID(m_Level); bool rewardingItem = rewards.size() > 0; - auto* inventoryComponent = m_Parent->GetComponent(); - auto* controllablePhysicsComponent = m_Parent->GetComponent(); + auto* inventoryComponent = m_OwningEntity->GetComponent(); + auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (!inventoryComponent || !controllablePhysicsComponent) return; // Tell the client we beginning to send level rewards. - if (rewardingItem) GameMessages::NotifyLevelRewards(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), m_Level, rewardingItem); + if (rewardingItem) GameMessages::NotifyLevelRewards(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), m_Level, rewardingItem); for (auto* reward : rewards) { switch (reward->rewardType) { @@ -79,11 +79,11 @@ void LevelProgressionComponent::HandleLevelUp() { } } // Tell the client we have finished sending level rewards. - if (rewardingItem) GameMessages::NotifyLevelRewards(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), m_Level, !rewardingItem); + if (rewardingItem) GameMessages::NotifyLevelRewards(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), m_Level, !rewardingItem); } void LevelProgressionComponent::SetRetroactiveBaseSpeed(){ if (m_Level >= 20) m_SpeedBase = 525.0f; - auto* controllablePhysicsComponent = m_Parent->GetComponent(); + auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f); } diff --git a/dGame/dComponents/MissionComponent.cpp b/dGame/dComponents/MissionComponent.cpp index 8f61c1aaf..dae79025e 100644 --- a/dGame/dComponents/MissionComponent.cpp +++ b/dGame/dComponents/MissionComponent.cpp @@ -103,9 +103,9 @@ void MissionComponent::AcceptMission(const uint32_t missionId, const bool skipCh if (missionId == 1728) { //Needs to send a mail - auto address = m_Parent->GetSystemAddress(); + auto address = m_OwningEntity->GetSystemAddress(); - Mail::HandleNotificationRequest(address, m_Parent->GetObjectID()); + Mail::HandleNotificationRequest(address, m_OwningEntity->GetObjectID()); } } diff --git a/dGame/dComponents/MissionOfferComponent.cpp b/dGame/dComponents/MissionOfferComponent.cpp index e4c94ebd9..e4cca8941 100644 --- a/dGame/dComponents/MissionOfferComponent.cpp +++ b/dGame/dComponents/MissionOfferComponent.cpp @@ -109,14 +109,14 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi if (mission != nullptr) { if (specifiedMissionId <= 0) { // Handles the odd case where the offer object should not display the mission again - if (!mission->IsComplete() && mission->GetClientInfo().offer_objectID == m_Parent->GetLOT() && mission->GetClientInfo().target_objectID != m_Parent->GetLOT() && mission->IsFetchMission()) { + if (!mission->IsComplete() && mission->GetClientInfo().offer_objectID == m_OwningEntity->GetLOT() && mission->GetClientInfo().target_objectID != m_OwningEntity->GetLOT() && mission->IsFetchMission()) { continue; } } // We have the mission, if it is not complete, offer it if (mission->IsActive() || mission->IsReadyToComplete()) { - GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_Parent->GetObjectID()); + GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_OwningEntity->GetObjectID()); offered.push_back(missionId); @@ -162,7 +162,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi const auto& iter = std::find(randomMissionPool.begin(), randomMissionPool.end(), specifiedMissionId); if (iter != randomMissionPool.end() && MissionPrerequisites::CanAccept(specifiedMissionId, missionComponent->GetMissions())) { - GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), specifiedMissionId, m_Parent->GetObjectID()); + GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), specifiedMissionId, m_OwningEntity->GetObjectID()); return; } @@ -184,7 +184,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi continue; } - GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_Parent->GetObjectID()); + GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_OwningEntity->GetObjectID()); canAcceptPool.clear(); @@ -202,9 +202,9 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi const auto selected = canAcceptPool[GeneralUtils::GenerateRandomNumber(0, canAcceptPool.size() - 1)]; - GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_Parent->GetObjectID()); + GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_OwningEntity->GetObjectID()); } else if (std::find(offered.begin(), offered.end(), missionId) == offered.end() && offeredMission->GetOfferMission()) { - GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_Parent->GetObjectID()); + GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_OwningEntity->GetObjectID()); } } } diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 74f614d10..91924b5c5 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -2,17 +2,17 @@ #include "Entity.h" ModelComponent::ModelComponent(Entity* parent) : Component(parent) { - m_OriginalPosition = m_Parent->GetDefaultPosition(); - m_OriginalRotation = m_Parent->GetDefaultRotation(); + m_OriginalPosition = m_OwningEntity->GetDefaultPosition(); + m_OriginalRotation = m_OwningEntity->GetDefaultRotation(); - m_userModelID = m_Parent->GetVarAs(u"userModelID"); + m_userModelID = m_OwningEntity->GetVarAs(u"userModelID"); } void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { // ItemComponent Serialization. Pets do not get this serialization. - if (!m_Parent->HasComponent(eReplicaComponentType::PET)) { + if (!m_OwningEntity->HasComponent(eReplicaComponentType::PET)) { outBitStream->Write1(); - outBitStream->Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID()); + outBitStream->Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_OwningEntity->GetObjectID()); outBitStream->Write(0); outBitStream->Write0(); } diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index 7acec5f75..4a9d2bf56 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -22,14 +22,14 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : m_BaseCombatAI = nullptr; - m_BaseCombatAI = reinterpret_cast(m_Parent->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); + m_BaseCombatAI = reinterpret_cast(m_OwningEntity->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); //Try and fix the insane values: if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f; if (m_Info.wanderRadius > 8.0f) m_Info.wanderRadius = 8.0f; if (m_Info.wanderSpeed > 0.5f) m_Info.wanderSpeed = m_Info.wanderSpeed * 0.5f; - m_BaseSpeed = GetBaseSpeed(m_Parent->GetLOT()); + m_BaseSpeed = GetBaseSpeed(m_OwningEntity->GetLOT()); m_NextWaypoint = GetCurrentPosition(); m_Acceleration = 0.4f; @@ -149,7 +149,7 @@ void MovementAIComponent::Update(const float deltaTime) { SetVelocity(velocity); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } const MovementAIInfo& MovementAIComponent::GetInfo() const { @@ -179,7 +179,7 @@ NiPoint3 MovementAIComponent::GetNextWaypoint() const { } NiPoint3 MovementAIComponent::GetCurrentPosition() const { - return m_Parent->GetPosition(); + return m_OwningEntity->GetPosition(); } NiPoint3 MovementAIComponent::ApproximateLocation() const { @@ -221,7 +221,7 @@ bool MovementAIComponent::Warp(const NiPoint3& point) { SetPosition(destination); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); return true; } @@ -253,7 +253,7 @@ void MovementAIComponent::Stop() { m_CurrentSpeed = 0; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void MovementAIComponent::PullToPoint(const NiPoint3& point) { @@ -322,7 +322,7 @@ float MovementAIComponent::GetBaseSpeed(LOT lot) { } void MovementAIComponent::SetPosition(const NiPoint3& value) { - auto* controllablePhysicsComponent = m_Parent->GetComponent(); + auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetPosition(value); @@ -330,7 +330,7 @@ void MovementAIComponent::SetPosition(const NiPoint3& value) { return; } - auto* simplePhysicsComponent = m_Parent->GetComponent(); + auto* simplePhysicsComponent = m_OwningEntity->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetPosition(value); @@ -342,7 +342,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) { return; } - auto* controllablePhysicsComponent = m_Parent->GetComponent(); + auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetRotation(value); @@ -350,7 +350,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) { return; } - auto* simplePhysicsComponent = m_Parent->GetComponent(); + auto* simplePhysicsComponent = m_OwningEntity->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetRotation(value); @@ -358,7 +358,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) { } void MovementAIComponent::SetVelocity(const NiPoint3& value) { - auto* controllablePhysicsComponent = m_Parent->GetComponent(); + auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetVelocity(value); @@ -366,7 +366,7 @@ void MovementAIComponent::SetVelocity(const NiPoint3& value) { return; } - auto* simplePhysicsComponent = m_Parent->GetComponent(); + auto* simplePhysicsComponent = m_OwningEntity->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetVelocity(value); diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 2666c60ce..d94547555 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -57,7 +57,7 @@ void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIniti MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::string& pathName) : Component(parent) { m_MoverSubComponentType = eMoverSubComponentType::mover; - m_MoverSubComponent = new MoverSubComponent(m_Parent->GetDefaultPosition()); + m_MoverSubComponent = new MoverSubComponent(m_OwningEntity->GetDefaultPosition()); m_PathName = GeneralUtils::ASCIIToUTF16(pathName); m_Path = dZoneManager::Instance()->GetZone()->GetPath(pathName); m_NoAutoStart = false; @@ -133,7 +133,7 @@ void MovingPlatformComponent::SetMovementState(eMovementPlatformState value) { subComponent->mState = value; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint) { @@ -147,7 +147,7 @@ void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint) } void MovingPlatformComponent::StartPathing() { - //GameMessages::SendStartPathing(m_Parent); + //GameMessages::SendStartPathing(m_OwningEntity); m_PathingStopped = false; auto* subComponent = static_cast(m_MoverSubComponent); @@ -167,14 +167,14 @@ void MovingPlatformComponent::StartPathing() { targetPosition = nextWaypoint.position; } else { - subComponent->mPosition = m_Parent->GetPosition(); + subComponent->mPosition = m_OwningEntity->GetPosition(); subComponent->mSpeed = 1.0f; subComponent->mWaitTime = 2.0f; - targetPosition = m_Parent->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f); + targetPosition = m_OwningEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f); } - m_Parent->AddCallbackTimer(subComponent->mWaitTime, [this] { + m_OwningEntity->AddCallbackTimer(subComponent->mWaitTime, [this] { SetMovementState(eMovementPlatformState::Moving); }); @@ -182,19 +182,19 @@ void MovingPlatformComponent::StartPathing() { const auto travelNext = subComponent->mWaitTime + travelTime; - m_Parent->AddCallbackTimer(travelTime, [subComponent, this] { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex); + m_OwningEntity->AddCallbackTimer(travelTime, [subComponent, this] { + for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnWaypointReached(m_OwningEntity, subComponent->mNextWaypointIndex); } }); - m_Parent->AddCallbackTimer(travelNext, [this] { + m_OwningEntity->AddCallbackTimer(travelNext, [this] { ContinuePathing(); }); - //GameMessages::SendPlatformResync(m_Parent, UNASSIGNED_SYSTEM_ADDRESS); + //GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void MovingPlatformComponent::ContinuePathing() { @@ -222,17 +222,17 @@ void MovingPlatformComponent::ContinuePathing() { targetPosition = nextWaypoint.position; } else { - subComponent->mPosition = m_Parent->GetPosition(); + subComponent->mPosition = m_OwningEntity->GetPosition(); subComponent->mSpeed = 1.0f; subComponent->mWaitTime = 2.0f; - targetPosition = m_Parent->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f); + targetPosition = m_OwningEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f); pathSize = 1; behavior = PathBehavior::Loop; } - if (m_Parent->GetLOT() == 9483) { + if (m_OwningEntity->GetLOT() == 9483) { behavior = PathBehavior::Bounce; } else { return; @@ -242,7 +242,7 @@ void MovingPlatformComponent::ContinuePathing() { subComponent->mCurrentWaypointIndex = pathSize; switch (behavior) { case PathBehavior::Once: - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); return; case PathBehavior::Bounce: @@ -271,7 +271,7 @@ void MovingPlatformComponent::ContinuePathing() { subComponent->mCurrentWaypointIndex = 1; */ - //GameMessages::SendPlatformResync(m_Parent, UNASSIGNED_SYSTEM_ADDRESS); + //GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS); if (subComponent->mCurrentWaypointIndex == subComponent->mDesiredWaypointIndex) { // TODO: Send event? @@ -280,35 +280,35 @@ void MovingPlatformComponent::ContinuePathing() { return; } - m_Parent->CancelCallbackTimers(); + m_OwningEntity->CancelCallbackTimers(); - m_Parent->AddCallbackTimer(subComponent->mWaitTime, [this] { + m_OwningEntity->AddCallbackTimer(subComponent->mWaitTime, [this] { SetMovementState(eMovementPlatformState::Moving); }); auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5; - if (m_Parent->GetLOT() == 9483) { + if (m_OwningEntity->GetLOT() == 9483) { travelTime += 20; } const auto travelNext = subComponent->mWaitTime + travelTime; - m_Parent->AddCallbackTimer(travelTime, [subComponent, this] { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex); + m_OwningEntity->AddCallbackTimer(travelTime, [subComponent, this] { + for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnWaypointReached(m_OwningEntity, subComponent->mNextWaypointIndex); } }); - m_Parent->AddCallbackTimer(travelNext, [this] { + m_OwningEntity->AddCallbackTimer(travelNext, [this] { ContinuePathing(); }); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void MovingPlatformComponent::StopPathing() { - //m_Parent->CancelCallbackTimers(); + //m_OwningEntity->CancelCallbackTimers(); auto* subComponent = static_cast(m_MoverSubComponent); @@ -318,9 +318,9 @@ void MovingPlatformComponent::StopPathing() { subComponent->mDesiredWaypointIndex = -1; subComponent->mShouldStopAtDesiredWaypoint = false; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); - //GameMessages::SendPlatformResync(m_Parent, UNASSIGNED_SYSTEM_ADDRESS); + //GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS); } void MovingPlatformComponent::SetSerialized(bool value) { @@ -338,10 +338,10 @@ void MovingPlatformComponent::SetNoAutoStart(const bool value) { void MovingPlatformComponent::WarpToWaypoint(size_t index) { const auto& waypoint = m_Path->pathWaypoints[index]; - m_Parent->SetPosition(waypoint.position); - m_Parent->SetRotation(waypoint.rotation); + m_OwningEntity->SetPosition(waypoint.position); + m_OwningEntity->SetRotation(waypoint.rotation); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } size_t MovingPlatformComponent::GetLastWaypointIndex() const { diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index c37ce6a0b..7eaa551cd 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -173,7 +173,7 @@ void PetComponent::OnUse(Entity* originator) { return; } - auto* movementAIComponent = m_Parent->GetComponent(); + auto* movementAIComponent = m_OwningEntity->GetComponent(); if (movementAIComponent != nullptr) { movementAIComponent->Stop(); @@ -181,7 +181,7 @@ void PetComponent::OnUse(Entity* originator) { inventoryComponent->DespawnPet(); - const auto& cached = buildCache.find(m_Parent->GetLOT()); + const auto& cached = buildCache.find(m_OwningEntity->GetLOT()); int32_t imaginationCost = 0; std::string buildFile; @@ -189,7 +189,7 @@ void PetComponent::OnUse(Entity* originator) { if (cached == buildCache.end()) { auto query = CDClientDatabase::CreatePreppedStmt( "SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;"); - query.bind(1, (int)m_Parent->GetLOT()); + query.bind(1, (int)m_OwningEntity->GetLOT()); auto result = query.execQuery(); @@ -216,7 +216,7 @@ void PetComponent::OnUse(Entity* originator) { if (data.timeLimit <= 0) data.timeLimit = 60; imaginationCost = data.imaginationCost; - buildCache[m_Parent->GetLOT()] = data; + buildCache[m_OwningEntity->GetLOT()] = data; result.finalize(); } else { @@ -245,13 +245,13 @@ void PetComponent::OnUse(Entity* originator) { return; } - auto petPosition = m_Parent->GetPosition(); + auto petPosition = m_OwningEntity->GetPosition(); auto originatorPosition = originator->GetPosition(); - m_Parent->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition)); + m_OwningEntity->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition)); - float interactionDistance = m_Parent->GetVar(u"interaction_distance"); + float interactionDistance = m_OwningEntity->GetVar(u"interaction_distance"); if (interactionDistance <= 0) { interactionDistance = 15; @@ -259,7 +259,7 @@ void PetComponent::OnUse(Entity* originator) { auto position = originatorPosition; - NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector(); + NiPoint3 forward = NiQuaternion::LookAt(m_OwningEntity->GetPosition(), originator->GetPosition()).GetForwardVector(); forward.y = 0; if (dpWorld::Instance().IsLoaded()) { @@ -268,7 +268,7 @@ void PetComponent::OnUse(Entity* originator) { float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt); while (std::abs(y - petPosition.y) > 4 && interactionDistance > 10) { - const NiPoint3 forward = m_Parent->GetRotation().GetForwardVector(); + const NiPoint3 forward = m_OwningEntity->GetRotation().GetForwardVector(); attempt = originatorPosition + forward * interactionDistance; @@ -287,7 +287,7 @@ void PetComponent::OnUse(Entity* originator) { GameMessages::SendNotifyPetTamingMinigame( originator->GetObjectID(), - m_Parent->GetObjectID(), + m_OwningEntity->GetObjectID(), LWOOBJID_EMPTY, true, ePetTamingNotifyType::BEGIN, @@ -298,7 +298,7 @@ void PetComponent::OnUse(Entity* originator) { ); GameMessages::SendNotifyPetTamingMinigame( - m_Parent->GetObjectID(), + m_OwningEntity->GetObjectID(), LWOOBJID_EMPTY, originator->GetObjectID(), true, @@ -314,17 +314,17 @@ void PetComponent::OnUse(Entity* originator) { m_Tamer = originator->GetObjectID(); SetStatus(5); - currentActivities.insert_or_assign(m_Tamer, m_Parent->GetObjectID()); + currentActivities.insert_or_assign(m_Tamer, m_OwningEntity->GetObjectID()); // Notify the start of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN); + for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnNotifyPetTamingMinigame(m_OwningEntity, originator, ePetTamingNotifyType::BEGIN); } } void PetComponent::Update(float deltaTime) { if (m_StartPosition == NiPoint3::ZERO) { - m_StartPosition = m_Parent->GetPosition(); + m_StartPosition = m_OwningEntity->GetPosition(); } if (m_Owner == LWOOBJID_EMPTY) { @@ -344,7 +344,7 @@ void PetComponent::Update(float deltaTime) { if (m_Timer <= 0) { Wander(); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } else { m_Timer = 5; @@ -357,12 +357,12 @@ void PetComponent::Update(float deltaTime) { auto* owner = GetOwner(); if (owner == nullptr) { - m_Parent->Kill(); + m_OwningEntity->Kill(); return; } - m_MovementAI = m_Parent->GetComponent(); + m_MovementAI = m_OwningEntity->GetComponent(); if (m_MovementAI == nullptr) { return; @@ -382,9 +382,9 @@ void PetComponent::Update(float deltaTime) { m_MovementAI->Stop(); if (m_TresureTime <= 0) { - m_Parent->SetOwnerOverride(m_Owner); + m_OwningEntity->SetOwnerOverride(m_Owner); - tresure->Smash(m_Parent->GetObjectID()); + tresure->Smash(m_OwningEntity->GetObjectID()); m_Interaction = LWOOBJID_EMPTY; @@ -430,7 +430,7 @@ void PetComponent::Update(float deltaTime) { float distance = Vector3::DistanceSquared(position, switchPosition); if (distance < 3 * 3) { m_Interaction = closestSwitch->GetParentEntity()->GetObjectID(); - closestSwitch->EntityEnter(m_Parent); + closestSwitch->EntityEnter(m_OwningEntity); } else if (distance < 20 * 20) { haltDistance = 1; @@ -443,7 +443,7 @@ void PetComponent::Update(float deltaTime) { if (closestTresure != nullptr) { // Skeleton Dragon Pat special case for bone digging - if (closestTresure->GetLOT() == 12192 && m_Parent->GetLOT() != 13067) { + if (closestTresure->GetLOT() == 12192 && m_OwningEntity->GetLOT() != 13067) { goto skipTresure; } @@ -484,7 +484,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) { return; } - const auto& cached = buildCache.find(m_Parent->GetLOT()); + const auto& cached = buildCache.find(m_OwningEntity->GetLOT()); if (cached == buildCache.end()) return; @@ -524,7 +524,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { return; } - const auto& cached = buildCache.find(m_Parent->GetLOT()); + const auto& cached = buildCache.find(m_OwningEntity->GetLOT()); if (cached == buildCache.end()) { return; @@ -547,7 +547,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress()); - GameMessages::SendPetResponse(m_Tamer, m_Parent->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress()); + GameMessages::SendPetResponse(m_Tamer, m_OwningEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress()); auto* inventoryComponent = tamer->GetComponent(); @@ -565,13 +565,13 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { std::string petName = tamer->GetCharacter()->GetName(); petName += "'s Pet"; - GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_Parent->GetLOT(), tamer->GetSystemAddress()); + GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_OwningEntity->GetLOT(), tamer->GetSystemAddress()); - GameMessages::SendRegisterPetID(m_Tamer, m_Parent->GetObjectID(), tamer->GetSystemAddress()); + GameMessages::SendRegisterPetID(m_Tamer, m_OwningEntity->GetObjectID(), tamer->GetSystemAddress()); GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress()); - inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey); + inventoryComponent->AddItem(m_OwningEntity->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey); auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS); if (item == nullptr) { @@ -580,7 +580,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { DatabasePet databasePet{}; - databasePet.lot = m_Parent->GetLOT(); + databasePet.lot = m_OwningEntity->GetLOT(); databasePet.moderationState = 1; databasePet.name = petName; @@ -603,14 +603,14 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { ); // Triggers the catch a pet missions - if (petFlags.find(m_Parent->GetLOT()) != petFlags.end()) { - tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_Parent->GetLOT()), true); + if (petFlags.find(m_OwningEntity->GetLOT()) != petFlags.end()) { + tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_OwningEntity->GetLOT()), true); } auto* missionComponent = tamer->GetComponent(); if (missionComponent != nullptr) { - missionComponent->Progress(eMissionTaskType::PET_TAMING, m_Parent->GetLOT()); + missionComponent->Progress(eMissionTaskType::PET_TAMING, m_OwningEntity->GetLOT()); } SetStatus(1); @@ -661,18 +661,18 @@ void PetComponent::RequestSetPetName(std::u16string name) { //Save our pet's new name to the db: SetPetNameForModeration(GeneralUtils::UTF16ToWTF8(name)); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); std::u16string u16name = GeneralUtils::UTF8ToUTF16(m_Name); std::u16string u16ownerName = GeneralUtils::UTF8ToUTF16(m_OwnerName); GameMessages::SendSetPetName(m_Tamer, u16name, m_DatabaseId, tamer->GetSystemAddress()); GameMessages::SendSetPetName(m_Tamer, u16name, LWOOBJID_EMPTY, tamer->GetSystemAddress()); - GameMessages::SendPetNameChanged(m_Parent->GetObjectID(), m_ModerationStatus, u16name, u16ownerName, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendPetNameChanged(m_OwningEntity->GetObjectID(), m_ModerationStatus, u16name, u16ownerName, UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendSetPetNameModerated(m_Tamer, m_DatabaseId, m_ModerationStatus, tamer->GetSystemAddress()); GameMessages::SendNotifyPetTamingMinigame( m_Tamer, - m_Parent->GetObjectID(), + m_OwningEntity->GetObjectID(), m_Tamer, false, ePetTamingNotifyType::SUCCESS, @@ -682,7 +682,7 @@ void PetComponent::RequestSetPetName(std::u16string name) { UNASSIGNED_SYSTEM_ADDRESS ); - GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); + GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID()); auto* modelEntity = EntityManager::Instance()->GetEntity(m_ModelId); @@ -695,8 +695,8 @@ void PetComponent::RequestSetPetName(std::u16string name) { m_Tamer = LWOOBJID_EMPTY; // Notify the end of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS); + for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::SUCCESS); } } @@ -713,7 +713,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { GameMessages::SendNotifyPetTamingMinigame( m_Tamer, - m_Parent->GetObjectID(), + m_OwningEntity->GetObjectID(), m_Tamer, false, ePetTamingNotifyType::QUIT, @@ -725,7 +725,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress()); - GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); + GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID()); currentActivities.erase(m_Tamer); @@ -733,16 +733,16 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { m_Tamer = LWOOBJID_EMPTY; m_Timer = 0; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); // Notify the end of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT); + for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::QUIT); } } void PetComponent::StartTimer() { - const auto& cached = buildCache.find(m_Parent->GetLOT()); + const auto& cached = buildCache.find(m_OwningEntity->GetLOT()); if (cached == buildCache.end()) { return; @@ -764,7 +764,7 @@ void PetComponent::ClientFailTamingMinigame() { GameMessages::SendNotifyPetTamingMinigame( m_Tamer, - m_Parent->GetObjectID(), + m_OwningEntity->GetObjectID(), m_Tamer, false, ePetTamingNotifyType::FAILED, @@ -776,7 +776,7 @@ void PetComponent::ClientFailTamingMinigame() { GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress()); - GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); + GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID()); currentActivities.erase(m_Tamer); @@ -784,16 +784,16 @@ void PetComponent::ClientFailTamingMinigame() { m_Tamer = LWOOBJID_EMPTY; m_Timer = 0; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); // Notify the end of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED); + for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::FAILED); } } void PetComponent::Wander() { - m_MovementAI = m_Parent->GetComponent(); + m_MovementAI = m_OwningEntity->GetComponent(); if (m_MovementAI == nullptr || !m_MovementAI->AtFinalWaypoint()) { return; @@ -847,7 +847,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { inventoryComponent->DespawnPet(); - m_Owner = inventoryComponent->GetParent()->GetObjectID(); + m_Owner = inventoryComponent->GetOwningEntity()->GetObjectID(); auto* owner = GetOwner(); @@ -883,18 +883,18 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { GameMessages::SendMarkInventoryItemAsActive(m_Owner, true, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress()); - activePets[m_Owner] = m_Parent->GetObjectID(); + activePets[m_Owner] = m_OwningEntity->GetObjectID(); m_Timer = 3; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true); if (registerPet) { - GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_Parent->GetLOT(), owner->GetSystemAddress()); + GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_OwningEntity->GetLOT(), owner->GetSystemAddress()); - GameMessages::SendRegisterPetID(m_Owner, m_Parent->GetObjectID(), owner->GetSystemAddress()); + GameMessages::SendRegisterPetID(m_Owner, m_OwningEntity->GetObjectID(), owner->GetSystemAddress()); GameMessages::SendRegisterPetDBID(m_Owner, m_DatabaseId, owner->GetSystemAddress()); } @@ -911,7 +911,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { auto playerInventoryComponent = playerInventory->GetComponent(); if (!playerInventoryComponent) return; - auto playerEntity = playerInventoryComponent->GetParent(); + auto playerEntity = playerInventoryComponent->GetOwningEntity(); if (!playerEntity) return; auto playerDestroyableComponent = playerEntity->GetComponent(); @@ -921,7 +921,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { if (!fromTaming) playerDestroyableComponent->Imagine(-1); // Set this to a variable so when this is called back from the player the timer doesn't fire off. - m_Parent->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() { + m_OwningEntity->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() { if (!playerDestroyableComponent) { Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent"); return; @@ -930,7 +930,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { // If we are out of imagination despawn the pet. if (playerDestroyableComponent->GetImagination() == 0) { this->Deactivate(); - auto playerEntity = playerDestroyableComponent->GetParent(); + auto playerEntity = playerDestroyableComponent->GetOwningEntity(); if (!playerEntity) return; GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet); @@ -941,13 +941,13 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { } void PetComponent::Deactivate() { - GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true); + GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true); GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress()); activePets.erase(m_Owner); - m_Parent->Kill(); + m_OwningEntity->Kill(); auto* owner = GetOwner(); @@ -987,7 +987,7 @@ void PetComponent::Command(NiPoint3 position, LWOOBJID source, int32_t commandTy if (commandType == 1) { // Emotes - GameMessages::SendPlayEmote(m_Parent->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendPlayEmote(m_OwningEntity->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); } else if (commandType == 3) { // Follow me, ??? } else if (commandType == 6) { @@ -1076,7 +1076,7 @@ PetComponent* PetComponent::GetActivePet(LWOOBJID owner) { } Entity* PetComponent::GetParentEntity() const { - return m_Parent; + return m_OwningEntity; } PetComponent::~PetComponent() { diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index e6272aa4a..02158de2b 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -28,9 +28,9 @@ #include "dpShapeSphere.h" PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) { - m_Position = m_Parent->GetDefaultPosition(); - m_Rotation = m_Parent->GetDefaultRotation(); - m_Scale = m_Parent->GetDefaultScale(); + m_Position = m_OwningEntity->GetDefaultPosition(); + m_Rotation = m_OwningEntity->GetDefaultRotation(); + m_Scale = m_OwningEntity->GetDefaultScale(); m_dpEntity = nullptr; m_EffectInfoDirty = false; @@ -47,17 +47,17 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par m_IsDirectional = false; m_Direction = NiPoint3(); // * m_DirectionalMultiplier - if (m_Parent->GetVar(u"create_physics")) { + if (m_OwningEntity->GetVar(u"create_physics")) { CreatePhysics(); } - if (m_Parent->GetVar(u"respawnVol")) { + if (m_OwningEntity->GetVar(u"respawnVol")) { m_IsRespawnVolume = true; } if (m_IsRespawnVolume) { { - auto respawnString = std::stringstream(m_Parent->GetVarAsString(u"rspPos")); + auto respawnString = std::stringstream(m_OwningEntity->GetVarAsString(u"rspPos")); std::string segment; std::vector seglist; @@ -70,7 +70,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par } { - auto respawnString = std::stringstream(m_Parent->GetVarAsString(u"rspRot")); + auto respawnString = std::stringstream(m_OwningEntity->GetVarAsString(u"rspRot")); std::string segment; std::vector seglist; @@ -84,7 +84,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par } // HF - RespawnPoints. Legacy respawn entity. - if (m_Parent->GetLOT() == 4945) { + if (m_OwningEntity->GetLOT() == 4945) { m_IsRespawnVolume = true; m_RespawnPos = m_Position; m_RespawnRot = m_Rotation; @@ -133,7 +133,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par } } - if (m_Parent->GetLOT() == 4945) // HF - RespawnPoints + if (m_OwningEntity->GetLOT() == 4945) // HF - RespawnPoints { m_IsRespawnVolume = true; m_RespawnPos = m_Position; @@ -145,7 +145,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par if (!m_HasCreatedPhysics) { CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable(); - auto componentID = compRegistryTable->GetByIDAndType(m_Parent->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS); + auto componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS); CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable(); @@ -156,7 +156,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par //temp test if (info->physicsAsset == "miscellaneous\\misc_phys_10x1x5.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 10.0f, 5.0f, 1.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 10.0f, 5.0f, 1.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); @@ -167,7 +167,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par // Move this down by 13.521004 units so it is still effectively at the same height as before m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f; // TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem... - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); @@ -175,49 +175,49 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 10.0f, 25.0f, 1.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 10.0f, 25.0f, 1.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 20.0f, 20.0f, 20.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 20.0f, 20.0f, 20.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 18.0f, 5.0f, 15.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 18.0f, 5.0f, 15.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1.0f, 1.0f, 12.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1.0f, 1.0f, 12.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\Ring_Trigger.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 6.0f, 6.0f, 6.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 6.0f, 6.0f, 6.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 4.5f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 4.5f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx"){ - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_Position.y -= (111.467964f * m_Scale) / 2; @@ -227,7 +227,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par //Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str()); //add fallback cube: - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 2.0f, 2.0f, 2.0f); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 2.0f, 2.0f, 2.0f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); @@ -255,14 +255,14 @@ void PhantomPhysicsComponent::CreatePhysics() { float width = 0.0f; //aka "radius" float height = 0.0f; - if (m_Parent->HasVar(u"primitiveModelType")) { - type = m_Parent->GetVar(u"primitiveModelType"); - x = m_Parent->GetVar(u"primitiveModelValueX"); - y = m_Parent->GetVar(u"primitiveModelValueY"); - z = m_Parent->GetVar(u"primitiveModelValueZ"); + if (m_OwningEntity->HasVar(u"primitiveModelType")) { + type = m_OwningEntity->GetVar(u"primitiveModelType"); + x = m_OwningEntity->GetVar(u"primitiveModelValueX"); + y = m_OwningEntity->GetVar(u"primitiveModelValueY"); + z = m_OwningEntity->GetVar(u"primitiveModelValueZ"); } else { CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable(); - auto componentID = compRegistryTable->GetByIDAndType(m_Parent->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS); + auto componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS); CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable(); @@ -292,7 +292,7 @@ void PhantomPhysicsComponent::CreatePhysics() { boxSize = NiPoint3(width, height, width); } - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), boxSize); + m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), boxSize); break; } } @@ -358,7 +358,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) { //Process enter events for (auto en : m_dpEntity->GetNewObjects()) { - m_Parent->OnCollisionPhantom(en->GetObjectID()); + m_OwningEntity->OnCollisionPhantom(en->GetObjectID()); //If we are a respawn volume, inform the client: if (m_IsRespawnVolume) { @@ -374,7 +374,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) { //Process exit events for (auto en : m_dpEntity->GetRemovedObjects()) { - m_Parent->OnCollisionLeavePhantom(en->GetObjectID()); + m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID()); } } @@ -391,7 +391,7 @@ void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) { void PhantomPhysicsComponent::SpawnVertices() { if (!m_dpEntity) return; - std::cout << m_Parent->GetObjectID() << std::endl; + std::cout << m_OwningEntity->GetObjectID() << std::endl; auto box = static_cast(m_dpEntity->GetShape()); for (auto vert : box->GetVertices()) { std::cout << vert.x << ", " << vert.y << ", " << vert.z << std::endl; @@ -400,7 +400,7 @@ void PhantomPhysicsComponent::SpawnVertices() { info.lot = 33; info.pos = vert; info.spawner = nullptr; - info.spawnerID = m_Parent->GetObjectID(); + info.spawnerID = m_OwningEntity->GetObjectID(); info.spawnerNodeID = 0; Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr); diff --git a/dGame/dComponents/PlayerForcedMovementComponent.cpp b/dGame/dComponents/PlayerForcedMovementComponent.cpp index 76993507f..02984746a 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.cpp +++ b/dGame/dComponents/PlayerForcedMovementComponent.cpp @@ -1,7 +1,7 @@ #include "PlayerForcedMovementComponent.h" PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : Component(parent) { - m_Parent = parent; + m_OwningEntity = parent; } PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {} diff --git a/dGame/dComponents/PossessableComponent.cpp b/dGame/dComponents/PossessableComponent.cpp index 5c45a6c19..1b137bb1c 100644 --- a/dGame/dComponents/PossessableComponent.cpp +++ b/dGame/dComponents/PossessableComponent.cpp @@ -6,7 +6,7 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent) { m_Possessor = LWOOBJID_EMPTY; - CDItemComponent item = Inventory::FindItemComponent(m_Parent->GetLOT()); + CDItemComponent item = Inventory::FindItemComponent(m_OwningEntity->GetLOT()); m_AnimationFlag = static_cast(item.animationFlag); // Get the possession Type from the CDClient @@ -44,12 +44,12 @@ void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn void PossessableComponent::Dismount() { SetPossessor(LWOOBJID_EMPTY); - if (m_ItemSpawned) m_Parent->ScheduleKillAfterUpdate(); + if (m_ItemSpawned) m_OwningEntity->ScheduleKillAfterUpdate(); } void PossessableComponent::OnUse(Entity* originator) { auto* possessor = originator->GetComponent(); if (possessor) { - possessor->Mount(m_Parent); + possessor->Mount(m_OwningEntity); } } diff --git a/dGame/dComponents/PossessorComponent.cpp b/dGame/dComponents/PossessorComponent.cpp index 387b34791..c1fd53808 100644 --- a/dGame/dComponents/PossessorComponent.cpp +++ b/dGame/dComponents/PossessorComponent.cpp @@ -18,7 +18,7 @@ PossessorComponent::~PossessorComponent() { auto* possessable = mount->GetComponent(); if (possessable) { if (possessable->GetIsItemSpawned()) { - GameMessages::SendMarkInventoryItemAsActive(m_Parent->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_Parent->GetSystemAddress()); + GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_OwningEntity->GetSystemAddress()); } possessable->Dismount(); } @@ -42,23 +42,23 @@ void PossessorComponent::Mount(Entity* mount) { // Don't do anything if we are busy dismounting if (GetIsDismounting() || !mount) return; - GameMessages::SendSetMountInventoryID(m_Parent, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendSetMountInventoryID(m_OwningEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); auto* possessableComponent = mount->GetComponent(); if (possessableComponent) { - possessableComponent->SetPossessor(m_Parent->GetObjectID()); + possessableComponent->SetPossessor(m_OwningEntity->GetObjectID()); SetPossessable(mount->GetObjectID()); SetPossessableType(possessableComponent->GetPossessionType()); } - auto characterComponent = m_Parent->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (characterComponent) characterComponent->SetIsRacing(true); // GM's to send - GameMessages::SendSetJetPackMode(m_Parent, false); - GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress()); - GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStateChangeType::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true); + GameMessages::SendSetJetPackMode(m_OwningEntity, false); + GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress()); + GameMessages::SendSetStunned(m_OwningEntity->GetObjectID(), eStateChangeType::PUSH, m_OwningEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); EntityManager::Instance()->SerializeEntity(mount); } @@ -73,12 +73,12 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) { possessableComponent->SetPossessor(LWOOBJID_EMPTY); if (forceDismount) possessableComponent->ForceDepossess(); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); EntityManager::Instance()->SerializeEntity(mount); - auto characterComponent = m_Parent->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (characterComponent) characterComponent->SetIsRacing(false); } // Make sure we don't have wacky controls - GameMessages::SendSetPlayerControlScheme(m_Parent, eControlScheme::SCHEME_A); + GameMessages::SendSetPlayerControlScheme(m_OwningEntity, eControlScheme::SCHEME_A); } diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index bff917d8a..6fab366bf 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -32,7 +32,7 @@ void PropertyEntranceComponent::OnUse(Entity* entity) { auto* rocket = entity->GetComponent()->RocketEquip(entity); if (!rocket) return; - GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), entity->GetSystemAddress()); + GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), entity->GetSystemAddress()); AMFArrayValue args; @@ -63,7 +63,7 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, cloneId = query[index].CloneId; } - auto* launcher = m_Parent->GetComponent(); + auto* launcher = m_OwningEntity->GetComponent(); if (launcher == nullptr) { return; @@ -330,5 +330,5 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl delete propertiesLeft; propertiesLeft = nullptr; - GameMessages::SendPropertySelectQuery(m_Parent->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr); + GameMessages::SendPropertySelectQuery(m_OwningEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr); } diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index c87d0744f..1520f4727 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -206,7 +206,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) { std::string name = zone->GetZoneName(); std::string description = ""; - auto prop_path = zone->GetPath(m_Parent->GetVarAsString(u"propertyName")); + auto prop_path = zone->GetPath(m_OwningEntity->GetVarAsString(u"propertyName")); if (prop_path){ if (!prop_path->property.displayName.empty()) name = prop_path->property.displayName; @@ -395,7 +395,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N models.insert_or_assign(model->GetObjectID(), spawnerId); - GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_Parent->GetObjectID(), 14, originalRotation); + GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_OwningEntity->GetObjectID(), 14, originalRotation); GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId); @@ -783,7 +783,7 @@ PropertyManagementComponent* PropertyManagementComponent::Instance() { void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author) { if (author == LWOOBJID_EMPTY) { - author = m_Parent->GetObjectID(); + author = m_OwningEntity->GetObjectID(); } const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID(); @@ -861,7 +861,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const void PropertyManagementComponent::OnUse(Entity* originator) { OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendOpenPropertyManagment(m_Parent->GetObjectID(), originator->GetSystemAddress()); + GameMessages::SendOpenPropertyManagment(m_OwningEntity->GetObjectID(), originator->GetSystemAddress()); } void PropertyManagementComponent::SetOwnerId(const LWOOBJID value) { diff --git a/dGame/dComponents/PropertyVendorComponent.cpp b/dGame/dComponents/PropertyVendorComponent.cpp index ed89bfc7e..6b65af474 100644 --- a/dGame/dComponents/PropertyVendorComponent.cpp +++ b/dGame/dComponents/PropertyVendorComponent.cpp @@ -21,7 +21,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) { if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) { Game::logger->Log("PropertyVendorComponent", "Property vendor opening!"); - GameMessages::SendOpenPropertyVendor(m_Parent->GetObjectID(), originator->GetSystemAddress()); + GameMessages::SendOpenPropertyVendor(m_OwningEntity->GetObjectID(), originator->GetSystemAddress()); return; } @@ -30,7 +30,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) { void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) { if (PropertyManagementComponent::Instance() == nullptr) return; - PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_Parent->GetObjectID()); + PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_OwningEntity->GetObjectID()); } void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) { @@ -41,11 +41,11 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con return; } - GameMessages::SendPropertyRentalResponse(m_Parent->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress()); + GameMessages::SendPropertyRentalResponse(m_OwningEntity->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress()); auto* controller = dZoneManager::Instance()->GetZoneControlObject(); - controller->OnFireEventServerSide(m_Parent, "propertyRented"); + controller->OnFireEventServerSide(m_OwningEntity, "propertyRented"); PropertyManagementComponent::Instance()->SetOwner(originator); diff --git a/dGame/dComponents/ProximityMonitorComponent.cpp b/dGame/dComponents/ProximityMonitorComponent.cpp index acc93fdea..20425948a 100644 --- a/dGame/dComponents/ProximityMonitorComponent.cpp +++ b/dGame/dComponents/ProximityMonitorComponent.cpp @@ -25,8 +25,8 @@ ProximityMonitorComponent::~ProximityMonitorComponent() { } void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::string& name) { - dpEntity* en = new dpEntity(m_Parent->GetObjectID(), proxRadius); - en->SetPosition(m_Parent->GetPosition()); + dpEntity* en = new dpEntity(m_OwningEntity->GetObjectID(), proxRadius); + en->SetPosition(m_OwningEntity->GetPosition()); dpWorld::Instance().AddEntity(en); m_ProximitiesData.insert(std::make_pair(name, en)); @@ -34,7 +34,7 @@ void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std:: void ProximityMonitorComponent::SetProximityRadius(dpEntity* entity, const std::string& name) { dpWorld::Instance().AddEntity(entity); - entity->SetPosition(m_Parent->GetPosition()); + entity->SetPosition(m_OwningEntity->GetPosition()); m_ProximitiesData.insert(std::make_pair(name, entity)); } @@ -66,12 +66,12 @@ void ProximityMonitorComponent::Update(float deltaTime) { //Process enter events for (auto* en : prox.second->GetNewObjects()) { - m_Parent->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER"); + m_OwningEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER"); } //Process exit events for (auto* en : prox.second->GetRemovedObjects()) { - m_Parent->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE"); + m_OwningEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE"); } } } diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 4a4ead59b..5c8ee8343 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -133,13 +133,13 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, info.lot = 8092; info.pos = startPosition; info.rot = startRotation; - info.spawnerID = m_Parent->GetObjectID(); + info.spawnerID = m_OwningEntity->GetObjectID(); auto* carEntity = - EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); + EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity); // Make the vehicle a child of the racing controller. - m_Parent->AddChild(carEntity); + m_OwningEntity->AddChild(carEntity); auto* destroyableComponent = carEntity->GetComponent(); @@ -209,17 +209,17 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, EntityManager::Instance()->ConstructEntity(carEntity); EntityManager::Instance()->SerializeEntity(player); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); GameMessages::SendRacingSetPlayerResetInfo( - m_Parent->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1, + m_OwningEntity->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1, UNASSIGNED_SYSTEM_ADDRESS); const auto playerID = player->GetObjectID(); // Reset the player to the start position during downtime, in case something // went wrong. - m_Parent->AddCallbackTimer(1, [this, playerID]() { + m_OwningEntity->AddCallbackTimer(1, [this, playerID]() { auto* player = EntityManager::Instance()->GetEntity(playerID); if (player == nullptr) { @@ -227,14 +227,14 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, } GameMessages::SendRacingResetPlayerToLastReset( - m_Parent->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS); + m_OwningEntity->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS); }); GameMessages::SendSetJetPackMode(player, false); // Set the vehicle's state. GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), - m_Parent->GetObjectID(), + m_OwningEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendVehicleSetWheelLockState(carEntity->GetObjectID(), false, @@ -257,7 +257,7 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) { if (racingPlayer.playerID != player->GetObjectID()) { if (racingPlayer.playerLoaded) { GameMessages::SendRacingPlayerLoaded( - m_Parent->GetObjectID(), racingPlayer.playerID, + m_OwningEntity->GetObjectID(), racingPlayer.playerID, racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS); } @@ -267,11 +267,11 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) { racingPlayer.playerLoaded = true; GameMessages::SendRacingPlayerLoaded( - m_Parent->GetObjectID(), racingPlayer.playerID, + m_OwningEntity->GetObjectID(), racingPlayer.playerID, racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void RacingControlComponent::OnRequestDie(Entity* player) { @@ -304,15 +304,15 @@ void RacingControlComponent::OnRequestDie(Entity* player) { // Respawn the player in 2 seconds, as was done in live. Not sure if this value is in a setting somewhere else... vehicle->AddCallbackTimer(2.0f, [=]() { - if (!vehicle || !this->m_Parent) return; + if (!vehicle || !this->m_OwningEntity) return; GameMessages::SendRacingResetPlayerToLastReset( - m_Parent->GetObjectID(), racingPlayer.playerID, + m_OwningEntity->GetObjectID(), racingPlayer.playerID, UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendVehicleStopBoost(vehicle, player->GetSystemAddress(), true); GameMessages::SendRacingSetPlayerResetInfo( - m_Parent->GetObjectID(), racingPlayer.lap, + m_OwningEntity->GetObjectID(), racingPlayer.lap, racingPlayer.respawnIndex, player->GetObjectID(), racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1, UNASSIGNED_SYSTEM_ADDRESS); @@ -330,12 +330,12 @@ void RacingControlComponent::OnRequestDie(Entity* player) { } } else { GameMessages::SendRacingSetPlayerResetInfo( - m_Parent->GetObjectID(), racingPlayer.lap, + m_OwningEntity->GetObjectID(), racingPlayer.lap, racingPlayer.respawnIndex, player->GetObjectID(), racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1, UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendRacingResetPlayerToLastReset( - m_Parent->GetObjectID(), racingPlayer.playerID, + m_OwningEntity->GetObjectID(), racingPlayer.playerID, UNASSIGNED_SYSTEM_ADDRESS); } } @@ -379,11 +379,11 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu // Calculate the score, different loot depending on player count const auto score = m_LoadedPlayers * 10 + data->finished; - LootGenerator::Instance().GiveActivityLoot(player, m_Parent, m_ActivityID, score); + LootGenerator::Instance().GiveActivityLoot(player, m_OwningEntity, m_ActivityID, score); // Giving rewards GameMessages::SendNotifyRacingClient( - m_Parent->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"", + m_OwningEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"", player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); auto* missionComponent = player->GetComponent(); @@ -413,7 +413,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu // Exiting race GameMessages::SendNotifyRacingClient( - m_Parent->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"", + m_OwningEntity->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"", player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); auto* playerInstance = dynamic_cast(player); @@ -621,7 +621,7 @@ void RacingControlComponent::Update(float deltaTime) { // Setup for racing if (m_StartTimer == 0) { GameMessages::SendNotifyRacingClient( - m_Parent->GetObjectID(), 1, 0, LWOOBJID_EMPTY, u"", + m_OwningEntity->GetObjectID(), 1, 0, LWOOBJID_EMPTY, u"", LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS); for (const auto& player : m_RacingPlayers) { @@ -705,14 +705,14 @@ void RacingControlComponent::Update(float deltaTime) { } // Start the race - GameMessages::SendActivityStart(m_Parent->GetObjectID(), + GameMessages::SendActivityStart(m_OwningEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); m_Started = true; Game::logger->Log("RacingControlComponent", "Starting race"); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); m_StartTime = std::time(nullptr); } @@ -743,7 +743,7 @@ void RacingControlComponent::Update(float deltaTime) { // If the player is this far below the map, safe to assume they should // be smashed by death plane if (vehiclePosition.y < -500) { - GameMessages::SendDie(vehicle, m_Parent->GetObjectID(), + GameMessages::SendDie(vehicle, m_OwningEntity->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0); diff --git a/dGame/dComponents/RailActivatorComponent.cpp b/dGame/dComponents/RailActivatorComponent.cpp index 8e13c37f7..db1504da4 100644 --- a/dGame/dComponents/RailActivatorComponent.cpp +++ b/dGame/dComponents/RailActivatorComponent.cpp @@ -43,7 +43,7 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t component RailActivatorComponent::~RailActivatorComponent() = default; void RailActivatorComponent::OnUse(Entity* originator) { - auto* rebuildComponent = m_Parent->GetComponent(); + auto* rebuildComponent = m_OwningEntity->GetComponent(); if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED) return; @@ -67,7 +67,7 @@ void RailActivatorComponent::OnUse(Entity* originator) { const auto originatorID = originator->GetObjectID(); - m_Parent->AddCallbackTimer(animationLength, [originatorID, this]() { + m_OwningEntity->AddCallbackTimer(animationLength, [originatorID, this]() { auto* originator = EntityManager::Instance()->GetEntity(originatorID); if (originator == nullptr) { @@ -78,7 +78,7 @@ void RailActivatorComponent::OnUse(Entity* originator) { m_loopSound, m_StopSound, originator->GetSystemAddress(), m_PathStart, m_PathDirection, m_DamageImmune, m_NoAggro, m_NotifyArrived, m_ShowNameBillboard, m_CameraLocked, m_CollisionEnabled, m_UseDB, m_ComponentID, - m_Parent->GetObjectID()); + m_OwningEntity->GetObjectID()); }); } @@ -106,7 +106,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const { GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart, originator->GetSystemAddress(), m_ComponentID, - m_Parent->GetObjectID()); + m_OwningEntity->GetObjectID()); } } @@ -116,7 +116,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) { true, true, true, true, true, true, true ); - auto* rebuildComponent = m_Parent->GetComponent(); + auto* rebuildComponent = m_OwningEntity->GetComponent(); if (rebuildComponent != nullptr) { // Set back reset time diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index 39c8fe8d6..15b3a2552 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -33,14 +33,14 @@ RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) { // Should a setting that has the build activator position exist, fetch that setting here and parse it for position. // It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F) - auto positionAsVector = GeneralUtils::SplitString(m_Parent->GetVarAsString(u"rebuild_activators"), 0x1F); + auto positionAsVector = GeneralUtils::SplitString(m_OwningEntity->GetVarAsString(u"rebuild_activators"), 0x1F); if (positionAsVector.size() == 3 && GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) && GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) && GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) { } else { - Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT()); - m_ActivatorPosition = m_Parent->GetPosition(); + Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_OwningEntity->GetLOT()); + m_ActivatorPosition = m_OwningEntity->GetPosition(); } SpawnActivator(); @@ -58,7 +58,7 @@ RebuildComponent::~RebuildComponent() { } void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { - if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { + if (m_OwningEntity->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { if (bIsInitialUpdate) { outBitStream->Write(false); } @@ -120,7 +120,7 @@ void RebuildComponent::Update(float deltaTime) { else { m_SoftTimer = 5.0f; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); }*/ switch (m_State) { @@ -128,7 +128,7 @@ void RebuildComponent::Update(float deltaTime) { SpawnActivator(); m_TimeBeforeDrain = 0; - auto* spawner = m_Parent->GetSpawner(); + auto* spawner = m_OwningEntity->GetSpawner(); const bool isSmashGroup = spawner != nullptr ? spawner->GetIsSpawnSmashGroup() : false; if (isSmashGroup) { @@ -139,13 +139,13 @@ void RebuildComponent::Update(float deltaTime) { if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) { m_ShowResetEffect = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } if (m_TimerIncomplete >= m_TimeBeforeSmash) { m_Builder = LWOOBJID_EMPTY; - GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); + GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); ResetRebuild(false); } @@ -163,13 +163,13 @@ void RebuildComponent::Update(float deltaTime) { if (!m_ShowResetEffect) { m_ShowResetEffect = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } if (m_Timer >= m_ResetTime) { - GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); + GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); ResetRebuild(false); } @@ -225,13 +225,13 @@ void RebuildComponent::Update(float deltaTime) { if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) { m_ShowResetEffect = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } if (m_TimerIncomplete >= m_TimeBeforeSmash) { m_Builder = LWOOBJID_EMPTY; - GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); + GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); ResetRebuild(false); } @@ -260,16 +260,16 @@ void RebuildComponent::SpawnActivator() { EntityInfo info; info.lot = 6604; - info.spawnerID = m_Parent->GetObjectID(); - info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition; + info.spawnerID = m_OwningEntity->GetObjectID(); + info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_OwningEntity->GetPosition() : m_ActivatorPosition; - m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); + m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity); if (m_Activator) { m_ActivatorId = m_Activator->GetObjectID(); EntityManager::Instance()->ConstructEntity(m_Activator); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } } @@ -405,25 +405,25 @@ void RebuildComponent::StartRebuild(Entity* user) { EntityManager::Instance()->SerializeEntity(user); - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::BUILDING, user->GetObjectID()); - GameMessages::SendEnableRebuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID()); + GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::BUILDING, user->GetObjectID()); + GameMessages::SendEnableRebuild(m_OwningEntity, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID()); m_State = eRebuildState::BUILDING; m_StateDirty = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); - auto* movingPlatform = m_Parent->GetComponent(); + auto* movingPlatform = m_OwningEntity->GetComponent(); if (movingPlatform != nullptr) { movingPlatform->OnRebuildInitilized(); } - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnRebuildStart(m_Parent, user); + for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnRebuildStart(m_OwningEntity, user); } // Notify scripts and possible subscribers - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnRebuildNotifyState(m_Parent, m_State); + for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) + script->OnRebuildNotifyState(m_OwningEntity, m_State); for (const auto& cb : m_RebuildStateCallbacks) cb(m_State); } @@ -445,10 +445,10 @@ void RebuildComponent::CompleteRebuild(Entity* user) { EntityManager::Instance()->SerializeEntity(user); - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::COMPLETED, user->GetObjectID()); - GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true); - GameMessages::SendEnableRebuild(m_Parent, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID()); - GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); + GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::COMPLETED, user->GetObjectID()); + GameMessages::SendPlayFXEffect(m_OwningEntity, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true); + GameMessages::SendEnableRebuild(m_OwningEntity, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID()); m_State = eRebuildState::COMPLETED; @@ -456,7 +456,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { m_Timer = 0.0f; m_DrainedImagination = 0; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); // Removes extra item requirements, isn't live accurate. // In live, all items were removed at the start of the quickbuild, then returned if it was cancelled. @@ -468,7 +468,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { DespawnActivator(); // Set owner override so that entities smashed by this quickbuild will result in the builder getting rewards. - m_Parent->SetOwnerOverride(user->GetObjectID()); + m_OwningEntity->SetOwnerOverride(user->GetObjectID()); auto* builder = GetBuilder(); @@ -486,13 +486,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) { auto* missionComponent = builder->GetComponent(); if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId); } - LootGenerator::Instance().DropActivityLoot(builder, m_Parent, m_ActivityId, 1); + LootGenerator::Instance().DropActivityLoot(builder, m_OwningEntity, m_ActivityId, 1); } // Notify scripts - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnRebuildComplete(m_Parent, user); - script->OnRebuildNotifyState(m_Parent, m_State); + for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnRebuildComplete(m_OwningEntity, user); + script->OnRebuildNotifyState(m_OwningEntity, m_State); } // Notify subscribers @@ -501,9 +501,9 @@ void RebuildComponent::CompleteRebuild(Entity* user) { for (const auto& callback : m_RebuildCompleteCallbacks) callback(user); - m_Parent->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user); + m_OwningEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user); - auto* movingPlatform = m_Parent->GetComponent(); + auto* movingPlatform = m_OwningEntity->GetComponent(); if (movingPlatform != nullptr) { movingPlatform->OnCompleteRebuild(); } @@ -512,7 +512,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { auto* character = user->GetCharacter(); if (character != nullptr) { - const auto flagNumber = m_Parent->GetVar(u"quickbuild_single_build_player_flag"); + const auto flagNumber = m_OwningEntity->GetVar(u"quickbuild_single_build_player_flag"); if (flagNumber != 0) { character->SetPlayerFlag(flagNumber, true); @@ -525,14 +525,14 @@ void RebuildComponent::ResetRebuild(bool failed) { Entity* builder = GetBuilder(); if (m_State == eRebuildState::BUILDING && builder) { - GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID()); + GameMessages::SendEnableRebuild(m_OwningEntity, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID()); if (failed) { RenderComponent::PlayAnimation(builder, u"rebuild-fail"); } } - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY); + GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY); m_State = eRebuildState::RESETTING; m_StateDirty = true; @@ -541,15 +541,15 @@ void RebuildComponent::ResetRebuild(bool failed) { m_ShowResetEffect = false; m_DrainedImagination = 0; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); // Notify scripts and possible subscribers - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnRebuildNotifyState(m_Parent, m_State); + for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) + script->OnRebuildNotifyState(m_OwningEntity, m_State); for (const auto& cb : m_RebuildStateCallbacks) cb(m_State); - m_Parent->ScheduleKillAfterUpdate(); + m_OwningEntity->ScheduleKillAfterUpdate(); if (m_Activator) { m_Activator->ScheduleKillAfterUpdate(); @@ -564,24 +564,24 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY; // Notify the client that a state has changed - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::INCOMPLETE, entityID); - GameMessages::SendEnableRebuild(m_Parent, false, true, false, failReason, m_Timer, entityID); + GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::INCOMPLETE, entityID); + GameMessages::SendEnableRebuild(m_OwningEntity, false, true, false, failReason, m_Timer, entityID); // Now terminate any interaction with the rebuild - GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); - GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); + GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID()); + GameMessages::SendTerminateInteraction(m_OwningEntity->GetObjectID(), eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID()); // Now update the component itself m_State = eRebuildState::INCOMPLETE; m_StateDirty = true; // Notify scripts and possible subscribers - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnRebuildNotifyState(m_Parent, m_State); + for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) + script->OnRebuildNotifyState(m_OwningEntity, m_State); for (const auto& cb : m_RebuildStateCallbacks) cb(m_State); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } if (entity == nullptr) { diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index 94f5fb5d0..f59e116dd 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -141,7 +141,7 @@ void RenderComponent::Update(const float deltaTime) { void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& effectType, const std::string& name, const LWOOBJID secondary, const float priority, const float scale, const bool serialize) { RemoveEffect(name); - GameMessages::SendPlayFXEffect(m_Parent, effectId, effectType, name, secondary, priority, scale, serialize); + GameMessages::SendPlayFXEffect(m_OwningEntity, effectId, effectType, name, secondary, priority, scale, serialize); auto* effect = AddEffect(effectId, name, effectType); @@ -180,7 +180,7 @@ void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& e } void RenderComponent::StopEffect(const std::string& name, const bool killImmediate) { - GameMessages::SendStopFXEffect(m_Parent, killImmediate, name); + GameMessages::SendStopFXEffect(m_OwningEntity, killImmediate, name); RemoveEffect(name); } diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp index babd19743..3ad8457ff 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp @@ -7,8 +7,8 @@ #include "Entity.h" RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* parent) : Component(parent) { - m_Position = m_Parent->GetDefaultPosition(); - m_Rotation = m_Parent->GetDefaultRotation(); + m_Position = m_OwningEntity->GetDefaultPosition(); + m_Rotation = m_OwningEntity->GetDefaultRotation(); m_IsDirty = true; } diff --git a/dGame/dComponents/RocketLaunchLupComponent.cpp b/dGame/dComponents/RocketLaunchLupComponent.cpp index 3c3265408..87e969ddc 100644 --- a/dGame/dComponents/RocketLaunchLupComponent.cpp +++ b/dGame/dComponents/RocketLaunchLupComponent.cpp @@ -4,8 +4,8 @@ #include "CharacterComponent.h" RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(parent) { - m_Parent = parent; - std::string zoneString = GeneralUtils::UTF16ToWTF8(m_Parent->GetVar(u"MultiZoneIDs")); + m_OwningEntity = parent; + std::string zoneString = GeneralUtils::UTF16ToWTF8(m_OwningEntity->GetVar(u"MultiZoneIDs")); std::stringstream ss(zoneString); for (int i; ss >> i;) { m_LUPWorlds.push_back(i); @@ -21,11 +21,11 @@ void RocketLaunchLupComponent::OnUse(Entity* originator) { if (!rocket) return; // the LUP world menu is just the property menu, the client knows how to handle it - GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), m_Parent->GetSystemAddress()); + GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress()); } void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) { - auto* rocketLaunchpadControlComponent = m_Parent->GetComponent(); + auto* rocketLaunchpadControlComponent = m_OwningEntity->GetComponent(); if (!rocketLaunchpadControlComponent) return; rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0); diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.cpp b/dGame/dComponents/RocketLaunchpadControlComponent.cpp index 3cac9e425..c4af8a4a0 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.cpp +++ b/dGame/dComponents/RocketLaunchpadControlComponent.cpp @@ -77,7 +77,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, SetSelectedMapId(originator->GetObjectID(), zone); - GameMessages::SendFireEventClientSide(m_Parent->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID()); + GameMessages::SendFireEventClientSide(m_OwningEntity->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID()); GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS); @@ -89,12 +89,12 @@ void RocketLaunchpadControlComponent::OnUse(Entity* originator) { // instead we let their OnUse handlers do their things // which components of an Object have their OnUse called when using them // so we don't need to call it here - auto* propertyEntrance = m_Parent->GetComponent(); + auto* propertyEntrance = m_OwningEntity->GetComponent(); if (propertyEntrance) { return; } - auto* rocketLaunchLUP = m_Parent->GetComponent(); + auto* rocketLaunchLUP = m_OwningEntity->GetComponent(); if (rocketLaunchLUP) { return; } diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index 555332f4b..88cc726c6 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -53,7 +53,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit } } - auto* destroyableComponent = m_Parent->GetComponent(); + auto* destroyableComponent = m_OwningEntity->GetComponent(); if (destroyableComponent) { // check for LMIs and set the loot LMIs @@ -137,11 +137,11 @@ void ScriptedActivityComponent::PlayerJoin(Entity* player) { instance->AddParticipant(player); } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) { - if (!m_Parent->HasComponent(eReplicaComponentType::QUICK_BUILD)) + if (!m_OwningEntity->HasComponent(eReplicaComponentType::QUICK_BUILD)) GameMessages::SendMatchResponse(player, player->GetSystemAddress(), 0); // tell the client they joined a lobby LobbyPlayer* newLobbyPlayer = new LobbyPlayer(); newLobbyPlayer->entityID = player->GetObjectID(); @@ -304,7 +304,7 @@ bool ScriptedActivityComponent::HasLobby() const { bool ScriptedActivityComponent::IsValidActivity(Entity* player) { // Makes it so that scripted activities with an unimplemented map cannot be joined /*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) { - if (m_Parent->GetLOT() == 4860) { + if (m_OwningEntity->GetLOT() == 4860) { auto* missionComponent = player->GetComponent(); missionComponent->CompleteMission(229); } @@ -390,7 +390,7 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) { } ActivityInstance* ScriptedActivityComponent::NewInstance() { - auto* instance = new ActivityInstance(m_Parent, m_ActivityInfo); + auto* instance = new ActivityInstance(m_OwningEntity, m_ActivityInfo); m_Instances.push_back(instance); return instance; } @@ -445,7 +445,7 @@ void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) { m_ActivityPlayers[i] = nullptr; m_ActivityPlayers.erase(m_ActivityPlayers.begin() + i); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); return; } @@ -458,7 +458,7 @@ ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID player return data; m_ActivityPlayers.push_back(new ActivityPlayer{ playerID, {} }); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); return GetActivityPlayerData(playerID); } @@ -480,7 +480,7 @@ void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t ind data->values[std::min(index, (uint32_t)9)] = value; } - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void ScriptedActivityComponent::PlayerRemove(LWOOBJID playerID) { @@ -576,7 +576,7 @@ void ActivityInstance::RewardParticipant(Entity* participant) { maxCoins = currencyTable[0].maxvalue; } - LootGenerator::Instance().DropLoot(participant, m_Parent, activityRewards[0].LootMatrixIndex, minCoins, maxCoins); + LootGenerator::Instance().DropLoot(participant, m_OwningEntity, activityRewards[0].LootMatrixIndex, minCoins, maxCoins); } } diff --git a/dGame/dComponents/ScriptedActivityComponent.h b/dGame/dComponents/ScriptedActivityComponent.h index 1d49a62d1..23b137bbe 100644 --- a/dGame/dComponents/ScriptedActivityComponent.h +++ b/dGame/dComponents/ScriptedActivityComponent.h @@ -20,7 +20,7 @@ */ class ActivityInstance { public: - ActivityInstance(Entity* parent, CDActivities activityInfo) { m_Parent = parent; m_ActivityInfo = activityInfo; }; + ActivityInstance(Entity* parent, CDActivities activityInfo) { m_OwningEntity = parent; m_ActivityInfo = activityInfo; }; //~ActivityInstance(); /** @@ -86,7 +86,7 @@ class ActivityInstance { /** * The entity that owns this activity (the entity that has the ScriptedActivityComponent) */ - Entity* m_Parent; + Entity* m_OwningEntity; /** * All the participants of this activity diff --git a/dGame/dComponents/ShootingGalleryComponent.cpp b/dGame/dComponents/ShootingGalleryComponent.cpp index d5e12b284..75e6281d9 100644 --- a/dGame/dComponents/ShootingGalleryComponent.cpp +++ b/dGame/dComponents/ShootingGalleryComponent.cpp @@ -14,7 +14,7 @@ void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryParams& params) { m_DynamicParams = params; m_Dirty = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const { diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 54a2e6163..e506e71c2 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -14,11 +14,11 @@ #include "Entity.h" SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* parent) : Component(parent) { - m_Position = m_Parent->GetDefaultPosition(); - m_Rotation = m_Parent->GetDefaultRotation(); + m_Position = m_OwningEntity->GetDefaultPosition(); + m_Rotation = m_OwningEntity->GetDefaultRotation(); m_IsDirty = true; - const auto& climbable_type = m_Parent->GetVar(u"climbable"); + const auto& climbable_type = m_OwningEntity->GetVar(u"climbable"); if (climbable_type == u"wall") { SetClimbableType(eClimbableType::CLIMBABLE_TYPE_WALL); } else if (climbable_type == u"ladder") { diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index c2f074255..95cbe3cd1 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -32,9 +32,9 @@ ProjectileSyncEntry::ProjectileSyncEntry() { std::unordered_map SkillComponent::m_skillBehaviorCache = {}; bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream* bitStream, const LWOOBJID target, uint32_t skillID) { - auto* context = new BehaviorContext(this->m_Parent->GetObjectID()); + auto* context = new BehaviorContext(this->m_OwningEntity->GetObjectID()); - context->caster = m_Parent->GetObjectID(); + context->caster = m_OwningEntity->GetObjectID(); context->skillID = skillID; @@ -130,11 +130,11 @@ void SkillComponent::RegisterPlayerProjectile(const LWOOBJID projectileId, Behav } void SkillComponent::Update(const float deltaTime) { - if (!m_Parent->HasComponent(eReplicaComponentType::BASE_COMBAT_AI) && m_Parent->GetLOT() != 1) { + if (!m_OwningEntity->HasComponent(eReplicaComponentType::BASE_COMBAT_AI) && m_OwningEntity->GetLOT() != 1) { CalculateUpdate(deltaTime); } - if (m_Parent->IsPlayer()) { + if (m_OwningEntity->IsPlayer()) { for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime); } @@ -193,7 +193,7 @@ void SkillComponent::Reset() { void SkillComponent::Interrupt() { // TODO: need to check immunities on the destroyable component, but they aren't implemented - auto* combat = m_Parent->GetComponent(); + auto* combat = m_OwningEntity->GetComponent(); if (combat != nullptr && combat->GetStunImmune()) return; for (const auto& behavior : this->m_managedBehaviors) { @@ -201,7 +201,7 @@ void SkillComponent::Interrupt() { behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second); } behavior.second->endEntries.clear(); - if (m_Parent->IsPlayer()) continue; + if (m_OwningEntity->IsPlayer()) continue; behavior.second->Interrupt(); } @@ -256,9 +256,9 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c auto* behavior = Behavior::CreateBehavior(behaviorId); - auto* context = new BehaviorContext(originatorOverride != LWOOBJID_EMPTY ? originatorOverride : this->m_Parent->GetObjectID(), true); + auto* context = new BehaviorContext(originatorOverride != LWOOBJID_EMPTY ? originatorOverride : this->m_OwningEntity->GetObjectID(), true); - context->caster = m_Parent->GetObjectID(); + context->caster = m_OwningEntity->GetObjectID(); context->skillID = skillId; @@ -268,8 +268,8 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c behavior->Calculate(context, bitStream, { target, 0 }); - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnSkillCast(m_Parent, skillId); + for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) { + script->OnSkillCast(m_OwningEntity, skillId); } if (!context->foundTarget) { @@ -305,7 +305,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c RakNet::BitStream message; PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); - message.Write(this->m_Parent->GetObjectID()); + message.Write(this->m_OwningEntity->GetObjectID()); start.Serialize(&message); Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true); @@ -431,14 +431,14 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) DoClientProjectileImpact projectileImpact; projectileImpact.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); - projectileImpact.i64OwnerID = this->m_Parent->GetObjectID(); + projectileImpact.i64OwnerID = this->m_OwningEntity->GetObjectID(); projectileImpact.i64OrgID = entry.id; projectileImpact.i64TargetID = entry.branchContext.target; RakNet::BitStream message; PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); - message.Write(this->m_Parent->GetObjectID()); + message.Write(this->m_OwningEntity->GetObjectID()); projectileImpact.Serialize(&message); Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true); diff --git a/dGame/dComponents/SoundTriggerComponent.cpp b/dGame/dComponents/SoundTriggerComponent.cpp index be62beee5..143fd27a5 100644 --- a/dGame/dComponents/SoundTriggerComponent.cpp +++ b/dGame/dComponents/SoundTriggerComponent.cpp @@ -76,7 +76,7 @@ void SoundTriggerComponent::ActivateMusicCue(const std::string& name) { -1.0f }); dirty = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } @@ -88,6 +88,6 @@ void SoundTriggerComponent::DeactivateMusicCue(const std::string& name) { if (musicCue != this->musicCues.end()) { this->musicCues.erase(musicCue); dirty = true; - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index b393bbef0..32f5f80dc 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -8,9 +8,9 @@ std::vector SwitchComponent::petSwitches; SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) { m_Active = false; - m_ResetTime = m_Parent->GetVarAs(u"switch_reset_time"); + m_ResetTime = m_OwningEntity->GetVarAs(u"switch_reset_time"); - m_Rebuild = m_Parent->GetComponent(); + m_Rebuild = m_OwningEntity->GetComponent(); } SwitchComponent::~SwitchComponent() { @@ -43,10 +43,10 @@ void SwitchComponent::EntityEnter(Entity* entity) { if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return; } m_Active = true; - if (!m_Parent) return; - m_Parent->TriggerEvent(eTriggerEventType::ACTIVATED, entity); + if (!m_OwningEntity) return; + m_OwningEntity->TriggerEvent(eTriggerEventType::ACTIVATED, entity); - const auto grpName = m_Parent->GetVarAsString(u"grp_name"); + const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name"); if (!grpName.empty()) { const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName); @@ -59,11 +59,11 @@ void SwitchComponent::EntityEnter(Entity* entity) { m_Timer = m_ResetTime; if (m_PetBouncer != nullptr) { - GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true); - RenderComponent::PlayAnimation(m_Parent, u"engaged"); + GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true); + RenderComponent::PlayAnimation(m_OwningEntity, u"engaged"); m_PetBouncer->SetPetBouncerEnabled(true); } else { - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } @@ -79,10 +79,10 @@ void SwitchComponent::Update(float deltaTime) { if (m_Timer <= 0.0f) { m_Active = false; - if (!m_Parent) return; - m_Parent->TriggerEvent(eTriggerEventType::DEACTIVATED, m_Parent); + if (!m_OwningEntity) return; + m_OwningEntity->TriggerEvent(eTriggerEventType::DEACTIVATED, m_OwningEntity); - const auto grpName = m_Parent->GetVarAsString(u"grp_name"); + const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name"); if (!grpName.empty()) { const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName); @@ -95,14 +95,14 @@ void SwitchComponent::Update(float deltaTime) { if (m_PetBouncer != nullptr) { m_PetBouncer->SetPetBouncerEnabled(false); } else { - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } } } } Entity* SwitchComponent::GetParentEntity() const { - return m_Parent; + return m_OwningEntity; } SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) { @@ -110,7 +110,7 @@ SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) { SwitchComponent* closest = nullptr; for (SwitchComponent* petSwitch : petSwitches) { - float distance = Vector3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position); + float distance = Vector3::DistanceSquared(petSwitch->m_OwningEntity->GetPosition(), position); if (closest == nullptr || distance < closestDistance) { closestDistance = distance; diff --git a/dGame/dComponents/TriggerComponent.cpp b/dGame/dComponents/TriggerComponent.cpp index 7adf47a83..fe141a4dc 100644 --- a/dGame/dComponents/TriggerComponent.cpp +++ b/dGame/dComponents/TriggerComponent.cpp @@ -16,7 +16,7 @@ TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) { - m_Parent = parent; + m_OwningEntity = parent; m_Trigger = nullptr; std::vector tokens = GeneralUtils::SplitString(triggerInfo, ':'); @@ -116,7 +116,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity HandleCastSkill(targetEntity, command->args); break; case eTriggerCommandType::DISPLAY_ZONE_SUMMARY: - GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_Parent->GetObjectID()); + GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_OwningEntity->GetObjectID()); break; case eTriggerCommandType::SET_PHYSICS_VOLUME_EFFECT: HandleSetPhysicsVolumeEffect(targetEntity, argArray); @@ -164,7 +164,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity std::vector TriggerComponent::GatherTargets(LUTriggers::Command* command, Entity* optionalTarget) { std::vector entities = {}; - if (command->target == "self") entities.push_back(m_Parent); + if (command->target == "self") entities.push_back(m_OwningEntity); else if (command->target == "zone") { /*TODO*/ } else if (command->target == "target" && optionalTarget) entities.push_back(optionalTarget); else if (command->target == "targetTeam" && optionalTarget) { @@ -185,14 +185,14 @@ std::vector TriggerComponent::GatherTargets(LUTriggers::Command* comman void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) { for (CppScripts::Script* script : CppScripts::GetEntityScripts(targetEntity)) { - script->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0); + script->OnFireEventServerSide(targetEntity, m_OwningEntity, args, 0, 0, 0); } } void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){ uint32_t killType; GeneralUtils::TryParse(args, killType); - targetEntity->Smash(m_Parent->GetObjectID(), static_cast(killType)); + targetEntity->Smash(m_OwningEntity->GetObjectID(), static_cast(killType)); } void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){ @@ -237,7 +237,7 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector argArray){ if (argArray.size() < 3) return; - auto* phantomPhysicsComponent = m_Parent->GetComponent(); + auto* phantomPhysicsComponent = m_OwningEntity->GetComponent(); if (!phantomPhysicsComponent) { Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!"); return; @@ -249,12 +249,12 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vectorSetDirection(direction); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){ - auto* phantomPhysicsComponent = m_Parent->GetComponent(); + auto* phantomPhysicsComponent = m_OwningEntity->GetComponent(); if (!phantomPhysicsComponent) { Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!"); return; @@ -265,7 +265,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args) phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE); phantomPhysicsComponent->SetDirectionalMultiplier(forceMultiplier); - auto triggerPos = m_Parent->GetPosition(); + auto triggerPos = m_OwningEntity->GetPosition(); auto targetPos = targetEntity->GetPosition(); // normalize the vectors to get the direction @@ -274,7 +274,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args) NiPoint3 direction = delta / length; phantomPhysicsComponent->SetDirection(direction); - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); } void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector argArray){ @@ -284,11 +284,11 @@ void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector(argArray.at(1), time); - m_Parent->AddTimer(argArray.at(0), time); + m_OwningEntity->AddTimer(argArray.at(0), time); } void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){ - m_Parent->CancelTimer(args); + m_OwningEntity->CancelTimer(args); } void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector argArray) { diff --git a/dGame/dComponents/VehiclePhysicsComponent.cpp b/dGame/dComponents/VehiclePhysicsComponent.cpp index d981acf77..c5818825b 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.cpp +++ b/dGame/dComponents/VehiclePhysicsComponent.cpp @@ -103,7 +103,7 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI void VehiclePhysicsComponent::Update(float deltaTime) { if (m_SoftUpdate > 5) { - EntityManager::Instance()->SerializeEntity(m_Parent); + EntityManager::Instance()->SerializeEntity(m_OwningEntity); m_SoftUpdate = 0; } else { diff --git a/dGame/dComponents/VendorComponent.cpp b/dGame/dComponents/VendorComponent.cpp index e89cc9263..8dc446a65 100644 --- a/dGame/dComponents/VendorComponent.cpp +++ b/dGame/dComponents/VendorComponent.cpp @@ -24,8 +24,8 @@ void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial } void VendorComponent::OnUse(Entity* originator) { - GameMessages::SendVendorOpenWindow(m_Parent, originator->GetSystemAddress()); - GameMessages::SendVendorStatusUpdate(m_Parent, originator->GetSystemAddress()); + GameMessages::SendVendorOpenWindow(m_OwningEntity, originator->GetSystemAddress()); + GameMessages::SendVendorStatusUpdate(m_OwningEntity, originator->GetSystemAddress()); } float VendorComponent::GetBuyScalar() const { @@ -50,12 +50,12 @@ std::map& VendorComponent::GetInventory() { bool VendorComponent::HasCraftingStation() { // As far as we know, only Umami has a crafting station - return m_Parent->GetLOT() == 13800; + return m_OwningEntity->GetLOT() == 13800; } void VendorComponent::RefreshInventory(bool isCreation) { //Custom code for Max vanity NPC - if (m_Parent->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) { + if (m_OwningEntity->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) { if (!isCreation) return; m_Inventory.insert({ 11909, 0 }); //Top hat w frog m_Inventory.insert({ 7785, 0 }); //Flash bulb @@ -97,7 +97,7 @@ void VendorComponent::RefreshInventory(bool isCreation) { } //Because I want a vendor to sell these cameras - if (m_Parent->GetLOT() == 13569) { + if (m_OwningEntity->GetLOT() == 13569) { auto randomCamera = GeneralUtils::GenerateRandomNumber(0, 2); switch (randomCamera) { @@ -116,15 +116,15 @@ void VendorComponent::RefreshInventory(bool isCreation) { } // Callback timer to refresh this inventory. - m_Parent->AddCallbackTimer(m_RefreshTimeSeconds, [this]() { + m_OwningEntity->AddCallbackTimer(m_RefreshTimeSeconds, [this]() { RefreshInventory(); }); - GameMessages::SendVendorStatusUpdate(m_Parent, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendVendorStatusUpdate(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS); } void VendorComponent::SetupConstants() { auto* compRegistryTable = CDClientManager::Instance().GetTable(); - int componentID = compRegistryTable->GetByIDAndType(m_Parent->GetLOT(), eReplicaComponentType::VENDOR); + int componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::VENDOR); auto* vendorComponentTable = CDClientManager::Instance().GetTable(); std::vector vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); }); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 16460025e..12d1a5ef5 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -1986,7 +1986,7 @@ void GameMessages::SendOpenPropertyManagment(const LWOOBJID objectId, const Syst CBITSTREAM; CMSGHEADER; - bitStream.Write(PropertyManagementComponent::Instance()->GetParent()->GetObjectID()); + bitStream.Write(PropertyManagementComponent::Instance()->GetOwningEntity()->GetObjectID()); bitStream.Write(eGameMessageType::OPEN_PROPERTY_MANAGEMENT); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index 3d2c82aeb..a528ea576 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -76,7 +76,7 @@ void Inventory::SetSize(const uint32_t value) { size = value; - GameMessages::SendSetInventorySize(component->GetParent(), type, static_cast(size)); + GameMessages::SendSetInventorySize(component->GetOwningEntity(), type, static_cast(size)); } int32_t Inventory::FindEmptySlot() { diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 83ac88699..6f3af0731 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -92,7 +92,7 @@ Item::Item( inventory->AddManagedItem(this); - auto* entity = inventory->GetComponent()->GetParent(); + auto* entity = inventory->GetComponent()->GetOwningEntity(); GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast(this->count), subKey, lootSourceType); if (isModMoveAndEquip) { @@ -100,7 +100,7 @@ Item::Item( Game::logger->Log("Item", "Move and equipped (%i) from (%i)", this->lot, this->inventory->GetType()); - EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetParent()); + EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetOwningEntity()); } } @@ -136,7 +136,7 @@ Inventory* Item::GetInventory() const { return inventory; } -LWOOBJID Item::GetParent() const { +LWOOBJID Item::GetOwningEntity() const { return parent; } @@ -166,7 +166,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem } if (!silent) { - auto* entity = inventory->GetComponent()->GetParent(); + auto* entity = inventory->GetComponent()->GetOwningEntity(); if (value > count) { GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType); @@ -262,7 +262,7 @@ bool Item::Consume() { Game::logger->LogDebug("Item", "Consumed LOT (%i) itemID (%llu). Success=(%d)", lot, id, success); - GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success); + GameMessages::SendUseItemResult(inventory->GetComponent()->GetOwningEntity(), lot, success); if (success) { inventory->GetComponent()->RemoveItem(lot, 1); @@ -284,7 +284,7 @@ void Item::UseNonEquip(Item* item) { return; } - auto* playerEntity = playerInventoryComponent->GetParent(); + auto* playerEntity = playerInventoryComponent->GetOwningEntity(); if (!playerEntity) { Game::logger->LogDebug("Item", "no player entity attached to inventory? item id is %llu", this->GetId()); return; @@ -314,8 +314,8 @@ void Item::UseNonEquip(Item* item) { auto success = !packages.empty(); if (success) { - if (this->GetPreconditionExpression()->Check(playerInventoryComponent->GetParent())) { - auto* entityParent = playerInventoryComponent->GetParent(); + if (this->GetPreconditionExpression()->Check(playerInventoryComponent->GetOwningEntity())) { + auto* entityParent = playerInventoryComponent->GetOwningEntity(); // Roll the loot for all the packages then see if it all fits. If it fits, give it to the player, otherwise don't. std::unordered_map rolledLoot{}; for (auto& pack : packages) { @@ -331,15 +331,15 @@ void Item::UseNonEquip(Item* item) { } } if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) { - LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::CONSUMPTION); + LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetOwningEntity(), rolledLoot, eLootSourceType::CONSUMPTION); item->SetCount(item->GetCount() - 1); } else { success = false; } } else { GameMessages::SendUseItemRequirementsResponse( - playerInventoryComponent->GetParent()->GetObjectID(), - playerInventoryComponent->GetParent()->GetSystemAddress(), + playerInventoryComponent->GetOwningEntity()->GetObjectID(), + playerInventoryComponent->GetOwningEntity()->GetSystemAddress(), eUseItemResponse::FailedPrecondition ); success = false; @@ -347,7 +347,7 @@ void Item::UseNonEquip(Item* item) { } } Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot); - GameMessages::SendUseItemResult(playerInventoryComponent->GetParent(), thisLot, success); + GameMessages::SendUseItemResult(playerInventoryComponent->GetOwningEntity(), thisLot, success); } } @@ -360,7 +360,7 @@ void Item::Disassemble(const eInventoryType inventoryType) { if (GetInventory()) { auto inventoryComponent = GetInventory()->GetComponent(); if (inventoryComponent) { - auto entity = inventoryComponent->GetParent(); + auto entity = inventoryComponent->GetOwningEntity(); if (entity) entity->SetVar(u"currentModifiedBuild", modStr); } } diff --git a/dGame/dInventory/Item.h b/dGame/dInventory/Item.h index be2359eff..0bd28f815 100644 --- a/dGame/dInventory/Item.h +++ b/dGame/dInventory/Item.h @@ -150,7 +150,7 @@ class Item final * Returns the parent of this item, e.g. for proxy items * @return the parent of this item */ - LWOOBJID GetParent() const; + LWOOBJID GetOwningEntity() const; /** * Sets the subkey for this item, e.g. for pets diff --git a/dGame/dInventory/ItemSet.cpp b/dGame/dInventory/ItemSet.cpp index a8e587399..4dd3650be 100644 --- a/dGame/dInventory/ItemSet.cpp +++ b/dGame/dInventory/ItemSet.cpp @@ -15,7 +15,7 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) { this->m_ID = id; this->m_InventoryComponent = inventoryComponent; - this->m_PassiveAbilities = ItemSetPassiveAbility::FindAbilities(id, m_InventoryComponent->GetParent(), this); + this->m_PassiveAbilities = ItemSetPassiveAbility::FindAbilities(id, m_InventoryComponent->GetOwningEntity(), this); auto query = CDClientDatabase::CreatePreppedStmt( "SELECT skillSetWith2, skillSetWith3, skillSetWith4, skillSetWith5, skillSetWith6, itemIDs FROM ItemSets WHERE setID = ?;"); @@ -125,8 +125,8 @@ void ItemSet::OnEquip(const LOT lot) { return; } - auto* skillComponent = m_InventoryComponent->GetParent()->GetComponent(); - auto* missionComponent = m_InventoryComponent->GetParent()->GetComponent(); + auto* skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); + auto* missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); for (const auto skill : skillSet) { auto* skillTable = CDClientManager::Instance().GetTable(); @@ -135,7 +135,7 @@ void ItemSet::OnEquip(const LOT lot) { missionComponent->Progress(eMissionTaskType::USE_SKILL, skill); - skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetParent()->GetObjectID()); + skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetOwningEntity()->GetObjectID()); } } @@ -158,14 +158,14 @@ void ItemSet::OnUnEquip(const LOT lot) { return; } - const auto& skillComponent = m_InventoryComponent->GetParent()->GetComponent(); + const auto& skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); for (const auto skill : skillSet) { auto* skillTable = CDClientManager::Instance().GetTable(); const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID; - skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetParent()->GetObjectID()); + skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetOwningEntity()->GetObjectID()); } } diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 32a930e4d..afde876cd 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -204,7 +204,7 @@ bool Mission::IsValidMission(const uint32_t missionId, CDMissions& info) { } Entity* Mission::GetAssociate() const { - return m_MissionComponent->GetParent(); + return m_MissionComponent->GetOwningEntity(); } User* Mission::GetUser() const { diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index d8a062ca5..c4d4a2aa8 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -47,11 +47,11 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* mode // args.InsertValue("behaviorID", behaviorIDString); // AMFStringValue* objectIDAsString = new AMFStringValue(); - // objectIDAsString->SetValue(std::to_string(modelComponent->GetParent()->GetObjectID())); + // objectIDAsString->SetValue(std::to_string(modelComponent->GetOwningEntity()->GetObjectID())); // args.InsertValue("objectID", objectIDAsString); // GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorID", &args); - // ControlBehaviors::SendBehaviorListToClient(modelComponent->GetParent(), sysAddr, modelOwner); + // ControlBehaviors::SendBehaviorListToClient(modelComponent->GetOwningEntity(), sysAddr, modelOwner); // }); // } } @@ -74,7 +74,7 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste */ behaviorsToSerialize.Insert("behaviors"); - behaviorsToSerialize.Insert("objectID", std::to_string(modelComponent->GetParent()->GetObjectID())); + behaviorsToSerialize.Insert("objectID", std::to_string(modelComponent->GetOwningEntity()->GetObjectID())); GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize); } @@ -197,7 +197,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // uiArray->InsertValue("x", xPosition); // thisStrip->InsertValue("ui", uiArray); - // targetObjectID = modelComponent->GetParent()->GetObjectID(); + // targetObjectID = modelComponent->GetOwningEntity()->GetObjectID(); // behaviorID = modelBehavior->GetBehaviorID(); // AMFArrayValue* stripSerialize = new AMFArrayValue(); @@ -276,7 +276,7 @@ void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const Sys MoveToInventoryMessage moveToInventoryMessage(arguments); - SendBehaviorListToClient(modelComponent->GetParent(), sysAddr, modelOwner); + SendBehaviorListToClient(modelComponent->GetOwningEntity(), sysAddr, modelOwner); } void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& sysAddr, AMFArrayValue* arguments, std::string command, Entity* modelOwner) { diff --git a/dScripts/ScriptComponent.cpp b/dScripts/ScriptComponent.cpp index 272de5ab4..456830573 100644 --- a/dScripts/ScriptComponent.cpp +++ b/dScripts/ScriptComponent.cpp @@ -19,7 +19,7 @@ ScriptComponent::~ScriptComponent() { void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { if (bIsInitialUpdate) { - const auto& networkSettings = m_Parent->GetNetworkSettings(); + const auto& networkSettings = m_OwningEntity->GetNetworkSettings(); auto hasNetworkSettings = !networkSettings.empty(); outBitStream->Write(hasNetworkSettings); @@ -52,5 +52,5 @@ void ScriptComponent::SetScript(const std::string& scriptName) { return; }*/ - m_Script = CppScripts::GetScript(m_Parent, scriptName); + m_Script = CppScripts::GetScript(m_OwningEntity, scriptName); } From ea9d0d8592b27091cf3b18391aa4aba0447586fe Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Tue, 6 Jun 2023 20:48:30 -0700 Subject: [PATCH 006/111] I hope this works --- dCommon/dEnums/eReplicaComponentType.h | 1 + .../Tables/CDComponentsRegistryTable.cpp | 9 +- dDatabase/Tables/CDComponentsRegistryTable.h | 2 + dGame/Character.cpp | 6 +- dGame/Entity.cpp | 1239 ++++------------- dGame/Entity.h | 50 +- dGame/EntityInitializeOld.cc | 640 +++++++++ dGame/EntityManager.cpp | 4 +- dGame/Player.cpp | 2 +- dGame/TradingManager.cpp | 12 +- dGame/UserManager.cpp | 2 +- dGame/dBehaviors/ApplyBuffBehavior.cpp | 5 +- dGame/dBehaviors/AreaOfEffectBehavior.cpp | 2 +- dGame/dBehaviors/BasicAttackBehavior.cpp | 6 +- dGame/dBehaviors/Behavior.cpp | 2 +- dGame/dBehaviors/BehaviorContext.cpp | 6 +- dGame/dBehaviors/BlockBehavior.cpp | 4 +- dGame/dBehaviors/BuffBehavior.cpp | 4 +- dGame/dBehaviors/CarBoostBehavior.cpp | 4 +- dGame/dBehaviors/DamageAbsorptionBehavior.cpp | 2 +- dGame/dComponents/Component.cpp | 4 + dGame/dComponents/Component.h | 9 + dNet/ClientPackets.cpp | 12 +- dScripts/NtFactionSpyServer.cpp | 8 +- dScripts/ai/AG/AgStromlingProperty.cpp | 3 +- 25 files changed, 1024 insertions(+), 1014 deletions(-) create mode 100644 dGame/EntityInitializeOld.cc diff --git a/dCommon/dEnums/eReplicaComponentType.h b/dCommon/dEnums/eReplicaComponentType.h index 2d24c19e4..39f91efff 100644 --- a/dCommon/dEnums/eReplicaComponentType.h +++ b/dCommon/dEnums/eReplicaComponentType.h @@ -121,6 +121,7 @@ enum class eReplicaComponentType : uint32_t { BUILD_BORDER, UNKNOWN_115, CULLING_PLANE, + NUMBER_OF_COMPONENTS, DESTROYABLE = 1000 // Actually 7 }; diff --git a/dDatabase/Tables/CDComponentsRegistryTable.cpp b/dDatabase/Tables/CDComponentsRegistryTable.cpp index 32012f6ce..c053de911 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.cpp +++ b/dDatabase/Tables/CDComponentsRegistryTable.cpp @@ -90,4 +90,11 @@ int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponent return defaultValue; #endif } - +std::vector> CDComponentsRegistryTable::GetTemplateComponents(LOT templateId) { + std::vector> components; + for (int8_t i = 0; static_cast(i) < eReplicaComponentType::NUMBER_OF_COMPONENTS; i++) { + auto compId = GetByIDAndType(templateId, static_cast(i), -1); + if (compId != -1) components.push_back(std::make_pair(static_cast(i), compId)); + } + return components; +} diff --git a/dDatabase/Tables/CDComponentsRegistryTable.h b/dDatabase/Tables/CDComponentsRegistryTable.h index 990072c99..855679d58 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.h +++ b/dDatabase/Tables/CDComponentsRegistryTable.h @@ -2,6 +2,7 @@ // Custom Classes #include "CDTable.h" +#include "dCommonVars.h" enum class eReplicaComponentType : uint32_t; struct CDComponentsRegistry { @@ -18,4 +19,5 @@ class CDComponentsRegistryTable : public CDTable { public: CDComponentsRegistryTable(); int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0); + std::vector> GetTemplateComponents(LOT templateId); }; diff --git a/dGame/Character.cpp b/dGame/Character.cpp index 319b9376d..f06416c15 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -427,7 +427,7 @@ void Character::SetPlayerFlag(const int32_t flagId, const bool value) { auto* player = EntityManager::Instance()->GetEntity(m_ObjectID); if (player != nullptr) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::PLAYER_FLAG, flagId); @@ -538,7 +538,7 @@ void Character::OnZoneLoad() { return; } - auto* missionComponent = m_OurEntity->GetComponent(); + auto missionComponent = m_OurEntity->GetComponent(); if (missionComponent != nullptr) { // Fix the monument race flag @@ -563,7 +563,7 @@ void Character::OnZoneLoad() { } } - auto* inventoryComponent = m_OurEntity->GetComponent(); + auto inventoryComponent = m_OurEntity->GetComponent(); if (inventoryComponent == nullptr) { return; diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 6de6ba621..3377e8cd0 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -120,667 +120,261 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity) } Entity::~Entity() { - if (m_Character) { - m_Character->SaveXMLToDatabase(); - } + if (m_Character) m_Character->SaveXMLToDatabase(); CancelAllTimers(); CancelCallbackTimers(); - const auto components = m_Components; - - for (const auto& pair : components) { - delete pair.second; - - m_Components.erase(pair.first); - } - - for (auto child : m_ChildEntities) { - if (child) child->RemoveParent(); - } + for (auto child : m_ChildEntities) if (child) child->RemoveParent(); - if (m_ParentEntity) { - m_ParentEntity->RemoveChild(this); - } + if (m_ParentEntity) m_ParentEntity->RemoveChild(this); } void Entity::Initialize() { - /** - * Setup trigger - */ - - const auto triggerInfo = GetVarAsString(u"trigger_id"); - - if (!triggerInfo.empty()) m_Components.emplace(eReplicaComponentType::TRIGGER, new TriggerComponent(this, triggerInfo)); - - /** - * Setup groups - */ - - const auto groupIDs = GetVarAsString(u"groupID"); - - if (!groupIDs.empty()) { - m_Groups = GeneralUtils::SplitString(groupIDs, ';'); - m_Groups.erase(m_Groups.end() - 1); - } - - /** - * Set ourselves as a child of our parent - */ - - if (m_ParentEntity != nullptr) { - m_ParentEntity->AddChild(this); - } - - // Get the registry table - CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable(); - - /** - * Special case for BBB models. They have components not corresponding to the registry. - */ - - if (m_TemplateID == 14) { - const auto simplePhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SIMPLE_PHYSICS); - - SimplePhysicsComponent* comp = new SimplePhysicsComponent(simplePhysicsComponentID, this); - m_Components.insert(std::make_pair(eReplicaComponentType::SIMPLE_PHYSICS, comp)); - - ModelComponent* modelcomp = new ModelComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::MODEL, modelcomp)); - - RenderComponent* render = new RenderComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::RENDER, render)); - - auto destroyableComponent = new DestroyableComponent(this); - destroyableComponent->SetHealth(1); - destroyableComponent->SetMaxHealth(1.0f); - destroyableComponent->SetFaction(-1, true); - destroyableComponent->SetIsSmashable(true); - m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, destroyableComponent)); - // We have all our components. - return; - } - - /** - * Go through all the components and check if this entity has them. - * - * Not all components are implemented. Some are represented by a nullptr, as they hold no data. - */ - - if (GetParentUser()) { - auto missions = new MissionComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::MISSION, missions)); - missions->LoadFromXml(m_Character->GetXMLDoc()); - } - - uint32_t petComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PET); - if (petComponentId > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::PET, new PetComponent(this, petComponentId))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ZONE_CONTROL) > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::ZONE_CONTROL, nullptr)); - } - - uint32_t possessableComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::POSSESSABLE); - if (possessableComponentId > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::POSSESSABLE, new PossessableComponent(this, possessableComponentId))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MODULE_ASSEMBLY) > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::MODULE_ASSEMBLY, new ModuleAssemblyComponent(this))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RACING_STATS) > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::RACING_STATS, nullptr)); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::LUP_EXHIBIT, -1) >= 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::LUP_EXHIBIT, new LUPExhibitComponent(this))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RACING_CONTROL) > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::RACING_CONTROL, new RacingControlComponent(this))); - } - - const auto propertyEntranceComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_ENTRANCE); - if (propertyEntranceComponentID > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::PROPERTY_ENTRANCE, - new PropertyEntranceComponent(propertyEntranceComponentID, this))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) { - ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this); - - if (m_Character) { - controllablePhysics->LoadFromXml(m_Character->GetXMLDoc()); - - const auto mapID = Game::server->GetZoneID(); - - //If we came from another zone, put us in the starting loc - if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof. - NiPoint3 pos; - NiQuaternion rot; - - const auto& targetSceneName = m_Character->GetTargetScene(); - auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName); - - if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) { - pos = m_Character->GetRespawnPoint(mapID); - rot = dZoneManager::Instance()->GetZone()->GetSpawnRot(); - } else if (targetScene != nullptr) { - pos = targetScene->GetPosition(); - rot = targetScene->GetRotation(); - } else { - pos = dZoneManager::Instance()->GetZone()->GetSpawnPos(); - rot = dZoneManager::Instance()->GetZone()->GetSpawnRot(); - } - - controllablePhysics->SetPosition(pos); - controllablePhysics->SetRotation(rot); - } - } else { - controllablePhysics->SetPosition(m_DefaultPosition); - controllablePhysics->SetRotation(m_DefaultRotation); - } - - m_Components.insert(std::make_pair(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysics)); - } - - // If an entity is marked a phantom, simple physics is made into phantom phyics. - bool markedAsPhantom = GetVar(u"markedAsPhantom"); - - const auto simplePhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SIMPLE_PHYSICS); - if (!markedAsPhantom && simplePhysicsComponentID > 0) { - SimplePhysicsComponent* comp = new SimplePhysicsComponent(simplePhysicsComponentID, this); - m_Components.insert(std::make_pair(eReplicaComponentType::SIMPLE_PHYSICS, comp)); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS) > 0) { - RigidbodyPhantomPhysicsComponent* comp = new RigidbodyPhantomPhysicsComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, comp)); - } - - if (markedAsPhantom || compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PHANTOM_PHYSICS) > 0) { - PhantomPhysicsComponent* phantomPhysics = new PhantomPhysicsComponent(this); - phantomPhysics->SetPhysicsEffectActive(false); - m_Components.insert(std::make_pair(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysics)); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::VEHICLE_PHYSICS) > 0) { - VehiclePhysicsComponent* vehiclePhysicsComponent = new VehiclePhysicsComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)); - vehiclePhysicsComponent->SetPosition(m_DefaultPosition); - vehiclePhysicsComponent->SetRotation(m_DefaultRotation); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SOUND_TRIGGER, -1) != -1) { - auto* comp = new SoundTriggerComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::SOUND_TRIGGER, comp)); - } - - //Also check for the collectible id: - m_CollectibleID = GetVarAs(u"collectible_id"); - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUFF) > 0) { - BuffComponent* comp = new BuffComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::BUFF, comp)); - } - - int collectibleComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::COLLECTIBLE); - - if (collectibleComponentID > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::COLLECTIBLE, nullptr)); - } - - /** - * Multiple components require the destructible component. - */ - - int buffComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUFF); - int rebuildComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD); - - int componentID = 0; - if (collectibleComponentID > 0) componentID = collectibleComponentID; - if (rebuildComponentID > 0) componentID = rebuildComponentID; - if (buffComponentID > 0) componentID = buffComponentID; - - CDDestructibleComponentTable* destCompTable = CDClientManager::Instance().GetTable(); - std::vector destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); }); - - if (buffComponentID > 0 || collectibleComponentID > 0) { - DestroyableComponent* comp = new DestroyableComponent(this); - if (m_Character) { - comp->LoadFromXml(m_Character->GetXMLDoc()); - } else { - if (componentID > 0) { - std::vector destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); }); - - if (destCompData.size() > 0) { - if (HasComponent(eReplicaComponentType::RACING_STATS)) { - destCompData[0].imagination = 60; - } - - comp->SetHealth(destCompData[0].life); - comp->SetImagination(destCompData[0].imagination); - comp->SetArmor(destCompData[0].armor); - - comp->SetMaxHealth(destCompData[0].life); - comp->SetMaxImagination(destCompData[0].imagination); - comp->SetMaxArmor(destCompData[0].armor); - - comp->SetIsSmashable(destCompData[0].isSmashable); - - comp->SetLootMatrixID(destCompData[0].LootMatrixIndex); - - // Now get currency information - uint32_t npcMinLevel = destCompData[0].level; - uint32_t currencyIndex = destCompData[0].CurrencyIndex; - - CDCurrencyTableTable* currencyTable = CDClientManager::Instance().GetTable(); - std::vector currencyValues = currencyTable->Query([=](CDCurrencyTable entry) { return (entry.currencyIndex == currencyIndex && entry.npcminlevel == npcMinLevel); }); - - if (currencyValues.size() > 0) { - // Set the coins - comp->SetMinCoins(currencyValues[0].minvalue); - comp->SetMaxCoins(currencyValues[0].maxvalue); - } - - // extraInfo overrides - comp->SetIsSmashable(GetVarAs(u"is_smashable") != 0); - } - } else { - comp->SetHealth(1); - comp->SetArmor(0); - - comp->SetMaxHealth(1); - comp->SetMaxArmor(0); - - comp->SetIsSmashable(true); - comp->AddFaction(-1); - comp->AddFaction(6); //Smashables - - // A race car has 60 imagination, other entities defaults to 0. - comp->SetImagination(HasComponent(eReplicaComponentType::RACING_STATS) ? 60 : 0); - comp->SetMaxImagination(HasComponent(eReplicaComponentType::RACING_STATS) ? 60 : 0); - } - } - - if (destCompData.size() > 0) { - comp->AddFaction(destCompData[0].faction); - std::stringstream ss(destCompData[0].factionList); - std::string token; - - while (std::getline(ss, token, ',')) { - if (std::stoi(token) == destCompData[0].faction) continue; - - if (token != "") { - comp->AddFaction(std::stoi(token)); - } - } - } - - m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, comp)); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CHARACTER) > 0 || m_Character) { - // Character Component always has a possessor, level, and forced movement components - m_Components.insert(std::make_pair(eReplicaComponentType::POSSESSOR, new PossessorComponent(this))); - - // load in the xml for the level - auto* levelComp = new LevelProgressionComponent(this); - levelComp->LoadFromXml(m_Character->GetXMLDoc()); - m_Components.insert(std::make_pair(eReplicaComponentType::LEVEL_PROGRESSION, levelComp)); - - m_Components.insert(std::make_pair(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, new PlayerForcedMovementComponent(this))); - - CharacterComponent* charComp = new CharacterComponent(this, m_Character); - charComp->LoadFromXml(m_Character->GetXMLDoc()); - m_Components.insert(std::make_pair(eReplicaComponentType::CHARACTER, charComp)); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) { - InventoryComponent* comp = nullptr; - if (m_Character) comp = new InventoryComponent(this, m_Character->GetXMLDoc()); - else comp = new InventoryComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::INVENTORY, comp)); - } - // if this component exists, then we initialize it. it's value is always 0 - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ROCKET_LAUNCH_LUP, -1) != -1) { - auto comp = new RocketLaunchLupComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::ROCKET_LAUNCH_LUP, comp)); - } - - /** - * This is a bit of a mess - */ - - CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable(); - int32_t scriptComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SCRIPT, -1); - - std::string scriptName = ""; - bool client = false; - if (scriptComponentID > 0 || m_Character) { - std::string clientScriptName; - if (!m_Character) { - CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID); - scriptName = scriptCompData.script_name; - clientScriptName = scriptCompData.client_script_name; - } else { - scriptName = ""; - } - - if (scriptName != "" || (scriptName == "" && m_Character)) { - - } else if (clientScriptName != "") { - client = true; - } else if (!m_Character) { - client = true; - } - } - - std::string customScriptServer; - bool hasCustomServerScript = false; - - const auto customScriptServerName = GetVarAsString(u"custom_script_server"); - const auto customScriptClientName = GetVarAsString(u"custom_script_client"); - - if (!customScriptServerName.empty()) { - customScriptServer = customScriptServerName; - hasCustomServerScript = true; - } - - if (!customScriptClientName.empty()) { - client = true; - } - - if (hasCustomServerScript && scriptName.empty()) { - scriptName = customScriptServer; - } - - if (!scriptName.empty() || client || m_Character || scriptComponentID >= 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPT, new ScriptComponent(this, scriptName, true, client && scriptName.empty()))); - } - - // ZoneControl script - if (m_TemplateID == 2365) { - CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable(); - const auto zoneID = dZoneManager::Instance()->GetZoneID(); - const CDZoneTable* zoneData = zoneTable->Query(zoneID.GetMapID()); - - if (zoneData != nullptr) { - int zoneScriptID = zoneData->scriptID; - CDScriptComponent zoneScriptData = scriptCompTable->GetByID(zoneScriptID); - - ScriptComponent* comp = new ScriptComponent(this, zoneScriptData.script_name, true); - m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPT, comp)); - } - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SKILL, -1) != -1 || m_Character) { - SkillComponent* comp = new SkillComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::SKILL, comp)); - } - - const auto combatAiId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BASE_COMBAT_AI); - if (combatAiId > 0) { - BaseCombatAIComponent* comp = new BaseCombatAIComponent(this, combatAiId); - m_Components.insert(std::make_pair(eReplicaComponentType::BASE_COMBAT_AI, comp)); - } - - if (int componentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD) > 0) { - RebuildComponent* comp = new RebuildComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::QUICK_BUILD, comp)); - - CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable(); - std::vector rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == rebuildComponentID); }); - - if (rebCompData.size() > 0) { - comp->SetResetTime(rebCompData[0].reset_time); - comp->SetCompleteTime(rebCompData[0].complete_time); - comp->SetTakeImagination(rebCompData[0].take_imagination); - comp->SetInterruptible(rebCompData[0].interruptible); - comp->SetSelfActivator(rebCompData[0].self_activator); - comp->SetActivityId(rebCompData[0].activityID); - comp->SetPostImaginationCost(rebCompData[0].post_imagination_cost); - comp->SetTimeBeforeSmash(rebCompData[0].time_before_smash); - - const auto rebuildResetTime = GetVar(u"rebuild_reset_time"); - - if (rebuildResetTime != 0.0f) { - comp->SetResetTime(rebuildResetTime); - - if (m_TemplateID == 9483) // Look away! - { - comp->SetResetTime(comp->GetResetTime() + 25); - } - } - - const auto activityID = GetVar(u"activityID"); - - if (activityID > 0) { - comp->SetActivityId(activityID); - } - - const auto compTime = GetVar(u"compTime"); - - if (compTime > 0) { - comp->SetCompleteTime(compTime); - } - } - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SWITCH, -1) != -1) { - SwitchComponent* comp = new SwitchComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::SWITCH, comp)); - } - - if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::VENDOR) > 0)) { - VendorComponent* comp = new VendorComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::VENDOR, comp)); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_VENDOR, -1) != -1) { - auto* component = new PropertyVendorComponent(this); - m_Components.insert_or_assign(eReplicaComponentType::PROPERTY_VENDOR, component); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_MANAGEMENT, -1) != -1) { - auto* component = new PropertyManagementComponent(this); - m_Components.insert_or_assign(eReplicaComponentType::PROPERTY_MANAGEMENT, component); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BOUNCER, -1) != -1) { // you have to determine it like this because all bouncers have a componentID of 0 - BouncerComponent* comp = new BouncerComponent(this); - m_Components.insert(std::make_pair(eReplicaComponentType::BOUNCER, comp)); - } - - int32_t renderComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RENDER); - if ((renderComponentId > 0 && m_TemplateID != 2365) || m_Character) { - RenderComponent* render = new RenderComponent(this, renderComponentId); - m_Components.insert(std::make_pair(eReplicaComponentType::RENDER, render)); - } - - if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MISSION_OFFER) > 0) || m_Character) { - m_Components.insert(std::make_pair(eReplicaComponentType::MISSION_OFFER, new MissionOfferComponent(this, m_TemplateID))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUILD_BORDER, -1) != -1) { - m_Components.insert(std::make_pair(eReplicaComponentType::BUILD_BORDER, new BuildBorderComponent(this))); - } - - // Scripted activity component - int scriptedActivityID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SCRIPTED_ACTIVITY); - if ((scriptedActivityID > 0)) { - m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPTED_ACTIVITY, new ScriptedActivityComponent(this, scriptedActivityID))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MODEL, -1) != -1 && !GetComponent()) { - m_Components.insert(std::make_pair(eReplicaComponentType::MODEL, new ModelComponent(this))); - if (m_Components.find(eReplicaComponentType::DESTROYABLE) == m_Components.end()) { - auto destroyableComponent = new DestroyableComponent(this); - destroyableComponent->SetHealth(1); - destroyableComponent->SetMaxHealth(1.0f); - destroyableComponent->SetFaction(-1, true); - destroyableComponent->SetIsSmashable(true); - m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, destroyableComponent)); - } - } - - PetComponent* petComponent; - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ITEM) > 0 && !TryGetComponent(eReplicaComponentType::PET, petComponent) && !HasComponent(eReplicaComponentType::MODEL)) { - m_Components.insert(std::make_pair(eReplicaComponentType::ITEM, nullptr)); - } - - // Shooting gallery component - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::SHOOTING_GALLERY, new ShootingGalleryComponent(this))); - } - - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) { - m_Components.insert(std::make_pair(eReplicaComponentType::PROPERTY, new PropertyComponent(this))); - } - - const int rocketId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ROCKET_LAUNCH); - if ((rocketId > 0)) { - m_Components.insert(std::make_pair(eReplicaComponentType::ROCKET_LAUNCH, new RocketLaunchpadControlComponent(this, rocketId))); - } - - const int32_t railComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RAIL_ACTIVATOR); - if (railComponentID > 0) { - m_Components.insert(std::make_pair(eReplicaComponentType::RAIL_ACTIVATOR, new RailActivatorComponent(this, railComponentID))); - } - - int movementAIID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVEMENT_AI); - if (movementAIID > 0) { - CDMovementAIComponentTable* moveAITable = CDClientManager::Instance().GetTable(); - std::vector moveAIComp = moveAITable->Query([=](CDMovementAIComponent entry) {return (entry.id == movementAIID); }); - - if (moveAIComp.size() > 0) { - MovementAIInfo moveInfo = MovementAIInfo(); - - moveInfo.movementType = moveAIComp[0].MovementType; - moveInfo.wanderChance = moveAIComp[0].WanderChance; - moveInfo.wanderRadius = moveAIComp[0].WanderRadius; - moveInfo.wanderSpeed = moveAIComp[0].WanderSpeed; - moveInfo.wanderDelayMax = moveAIComp[0].WanderDelayMax; - moveInfo.wanderDelayMin = moveAIComp[0].WanderDelayMin; - - bool useWanderDB = GetVar(u"usewanderdb"); - - if (!useWanderDB) { - const auto wanderOverride = GetVarAs(u"wanderRadius"); - - if (wanderOverride != 0.0f) { - moveInfo.wanderRadius = wanderOverride; - } - } - - m_Components.insert(std::make_pair(eReplicaComponentType::MOVEMENT_AI, new MovementAIComponent(this, moveInfo))); - } - } else if (petComponentId > 0 || combatAiId > 0 && GetComponent()->GetTetherSpeed() > 0) { - MovementAIInfo moveInfo = MovementAIInfo(); - moveInfo.movementType = ""; - moveInfo.wanderChance = 0; - moveInfo.wanderRadius = 16; - moveInfo.wanderSpeed = 2.5f; - moveInfo.wanderDelayMax = 5; - moveInfo.wanderDelayMin = 2; - - m_Components.insert(std::make_pair(eReplicaComponentType::MOVEMENT_AI, new MovementAIComponent(this, moveInfo))); - } - - std::string pathName = GetVarAsString(u"attached_path"); - const Path* path = dZoneManager::Instance()->GetZone()->GetPath(pathName); - - //Check to see if we have an attached path and add the appropiate component to handle it: - if (path){ - // if we have a moving platform path, then we need a moving platform component - if (path->pathType == PathType::MovingPlatform) { - MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); - m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); - // else if we are a movement path - } /*else if (path->pathType == PathType::Movement) { - auto movementAIcomp = GetComponent(); - if (movementAIcomp){ - // TODO: set path in existing movementAIComp - } else { - // TODO: create movementAIcomp and set path - } - }*/ - } else { - // else we still need to setup moving platform if it has a moving platform comp but no path - int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1); - if (movingPlatformComponentId >= 0) { - MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); - m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); - } - } - - int proximityMonitorID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROXIMITY_MONITOR); - if (proximityMonitorID > 0) { - CDProximityMonitorComponentTable* proxCompTable = CDClientManager::Instance().GetTable(); - std::vector proxCompData = proxCompTable->Query([=](CDProximityMonitorComponent entry) { return (entry.id == proximityMonitorID); }); - if (proxCompData.size() > 0) { - std::vector proximityStr = GeneralUtils::SplitString(proxCompData[0].Proximities, ','); - ProximityMonitorComponent* comp = new ProximityMonitorComponent(this, std::stoi(proximityStr[0]), std::stoi(proximityStr[1])); - m_Components.insert(std::make_pair(eReplicaComponentType::PROXIMITY_MONITOR, comp)); - } - } - - // Hacky way to trigger these when the object has had a chance to get constructed - AddCallbackTimer(0, [this]() { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnStartup(this); - } - }); - - if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) { - // Don't ghost what is likely large scene elements - if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) { - goto no_ghosting; - } - - /* Filter for ghosting candidates. - * - * Don't ghost moving platforms, until we've got proper syncing for those. - * Don't ghost big phantom physics triggers, as putting those to sleep might prevent interactions. - * Don't ghost property related objects, as the client expects those to always be loaded. - */ - if ( - !EntityManager::IsExcludedFromGhosting(GetLOT()) && - !HasComponent(eReplicaComponentType::SCRIPTED_ACTIVITY) && - !HasComponent(eReplicaComponentType::MOVING_PLATFORM) && - !HasComponent(eReplicaComponentType::PHANTOM_PHYSICS) && - !HasComponent(eReplicaComponentType::PROPERTY) && - !HasComponent(eReplicaComponentType::RACING_CONTROL) && - !HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) - ) - //if (HasComponent(eReplicaComponentType::BASE_COMBAT_AI)) - { - m_IsGhostingCandidate = true; - } - - if (GetLOT() == 6368) { - m_IsGhostingCandidate = true; - } - - // Special case for collectibles in Ninjago - if (HasComponent(eReplicaComponentType::COLLECTIBLE) && Game::server->GetZoneID() == 2000) { - m_IsGhostingCandidate = true; - } - } - -no_ghosting: - - TriggerEvent(eTriggerEventType::CREATE, this); - - if (m_Character) { - auto* controllablePhysicsComponent = GetComponent(); - auto* levelComponent = GetComponent(); - - if (controllablePhysicsComponent && levelComponent) { - controllablePhysicsComponent->SetSpeedMultiplier(levelComponent->GetSpeedBase() / 500.0f); + auto* componentsRegistry = CDClientManager::Instance().GetTable(); + auto components = componentsRegistry->GetTemplateComponents(m_TemplateID); + for (const auto& [componentTemplate, componentId] : components) { + switch (componentTemplate) { + case eReplicaComponentType::CONTROLLABLE_PHYSICS: + AddComponent(this); + break; + case eReplicaComponentType::RENDER: + break; + case eReplicaComponentType::SIMPLE_PHYSICS: + break; + case eReplicaComponentType::CHARACTER: + break; + case eReplicaComponentType::SCRIPT: + break; + case eReplicaComponentType::BOUNCER: + break; + case eReplicaComponentType::BUFF: + break; + case eReplicaComponentType::GHOST: + break; + case eReplicaComponentType::SKILL: + break; + case eReplicaComponentType::SPAWNER: + break; + case eReplicaComponentType::ITEM: + break; + case eReplicaComponentType::REBUILD: + break; + case eReplicaComponentType::REBUILD_START: + break; + case eReplicaComponentType::REBUILD_ACTIVATOR: + break; + case eReplicaComponentType::ICON_ONLY: + break; + case eReplicaComponentType::VENDOR: + break; + case eReplicaComponentType::INVENTORY: + break; + case eReplicaComponentType::PROJECTILE_PHYSICS: + break; + case eReplicaComponentType::SHOOTING_GALLERY: + break; + case eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS: + break; + case eReplicaComponentType::DROP_EFFECT: + break; + case eReplicaComponentType::CHEST: + break; + case eReplicaComponentType::COLLECTIBLE: + break; + case eReplicaComponentType::BLUEPRINT: + break; + case eReplicaComponentType::MOVING_PLATFORM: + break; + case eReplicaComponentType::PET: + break; + case eReplicaComponentType::PLATFORM_BOUNDARY: + break; + case eReplicaComponentType::MODULE: + break; + case eReplicaComponentType::ARCADE: + break; + case eReplicaComponentType::VEHICLE_PHYSICS: + break; + case eReplicaComponentType::MOVEMENT_AI: + break; + case eReplicaComponentType::EXHIBIT: + break; + case eReplicaComponentType::OVERHEAD_ICON: + break; + case eReplicaComponentType::PET_CONTROL: + break; + case eReplicaComponentType::MINIFIG: + break; + case eReplicaComponentType::PROPERTY: + break; + case eReplicaComponentType::PET_CREATOR: + break; + case eReplicaComponentType::MODEL_BUILDER: + break; + case eReplicaComponentType::SCRIPTED_ACTIVITY: + break; + case eReplicaComponentType::PHANTOM_PHYSICS: + break; + case eReplicaComponentType::SPRINGPAD: + break; + case eReplicaComponentType::MODEL: + break; + case eReplicaComponentType::PROPERTY_ENTRANCE: + break; + case eReplicaComponentType::FX: + break; + case eReplicaComponentType::PROPERTY_MANAGEMENT: + break; + case eReplicaComponentType::VEHICLE_PHYSICS_NEW: + break; + case eReplicaComponentType::PHYSICS_SYSTEM: + break; + case eReplicaComponentType::QUICK_BUILD: + break; + case eReplicaComponentType::SWITCH: + break; + case eReplicaComponentType::ZONE_CONTROL: + break; + case eReplicaComponentType::CHANGLING: + break; + case eReplicaComponentType::CHOICE_BUILD: + break; + case eReplicaComponentType::PACKAGE: + break; + case eReplicaComponentType::SOUND_REPEATER: + break; + case eReplicaComponentType::SOUND_AMBIENT_2D: + break; + case eReplicaComponentType::SOUND_AMBIENT_3D: + break; + case eReplicaComponentType::PRECONDITION: + break; + case eReplicaComponentType::PLAYER_FLAG: + break; + case eReplicaComponentType::CUSTOM_BUILD_ASSEMBLY: + break; + case eReplicaComponentType::BASE_COMBAT_AI: + break; + case eReplicaComponentType::MODULE_ASSEMBLY: + break; + case eReplicaComponentType::SHOWCASE_MODEL_HANDLER: + break; + case eReplicaComponentType::RACING_MODULE: + break; + case eReplicaComponentType::GENERIC_ACTIVATOR: + break; + case eReplicaComponentType::PROPERTY_VENDOR: + break; + case eReplicaComponentType::HF_LIGHT_DIRECTION_GADGET: + break; + case eReplicaComponentType::ROCKET_LAUNCH: + break; + case eReplicaComponentType::ROCKET_LANDING: + break; + case eReplicaComponentType::TRIGGER: + break; + case eReplicaComponentType::DROPPED_LOOT: + break; + case eReplicaComponentType::RACING_CONTROL: + break; + case eReplicaComponentType::FACTION_TRIGGER: + break; + case eReplicaComponentType::MISSION_OFFER: + break; + case eReplicaComponentType::RACING_STATS: + break; + case eReplicaComponentType::LUP_EXHIBIT: + break; + case eReplicaComponentType::BBB: + break; + case eReplicaComponentType::SOUND_TRIGGER: + break; + case eReplicaComponentType::PROXIMITY_MONITOR: + break; + case eReplicaComponentType::RACING_SOUND_TRIGGER: + break; + case eReplicaComponentType::CHAT: + break; + case eReplicaComponentType::FRIENDS_LIST: + break; + case eReplicaComponentType::GUILD: + break; + case eReplicaComponentType::LOCAL_SYSTEM: + break; + case eReplicaComponentType::MISSION: + break; + case eReplicaComponentType::MUTABLE_MODEL_BEHAVIORS: + break; + case eReplicaComponentType::PATHFINDING: + break; + case eReplicaComponentType::PET_TAMING_CONTROL: + break; + case eReplicaComponentType::PROPERTY_EDITOR: + break; + case eReplicaComponentType::SKINNED_RENDER: + break; + case eReplicaComponentType::SLASH_COMMAND: + break; + case eReplicaComponentType::STATUS_EFFECT: + break; + case eReplicaComponentType::TEAMS: + break; + case eReplicaComponentType::TEXT_EFFECT: + break; + case eReplicaComponentType::TRADE: + break; + case eReplicaComponentType::USER_CONTROL: + break; + case eReplicaComponentType::IGNORE_LIST: + break; + case eReplicaComponentType::ROCKET_LAUNCH_LUP: + break; + case eReplicaComponentType::BUFF_REAL: + break; + case eReplicaComponentType::INTERACTION_MANAGER: + break; + case eReplicaComponentType::DONATION_VENDOR: + break; + case eReplicaComponentType::COMBAT_MEDIATOR: + break; + case eReplicaComponentType::COMMENDATION_VENDOR: + break; + case eReplicaComponentType::GATE_RUSH_CONTROL: + break; + case eReplicaComponentType::RAIL_ACTIVATOR: + break; + case eReplicaComponentType::ROLLER: + break; + case eReplicaComponentType::PLAYER_FORCED_MOVEMENT: + break; + case eReplicaComponentType::CRAFTING: + break; + case eReplicaComponentType::POSSESSABLE: + break; + case eReplicaComponentType::LEVEL_PROGRESSION: + break; + case eReplicaComponentType::POSSESSOR: + break; + case eReplicaComponentType::MOUNT_CONTROL: + break; + case eReplicaComponentType::UNKNOWN_112: + break; + case eReplicaComponentType::PROPERTY_PLAQUE: + break; + case eReplicaComponentType::BUILD_BORDER: + break; + case eReplicaComponentType::UNKNOWN_115: + break; + case eReplicaComponentType::CULLING_PLANE: + break; + case eReplicaComponentType::NUMBER_OF_COMPONENTS: + break; + case eReplicaComponentType::DESTROYABLE: + break; + case eReplicaComponentType::INVALID: + default: + Game::logger->Log("Entity", "blah %i %i", componentId, m_TemplateID); } } } @@ -801,33 +395,20 @@ User* Entity::GetParentUser() const { return static_cast(this)->GetParentUser(); } -Component* Entity::GetComponent(eReplicaComponentType componentID) const { +const ComponentPtr Entity::GetComponent(eReplicaComponentType componentID) const { const auto& index = m_Components.find(componentID); - - if (index == m_Components.end()) { - return nullptr; - } - - return index->second; + return index != m_Components.end() ? index->second : nullptr; } bool Entity::HasComponent(const eReplicaComponentType componentId) const { return m_Components.find(componentId) != m_Components.end(); } -void Entity::AddComponent(const eReplicaComponentType componentId, Component* component) { - if (HasComponent(componentId)) { - return; - } - - m_Components.insert_or_assign(componentId, component); -} - -std::vector Entity::GetScriptComponents() { - std::vector comps; - for (std::pair p : m_Components) { - if (p.first == eReplicaComponentType::SCRIPT) { - comps.push_back(static_cast(p.second)); +std::vector> Entity::GetScriptComponents() { + std::vector> comps; + for (const auto&[componentType, component] : m_Components) { + if (componentType == eReplicaComponentType::SCRIPT) { + comps.push_back(std::dynamic_pointer_cast(component)); } } @@ -836,7 +417,7 @@ std::vector Entity::GetScriptComponents() { void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) { if (notificationName == "HitOrHealResult" || notificationName == "Hit") { - auto* destroyableComponent = GetComponent(); + auto destroyableComponent = GetComponent(); if (!destroyableComponent) return; destroyableComponent->Subscribe(scriptObjId, scriptToAdd); } @@ -844,28 +425,20 @@ void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, co void Entity::Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName) { if (notificationName == "HitOrHealResult" || notificationName == "Hit") { - auto* destroyableComponent = GetComponent(); + auto destroyableComponent = GetComponent(); if (!destroyableComponent) return; destroyableComponent->Unsubscribe(scriptObjId); } } void Entity::SetProximityRadius(float proxRadius, std::string name) { - ProximityMonitorComponent* proxMon = GetComponent(); - if (!proxMon) { - proxMon = new ProximityMonitorComponent(this); - m_Components.insert_or_assign(eReplicaComponentType::PROXIMITY_MONITOR, proxMon); - } - proxMon->SetProximityRadius(proxRadius, name); + auto proximityMonitorComponent = AddComponent(this); + if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(proxRadius, name); } void Entity::SetProximityRadius(dpEntity* entity, std::string name) { - ProximityMonitorComponent* proxMon = GetComponent(); - if (!proxMon) { - proxMon = new ProximityMonitorComponent(this); - m_Components.insert_or_assign(eReplicaComponentType::PROXIMITY_MONITOR, proxMon); - } - proxMon->SetProximityRadius(entity, name); + auto proximityMonitorComponent = AddComponent(this); + if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(entity, name); } void Entity::SetGMLevel(eGameMasterLevel value) { @@ -878,7 +451,7 @@ void Entity::SetGMLevel(eGameMasterLevel value) { } } - CharacterComponent* character = GetComponent(); + auto character = GetComponent(); if (character) character->SetGMLevel(value); GameMessages::SendGMLevelBroadcast(m_ObjectID, value); @@ -950,8 +523,8 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke outBitStream->Write0(); //No ldf data } - TriggerComponent* triggerComponent; - if (TryGetComponent(eReplicaComponentType::TRIGGER, triggerComponent)) { + auto triggerComponent = GetComponent(); + if (triggerComponent) { // has trigger component, check to see if we have events to handle auto* trigger = triggerComponent->GetTrigger(); outBitStream->Write(trigger && trigger->events.size() > 0); @@ -1007,210 +580,6 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) { - /** - * This has to be done in a specific order. - */ - - bool destroyableSerialized = false; - bool bIsInitialUpdate = false; - if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true; - unsigned int flags = 0; - - PossessableComponent* possessableComponent; - if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) { - possessableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - ModuleAssemblyComponent* moduleAssemblyComponent; - if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) { - moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - ControllablePhysicsComponent* controllablePhysicsComponent; - if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) { - controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - SimplePhysicsComponent* simplePhysicsComponent; - if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) { - simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics; - if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) { - rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - VehiclePhysicsComponent* vehiclePhysicsComponent; - if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) { - vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - PhantomPhysicsComponent* phantomPhysicsComponent; - if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) { - phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - SoundTriggerComponent* soundTriggerComponent; - if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) { - soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - BuffComponent* buffComponent; - if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) { - buffComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - - DestroyableComponent* destroyableComponent; - if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - destroyableSerialized = true; - } - - if (HasComponent(eReplicaComponentType::COLLECTIBLE)) { - DestroyableComponent* destroyableComponent; - if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - destroyableSerialized = true; - outBitStream->Write(m_CollectibleID); // Collectable component - } - - PetComponent* petComponent; - if (TryGetComponent(eReplicaComponentType::PET, petComponent)) { - petComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - CharacterComponent* characterComponent; - if (TryGetComponent(eReplicaComponentType::CHARACTER, characterComponent)) { - - PossessorComponent* possessorComponent; - if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) { - possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } else { - // Should never happen, but just to be safe - outBitStream->Write0(); - } - - LevelProgressionComponent* levelProgressionComponent; - if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) { - levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } else { - // Should never happen, but just to be safe - outBitStream->Write0(); - } - - PlayerForcedMovementComponent* playerForcedMovementComponent; - if (TryGetComponent(eReplicaComponentType::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); - } - - if (HasComponent(eReplicaComponentType::ITEM)) { - outBitStream->Write0(); - } - - InventoryComponent* inventoryComponent; - if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) { - inventoryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - ScriptComponent* scriptComponent; - if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) { - scriptComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - SkillComponent* skillComponent; - if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { - skillComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - BaseCombatAIComponent* baseCombatAiComponent; - if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) { - baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - RebuildComponent* rebuildComponent; - if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) { - DestroyableComponent* destroyableComponent; - if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - destroyableSerialized = true; - rebuildComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - MovingPlatformComponent* movingPlatformComponent; - if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) { - movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - SwitchComponent* switchComponent; - if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) { - switchComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - VendorComponent* vendorComponent; - if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) { - vendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - BouncerComponent* bouncerComponent; - if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) { - bouncerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - ScriptedActivityComponent* scriptedActivityComponent; - if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) { - scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - ShootingGalleryComponent* shootingGalleryComponent; - if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) { - shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - RacingControlComponent* racingControlComponent; - if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) { - racingControlComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - LUPExhibitComponent* lupExhibitComponent; - if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) { - lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - ModelComponent* modelComponent; - if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) { - modelComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - RenderComponent* renderComponent; - if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) { - renderComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - } - - if (modelComponent) { - DestroyableComponent* destroyableComponent; - if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); - destroyableSerialized = true; - } - } - - if (HasComponent(eReplicaComponentType::ZONE_CONTROL)) { - outBitStream->Write(0x40000000); - } - - // BBB Component, unused currently - // Need to to write0 so that is serialized correctly - // TODO: Implement BBB Component - outBitStream->Write0(); } void Entity::ResetFlags() { @@ -1296,7 +665,7 @@ void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxN script->OnProximityUpdate(this, other, proxName, status); } - RocketLaunchpadControlComponent* rocketComp = GetComponent(); + auto rocketComp = GetComponent(); if (!rocketComp) return; rocketComp->OnProximityUpdate(other, proxName, status); @@ -1314,7 +683,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { callback(other); } - SwitchComponent* switchComp = GetComponent(); + auto switchComp = GetComponent(); if (switchComp) { switchComp->EntityEnter(other); } @@ -1325,7 +694,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { const auto& poi = GetVar(u"POI"); if (!poi.empty()) { - auto* missionComponent = other->GetComponent(); + auto missionComponent = other->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::EXPLORE, 0, 0, GeneralUtils::UTF16ToWTF8(poi)); @@ -1333,7 +702,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { } if (!other->GetIsDead()) { - auto* combat = GetComponent(); + auto combat = GetComponent(); if (combat != nullptr) { const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity); @@ -1359,7 +728,7 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) { TriggerEvent(eTriggerEventType::EXIT, other); - SwitchComponent* switchComp = GetComponent(); + auto switchComp = GetComponent(); if (switchComp) { switchComp->EntityLeave(other); } @@ -1502,12 +871,12 @@ void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) { if (!m_PlayerIsReadyForUpdates) return; - auto* destroyableComponent = GetComponent(); + auto destroyableComponent = GetComponent(); if (destroyableComponent == nullptr) { Kill(EntityManager::Instance()->GetEntity(source)); return; } - auto* possessorComponent = GetComponent(); + auto possessorComponent = GetComponent(); if (possessorComponent) { if (possessorComponent->GetPossessable() != LWOOBJID_EMPTY) { auto* mount = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); @@ -1564,14 +933,14 @@ void Entity::Kill(Entity* murderer) { } // Track a player being smashed - auto* characterComponent = GetComponent(); + auto characterComponent = GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(TimesSmashed); } // Track a player smashing something else if (murderer != nullptr) { - auto* murdererCharacterComponent = murderer->GetComponent(); + auto murdererCharacterComponent = murderer->GetComponent(); if (murdererCharacterComponent != nullptr) { murdererCharacterComponent->UpdatePlayerStatistic(SmashablesSmashed); } @@ -1587,14 +956,14 @@ void Entity::AddCollisionPhantomCallback(const std::function& callback) const { - auto* rebuildComponent = GetComponent(); + auto rebuildComponent = GetComponent(); if (rebuildComponent != nullptr) { rebuildComponent->AddRebuildCompleteCallback(callback); } } bool Entity::GetIsDead() const { - DestroyableComponent* dest = GetComponent(); + auto dest = GetComponent(); if (dest && dest->GetArmor() == 0 && dest->GetHealth() == 0) return true; return false; @@ -1608,7 +977,7 @@ void Entity::AddLootItem(const Loot::Info& info) { void Entity::PickupItem(const LWOOBJID& objectID) { if (!IsPlayer()) return; - InventoryComponent* inv = GetComponent(); + auto inv = GetComponent(); if (!inv) return; CDObjectsTable* objectsTable = CDClientManager::Instance().GetTable(); @@ -1617,7 +986,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { for (const auto& p : droppedLoot) { if (p.first == objectID) { - auto* characterComponent = GetComponent(); + auto characterComponent = GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackLOTCollection(p.second.lot); } @@ -1632,7 +1001,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { SkillComponent::HandleUnmanaged(behaviorData.behaviorID, GetObjectID()); - auto* missionComponent = GetComponent(); + auto missionComponent = GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::POWERUP, skill.skillID); @@ -1757,7 +1126,7 @@ bool Entity::IsPlayer() const { } void Entity::TriggerEvent(eTriggerEventType event, Entity* optionalTarget) { - auto* triggerComponent = GetComponent(); + auto triggerComponent = GetComponent(); if (triggerComponent) triggerComponent->TriggerEvent(event, optionalTarget); } @@ -1806,7 +1175,7 @@ void Entity::SetObservers(int8_t value) { } void Entity::Sleep() { - auto* baseCombatAIComponent = GetComponent(); + auto baseCombatAIComponent = GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->Sleep(); @@ -1814,7 +1183,7 @@ void Entity::Sleep() { } void Entity::Wake() { - auto* baseCombatAIComponent = GetComponent(); + auto baseCombatAIComponent = GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->Wake(); @@ -1829,112 +1198,112 @@ bool Entity::IsSleeping() const { const NiPoint3& Entity::GetPosition() const { if (!this) return NiPoint3::ZERO; - auto* controllable = GetComponent(); + auto controllable = GetComponent(); if (controllable != nullptr) { return controllable->GetPosition(); } - auto* phantom = GetComponent(); + auto phantom = GetComponent(); if (phantom != nullptr) { return phantom->GetPosition(); } - auto* simple = GetComponent(); + auto simple = GetComponent(); if (simple != nullptr) { return simple->GetPosition(); } - auto* vehicel = GetComponent(); + auto vehicle = GetComponent(); - if (vehicel != nullptr) { - return vehicel->GetPosition(); + if (vehicle != nullptr) { + return vehicle->GetPosition(); } return NiPoint3::ZERO; } const NiQuaternion& Entity::GetRotation() const { - auto* controllable = GetComponent(); + auto controllable = GetComponent(); if (controllable != nullptr) { return controllable->GetRotation(); } - auto* phantom = GetComponent(); + auto phantom = GetComponent(); if (phantom != nullptr) { return phantom->GetRotation(); } - auto* simple = GetComponent(); + auto simple = GetComponent(); if (simple != nullptr) { return simple->GetRotation(); } - auto* vehicel = GetComponent(); + auto vehicle = GetComponent(); - if (vehicel != nullptr) { - return vehicel->GetRotation(); + if (vehicle != nullptr) { + return vehicle->GetRotation(); } return NiQuaternion::IDENTITY; } void Entity::SetPosition(NiPoint3 position) { - auto* controllable = GetComponent(); + auto controllable = GetComponent(); if (controllable != nullptr) { controllable->SetPosition(position); } - auto* phantom = GetComponent(); + auto phantom = GetComponent(); if (phantom != nullptr) { phantom->SetPosition(position); } - auto* simple = GetComponent(); + auto simple = GetComponent(); if (simple != nullptr) { simple->SetPosition(position); } - auto* vehicel = GetComponent(); + auto vehicle = GetComponent(); - if (vehicel != nullptr) { - vehicel->SetPosition(position); + if (vehicle != nullptr) { + vehicle->SetPosition(position); } EntityManager::Instance()->SerializeEntity(this); } void Entity::SetRotation(NiQuaternion rotation) { - auto* controllable = GetComponent(); + auto controllable = GetComponent(); if (controllable != nullptr) { controllable->SetRotation(rotation); } - auto* phantom = GetComponent(); + auto phantom = GetComponent(); if (phantom != nullptr) { phantom->SetRotation(rotation); } - auto* simple = GetComponent(); + auto simple = GetComponent(); if (simple != nullptr) { simple->SetRotation(rotation); } - auto* vehicel = GetComponent(); + auto vehicle = GetComponent(); - if (vehicel != nullptr) { - vehicel->SetRotation(rotation); + if (vehicle != nullptr) { + vehicle->SetRotation(rotation); } EntityManager::Instance()->SerializeEntity(this); diff --git a/dGame/Entity.h b/dGame/Entity.h index 90f2a34fb..9f3198a62 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "NiPoint3.h" #include "NiQuaternion.h" @@ -44,6 +45,8 @@ namespace CppScripts { /** * An entity in the world. Has multiple components. */ + +using ComponentPtr = std::shared_ptr; class Entity { public: explicit Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity = nullptr); @@ -136,19 +139,17 @@ class Entity { * Component management */ - Component* GetComponent(eReplicaComponentType componentID) const; - - template - T* GetComponent() const; + const ComponentPtr GetComponent(eReplicaComponentType componentID) const; template - bool TryGetComponent(eReplicaComponentType componentId, T*& component) const; + std::shared_ptr GetComponent() const; bool HasComponent(eReplicaComponentType componentId) const; - void AddComponent(eReplicaComponentType componentId, Component* component); + template + std::shared_ptr AddComponent(ConstructorValues... arguments); - std::vector GetScriptComponents(); + std::vector> GetScriptComponents(); void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName); void Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName); @@ -169,8 +170,6 @@ class Entity { void AddToGroup(const std::string& group); bool IsPlayer() const; - std::unordered_map& GetComponents() { return m_Components; } // TODO: Remove - void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void ResetFlags(); @@ -320,7 +319,7 @@ class Entity { std::vector> m_DieCallbacks; std::vector> m_PhantomCollisionCallbacks; - std::unordered_map m_Components; + std::unordered_map m_Components; std::vector m_Timers; std::vector m_PendingTimers; std::vector m_CallbackTimers; @@ -345,31 +344,11 @@ class Entity { std::vector m_TargetsInPhantom; }; -/** - * Template definitions. - */ - -template -bool Entity::TryGetComponent(const eReplicaComponentType componentId, T*& component) const { - const auto& index = m_Components.find(componentId); - - if (index == m_Components.end()) { - component = nullptr; - - return false; - } - - component = dynamic_cast(index->second); - - return true; -} - template -T* Entity::GetComponent() const { - return dynamic_cast(GetComponent(T::ComponentType)); +std::shared_ptr Entity::GetComponent() const { + return std::dynamic_pointer_cast(GetComponent(T::ComponentType)); } - template const T& Entity::GetVar(const std::u16string& name) const { auto* data = GetVarData(name); @@ -501,3 +480,10 @@ T Entity::GetNetworkVar(const std::u16string& name) { return LDFData::Default; } + +template +std::shared_ptr Entity::AddComponent(ConstructorValues...arguments) { + if (GetComponent()) return nullptr; + + m_Components.insert_or_assign(ComponentType::ComponentType, std::make_shared(arguments...)); +} diff --git a/dGame/EntityInitializeOld.cc b/dGame/EntityInitializeOld.cc new file mode 100644 index 000000000..321b220c2 --- /dev/null +++ b/dGame/EntityInitializeOld.cc @@ -0,0 +1,640 @@ +Entity::Initialize() { + /** + * Setup trigger + */ + + const auto triggerInfo = GetVarAsString(u"trigger_id"); + + if (!triggerInfo.empty()) m_Components.emplace(eReplicaComponentType::TRIGGER, new TriggerComponent(this, triggerInfo)); + + /** + * Setup groups + */ + + const auto groupIDs = GetVarAsString(u"groupID"); + + if (!groupIDs.empty()) { + m_Groups = GeneralUtils::SplitString(groupIDs, ';'); + m_Groups.erase(m_Groups.end() - 1); + } + + /** + * Set ourselves as a child of our parent + */ + + if (m_ParentEntity != nullptr) { + m_ParentEntity->AddChild(this); + } + + // Get the registry table + CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable(); + + /** + * Special case for BBB models. They have components not corresponding to the registry. + */ + + if (m_TemplateID == 14) { + const auto simplePhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SIMPLE_PHYSICS); + + SimplePhysicsComponent* comp = new SimplePhysicsComponent(simplePhysicsComponentID, this); + m_Components.insert(std::make_pair(eReplicaComponentType::SIMPLE_PHYSICS, comp)); + + ModelComponent* modelcomp = new ModelComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::MODEL, modelcomp)); + + RenderComponent* render = new RenderComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::RENDER, render)); + + auto destroyableComponent = new DestroyableComponent(this); + destroyableComponent->SetHealth(1); + destroyableComponent->SetMaxHealth(1.0f); + destroyableComponent->SetFaction(-1, true); + destroyableComponent->SetIsSmashable(true); + m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, destroyableComponent)); + // We have all our components. + return; + } + + /** + * Go through all the components and check if this entity has them. + * + * Not all components are implemented. Some are represented by a nullptr, as they hold no data. + */ + + if (GetParentUser()) { + auto missions = new MissionComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::MISSION, missions)); + missions->LoadFromXml(m_Character->GetXMLDoc()); + } + + uint32_t petComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PET); + if (petComponentId > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::PET, new PetComponent(this, petComponentId))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ZONE_CONTROL) > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::ZONE_CONTROL, nullptr)); + } + + uint32_t possessableComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::POSSESSABLE); + if (possessableComponentId > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::POSSESSABLE, new PossessableComponent(this, possessableComponentId))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MODULE_ASSEMBLY) > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::MODULE_ASSEMBLY, new ModuleAssemblyComponent(this))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RACING_STATS) > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::RACING_STATS, nullptr)); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::LUP_EXHIBIT, -1) >= 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::LUP_EXHIBIT, new LUPExhibitComponent(this))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RACING_CONTROL) > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::RACING_CONTROL, new RacingControlComponent(this))); + } + + const auto propertyEntranceComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_ENTRANCE); + if (propertyEntranceComponentID > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::PROPERTY_ENTRANCE, + new PropertyEntranceComponent(propertyEntranceComponentID, this))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) { + ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this); + + if (m_Character) { + controllablePhysics->LoadFromXml(m_Character->GetXMLDoc()); + + const auto mapID = Game::server->GetZoneID(); + + //If we came from another zone, put us in the starting loc + if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof. + NiPoint3 pos; + NiQuaternion rot; + + const auto& targetSceneName = m_Character->GetTargetScene(); + auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName); + + if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) { + pos = m_Character->GetRespawnPoint(mapID); + rot = dZoneManager::Instance()->GetZone()->GetSpawnRot(); + } else if (targetScene != nullptr) { + pos = targetScene->GetPosition(); + rot = targetScene->GetRotation(); + } else { + pos = dZoneManager::Instance()->GetZone()->GetSpawnPos(); + rot = dZoneManager::Instance()->GetZone()->GetSpawnRot(); + } + + controllablePhysics->SetPosition(pos); + controllablePhysics->SetRotation(rot); + } + } else { + controllablePhysics->SetPosition(m_DefaultPosition); + controllablePhysics->SetRotation(m_DefaultRotation); + } + + m_Components.insert(std::make_pair(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysics)); + } + + // If an entity is marked a phantom, simple physics is made into phantom phyics. + bool markedAsPhantom = GetVar(u"markedAsPhantom"); + + const auto simplePhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SIMPLE_PHYSICS); + if (!markedAsPhantom && simplePhysicsComponentID > 0) { + SimplePhysicsComponent* comp = new SimplePhysicsComponent(simplePhysicsComponentID, this); + m_Components.insert(std::make_pair(eReplicaComponentType::SIMPLE_PHYSICS, comp)); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS) > 0) { + RigidbodyPhantomPhysicsComponent* comp = new RigidbodyPhantomPhysicsComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, comp)); + } + + if (markedAsPhantom || compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PHANTOM_PHYSICS) > 0) { + PhantomPhysicsComponent* phantomPhysics = new PhantomPhysicsComponent(this); + phantomPhysics->SetPhysicsEffectActive(false); + m_Components.insert(std::make_pair(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysics)); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::VEHICLE_PHYSICS) > 0) { + VehiclePhysicsComponent* vehiclePhysicsComponent = new VehiclePhysicsComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)); + vehiclePhysicsComponent->SetPosition(m_DefaultPosition); + vehiclePhysicsComponent->SetRotation(m_DefaultRotation); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SOUND_TRIGGER, -1) != -1) { + auto* comp = new SoundTriggerComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::SOUND_TRIGGER, comp)); + } + + //Also check for the collectible id: + m_CollectibleID = GetVarAs(u"collectible_id"); + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUFF) > 0) { + BuffComponent* comp = new BuffComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::BUFF, comp)); + } + + int collectibleComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::COLLECTIBLE); + + if (collectibleComponentID > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::COLLECTIBLE, nullptr)); + } + + /** + * Multiple components require the destructible component. + */ + + int buffComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUFF); + int rebuildComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD); + + int componentID = 0; + if (collectibleComponentID > 0) componentID = collectibleComponentID; + if (rebuildComponentID > 0) componentID = rebuildComponentID; + if (buffComponentID > 0) componentID = buffComponentID; + + CDDestructibleComponentTable* destCompTable = CDClientManager::Instance().GetTable(); + std::vector destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); }); + + if (buffComponentID > 0 || collectibleComponentID > 0) { + DestroyableComponent* comp = new DestroyableComponent(this); + if (m_Character) { + comp->LoadFromXml(m_Character->GetXMLDoc()); + } else { + if (componentID > 0) { + std::vector destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); }); + + if (destCompData.size() > 0) { + if (HasComponent(eReplicaComponentType::RACING_STATS)) { + destCompData[0].imagination = 60; + } + + comp->SetHealth(destCompData[0].life); + comp->SetImagination(destCompData[0].imagination); + comp->SetArmor(destCompData[0].armor); + + comp->SetMaxHealth(destCompData[0].life); + comp->SetMaxImagination(destCompData[0].imagination); + comp->SetMaxArmor(destCompData[0].armor); + + comp->SetIsSmashable(destCompData[0].isSmashable); + + comp->SetLootMatrixID(destCompData[0].LootMatrixIndex); + + // Now get currency information + uint32_t npcMinLevel = destCompData[0].level; + uint32_t currencyIndex = destCompData[0].CurrencyIndex; + + CDCurrencyTableTable* currencyTable = CDClientManager::Instance().GetTable(); + std::vector currencyValues = currencyTable->Query([=](CDCurrencyTable entry) { return (entry.currencyIndex == currencyIndex && entry.npcminlevel == npcMinLevel); }); + + if (currencyValues.size() > 0) { + // Set the coins + comp->SetMinCoins(currencyValues[0].minvalue); + comp->SetMaxCoins(currencyValues[0].maxvalue); + } + + // extraInfo overrides + comp->SetIsSmashable(GetVarAs(u"is_smashable") != 0); + } + } else { + comp->SetHealth(1); + comp->SetArmor(0); + + comp->SetMaxHealth(1); + comp->SetMaxArmor(0); + + comp->SetIsSmashable(true); + comp->AddFaction(-1); + comp->AddFaction(6); //Smashables + + // A race car has 60 imagination, other entities defaults to 0. + comp->SetImagination(HasComponent(eReplicaComponentType::RACING_STATS) ? 60 : 0); + comp->SetMaxImagination(HasComponent(eReplicaComponentType::RACING_STATS) ? 60 : 0); + } + } + + if (destCompData.size() > 0) { + comp->AddFaction(destCompData[0].faction); + std::stringstream ss(destCompData[0].factionList); + std::string token; + + while (std::getline(ss, token, ',')) { + if (std::stoi(token) == destCompData[0].faction) continue; + + if (token != "") { + comp->AddFaction(std::stoi(token)); + } + } + } + + m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, comp)); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CHARACTER) > 0 || m_Character) { + // Character Component always has a possessor, level, and forced movement components + m_Components.insert(std::make_pair(eReplicaComponentType::POSSESSOR, new PossessorComponent(this))); + + // load in the xml for the level + auto* levelComp = new LevelProgressionComponent(this); + levelComp->LoadFromXml(m_Character->GetXMLDoc()); + m_Components.insert(std::make_pair(eReplicaComponentType::LEVEL_PROGRESSION, levelComp)); + + m_Components.insert(std::make_pair(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, new PlayerForcedMovementComponent(this))); + + CharacterComponent* charComp = new CharacterComponent(this, m_Character); + charComp->LoadFromXml(m_Character->GetXMLDoc()); + m_Components.insert(std::make_pair(eReplicaComponentType::CHARACTER, charComp)); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) { + InventoryComponent* comp = nullptr; + if (m_Character) comp = new InventoryComponent(this, m_Character->GetXMLDoc()); + else comp = new InventoryComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::INVENTORY, comp)); + } + // if this component exists, then we initialize it. it's value is always 0 + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ROCKET_LAUNCH_LUP, -1) != -1) { + auto comp = new RocketLaunchLupComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::ROCKET_LAUNCH_LUP, comp)); + } + + /** + * This is a bit of a mess + */ + + CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable(); + int32_t scriptComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SCRIPT, -1); + + std::string scriptName = ""; + bool client = false; + if (scriptComponentID > 0 || m_Character) { + std::string clientScriptName; + if (!m_Character) { + CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID); + scriptName = scriptCompData.script_name; + clientScriptName = scriptCompData.client_script_name; + } else { + scriptName = ""; + } + + if (scriptName != "" || (scriptName == "" && m_Character)) { + + } else if (clientScriptName != "") { + client = true; + } else if (!m_Character) { + client = true; + } + } + + std::string customScriptServer; + bool hasCustomServerScript = false; + + const auto customScriptServerName = GetVarAsString(u"custom_script_server"); + const auto customScriptClientName = GetVarAsString(u"custom_script_client"); + + if (!customScriptServerName.empty()) { + customScriptServer = customScriptServerName; + hasCustomServerScript = true; + } + + if (!customScriptClientName.empty()) { + client = true; + } + + if (hasCustomServerScript && scriptName.empty()) { + scriptName = customScriptServer; + } + + if (!scriptName.empty() || client || m_Character || scriptComponentID >= 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPT, new ScriptComponent(this, scriptName, true, client && scriptName.empty()))); + } + + // ZoneControl script + if (m_TemplateID == 2365) { + CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable(); + const auto zoneID = dZoneManager::Instance()->GetZoneID(); + const CDZoneTable* zoneData = zoneTable->Query(zoneID.GetMapID()); + + if (zoneData != nullptr) { + int zoneScriptID = zoneData->scriptID; + CDScriptComponent zoneScriptData = scriptCompTable->GetByID(zoneScriptID); + + ScriptComponent* comp = new ScriptComponent(this, zoneScriptData.script_name, true); + m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPT, comp)); + } + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SKILL, -1) != -1 || m_Character) { + SkillComponent* comp = new SkillComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::SKILL, comp)); + } + + const auto combatAiId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BASE_COMBAT_AI); + if (combatAiId > 0) { + BaseCombatAIComponent* comp = new BaseCombatAIComponent(this, combatAiId); + m_Components.insert(std::make_pair(eReplicaComponentType::BASE_COMBAT_AI, comp)); + } + + if (int componentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD) > 0) { + RebuildComponent* comp = new RebuildComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::QUICK_BUILD, comp)); + + CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable(); + std::vector rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == rebuildComponentID); }); + + if (rebCompData.size() > 0) { + comp->SetResetTime(rebCompData[0].reset_time); + comp->SetCompleteTime(rebCompData[0].complete_time); + comp->SetTakeImagination(rebCompData[0].take_imagination); + comp->SetInterruptible(rebCompData[0].interruptible); + comp->SetSelfActivator(rebCompData[0].self_activator); + comp->SetActivityId(rebCompData[0].activityID); + comp->SetPostImaginationCost(rebCompData[0].post_imagination_cost); + comp->SetTimeBeforeSmash(rebCompData[0].time_before_smash); + + const auto rebuildResetTime = GetVar(u"rebuild_reset_time"); + + if (rebuildResetTime != 0.0f) { + comp->SetResetTime(rebuildResetTime); + + if (m_TemplateID == 9483) // Look away! + { + comp->SetResetTime(comp->GetResetTime() + 25); + } + } + + const auto activityID = GetVar(u"activityID"); + + if (activityID > 0) { + comp->SetActivityId(activityID); + } + + const auto compTime = GetVar(u"compTime"); + + if (compTime > 0) { + comp->SetCompleteTime(compTime); + } + } + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SWITCH, -1) != -1) { + SwitchComponent* comp = new SwitchComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::SWITCH, comp)); + } + + if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::VENDOR) > 0)) { + VendorComponent* comp = new VendorComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::VENDOR, comp)); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_VENDOR, -1) != -1) { + auto* component = new PropertyVendorComponent(this); + m_Components.insert_or_assign(eReplicaComponentType::PROPERTY_VENDOR, component); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY_MANAGEMENT, -1) != -1) { + auto* component = new PropertyManagementComponent(this); + m_Components.insert_or_assign(eReplicaComponentType::PROPERTY_MANAGEMENT, component); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BOUNCER, -1) != -1) { // you have to determine it like this because all bouncers have a componentID of 0 + BouncerComponent* comp = new BouncerComponent(this); + m_Components.insert(std::make_pair(eReplicaComponentType::BOUNCER, comp)); + } + + int32_t renderComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RENDER); + if ((renderComponentId > 0 && m_TemplateID != 2365) || m_Character) { + RenderComponent* render = new RenderComponent(this, renderComponentId); + m_Components.insert(std::make_pair(eReplicaComponentType::RENDER, render)); + } + + if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MISSION_OFFER) > 0) || m_Character) { + m_Components.insert(std::make_pair(eReplicaComponentType::MISSION_OFFER, new MissionOfferComponent(this, m_TemplateID))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUILD_BORDER, -1) != -1) { + m_Components.insert(std::make_pair(eReplicaComponentType::BUILD_BORDER, new BuildBorderComponent(this))); + } + + // Scripted activity component + int scriptedActivityID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SCRIPTED_ACTIVITY); + if ((scriptedActivityID > 0)) { + m_Components.insert(std::make_pair(eReplicaComponentType::SCRIPTED_ACTIVITY, new ScriptedActivityComponent(this, scriptedActivityID))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MODEL, -1) != -1 && !GetComponent()) { + m_Components.insert(std::make_pair(eReplicaComponentType::MODEL, new ModelComponent(this))); + if (m_Components.find(eReplicaComponentType::DESTROYABLE) == m_Components.end()) { + auto destroyableComponent = new DestroyableComponent(this); + destroyableComponent->SetHealth(1); + destroyableComponent->SetMaxHealth(1.0f); + destroyableComponent->SetFaction(-1, true); + destroyableComponent->SetIsSmashable(true); + m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, destroyableComponent)); + } + } + + PetComponent* petComponent; + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ITEM) > 0 && !TryGetComponent(eReplicaComponentType::PET, petComponent) && !HasComponent(eReplicaComponentType::MODEL)) { + m_Components.insert(std::make_pair(eReplicaComponentType::ITEM, nullptr)); + } + + // Shooting gallery component + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::SHOOTING_GALLERY, new ShootingGalleryComponent(this))); + } + + if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) { + m_Components.insert(std::make_pair(eReplicaComponentType::PROPERTY, new PropertyComponent(this))); + } + + const int rocketId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::ROCKET_LAUNCH); + if ((rocketId > 0)) { + m_Components.insert(std::make_pair(eReplicaComponentType::ROCKET_LAUNCH, new RocketLaunchpadControlComponent(this, rocketId))); + } + + const int32_t railComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RAIL_ACTIVATOR); + if (railComponentID > 0) { + m_Components.insert(std::make_pair(eReplicaComponentType::RAIL_ACTIVATOR, new RailActivatorComponent(this, railComponentID))); + } + + int movementAIID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVEMENT_AI); + if (movementAIID > 0) { + CDMovementAIComponentTable* moveAITable = CDClientManager::Instance().GetTable(); + std::vector moveAIComp = moveAITable->Query([=](CDMovementAIComponent entry) {return (entry.id == movementAIID); }); + + if (moveAIComp.size() > 0) { + MovementAIInfo moveInfo = MovementAIInfo(); + + moveInfo.movementType = moveAIComp[0].MovementType; + moveInfo.wanderChance = moveAIComp[0].WanderChance; + moveInfo.wanderRadius = moveAIComp[0].WanderRadius; + moveInfo.wanderSpeed = moveAIComp[0].WanderSpeed; + moveInfo.wanderDelayMax = moveAIComp[0].WanderDelayMax; + moveInfo.wanderDelayMin = moveAIComp[0].WanderDelayMin; + + bool useWanderDB = GetVar(u"usewanderdb"); + + if (!useWanderDB) { + const auto wanderOverride = GetVarAs(u"wanderRadius"); + + if (wanderOverride != 0.0f) { + moveInfo.wanderRadius = wanderOverride; + } + } + + m_Components.insert(std::make_pair(eReplicaComponentType::MOVEMENT_AI, new MovementAIComponent(this, moveInfo))); + } + } else if (petComponentId > 0 || combatAiId > 0 && GetComponent()->GetTetherSpeed() > 0) { + MovementAIInfo moveInfo = MovementAIInfo(); + moveInfo.movementType = ""; + moveInfo.wanderChance = 0; + moveInfo.wanderRadius = 16; + moveInfo.wanderSpeed = 2.5f; + moveInfo.wanderDelayMax = 5; + moveInfo.wanderDelayMin = 2; + + m_Components.insert(std::make_pair(eReplicaComponentType::MOVEMENT_AI, new MovementAIComponent(this, moveInfo))); + } + + std::string pathName = GetVarAsString(u"attached_path"); + const Path* path = dZoneManager::Instance()->GetZone()->GetPath(pathName); + + //Check to see if we have an attached path and add the appropiate component to handle it: + if (path){ + // if we have a moving platform path, then we need a moving platform component + if (path->pathType == PathType::MovingPlatform) { + MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); + m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); + // else if we are a movement path + } /*else if (path->pathType == PathType::Movement) { + auto movementAIcomp = GetComponent(); + if (movementAIcomp){ + // TODO: set path in existing movementAIComp + } else { + // TODO: create movementAIcomp and set path + } + }*/ + } else { + // else we still need to setup moving platform if it has a moving platform comp but no path + int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1); + if (movingPlatformComponentId >= 0) { + MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); + m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); + } + } + + int proximityMonitorID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROXIMITY_MONITOR); + if (proximityMonitorID > 0) { + CDProximityMonitorComponentTable* proxCompTable = CDClientManager::Instance().GetTable(); + std::vector proxCompData = proxCompTable->Query([=](CDProximityMonitorComponent entry) { return (entry.id == proximityMonitorID); }); + if (proxCompData.size() > 0) { + std::vector proximityStr = GeneralUtils::SplitString(proxCompData[0].Proximities, ','); + ProximityMonitorComponent* comp = new ProximityMonitorComponent(this, std::stoi(proximityStr[0]), std::stoi(proximityStr[1])); + m_Components.insert(std::make_pair(eReplicaComponentType::PROXIMITY_MONITOR, comp)); + } + } + + // Hacky way to trigger these when the object has had a chance to get constructed + AddCallbackTimer(0, [this]() { + for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { + script->OnStartup(this); + } + }); + + if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) { + // Don't ghost what is likely large scene elements + if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) { + goto no_ghosting; + } + + /* Filter for ghosting candidates. + * + * Don't ghost moving platforms, until we've got proper syncing for those. + * Don't ghost big phantom physics triggers, as putting those to sleep might prevent interactions. + * Don't ghost property related objects, as the client expects those to always be loaded. + */ + if ( + !EntityManager::IsExcludedFromGhosting(GetLOT()) && + !HasComponent(eReplicaComponentType::SCRIPTED_ACTIVITY) && + !HasComponent(eReplicaComponentType::MOVING_PLATFORM) && + !HasComponent(eReplicaComponentType::PHANTOM_PHYSICS) && + !HasComponent(eReplicaComponentType::PROPERTY) && + !HasComponent(eReplicaComponentType::RACING_CONTROL) && + !HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) + ) + //if (HasComponent(eReplicaComponentType::BASE_COMBAT_AI)) + { + m_IsGhostingCandidate = true; + } + + if (GetLOT() == 6368) { + m_IsGhostingCandidate = true; + } + + // Special case for collectibles in Ninjago + if (HasComponent(eReplicaComponentType::COLLECTIBLE) && Game::server->GetZoneID() == 2000) { + m_IsGhostingCandidate = true; + } + } + +no_ghosting: + + TriggerEvent(eTriggerEventType::CREATE, this); + + if (m_Character) { + auto* controllablePhysicsComponent = GetComponent(); + auto* levelComponent = GetComponent(); + + if (controllablePhysicsComponent && levelComponent) { + controllablePhysicsComponent->SetSpeedMultiplier(levelComponent->GetSpeedBase() / 500.0f); + } + } +} diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index 0fc859bd7..c4ccbcdb7 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -483,7 +483,7 @@ void EntityManager::UpdateGhosting(Player* player) { return; } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) { return; @@ -599,7 +599,7 @@ void EntityManager::ScheduleForKill(Entity* entity) { if (!entity) return; - SwitchComponent* switchComp = entity->GetComponent(); + auto switchComp = entity->GetComponent(); if (switchComp) { entity->TriggerEvent(eTriggerEventType::DEACTIVATED, entity); } diff --git a/dGame/Player.cpp b/dGame/Player.cpp index 2e194e6af..c8e35c58e 100644 --- a/dGame/Player.cpp +++ b/dGame/Player.cpp @@ -94,7 +94,7 @@ void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) { const auto sysAddr = entity->GetSystemAddress(); auto* character = entity->GetCharacter(); - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (character != nullptr && characterComponent != nullptr) { character->SetZoneID(zoneID); diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index 281c003d1..638e98f82 100644 --- a/dGame/TradingManager.cpp +++ b/dGame/TradingManager.cpp @@ -114,10 +114,10 @@ void Trade::Complete() { if (entityA == nullptr || entityB == nullptr) return; - auto* inventoryA = entityA->GetComponent(); - auto* inventoryB = entityB->GetComponent(); - auto* missionsA = entityA->GetComponent(); - auto* missionsB = entityB->GetComponent(); + auto inventoryA = entityA->GetComponent(); + auto inventoryB = entityB->GetComponent(); + auto missionsA = entityA->GetComponent(); + auto missionsB = entityB->GetComponent(); auto* characterA = entityA->GetCharacter(); auto* characterB = entityB->GetCharacter(); @@ -214,12 +214,12 @@ void Trade::SendUpdateToOther(LWOOBJID participant) { std::vector items{}; - auto* inventoryComponent = self->GetComponent(); + auto inventoryComponent = self->GetComponent(); if (inventoryComponent == nullptr) return; for (const auto tradeItem : itemIds) { - auto* item = inventoryComponent->FindItemById(tradeItem.itemId); + auto item = inventoryComponent->FindItemById(tradeItem.itemId); if (item == nullptr) return; diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index 0161395cf..1d58b7836 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -214,7 +214,7 @@ void UserManager::RequestCharacterList(const SystemAddress& sysAddr) { continue; } - auto* skillComponent = chars[i]->GetEntity()->GetComponent(); + auto skillComponent = chars[i]->GetEntity()->GetComponent(); if (skillComponent != nullptr) { skillComponent->Reset(); diff --git a/dGame/dBehaviors/ApplyBuffBehavior.cpp b/dGame/dBehaviors/ApplyBuffBehavior.cpp index 35b0f269d..e162b5e4f 100644 --- a/dGame/dBehaviors/ApplyBuffBehavior.cpp +++ b/dGame/dBehaviors/ApplyBuffBehavior.cpp @@ -4,13 +4,12 @@ #include "BehaviorBranchContext.h" #include "BuffComponent.h" - void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { auto* entity = EntityManager::Instance()->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target); if (entity == nullptr) return; - auto* buffComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); if (buffComponent == nullptr) return; @@ -23,7 +22,7 @@ void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext b if (entity == nullptr) return; - auto* buffComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); if (buffComponent == nullptr) return; diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.cpp b/dGame/dBehaviors/AreaOfEffectBehavior.cpp index dedede2ad..e2f1921d9 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.cpp +++ b/dGame/dBehaviors/AreaOfEffectBehavior.cpp @@ -87,7 +87,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream continue; } - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); if (destroyableComponent == nullptr) { continue; diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 08d468ef9..c0269e364 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -11,7 +11,7 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi if (context->unmanaged) { auto* entity = EntityManager::Instance()->GetEntity(branch.target); - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); if (destroyableComponent != nullptr) { PlayFx(u"onhit", entity->GetObjectID()); destroyableComponent->Damage(this->m_MaxDamage, context->originator, context->skillID); @@ -44,7 +44,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit return; } - auto* destroyableComponent = targetEntity->GetComponent(); + auto destroyableComponent = targetEntity->GetComponent(); if (!destroyableComponent) { Game::logger->Log("BasicAttackBehavior", "No destroyable found on the obj/lot %llu/%i", branch.target, targetEntity->GetLOT()); return; @@ -161,7 +161,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet return; } - auto* destroyableComponent = targetEntity->GetComponent(); + auto destroyableComponent = targetEntity->GetComponent(); if (!destroyableComponent || !destroyableComponent->GetOwningEntity()) { Game::logger->Log("BasicAttackBehavior", "No destroyable component on %llu", branch.target); return; diff --git a/dGame/dBehaviors/Behavior.cpp b/dGame/dBehaviors/Behavior.cpp index 8b34507a4..cd33da295 100644 --- a/dGame/dBehaviors/Behavior.cpp +++ b/dGame/dBehaviors/Behavior.cpp @@ -328,7 +328,7 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID return; } - auto* renderComponent = targetEntity->GetComponent(); + auto renderComponent = targetEntity->GetComponent(); const auto typeString = GeneralUtils::UTF16ToWTF8(type); diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index c7db42087..09920939f 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -35,7 +35,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const { return 0; } - auto* component = entity->GetComponent(); + auto component = entity->GetComponent(); if (component == nullptr) { Game::logger->Log("BehaviorContext", "No skill component attached to (%llu)!", this->originator);; @@ -331,8 +331,8 @@ std::vector BehaviorContext::GetValidTargets(int32_t ignoreFaction, in } if (ignoreFaction || includeFaction || (!entity->HasComponent(eReplicaComponentType::PHANTOM_PHYSICS) && targets.empty())) { - DestroyableComponent* destroyableComponent; - if (!entity->TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { + auto destroyableComponent = entity->GetComponent(); + if (!destroyableComponent) { return targets; } diff --git a/dGame/dBehaviors/BlockBehavior.cpp b/dGame/dBehaviors/BlockBehavior.cpp index cdbb3d807..bc8e3c3f6 100644 --- a/dGame/dBehaviors/BlockBehavior.cpp +++ b/dGame/dBehaviors/BlockBehavior.cpp @@ -18,7 +18,7 @@ void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea return; } - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); if (destroyableComponent == nullptr) { return; @@ -48,7 +48,7 @@ void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branc return; } - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); destroyableComponent->SetAttacksToBlock(this->m_numAttacksCanBlock); diff --git a/dGame/dBehaviors/BuffBehavior.cpp b/dGame/dBehaviors/BuffBehavior.cpp index a39fd1652..552ca1605 100644 --- a/dGame/dBehaviors/BuffBehavior.cpp +++ b/dGame/dBehaviors/BuffBehavior.cpp @@ -18,7 +18,7 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream return; } - auto* component = entity->GetComponent(); + auto component = entity->GetComponent(); if (component == nullptr) { Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target); @@ -52,7 +52,7 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch return; } - auto* component = entity->GetComponent(); + auto component = entity->GetComponent(); if (component == nullptr) { Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target); diff --git a/dGame/dBehaviors/CarBoostBehavior.cpp b/dGame/dBehaviors/CarBoostBehavior.cpp index 1ab0af95e..1ed647351 100644 --- a/dGame/dBehaviors/CarBoostBehavior.cpp +++ b/dGame/dBehaviors/CarBoostBehavior.cpp @@ -19,13 +19,13 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt Game::logger->Log("Car boost", "Activating car boost!"); - auto* possessableComponent = entity->GetComponent(); + auto possessableComponent = entity->GetComponent(); if (possessableComponent != nullptr) { auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); if (possessor != nullptr) { - auto* characterComponent = possessor->GetComponent(); + auto characterComponent = possessor->GetComponent(); if (characterComponent != nullptr) { Game::logger->Log("Car boost", "Tracking car boost!"); characterComponent->UpdatePlayerStatistic(RacingCarBoostsActivated); diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp index 48dbf7058..799641c41 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp @@ -16,7 +16,7 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea return; } - auto* destroyable = target->GetComponent(); + auto destroyable = target->GetComponent(); if (destroyable == nullptr) { return; diff --git a/dGame/dComponents/Component.cpp b/dGame/dComponents/Component.cpp index d04397f47..d46c57dcd 100644 --- a/dGame/dComponents/Component.cpp +++ b/dGame/dComponents/Component.cpp @@ -37,3 +37,7 @@ void Component::LoadConfigData() { void Component::LoadTemplateData() { } + +void Component::Serialize(RakNet::BitStream* bitStream, bool isConstruction = false) { + +} diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index 25df2d878..c96908118 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -4,6 +4,10 @@ class Entity; +namespace RakNet { + class BitStream; +} + /** * Component base class, provides methods for game loop updates, usage events and loading and saving to XML. */ @@ -56,6 +60,11 @@ class Component { * Loads the data of this component from the cdclient database */ virtual void LoadTemplateData(); + + /** + * Serializes the component for delivery to the client(s) + */ + virtual void Serialize(RakNet::BitStream* bitStream, bool isConstruction = false); protected: /** diff --git a/dNet/ClientPackets.cpp b/dNet/ClientPackets.cpp index 1c22bdcda..3400aa11b 100644 --- a/dNet/ClientPackets.cpp +++ b/dNet/ClientPackets.cpp @@ -85,7 +85,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac Entity* entity = EntityManager::Instance()->GetEntity(user->GetLastUsedChar()->GetObjectID()); if (!entity) return; - ControllablePhysicsComponent* comp = static_cast(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); + auto comp = entity->GetComponent(); if (!comp) return; /* @@ -100,7 +100,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac } */ - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); NiPoint3 position; inStream.Read(position.x); @@ -142,13 +142,13 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); if (possassableEntity != nullptr) { - auto* possessableComponent = possassableEntity->GetComponent(); + auto possessableComponent = possassableEntity->GetComponent(); if (possessableComponent) { // While possessing something, only update char if we are attached to the thing we are possessing if (possessableComponent->GetPossessionType() != ePossessionType::ATTACHED_VISIBLE) updateChar = false; } - auto* vehiclePhysicsComponent = possassableEntity->GetComponent(); + auto vehiclePhysicsComponent = possassableEntity->GetComponent(); if (vehiclePhysicsComponent != nullptr) { // This is flipped for whatever reason rotation = NiQuaternion(rotation.z, rotation.y, rotation.x, rotation.w); @@ -163,7 +163,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac vehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag); } else { // Need to get the mount's controllable physics - auto* controllablePhysicsComponent = possassableEntity->GetComponent(); + auto controllablePhysicsComponent = possassableEntity->GetComponent(); if (!controllablePhysicsComponent) return; controllablePhysicsComponent->SetPosition(position); controllablePhysicsComponent->SetRotation(rotation); @@ -186,7 +186,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac // Handle statistics - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackPositionUpdate(position); } diff --git a/dScripts/NtFactionSpyServer.cpp b/dScripts/NtFactionSpyServer.cpp index a11618802..5c3d689bd 100644 --- a/dScripts/NtFactionSpyServer.cpp +++ b/dScripts/NtFactionSpyServer.cpp @@ -13,13 +13,7 @@ void NtFactionSpyServer::OnStartup(Entity* self) { SetVariables(self); // Set the proximity to sense later - auto* proximityMonitor = self->GetComponent(); - if (proximityMonitor == nullptr) { - proximityMonitor = new ProximityMonitorComponent(self, -1, -1); - self->AddComponent(eReplicaComponentType::PROXIMITY_MONITOR, proximityMonitor); - } - - proximityMonitor->SetProximityRadius(self->GetVar(m_SpyProximityVariable), m_ProximityName); + self->SetProximityRadius(self->GetVar(m_SpyProximityVariable), m_ProximityName); } void NtFactionSpyServer::SetVariables(Entity* self) { diff --git a/dScripts/ai/AG/AgStromlingProperty.cpp b/dScripts/ai/AG/AgStromlingProperty.cpp index 9a9ae33b7..83f5ab7a7 100644 --- a/dScripts/ai/AG/AgStromlingProperty.cpp +++ b/dScripts/ai/AG/AgStromlingProperty.cpp @@ -12,6 +12,5 @@ void AgStromlingProperty::OnStartup(Entity* self) { 4 }; - auto* movementAIComponent = new MovementAIComponent(self, movementInfo); - self->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAIComponent); + self->AddComponent(movementInfo); } From 9e9e4dc0875949b460ea6af3331941962ea6276d Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Wed, 7 Jun 2023 00:23:50 -0700 Subject: [PATCH 007/111] Move to shared pointer --- dGame/Entity.cpp | 6 +- dGame/Entity.h | 22 ++- dGame/EntityInitializeOld.cc | 4 +- dGame/dBehaviors/DamageAbsorptionBehavior.cpp | 2 +- dGame/dBehaviors/DamageReductionBehavior.cpp | 4 +- dGame/dBehaviors/DarkInspirationBehavior.cpp | 4 +- dGame/dBehaviors/FallSpeedBehavior.cpp | 4 +- dGame/dBehaviors/ForceMovementBehavior.cpp | 4 +- dGame/dBehaviors/HealBehavior.cpp | 2 +- dGame/dBehaviors/ImaginationBehavior.cpp | 2 +- dGame/dBehaviors/ImmunityBehavior.cpp | 8 +- dGame/dBehaviors/InterruptBehavior.cpp | 4 +- dGame/dBehaviors/KnockbackBehavior.cpp | 2 +- dGame/dBehaviors/OverTimeBehavior.cpp | 2 +- dGame/dBehaviors/ProjectileAttackBehavior.cpp | 4 +- dGame/dBehaviors/PullToPointBehavior.cpp | 2 +- dGame/dBehaviors/RemoveBuffBehavior.cpp | 2 +- dGame/dBehaviors/RepairBehavior.cpp | 2 +- dGame/dBehaviors/SpawnBehavior.cpp | 6 +- dGame/dBehaviors/SpeedBehavior.cpp | 4 +- dGame/dBehaviors/StunBehavior.cpp | 8 +- dGame/dBehaviors/SwitchBehavior.cpp | 4 +- dGame/dBehaviors/TacArcBehavior.cpp | 4 +- dGame/dBehaviors/TauntBehavior.cpp | 4 +- dGame/dComponents/BaseCombatAIComponent.cpp | 19 ++- dGame/dComponents/BaseCombatAIComponent.h | 3 +- dGame/dComponents/BouncerComponent.cpp | 2 +- dGame/dComponents/BuffComponent.cpp | 16 +- dGame/dComponents/BuildBorderComponent.cpp | 4 +- dGame/dComponents/CharacterComponent.cpp | 2 +- dGame/dComponents/Component.cpp | 2 +- .../ControllablePhysicsComponent.cpp | 2 +- dGame/dComponents/DestroyableComponent.cpp | 52 +++--- dGame/dComponents/DestroyableComponent.h | 2 +- dGame/dComponents/InventoryComponent.cpp | 24 +-- .../dComponents/LevelProgressionComponent.cpp | 6 +- dGame/dComponents/MissionOfferComponent.cpp | 2 +- dGame/dComponents/MovementAIComponent.cpp | 14 +- dGame/dComponents/MovementAIComponent.h | 4 +- dGame/dComponents/PetComponent.cpp | 29 ++-- dGame/dComponents/PetComponent.h | 6 +- dGame/dComponents/PossessableComponent.cpp | 2 +- dGame/dComponents/PossessorComponent.cpp | 6 +- .../dComponents/PropertyEntranceComponent.cpp | 6 +- .../PropertyManagementComponent.cpp | 6 +- dGame/dComponents/RacingControlComponent.cpp | 31 ++-- dGame/dComponents/RailActivatorComponent.cpp | 4 +- dGame/dComponents/RebuildComponent.cpp | 16 +- dGame/dComponents/RenderComponent.cpp | 2 +- .../dComponents/RocketLaunchLupComponent.cpp | 4 +- .../RocketLaunchpadControlComponent.cpp | 8 +- .../dComponents/ScriptedActivityComponent.cpp | 8 +- dGame/dComponents/SkillComponent.cpp | 2 +- dGame/dComponents/SwitchComponent.h | 2 +- dGame/dComponents/TriggerComponent.cpp | 16 +- dGame/dGameMessages/GameMessageHandler.cpp | 23 +-- dGame/dGameMessages/GameMessages.cpp | 154 +++++++++--------- dGame/dInventory/Item.cpp | 8 +- dGame/dInventory/ItemSet.cpp | 4 +- dGame/dInventory/ItemSetPassiveAbility.cpp | 8 +- dGame/dMission/Mission.cpp | 16 +- dGame/dMission/MissionTask.cpp | 10 +- dGame/dPropertyBehaviors/ControlBehaviors.cpp | 12 +- dGame/dPropertyBehaviors/ControlBehaviors.h | 8 +- dGame/dUtilities/Loot.cpp | 8 +- dGame/dUtilities/Mail.cpp | 6 +- dGame/dUtilities/Preconditions.cpp | 8 +- dGame/dUtilities/SlashCommandHandler.cpp | 74 ++++----- dGame/dUtilities/VanityUtilities.cpp | 8 +- .../Enemy/AG/BossSpiderQueenEnemyServer.cpp | 22 +-- .../02_server/Enemy/AM/AmDarklingDragon.cpp | 12 +- .../02_server/Enemy/AM/AmSkeletonEngineer.cpp | 4 +- .../02_server/Enemy/FV/FvMaelstromDragon.cpp | 12 +- .../02_server/Enemy/General/BaseEnemyApe.cpp | 12 +- .../02_server/Enemy/General/BaseEnemyMech.cpp | 4 +- .../02_server/Enemy/General/EnemyNjBuff.cpp | 2 +- .../General/TreasureChestDragonServer.cpp | 2 +- .../Enemy/Survival/AgSurvivalMech.cpp | 2 +- .../Enemy/Survival/AgSurvivalSpiderling.cpp | 2 +- .../02_server/Enemy/Waves/WaveBossApe.cpp | 4 +- .../Enemy/Waves/WaveBossHammerling.cpp | 4 +- .../Enemy/Waves/WaveBossHorsemen.cpp | 4 +- .../Enemy/Waves/WaveBossSpiderling.cpp | 4 +- .../02_server/Equipment/BootyDigServer.cpp | 4 +- dScripts/02_server/Map/AG/AgBugsprayer.cpp | 2 +- .../02_server/Map/AG/AgCagedBricksServer.cpp | 2 +- .../02_server/Map/AG/AgLaserSensorServer.cpp | 4 +- .../02_server/Map/AG/NpcAgCourseStarter.cpp | 8 +- dScripts/02_server/Map/AG/NpcCowboyServer.cpp | 2 +- .../02_server/Map/AG/NpcNjAssistantServer.cpp | 4 +- dScripts/02_server/Map/AG/NpcPirateServer.cpp | 2 +- dScripts/02_server/Map/AG/NpcWispServer.cpp | 2 +- .../02_server/Map/AG/RemoveRentalGear.cpp | 2 +- .../Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp | 2 +- dScripts/02_server/Map/AM/AmBlueX.cpp | 4 +- dScripts/02_server/Map/AM/AmDrawBridge.cpp | 4 +- .../02_server/Map/AM/AmDropshipComputer.cpp | 8 +- .../02_server/Map/AM/AmScrollReaderServer.cpp | 2 +- .../02_server/Map/AM/AmShieldGenerator.cpp | 8 +- .../Map/AM/AmShieldGeneratorQuickbuild.cpp | 12 +- dScripts/02_server/Map/AM/AmSkullkinDrill.cpp | 12 +- dScripts/02_server/Map/AM/AmSkullkinTower.cpp | 6 +- dScripts/02_server/Map/AM/AmTeapotServer.cpp | 2 +- .../Map/AM/AmTemplateSkillVolume.cpp | 2 +- .../02_server/Map/FV/EnemyRoninSpawner.cpp | 6 +- dScripts/02_server/Map/FV/FvCandle.cpp | 8 +- .../02_server/Map/FV/FvHorsemenTrigger.cpp | 2 +- .../02_server/Map/FV/ImgBrickConsoleQB.cpp | 14 +- .../Map/FV/Racing/RaceMaelstromGeiser.cpp | 6 +- .../02_server/Map/GF/GfCaptainsCannon.cpp | 2 +- dScripts/02_server/Map/GF/GfTikiTorch.cpp | 6 +- dScripts/02_server/Map/GF/MastTeleport.cpp | 4 +- .../02_server/Map/General/ExplodingAsset.cpp | 8 +- .../Map/General/ForceVolumeServer.cpp | 2 +- .../02_server/Map/General/GrowingFlower.cpp | 2 +- .../General/ImaginationBackpackHealServer.cpp | 2 +- .../Ninjago/NjRailActivatorsServer.cpp | 2 +- .../Map/General/Ninjago/NjRailPostServer.cpp | 2 +- .../02_server/Map/General/PetDigServer.cpp | 6 +- .../02_server/Map/General/PropertyDevice.cpp | 2 +- .../Map/General/PropertyPlatform.cpp | 6 +- .../02_server/Map/General/QbEnemyStunner.cpp | 4 +- dScripts/02_server/Map/General/QbSpawner.cpp | 4 +- .../Map/General/TokenConsoleServer.cpp | 2 +- .../Map/General/TouchMissionUpdateServer.cpp | 2 +- .../Map/General/WishingWellServer.cpp | 2 +- .../02_server/Map/NS/NsTokenConsoleServer.cpp | 6 +- .../02_server/Map/NT/NtAssemblyTubeServer.cpp | 2 +- .../Map/NT/NtCombatChallengeServer.cpp | 4 +- .../Map/NT/NtDarkitectRevealServer.cpp | 2 +- .../02_server/Map/NT/NtDirtCloudServer.cpp | 2 +- dScripts/02_server/Map/NT/NtDukeServer.cpp | 4 +- .../02_server/Map/NT/NtImagBeamBuffer.cpp | 2 +- .../02_server/Map/NT/NtParadoxPanelServer.cpp | 2 +- .../02_server/Map/NT/NtParadoxTeleServer.cpp | 2 +- .../Map/NT/NtSentinelWalkwayServer.cpp | 4 +- dScripts/02_server/Map/NT/NtSleepingGuard.cpp | 2 +- dScripts/02_server/Map/NT/NtVandaServer.cpp | 2 +- .../Map/NT/NtVentureSpeedPadServer.cpp | 4 +- dScripts/02_server/Map/NT/NtXRayServer.cpp | 2 +- .../02_server/Map/PR/SpawnGryphonServer.cpp | 4 +- .../Property/AG_Small/EnemySpiderSpawner.cpp | 4 +- .../Map/Property/AG_Small/ZoneAgProperty.cpp | 14 +- .../02_server/Map/SS/SsModularBuildServer.cpp | 2 +- .../02_server/Map/VE/VeBricksampleServer.cpp | 4 +- .../02_server/Map/VE/VeMissionConsole.cpp | 2 +- dScripts/02_server/Map/njhub/BurningTile.cpp | 2 +- .../02_server/Map/njhub/CavePrisonCage.cpp | 2 +- .../Map/njhub/EnemySkeletonSpawner.cpp | 8 +- dScripts/02_server/Map/njhub/FallingTile.cpp | 4 +- .../02_server/Map/njhub/FlameJetServer.cpp | 2 +- .../Map/njhub/ImaginationShrineServer.cpp | 2 +- dScripts/02_server/Map/njhub/Lieutenant.cpp | 2 +- dScripts/02_server/Map/njhub/NjColeNPC.cpp | 8 +- .../Map/njhub/NjDragonEmblemChestServer.cpp | 2 +- .../02_server/Map/njhub/NjEarthPetServer.cpp | 2 +- .../Map/njhub/NjScrollChestServer.cpp | 2 +- dScripts/02_server/Map/njhub/NjWuNPC.cpp | 2 +- dScripts/02_server/Map/njhub/RainOfArrows.cpp | 2 +- .../boss_instance/NjMonastryBossInstance.cpp | 22 +-- .../General/MinigameTreasureChestServer.cpp | 4 +- dScripts/02_server/Pets/DamagingPets.cpp | 24 +-- dScripts/02_server/Pets/PetFromDigServer.cpp | 6 +- .../02_server/Pets/PetFromObjectServer.cpp | 2 +- dScripts/ActivityManager.cpp | 18 +- dScripts/BasePropertyServer.cpp | 14 +- dScripts/BaseSurvivalServer.cpp | 4 +- dScripts/BaseWavesServer.cpp | 8 +- dScripts/CppScripts.cpp | 4 +- dScripts/Darkitect.cpp | 4 +- .../EquipmentScripts/BuccaneerValiantShip.cpp | 2 +- .../EquipmentScripts/PersonalFortress.cpp | 10 +- dScripts/EquipmentScripts/StunImmunity.cpp | 4 +- .../EquipmentTriggers/CoilBackpackBase.cpp | 2 +- dScripts/NPCAddRemoveItem.cpp | 2 +- dScripts/NtFactionSpyServer.cpp | 4 +- dScripts/ScriptedPowerupSpawner.cpp | 2 +- dScripts/SpawnPetBaseServer.cpp | 2 +- dScripts/ai/ACT/ActMine.cpp | 6 +- dScripts/ai/ACT/ActVehicleDeathTrigger.cpp | 6 +- dScripts/ai/AG/AgBusDoor.cpp | 2 +- dScripts/ai/AG/AgDarkSpiderling.cpp | 2 +- dScripts/ai/AG/AgFans.cpp | 8 +- dScripts/ai/AG/AgImagSmashable.cpp | 2 +- dScripts/ai/AG/AgJetEffectServer.cpp | 2 +- dScripts/ai/AG/AgStagePlatforms.cpp | 4 +- dScripts/ai/FV/ActParadoxPipeFix.cpp | 4 +- dScripts/ai/FV/FvBrickPuzzleServer.cpp | 2 +- dScripts/ai/FV/FvFlyingCreviceDragon.cpp | 4 +- dScripts/ai/FV/FvFreeGfNinjas.cpp | 4 +- dScripts/ai/FV/FvMaelstromGeyser.cpp | 2 +- dScripts/ai/FV/FvPandaServer.cpp | 4 +- dScripts/ai/FV/FvPandaSpawnerServer.cpp | 2 +- dScripts/ai/FV/TriggerGas.cpp | 2 +- dScripts/ai/GENERAL/LegoDieRoll.cpp | 2 +- dScripts/ai/GF/GfArchway.cpp | 2 +- dScripts/ai/GF/GfBanana.cpp | 4 +- dScripts/ai/GF/GfCampfire.cpp | 12 +- dScripts/ai/GF/GfJailkeepMission.cpp | 4 +- dScripts/ai/GF/GfMaelstromGeyser.cpp | 2 +- dScripts/ai/GF/GfParrotCrash.cpp | 2 +- dScripts/ai/GF/PetDigBuild.cpp | 2 +- .../ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp | 22 ++- dScripts/ai/NP/NpcNpSpacemanBob.cpp | 4 +- dScripts/ai/NS/NsConcertInstrument.cpp | 20 +-- dScripts/ai/NS/NsConcertQuickBuild.cpp | 6 +- dScripts/ai/NS/NsGetFactionMissionServer.cpp | 2 +- dScripts/ai/NS/NsJohnnyMissionServer.cpp | 2 +- dScripts/ai/NS/NsModularBuild.cpp | 2 +- dScripts/ai/NS/WhFans.cpp | 2 +- dScripts/ai/PROPERTY/AG/AgPropGuard.cpp | 4 +- dScripts/ai/PROPERTY/PropertyFXDamage.cpp | 4 +- .../OBJECTS/FvRaceSmashEggImagineServer.cpp | 8 +- .../RACING/OBJECTS/RaceImagineCrateServer.cpp | 10 +- .../ai/RACING/OBJECTS/RaceImaginePowerup.cpp | 6 +- .../ai/RACING/OBJECTS/RaceSmashServer.cpp | 6 +- dScripts/client/ai/PR/CrabServer.cpp | 6 +- dWorldServer/WorldServer.cpp | 10 +- .../DestroyableComponentTests.cpp | 6 +- 219 files changed, 743 insertions(+), 748 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 3377e8cd0..4d4a5af93 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -136,7 +136,7 @@ void Entity::Initialize() { for (const auto& [componentTemplate, componentId] : components) { switch (componentTemplate) { case eReplicaComponentType::CONTROLLABLE_PHYSICS: - AddComponent(this); + AddComponent(); break; case eReplicaComponentType::RENDER: break; @@ -432,12 +432,12 @@ void Entity::Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationNa } void Entity::SetProximityRadius(float proxRadius, std::string name) { - auto proximityMonitorComponent = AddComponent(this); + auto proximityMonitorComponent = AddComponent(); if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(proxRadius, name); } void Entity::SetProximityRadius(dpEntity* entity, std::string name) { - auto proximityMonitorComponent = AddComponent(this); + auto proximityMonitorComponent = AddComponent(); if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(entity, name); } diff --git a/dGame/Entity.h b/dGame/Entity.h index 9f3198a62..8137e2b2c 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __ENTITY__H__ +#define __ENTITY__H__ #include #include @@ -146,8 +147,8 @@ class Entity { bool HasComponent(eReplicaComponentType componentId) const; - template - std::shared_ptr AddComponent(ConstructorValues... arguments); + template + std::shared_ptr AddComponent(ConstructorValues... arguments); std::vector> GetScriptComponents(); @@ -290,6 +291,8 @@ class Entity { Entity* GetScheduledKiller() { return m_ScheduleKiller; } + std::unordered_map& GetComponents() { return m_Components; } + protected: LWOOBJID m_ObjectID; @@ -481,9 +484,14 @@ T Entity::GetNetworkVar(const std::u16string& name) { return LDFData::Default; } -template -std::shared_ptr Entity::AddComponent(ConstructorValues...arguments) { - if (GetComponent()) return nullptr; +template +std::shared_ptr Entity::AddComponent(ConstructorValues...arguments) { + auto component = GetComponent(); + if (component) return component; - m_Components.insert_or_assign(ComponentType::ComponentType, std::make_shared(arguments...)); + auto insertedComponent = m_Components.insert_or_assign(Cmpt::ComponentType, + std::make_shared(this, std::forward(arguments)...)).first->second; + return std::dynamic_pointer_cast(insertedComponent); } + +#endif //!__ENTITY__H__ diff --git a/dGame/EntityInitializeOld.cc b/dGame/EntityInitializeOld.cc index 321b220c2..edb5ba2e2 100644 --- a/dGame/EntityInitializeOld.cc +++ b/dGame/EntityInitializeOld.cc @@ -630,8 +630,8 @@ Entity::Initialize() { TriggerEvent(eTriggerEventType::CREATE, this); if (m_Character) { - auto* controllablePhysicsComponent = GetComponent(); - auto* levelComponent = GetComponent(); + auto controllablePhysicsComponent = GetComponent(); + auto levelComponent = GetComponent(); if (controllablePhysicsComponent && levelComponent) { controllablePhysicsComponent->SetSpeedMultiplier(levelComponent->GetSpeedBase() / 500.0f); diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp index 799641c41..84f597f14 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp @@ -42,7 +42,7 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon return; } - auto* destroyable = target->GetComponent(); + auto destroyable = target->GetComponent(); if (destroyable == nullptr) { return; diff --git a/dGame/dBehaviors/DamageReductionBehavior.cpp b/dGame/dBehaviors/DamageReductionBehavior.cpp index 2b18b7c2d..e28839d58 100644 --- a/dGame/dBehaviors/DamageReductionBehavior.cpp +++ b/dGame/dBehaviors/DamageReductionBehavior.cpp @@ -16,7 +16,7 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream return; } - auto* destroyable = target->GetComponent(); + auto destroyable = target->GetComponent(); if (destroyable == nullptr) { return; @@ -40,7 +40,7 @@ void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchCont return; } - auto* destroyable = target->GetComponent(); + auto destroyable = target->GetComponent(); if (destroyable == nullptr) { return; diff --git a/dGame/dBehaviors/DarkInspirationBehavior.cpp b/dGame/dBehaviors/DarkInspirationBehavior.cpp index ea80cbbac..45d501b1d 100644 --- a/dGame/dBehaviors/DarkInspirationBehavior.cpp +++ b/dGame/dBehaviors/DarkInspirationBehavior.cpp @@ -14,7 +14,7 @@ void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream return; } - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent == nullptr) { return; @@ -34,7 +34,7 @@ void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStr return; } - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent == nullptr) { return; diff --git a/dGame/dBehaviors/FallSpeedBehavior.cpp b/dGame/dBehaviors/FallSpeedBehavior.cpp index 158c87f6d..5b8a50cdd 100644 --- a/dGame/dBehaviors/FallSpeedBehavior.cpp +++ b/dGame/dBehaviors/FallSpeedBehavior.cpp @@ -11,7 +11,7 @@ void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS auto* target = EntityManager::Instance()->GetEntity(branch.target); if (!target) return; - auto* controllablePhysicsComponent = target->GetComponent(); + auto controllablePhysicsComponent = target->GetComponent(); if (!controllablePhysicsComponent) return; controllablePhysicsComponent->SetGravityScale(m_PercentSlowed); EntityManager::Instance()->SerializeEntity(target); @@ -39,7 +39,7 @@ void FallSpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext bran auto* target = EntityManager::Instance()->GetEntity(branch.target); if (!target) return; - auto* controllablePhysicsComponent = target->GetComponent(); + auto controllablePhysicsComponent = target->GetComponent(); if (!controllablePhysicsComponent) return; controllablePhysicsComponent->SetGravityScale(1); EntityManager::Instance()->SerializeEntity(target); diff --git a/dGame/dBehaviors/ForceMovementBehavior.cpp b/dGame/dBehaviors/ForceMovementBehavior.cpp index 52359cf7a..5c0cafba0 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.cpp +++ b/dGame/dBehaviors/ForceMovementBehavior.cpp @@ -44,7 +44,7 @@ void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStrea auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster); if (casterEntity != nullptr) { - auto* controllablePhysicsComponent = casterEntity->GetComponent(); + auto controllablePhysicsComponent = casterEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { if (m_Forward == 1) { @@ -74,7 +74,7 @@ void ForceMovementBehavior::Load() { void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster); if (casterEntity != nullptr) { - auto* controllablePhysicsComponent = casterEntity->GetComponent(); + auto controllablePhysicsComponent = casterEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetPosition(controllablePhysicsComponent->GetPosition() + controllablePhysicsComponent->GetVelocity() * m_Duration); diff --git a/dGame/dBehaviors/HealBehavior.cpp b/dGame/dBehaviors/HealBehavior.cpp index 66fe2c791..4c4c2bf78 100644 --- a/dGame/dBehaviors/HealBehavior.cpp +++ b/dGame/dBehaviors/HealBehavior.cpp @@ -16,7 +16,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea return; } - auto* destroyable = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto destroyable = entity->GetComponent(); if (destroyable == nullptr) { Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target); diff --git a/dGame/dBehaviors/ImaginationBehavior.cpp b/dGame/dBehaviors/ImaginationBehavior.cpp index 59b192b0e..f46d7ad61 100644 --- a/dGame/dBehaviors/ImaginationBehavior.cpp +++ b/dGame/dBehaviors/ImaginationBehavior.cpp @@ -13,7 +13,7 @@ void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi return; } - auto* destroyable = entity->GetComponent(); + auto destroyable = entity->GetComponent(); if (destroyable == nullptr) { return; diff --git a/dGame/dBehaviors/ImmunityBehavior.cpp b/dGame/dBehaviors/ImmunityBehavior.cpp index a5dd4c857..9082bb807 100644 --- a/dGame/dBehaviors/ImmunityBehavior.cpp +++ b/dGame/dBehaviors/ImmunityBehavior.cpp @@ -17,7 +17,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt return; } - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent) { destroyableComponent->SetStatusImmunity( eStateChangeType::PUSH, @@ -33,7 +33,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt ); } - auto* controllablePhysicsComponent = target->GetComponent(); + auto controllablePhysicsComponent = target->GetComponent(); if (controllablePhysicsComponent) { controllablePhysicsComponent->SetStunImmunity( eStateChangeType::PUSH, @@ -63,7 +63,7 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra return; } - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent) { destroyableComponent->SetStatusImmunity( eStateChangeType::POP, @@ -79,7 +79,7 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra ); } - auto* controllablePhysicsComponent = target->GetComponent(); + auto controllablePhysicsComponent = target->GetComponent(); if (controllablePhysicsComponent) { controllablePhysicsComponent->SetStunImmunity( eStateChangeType::POP, diff --git a/dGame/dBehaviors/InterruptBehavior.cpp b/dGame/dBehaviors/InterruptBehavior.cpp index 9035c092f..ab711b10d 100644 --- a/dGame/dBehaviors/InterruptBehavior.cpp +++ b/dGame/dBehaviors/InterruptBehavior.cpp @@ -46,7 +46,7 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS if (target == nullptr) return; - auto* skillComponent = target->GetComponent(); + auto skillComponent = target->GetComponent(); if (skillComponent == nullptr) return; @@ -71,7 +71,7 @@ void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b if (target == nullptr) return; - auto* skillComponent = target->GetComponent(); + auto skillComponent = target->GetComponent(); if (skillComponent == nullptr) return; diff --git a/dGame/dBehaviors/KnockbackBehavior.cpp b/dGame/dBehaviors/KnockbackBehavior.cpp index 1b878ed02..5c820e590 100644 --- a/dGame/dBehaviors/KnockbackBehavior.cpp +++ b/dGame/dBehaviors/KnockbackBehavior.cpp @@ -24,7 +24,7 @@ void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b auto* target = EntityManager::Instance()->GetEntity(branch.target); if (target != nullptr) { - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent != nullptr) { blocked = destroyableComponent->IsKnockbackImmune(); diff --git a/dGame/dBehaviors/OverTimeBehavior.cpp b/dGame/dBehaviors/OverTimeBehavior.cpp index 5afbbd269..df597c007 100644 --- a/dGame/dBehaviors/OverTimeBehavior.cpp +++ b/dGame/dBehaviors/OverTimeBehavior.cpp @@ -24,7 +24,7 @@ void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt if (entity == nullptr) return; - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); if (skillComponent == nullptr) return; diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index f65421cb7..6fc724e18 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -24,7 +24,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea return; } - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); if (skillComponent == nullptr) { Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator); @@ -69,7 +69,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt return; } - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); if (skillComponent == nullptr) { Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator); diff --git a/dGame/dBehaviors/PullToPointBehavior.cpp b/dGame/dBehaviors/PullToPointBehavior.cpp index 7427ccc42..e553d3a9a 100644 --- a/dGame/dBehaviors/PullToPointBehavior.cpp +++ b/dGame/dBehaviors/PullToPointBehavior.cpp @@ -14,7 +14,7 @@ void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi return; } - auto* movement = target->GetComponent(); + auto movement = target->GetComponent(); if (movement == nullptr) { return; diff --git a/dGame/dBehaviors/RemoveBuffBehavior.cpp b/dGame/dBehaviors/RemoveBuffBehavior.cpp index be3066ac0..fb9f49ec8 100644 --- a/dGame/dBehaviors/RemoveBuffBehavior.cpp +++ b/dGame/dBehaviors/RemoveBuffBehavior.cpp @@ -9,7 +9,7 @@ void RemoveBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit auto* entity = EntityManager::Instance()->GetEntity(context->caster); if (!entity) return; - auto* buffComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); if (!buffComponent) return; buffComponent->RemoveBuff(m_BuffId, false, m_RemoveImmunity); diff --git a/dGame/dBehaviors/RepairBehavior.cpp b/dGame/dBehaviors/RepairBehavior.cpp index ce2e5fd20..836923a43 100644 --- a/dGame/dBehaviors/RepairBehavior.cpp +++ b/dGame/dBehaviors/RepairBehavior.cpp @@ -16,7 +16,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str return; } - auto* destroyable = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto destroyable = entity->GetComponent(); if (destroyable == nullptr) { Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target); diff --git a/dGame/dBehaviors/SpawnBehavior.cpp b/dGame/dBehaviors/SpawnBehavior.cpp index 75c84f6c5..a79ad4c05 100644 --- a/dGame/dBehaviors/SpawnBehavior.cpp +++ b/dGame/dBehaviors/SpawnBehavior.cpp @@ -53,7 +53,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea entity->SetOwnerOverride(context->originator); // Unset the flag to reposition the player, this makes it harder to glitch out of the map - auto* rebuildComponent = entity->GetComponent(); + auto rebuildComponent = entity->GetComponent(); if (rebuildComponent != nullptr) { rebuildComponent->SetRepositionPlayer(false); @@ -87,9 +87,9 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext return; } - auto* destroyable = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto destroyable = entity->GetComponent(); - if (destroyable == nullptr) { + if (!destroyable) { entity->Smash(context->originator); return; diff --git a/dGame/dBehaviors/SpeedBehavior.cpp b/dGame/dBehaviors/SpeedBehavior.cpp index d326aa45e..b780d215f 100644 --- a/dGame/dBehaviors/SpeedBehavior.cpp +++ b/dGame/dBehaviors/SpeedBehavior.cpp @@ -12,7 +12,7 @@ void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea auto* target = EntityManager::Instance()->GetEntity(branch.target); if (!target) return; - auto* controllablePhysicsComponent = target->GetComponent(); + auto controllablePhysicsComponent = target->GetComponent(); if (!controllablePhysicsComponent) return; controllablePhysicsComponent->AddSpeedboost(m_RunSpeed); @@ -41,7 +41,7 @@ void SpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, auto* target = EntityManager::Instance()->GetEntity(branch.target); if (!target) return; - auto* controllablePhysicsComponent = target->GetComponent(); + auto controllablePhysicsComponent = target->GetComponent(); if (!controllablePhysicsComponent) return; controllablePhysicsComponent->RemoveSpeedboost(m_RunSpeed); diff --git a/dGame/dBehaviors/StunBehavior.cpp b/dGame/dBehaviors/StunBehavior.cpp index 4e34d3a23..9b91d61e4 100644 --- a/dGame/dBehaviors/StunBehavior.cpp +++ b/dGame/dBehaviors/StunBehavior.cpp @@ -33,7 +33,7 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream * If our target is an enemy we can go ahead and stun it. */ - auto* combatAiComponent = static_cast(target->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); + auto combatAiComponent = target->GetComponent(); if (combatAiComponent == nullptr) { return; @@ -56,7 +56,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr * See if we can stun ourselves */ - auto* combatAiComponent = static_cast(self->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); + auto combatAiComponent = self->GetComponent(); if (combatAiComponent == nullptr) { return; @@ -72,7 +72,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr auto* target = EntityManager::Instance()->GetEntity(branch.target); if (target != nullptr) { - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent != nullptr) { blocked = destroyableComponent->IsKnockbackImmune(); @@ -91,7 +91,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr * If our target is an enemy we can go ahead and stun it. */ - auto* combatAiComponent = static_cast(target->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); + auto combatAiComponent = target->GetComponent(); if (combatAiComponent == nullptr) { return; diff --git a/dGame/dBehaviors/SwitchBehavior.cpp b/dGame/dBehaviors/SwitchBehavior.cpp index bd2619066..5395e32f8 100644 --- a/dGame/dBehaviors/SwitchBehavior.cpp +++ b/dGame/dBehaviors/SwitchBehavior.cpp @@ -22,7 +22,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre return; } - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); if (destroyableComponent == nullptr) { return; @@ -46,7 +46,7 @@ void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS state = entity != nullptr; if (state && m_targetHasBuff != 0) { - auto* buffComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); if (buffComponent != nullptr && !buffComponent->HasBuff(m_targetHasBuff)) { state = false; diff --git a/dGame/dBehaviors/TacArcBehavior.cpp b/dGame/dBehaviors/TacArcBehavior.cpp index 91df3879c..4583bd299 100644 --- a/dGame/dBehaviors/TacArcBehavior.cpp +++ b/dGame/dBehaviors/TacArcBehavior.cpp @@ -82,7 +82,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS return; } - const auto* destroyableComponent = self->GetComponent(); + const auto destroyableComponent = self->GetComponent(); if ((this->m_usePickedTarget || context->clientInitalized) && branch.target > 0) { const auto* target = EntityManager::Instance()->GetEntity(branch.target); @@ -101,7 +101,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS return; } - auto* combatAi = self->GetComponent(); + auto combatAi = self->GetComponent(); const auto casterPosition = self->GetPosition(); diff --git a/dGame/dBehaviors/TauntBehavior.cpp b/dGame/dBehaviors/TauntBehavior.cpp index 7ed3b897d..878da4fd8 100644 --- a/dGame/dBehaviors/TauntBehavior.cpp +++ b/dGame/dBehaviors/TauntBehavior.cpp @@ -15,7 +15,7 @@ void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea return; } - auto* combatComponent = target->GetComponent(); + auto combatComponent = target->GetComponent(); if (combatComponent != nullptr) { combatComponent->Taunt(context->originator, m_threatToAdd); @@ -31,7 +31,7 @@ void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitSt return; } - auto* combatComponent = target->GetComponent(); + auto combatComponent = target->GetComponent(); if (combatComponent != nullptr) { combatComponent->Taunt(context->originator, m_threatToAdd); diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 4e6dc0928..f95cab1cd 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -189,10 +189,11 @@ void BaseCombatAIComponent::Update(const float deltaTime) { m_StartPosition = m_OwningEntity->GetPosition(); } - m_MovementAI = m_OwningEntity->GetComponent(); - if (m_MovementAI == nullptr) { - return; + m_MovementAI = m_OwningEntity->GetComponent(); + if (m_MovementAI == nullptr) { + return; + } } if (stunnedThisFrame) { @@ -243,7 +244,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { bool hadRemainingDowntime = m_SkillTime > 0.0f; if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime; - auto* rebuild = m_OwningEntity->GetComponent(); + auto rebuild = m_OwningEntity->GetComponent(); if (rebuild != nullptr) { const auto state = rebuild->GetState(); @@ -253,7 +254,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { } } - auto* skillComponent = m_OwningEntity->GetComponent(); + auto skillComponent = m_OwningEntity->GetComponent(); if (skillComponent == nullptr) { return; @@ -287,7 +288,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { } if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) { - auto* destroyableComponent = m_OwningEntity->GetComponent(); + auto destroyableComponent = m_OwningEntity->GetComponent(); if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) { auto serilizationRequired = false; @@ -547,13 +548,13 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { return false; } - auto* destroyable = entity->GetComponent(); + auto destroyable = entity->GetComponent(); if (destroyable == nullptr) { return false; } - auto* referenceDestroyable = m_OwningEntity->GetComponent(); + auto referenceDestroyable = m_OwningEntity->GetComponent(); if (referenceDestroyable == nullptr) { Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID()); @@ -561,7 +562,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { return false; } - auto* quickbuild = entity->GetComponent(); + auto quickbuild = entity->GetComponent(); if (quickbuild != nullptr) { const auto state = quickbuild->GetState(); diff --git a/dGame/dComponents/BaseCombatAIComponent.h b/dGame/dComponents/BaseCombatAIComponent.h index 8bf6140ab..37589d34a 100644 --- a/dGame/dComponents/BaseCombatAIComponent.h +++ b/dGame/dComponents/BaseCombatAIComponent.h @@ -10,6 +10,7 @@ #include "Component.h" #include "eReplicaComponentType.h" +#include #include #include @@ -319,7 +320,7 @@ class BaseCombatAIComponent : public Component { /** * The component that handles movement AI, also owned by this entity */ - MovementAIComponent* m_MovementAI; + std::shared_ptr m_MovementAI; /** * The position at which this entity spawned diff --git a/dGame/dComponents/BouncerComponent.cpp b/dGame/dComponents/BouncerComponent.cpp index e26e23a83..0013021f5 100644 --- a/dGame/dComponents/BouncerComponent.cpp +++ b/dGame/dComponents/BouncerComponent.cpp @@ -71,7 +71,7 @@ void BouncerComponent::LookupPetSwitch() { const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group); for (auto* entity : entities) { - auto* switchComponent = entity->GetComponent(); + auto switchComponent = entity->GetComponent(); if (switchComponent != nullptr) { switchComponent->SetPetBouncer(this); diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index 3a10c3c3c..5d4b3f911 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -149,7 +149,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { if (parameter.name == "max_health") { const auto maxHealth = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -157,7 +157,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { } else if (parameter.name == "max_armor") { const auto maxArmor = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -165,13 +165,13 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { } else if (parameter.name == "max_imagination") { const auto maxImagination = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination); } else if (parameter.name == "speed") { - auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); + auto controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); if (!controllablePhysicsComponent) return; const auto speed = parameter.value; controllablePhysicsComponent->AddSpeedboost(speed); @@ -185,7 +185,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { if (parameter.name == "max_health") { const auto maxHealth = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -193,7 +193,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { } else if (parameter.name == "max_armor") { const auto maxArmor = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -201,13 +201,13 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { } else if (parameter.name == "max_imagination") { const auto maxImagination = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto destroyable = this->GetOwningEntity()->GetComponent(); if (destroyable == nullptr) return; destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination); } else if (parameter.name == "speed") { - auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); + auto controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); if (!controllablePhysicsComponent) return; const auto speed = parameter.value; controllablePhysicsComponent->RemoveSpeedboost(speed); diff --git a/dGame/dComponents/BuildBorderComponent.cpp b/dGame/dComponents/BuildBorderComponent.cpp index 5b46d5731..c33ae8d5a 100644 --- a/dGame/dComponents/BuildBorderComponent.cpp +++ b/dGame/dComponents/BuildBorderComponent.cpp @@ -27,7 +27,7 @@ void BuildBorderComponent::OnUse(Entity* originator) { Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque"); } - auto* inventoryComponent = originator->GetComponent(); + auto inventoryComponent = originator->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -63,7 +63,7 @@ void BuildBorderComponent::OnUse(Entity* originator) { GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition()); } - InventoryComponent* inv = m_OwningEntity->GetComponent(); + auto inv = m_OwningEntity->GetComponent(); if (!inv) return; inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here } diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 7bd4cc192..7d757c624 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -367,7 +367,7 @@ void CharacterComponent::SetLastRocketConfig(std::u16string config) { Item* CharacterComponent::GetRocket(Entity* player) { Item* rocket = nullptr; - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (!inventoryComponent) return rocket; diff --git a/dGame/dComponents/Component.cpp b/dGame/dComponents/Component.cpp index d46c57dcd..1f2678806 100644 --- a/dGame/dComponents/Component.cpp +++ b/dGame/dComponents/Component.cpp @@ -38,6 +38,6 @@ void Component::LoadTemplateData() { } -void Component::Serialize(RakNet::BitStream* bitStream, bool isConstruction = false) { +void Component::Serialize(RakNet::BitStream* bitStream, bool isConstruction) { } diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index 04f627e72..2e8d0e403 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -321,7 +321,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) { // Recalculate speedboost since we removed one m_SpeedBoost = 0.0f; if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed - auto* levelProgressionComponent = m_OwningEntity->GetComponent(); + auto levelProgressionComponent = m_OwningEntity->GetComponent(); if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase(); } else { // Used the last applied speedboost m_SpeedBoost = m_ActiveSpeedBoosts.back(); diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index bb47ce32f..3de0ff4b4 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -185,7 +185,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { return; } - auto* buffComponent = m_OwningEntity->GetComponent(); + auto buffComponent = m_OwningEntity->GetComponent(); if (buffComponent != nullptr) { buffComponent->LoadFromXml(doc); @@ -207,7 +207,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) { return; } - auto* buffComponent = m_OwningEntity->GetComponent(); + auto buffComponent = m_OwningEntity->GetComponent(); if (buffComponent != nullptr) { buffComponent->UpdateXml(doc); @@ -224,7 +224,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) { void DestroyableComponent::SetHealth(int32_t value) { m_DirtyHealth = true; - auto* characterComponent = m_OwningEntity->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackHealthDelta(value - m_iHealth); } @@ -262,14 +262,14 @@ void DestroyableComponent::SetArmor(int32_t value) { // If Destroyable Component already has zero armor do not trigger the passive ability again. bool hadArmor = m_iArmor > 0; - auto* characterComponent = m_OwningEntity->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackArmorDelta(value - m_iArmor); } m_iArmor = value; - auto* inventroyComponent = m_OwningEntity->GetComponent(); + auto inventroyComponent = m_OwningEntity->GetComponent(); if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) { inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor); } @@ -300,14 +300,14 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) { void DestroyableComponent::SetImagination(int32_t value) { m_DirtyHealth = true; - auto* characterComponent = m_OwningEntity->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackImaginationDelta(value - m_iImagination); } m_iImagination = value; - auto* inventroyComponent = m_OwningEntity->GetComponent(); + auto inventroyComponent = m_OwningEntity->GetComponent(); if (m_iImagination == 0 && inventroyComponent != nullptr) { inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination); } @@ -407,7 +407,7 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore } bool DestroyableComponent::IsEnemy(const Entity* other) const { - const auto* otherDestroyableComponent = other->GetComponent(); + const auto otherDestroyableComponent = other->GetComponent(); if (otherDestroyableComponent != nullptr) { for (const auto enemyFaction : m_EnemyFactionIDs) { for (const auto otherFaction : otherDestroyableComponent->GetFactionIDs()) { @@ -421,7 +421,7 @@ bool DestroyableComponent::IsEnemy(const Entity* other) const { } bool DestroyableComponent::IsFriend(const Entity* other) const { - const auto* otherDestroyableComponent = other->GetComponent(); + const auto otherDestroyableComponent = other->GetComponent(); if (otherDestroyableComponent != nullptr) { for (const auto enemyFaction : m_EnemyFactionIDs) { for (const auto otherFaction : otherDestroyableComponent->GetFactionIDs()) { @@ -455,8 +455,8 @@ bool DestroyableComponent::IsImmune() const { } bool DestroyableComponent::IsKnockbackImmune() const { - auto* characterComponent = m_OwningEntity->GetComponent(); - auto* inventoryComponent = m_OwningEntity->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); + auto inventoryComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) { const auto hasPassive = inventoryComponent->HasAnyPassive({ @@ -493,13 +493,13 @@ bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignor return false; } - auto* targetDestroyable = targetEntity->GetComponent(); + auto targetDestroyable = targetEntity->GetComponent(); if (targetDestroyable == nullptr) { return false; } - auto* targetQuickbuild = targetEntity->GetComponent(); + auto targetQuickbuild = targetEntity->GetComponent(); if (targetQuickbuild != nullptr) { const auto state = targetQuickbuild->GetState(); @@ -651,7 +651,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 } if (health != 0) { - auto* combatComponent = m_OwningEntity->GetComponent(); + auto combatComponent = m_OwningEntity->GetComponent(); if (combatComponent != nullptr) { combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary @@ -710,13 +710,13 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType const auto isEnemy = m_OwningEntity->GetComponent() != nullptr; - auto* inventoryComponent = owner->GetComponent(); + auto inventoryComponent = owner->GetComponent(); if (inventoryComponent != nullptr && isEnemy) { inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_OwningEntity); } - auto* missions = owner->GetComponent(); + auto missions = owner->GetComponent(); if (missions != nullptr) { if (team != nullptr) { @@ -725,7 +725,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType if (member == nullptr) continue; - auto* memberMissions = member->GetComponent(); + auto memberMissions = member->GetComponent(); if (memberMissions == nullptr) continue; @@ -750,7 +750,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType if (team != nullptr && m_OwningEntity->GetComponent() != nullptr) { LWOOBJID specificOwner = LWOOBJID_EMPTY; - auto* scriptedActivityComponent = m_OwningEntity->GetComponent(); + auto scriptedActivityComponent = m_OwningEntity->GetComponent(); uint32_t teamSize = team->members.size(); uint32_t lootMatrixId = GetLootMatrixID(); @@ -877,11 +877,11 @@ void DestroyableComponent::FixStats() { if (entity == nullptr) return; // Reset skill component and buff component - auto* skillComponent = entity->GetComponent(); - auto* buffComponent = entity->GetComponent(); - auto* missionComponent = entity->GetComponent(); - auto* inventoryComponent = entity->GetComponent(); - auto* destroyableComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); + auto missionComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); // If any of the components are nullptr, return if (skillComponent == nullptr || buffComponent == nullptr || missionComponent == nullptr || inventoryComponent == nullptr || destroyableComponent == nullptr) { @@ -976,7 +976,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ //check if this is a player: if (m_OwningEntity->IsPlayer()) { //remove hardcore_lose_uscore_on_death_percent from the player's uscore: - auto* character = m_OwningEntity->GetComponent(); + auto character = m_OwningEntity->GetComponent(); auto uscore = character->GetUScore(); auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100); @@ -986,7 +986,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) { //drop all items from inventory: - auto* inventory = m_OwningEntity->GetComponent(); + auto inventory = m_OwningEntity->GetComponent(); if (inventory) { //get the items inventory: auto items = inventory->GetInventory(eInventoryType::ITEMS); @@ -1029,7 +1029,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ //award the player some u-score: auto* player = EntityManager::Instance()->GetEntity(source); if (player && player->IsPlayer()) { - auto* playerStats = player->GetComponent(); + auto playerStats = player->GetComponent(); if (playerStats) { //get the maximum health from this enemy: auto maxHealth = GetMaxHealth(); diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 66c8374d2..1b6a7907b 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -19,7 +19,7 @@ enum class eStateChangeType : uint32_t; */ class DestroyableComponent : public Component { public: - static const eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE; + inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE; DestroyableComponent(Entity* parentEntity); ~DestroyableComponent() override; diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 28294dbf3..1cbef0e0b 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -189,7 +189,7 @@ void InventoryComponent::AddItem( inventoryType = Inventory::FindInventoryTypeForLot(lot); } - auto* missions = static_cast(this->m_OwningEntity->GetComponent(eReplicaComponentType::MISSION)); + auto missions = m_OwningEntity->GetComponent(); auto* inventory = GetInventory(inventoryType); @@ -378,7 +378,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in item->SetCount(item->GetCount() - delta, false, false); } - auto* missionComponent = m_OwningEntity->GetComponent(); + auto missionComponent = m_OwningEntity->GetComponent(); if (missionComponent != nullptr) { if (IsTransferInventory(inventory)) { @@ -833,7 +833,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) { for (auto* lauchPad : rocketLauchPads) { if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue; - auto* characterComponent = m_OwningEntity->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId()); @@ -950,10 +950,10 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) { } void InventoryComponent::HandlePossession(Item* item) { - auto* characterComponent = m_OwningEntity->GetComponent(); + auto characterComponent = m_OwningEntity->GetComponent(); if (!characterComponent) return; - auto* possessorComponent = m_OwningEntity->GetComponent(); + auto possessorComponent = m_OwningEntity->GetComponent(); if (!possessorComponent) return; // Don't do anything if we are busy dismounting @@ -986,7 +986,7 @@ void InventoryComponent::HandlePossession(Item* item) { auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity); // Check to see if the mount is a vehicle, if so, flip it - auto* vehicleComponent = mount->GetComponent(); + auto vehicleComponent = mount->GetComponent(); if (vehicleComponent) { auto angles = startRotation.GetEulerAngles(); // Make it right side up @@ -1000,14 +1000,14 @@ void InventoryComponent::HandlePossession(Item* item) { } // Setup the destroyable stats - auto* destroyableComponent = mount->GetComponent(); + auto destroyableComponent = mount->GetComponent(); if (destroyableComponent) { destroyableComponent->SetIsSmashable(false); destroyableComponent->SetIsImmune(true); } // Mount it - auto* possessableComponent = mount->GetComponent(); + auto possessableComponent = mount->GetComponent(); if (possessableComponent) { possessableComponent->SetIsItemSpawned(true); possessableComponent->SetPossessor(m_OwningEntity->GetObjectID()); @@ -1227,7 +1227,7 @@ bool InventoryComponent::HasAnyPassive(const std::vectorGetObjectID()); + auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); if (current != nullptr) { current->Deactivate(); @@ -1235,7 +1235,7 @@ void InventoryComponent::DespawnPet() { } void InventoryComponent::SpawnPet(Item* item) { - auto* current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); + auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID()); if (current != nullptr) { current->Deactivate(); @@ -1261,7 +1261,7 @@ void InventoryComponent::SpawnPet(Item* item) { auto* pet = EntityManager::Instance()->CreateEntity(info); - auto* petComponent = pet->GetComponent(); + auto petComponent = pet->GetComponent(); if (petComponent != nullptr) { petComponent->Activate(item); @@ -1339,7 +1339,7 @@ std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip return entry.objectTemplate == static_cast(item->GetLot()); }); - auto* missions = static_cast(m_OwningEntity->GetComponent(eReplicaComponentType::MISSION)); + auto missions = m_OwningEntity->GetComponent(); for (const auto& result : results) { if (result.castOnType == 1) { diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index 682b9ac39..dfcbebf64 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -49,8 +49,8 @@ void LevelProgressionComponent::HandleLevelUp() { const auto& rewards = rewardsTable->GetByLevelID(m_Level); bool rewardingItem = rewards.size() > 0; - auto* inventoryComponent = m_OwningEntity->GetComponent(); - auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); + auto inventoryComponent = m_OwningEntity->GetComponent(); + auto controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (!inventoryComponent || !controllablePhysicsComponent) return; // Tell the client we beginning to send level rewards. @@ -84,6 +84,6 @@ void LevelProgressionComponent::HandleLevelUp() { void LevelProgressionComponent::SetRetroactiveBaseSpeed(){ if (m_Level >= 20) m_SpeedBase = 525.0f; - auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); + auto controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f); } diff --git a/dGame/dComponents/MissionOfferComponent.cpp b/dGame/dComponents/MissionOfferComponent.cpp index e4cca8941..4a4b3c937 100644 --- a/dGame/dComponents/MissionOfferComponent.cpp +++ b/dGame/dComponents/MissionOfferComponent.cpp @@ -79,7 +79,7 @@ void MissionOfferComponent::OnUse(Entity* originator) { void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifiedMissionId) { // First, get the entity's MissionComponent. If there is not one, then we cannot offer missions to this entity. - auto* missionComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = entity->GetComponent(); if (!missionComponent) { Game::logger->Log("MissionOfferComponent", "Unable to get mission component for Entity %llu", entity->GetObjectID()); diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index 4a9d2bf56..d4629942e 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -22,7 +22,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : m_BaseCombatAI = nullptr; - m_BaseCombatAI = reinterpret_cast(m_OwningEntity->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); + m_BaseCombatAI = m_OwningEntity->GetComponent(); //Try and fix the insane values: if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f; @@ -322,7 +322,7 @@ float MovementAIComponent::GetBaseSpeed(LOT lot) { } void MovementAIComponent::SetPosition(const NiPoint3& value) { - auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); + auto controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetPosition(value); @@ -330,7 +330,7 @@ void MovementAIComponent::SetPosition(const NiPoint3& value) { return; } - auto* simplePhysicsComponent = m_OwningEntity->GetComponent(); + auto simplePhysicsComponent = m_OwningEntity->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetPosition(value); @@ -342,7 +342,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) { return; } - auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); + auto controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetRotation(value); @@ -350,7 +350,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) { return; } - auto* simplePhysicsComponent = m_OwningEntity->GetComponent(); + auto simplePhysicsComponent = m_OwningEntity->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetRotation(value); @@ -358,7 +358,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) { } void MovementAIComponent::SetVelocity(const NiPoint3& value) { - auto* controllablePhysicsComponent = m_OwningEntity->GetComponent(); + auto controllablePhysicsComponent = m_OwningEntity->GetComponent(); if (controllablePhysicsComponent != nullptr) { controllablePhysicsComponent->SetVelocity(value); @@ -366,7 +366,7 @@ void MovementAIComponent::SetVelocity(const NiPoint3& value) { return; } - auto* simplePhysicsComponent = m_OwningEntity->GetComponent(); + auto simplePhysicsComponent = m_OwningEntity->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetVelocity(value); diff --git a/dGame/dComponents/MovementAIComponent.h b/dGame/dComponents/MovementAIComponent.h index 3c9044aae..7b82edc77 100644 --- a/dGame/dComponents/MovementAIComponent.h +++ b/dGame/dComponents/MovementAIComponent.h @@ -57,7 +57,7 @@ struct MovementAIInfo { */ class MovementAIComponent : public Component { public: - static const eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI; + inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI; MovementAIComponent(Entity* parentEntity, MovementAIInfo info); ~MovementAIComponent() override; @@ -310,7 +310,7 @@ class MovementAIComponent : public Component { /** * Optional direct link to the combat AI component of the parent entity */ - BaseCombatAIComponent* m_BaseCombatAI = nullptr; + std::shared_ptr m_BaseCombatAI = nullptr; /** * The path the entity is currently following diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 7eaa551cd..a2d441680 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -163,7 +163,7 @@ void PetComponent::OnUse(Entity* originator) { m_Tamer = LWOOBJID_EMPTY; } - auto* inventoryComponent = originator->GetComponent(); + auto inventoryComponent = originator->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -173,7 +173,7 @@ void PetComponent::OnUse(Entity* originator) { return; } - auto* movementAIComponent = m_OwningEntity->GetComponent(); + auto movementAIComponent = m_OwningEntity->GetComponent(); if (movementAIComponent != nullptr) { movementAIComponent->Stop(); @@ -224,7 +224,7 @@ void PetComponent::OnUse(Entity* originator) { imaginationCost = cached->second.imaginationCost; } - auto* destroyableComponent = originator->GetComponent(); + auto destroyableComponent = originator->GetComponent(); if (destroyableComponent == nullptr) { return; @@ -362,10 +362,9 @@ void PetComponent::Update(float deltaTime) { return; } - m_MovementAI = m_OwningEntity->GetComponent(); - if (m_MovementAI == nullptr) { - return; + m_MovementAI = m_OwningEntity->GetComponent(); + if (!m_MovementAI) return; } if (m_TresureTime > 0) { @@ -488,7 +487,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) { if (cached == buildCache.end()) return; - auto* destroyableComponent = tamer->GetComponent(); + auto destroyableComponent = tamer->GetComponent(); if (destroyableComponent == nullptr) return; @@ -549,7 +548,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { GameMessages::SendPetResponse(m_Tamer, m_OwningEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress()); - auto* inventoryComponent = tamer->GetComponent(); + auto inventoryComponent = tamer->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -607,7 +606,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_OwningEntity->GetLOT()), true); } - auto* missionComponent = tamer->GetComponent(); + auto missionComponent = tamer->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::PET_TAMING, m_OwningEntity->GetLOT()); @@ -615,7 +614,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { SetStatus(1); - auto* characterComponent = tamer->GetComponent(); + auto characterComponent = tamer->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(PetsTamed); } @@ -649,7 +648,7 @@ void PetComponent::RequestSetPetName(std::u16string name) { Game::logger->Log("PetComponent", "Got set pet name (%s)", GeneralUtils::UTF16ToWTF8(name).c_str()); - auto* inventoryComponent = tamer->GetComponent(); + auto inventoryComponent = tamer->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -841,7 +840,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { m_ItemId = item->GetId(); m_DatabaseId = item->GetSubKey(); - auto* inventoryComponent = item->GetInventory()->GetComponent(); + auto inventoryComponent = item->GetInventory()->GetComponent(); if (inventoryComponent == nullptr) return; @@ -963,7 +962,7 @@ void PetComponent::Deactivate() { } void PetComponent::Release() { - auto* inventoryComponent = GetOwner()->GetComponent(); + auto inventoryComponent = GetOwner()->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -1039,7 +1038,7 @@ void PetComponent::SetAbility(PetAbilityType value) { m_Ability = value; } -PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer) { +std::shared_ptr PetComponent::GetTamingPet(LWOOBJID tamer) { const auto& pair = currentActivities.find(tamer); if (pair == currentActivities.end()) { @@ -1057,7 +1056,7 @@ PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer) { return entity->GetComponent(); } -PetComponent* PetComponent::GetActivePet(LWOOBJID owner) { +std::shared_ptr PetComponent::GetActivePet(LWOOBJID owner) { const auto& pair = activePets.find(owner); if (pair == activePets.end()) { diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index b3d089a93..4eaaa3bc7 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -195,14 +195,14 @@ class PetComponent : public Component * @param tamer the entity that's currently taming * @return the pet component of the entity that's being tamed */ - static PetComponent* GetTamingPet(LWOOBJID tamer); + static std::shared_ptr GetTamingPet(LWOOBJID tamer); /** * Returns the pet that's currently spawned for some entity (if any) * @param owner the owner of the pet that's spawned * @return the pet component of the entity that was spawned by the owner */ - static PetComponent* GetActivePet(LWOOBJID owner); + static std::shared_ptr GetActivePet(LWOOBJID owner); /** * Adds the timer to the owner of this pet to drain imagination at the rate @@ -349,7 +349,7 @@ class PetComponent : public Component /** * The movement AI component that is related to this pet, required to move it around */ - MovementAIComponent* m_MovementAI; + std::shared_ptr m_MovementAI; /** * Preconditions that need to be met before an entity can tame this pet diff --git a/dGame/dComponents/PossessableComponent.cpp b/dGame/dComponents/PossessableComponent.cpp index 1b137bb1c..6172f3e67 100644 --- a/dGame/dComponents/PossessableComponent.cpp +++ b/dGame/dComponents/PossessableComponent.cpp @@ -48,7 +48,7 @@ void PossessableComponent::Dismount() { } void PossessableComponent::OnUse(Entity* originator) { - auto* possessor = originator->GetComponent(); + auto possessor = originator->GetComponent(); if (possessor) { possessor->Mount(m_OwningEntity); } diff --git a/dGame/dComponents/PossessorComponent.cpp b/dGame/dComponents/PossessorComponent.cpp index c1fd53808..347822ac4 100644 --- a/dGame/dComponents/PossessorComponent.cpp +++ b/dGame/dComponents/PossessorComponent.cpp @@ -15,7 +15,7 @@ PossessorComponent::~PossessorComponent() { if (m_Possessable != LWOOBJID_EMPTY) { auto* mount = EntityManager::Instance()->GetEntity(m_Possessable); if (mount) { - auto* possessable = mount->GetComponent(); + auto possessable = mount->GetComponent(); if (possessable) { if (possessable->GetIsItemSpawned()) { GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_OwningEntity->GetSystemAddress()); @@ -43,7 +43,7 @@ void PossessorComponent::Mount(Entity* mount) { if (GetIsDismounting() || !mount) return; GameMessages::SendSetMountInventoryID(m_OwningEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); - auto* possessableComponent = mount->GetComponent(); + auto possessableComponent = mount->GetComponent(); if (possessableComponent) { possessableComponent->SetPossessor(m_OwningEntity->GetObjectID()); SetPossessable(mount->GetObjectID()); @@ -68,7 +68,7 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) { SetIsDismounting(true); if (mount) { - auto* possessableComponent = mount->GetComponent(); + auto possessableComponent = mount->GetComponent(); if (possessableComponent) { possessableComponent->SetPossessor(LWOOBJID_EMPTY); if (forceDismount) possessableComponent->ForceDepossess(); diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index 6fab366bf..0fc2cc0c8 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -26,10 +26,10 @@ PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entit } void PropertyEntranceComponent::OnUse(Entity* entity) { - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (!characterComponent) return; - auto* rocket = entity->GetComponent()->RocketEquip(entity); + auto rocket = entity->GetComponent()->RocketEquip(entity); if (!rocket) return; GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), entity->GetSystemAddress()); @@ -63,7 +63,7 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, cloneId = query[index].CloneId; } - auto* launcher = m_OwningEntity->GetComponent(); + auto launcher = m_OwningEntity->GetComponent(); if (launcher == nullptr) { return; diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index 1520f4727..105382a63 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -263,7 +263,7 @@ void PropertyManagementComponent::OnStartBuilding() { SetPrivacyOption(PropertyPrivacyOption::Private); // Cant visit player which is building if (!entrance.empty()) { - auto* rocketPad = entrance[0]->GetComponent(); + auto rocketPad = entrance[0]->GetComponent(); if (rocketPad != nullptr) { zoneId = rocketPad->GetDefaultZone(); @@ -302,7 +302,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N return; } - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -417,7 +417,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet return; } - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent == nullptr) { return; diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 5c8ee8343..6350107fc 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -87,7 +87,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, return; } - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -141,8 +141,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, // Make the vehicle a child of the racing controller. m_OwningEntity->AddChild(carEntity); - auto* destroyableComponent = - carEntity->GetComponent(); + auto destroyableComponent = carEntity->GetComponent(); // Setup the vehicle stats. if (destroyableComponent != nullptr) { @@ -151,16 +150,14 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, } // Setup the vehicle as being possessed by the player. - auto* possessableComponent = - carEntity->GetComponent(); + auto possessableComponent = carEntity->GetComponent(); if (possessableComponent != nullptr) { possessableComponent->SetPossessor(player->GetObjectID()); } // Load the vehicle's assemblyPartLOTs for display. - auto* moduleAssemblyComponent = - carEntity->GetComponent(); + auto moduleAssemblyComponent = carEntity->GetComponent(); if (moduleAssemblyComponent) { moduleAssemblyComponent->SetSubKey(item->GetSubKey()); @@ -175,7 +172,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, } // Setup the player as possessing the vehicle. - auto* possessorComponent = player->GetComponent(); + auto possessorComponent = player->GetComponent(); if (possessorComponent != nullptr) { possessorComponent->SetPossessable(carEntity->GetObjectID()); @@ -183,7 +180,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, } // Set the player's current activity as racing. - auto* characterComponent = player->GetComponent(); + auto characterComponent = player->GetComponent(); if (characterComponent != nullptr) { characterComponent->SetIsRacing(true); @@ -293,7 +290,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) { GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0); - auto* destroyableComponent = vehicle->GetComponent(); + auto destroyableComponent = vehicle->GetComponent(); uint32_t respawnImagination = 0; // Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live. // Do not actually change the value yet. Do that on respawn. @@ -318,13 +315,13 @@ void RacingControlComponent::OnRequestDie(Entity* player) { UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendResurrect(vehicle); - auto* destroyableComponent = vehicle->GetComponent(); + auto destroyableComponent = vehicle->GetComponent(); // Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live. if (destroyableComponent) destroyableComponent->SetImagination(respawnImagination); EntityManager::Instance()->SerializeEntity(vehicle); }); - auto* characterComponent = player->GetComponent(); + auto characterComponent = player->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(RacingTimesWrecked); } @@ -386,7 +383,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu m_OwningEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"", player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) return; @@ -639,8 +636,7 @@ void RacingControlComponent::Update(float deltaTime) { vehicle->SetPosition(player.respawnPosition); vehicle->SetRotation(player.respawnRotation); - auto* destroyableComponent = - vehicle->GetComponent(); + auto destroyableComponent = vehicle->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetImagination(0); @@ -817,8 +813,7 @@ void RacingControlComponent::Update(float deltaTime) { "Best lap time (%llu)", lapTime); } - auto* missionComponent = - playerEntity->GetComponent(); + auto missionComponent = playerEntity->GetComponent(); if (missionComponent != nullptr) { @@ -841,7 +836,7 @@ void RacingControlComponent::Update(float deltaTime) { // Entire race time missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, (LWOOBJID)eRacingTaskParam::TOTAL_TRACK_TIME); - auto* characterComponent = playerEntity->GetComponent(); + auto characterComponent = playerEntity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackRaceCompleted(m_Finished == 1); } diff --git a/dGame/dComponents/RailActivatorComponent.cpp b/dGame/dComponents/RailActivatorComponent.cpp index db1504da4..25bdf9b89 100644 --- a/dGame/dComponents/RailActivatorComponent.cpp +++ b/dGame/dComponents/RailActivatorComponent.cpp @@ -43,7 +43,7 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t component RailActivatorComponent::~RailActivatorComponent() = default; void RailActivatorComponent::OnUse(Entity* originator) { - auto* rebuildComponent = m_OwningEntity->GetComponent(); + auto rebuildComponent = m_OwningEntity->GetComponent(); if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED) return; @@ -116,7 +116,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) { true, true, true, true, true, true, true ); - auto* rebuildComponent = m_OwningEntity->GetComponent(); + auto rebuildComponent = m_OwningEntity->GetComponent(); if (rebuildComponent != nullptr) { // Set back reset time diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index 15b3a2552..d224402f7 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -194,7 +194,7 @@ void RebuildComponent::Update(float deltaTime) { if (m_TimeBeforeDrain <= 0.0f) { m_TimeBeforeDrain = m_CompleteTime / static_cast(m_TakeImagination); - DestroyableComponent* destComp = builder->GetComponent(); + auto destComp = builder->GetComponent(); if (!destComp) break; int newImagination = destComp->GetImagination(); @@ -400,7 +400,7 @@ void RebuildComponent::StartRebuild(Entity* user) { if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) { m_Builder = user->GetObjectID(); - auto* character = user->GetComponent(); + auto character = user->GetComponent(); character->SetCurrentActivity(eGameActivity::QUICKBUILDING); EntityManager::Instance()->SerializeEntity(user); @@ -412,7 +412,7 @@ void RebuildComponent::StartRebuild(Entity* user) { m_StateDirty = true; EntityManager::Instance()->SerializeEntity(m_OwningEntity); - auto* movingPlatform = m_OwningEntity->GetComponent(); + auto movingPlatform = m_OwningEntity->GetComponent(); if (movingPlatform != nullptr) { movingPlatform->OnRebuildInitilized(); } @@ -434,7 +434,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { return; } - auto* characterComponent = user->GetComponent(); + auto characterComponent = user->GetComponent(); if (characterComponent != nullptr) { characterComponent->SetCurrentActivity(eGameActivity::NONE); characterComponent->TrackRebuildComplete(); @@ -478,12 +478,12 @@ void RebuildComponent::CompleteRebuild(Entity* user) { for (const auto memberId : team->members) { // progress missions for all team members auto* member = EntityManager::Instance()->GetEntity(memberId); if (member) { - auto* missionComponent = member->GetComponent(); + auto missionComponent = member->GetComponent(); if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId); } } } else{ - auto* missionComponent = builder->GetComponent(); + auto missionComponent = builder->GetComponent(); if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId); } LootGenerator::Instance().DropActivityLoot(builder, m_OwningEntity, m_ActivityId, 1); @@ -503,7 +503,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { m_OwningEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user); - auto* movingPlatform = m_OwningEntity->GetComponent(); + auto movingPlatform = m_OwningEntity->GetComponent(); if (movingPlatform != nullptr) { movingPlatform->OnCompleteRebuild(); } @@ -588,7 +588,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR return; } - CharacterComponent* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (characterComponent) { characterComponent->SetCurrentActivity(eGameActivity::NONE); EntityManager::Instance()->SerializeEntity(entity); diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index f59e116dd..feedfd85a 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -214,7 +214,7 @@ float RenderComponent::GetAnimationTime(Entity* self, const std::string& animati float RenderComponent::DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority, float scale) { float returnlength = 0.0f; if (!self) return returnlength; - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (!renderComponent) return returnlength; auto* animationsTable = CDClientManager::Instance().GetTable(); diff --git a/dGame/dComponents/RocketLaunchLupComponent.cpp b/dGame/dComponents/RocketLaunchLupComponent.cpp index 87e969ddc..442ee09cd 100644 --- a/dGame/dComponents/RocketLaunchLupComponent.cpp +++ b/dGame/dComponents/RocketLaunchLupComponent.cpp @@ -17,7 +17,7 @@ RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(p RocketLaunchLupComponent::~RocketLaunchLupComponent() {} void RocketLaunchLupComponent::OnUse(Entity* originator) { - auto* rocket = originator->GetComponent()->RocketEquip(originator); + auto rocket = originator->GetComponent()->RocketEquip(originator); if (!rocket) return; // the LUP world menu is just the property menu, the client knows how to handle it @@ -25,7 +25,7 @@ void RocketLaunchLupComponent::OnUse(Entity* originator) { } void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) { - auto* rocketLaunchpadControlComponent = m_OwningEntity->GetComponent(); + auto rocketLaunchpadControlComponent = m_OwningEntity->GetComponent(); if (!rocketLaunchpadControlComponent) return; rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0); diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.cpp b/dGame/dComponents/RocketLaunchpadControlComponent.cpp index c4af8a4a0..5376faa7a 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.cpp +++ b/dGame/dComponents/RocketLaunchpadControlComponent.cpp @@ -50,7 +50,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, } // This also gets triggered by a proximity monitor + item equip, I will set that up when havok is ready - auto* characterComponent = originator->GetComponent(); + auto characterComponent = originator->GetComponent(); auto* character = originator->GetCharacter(); if (!characterComponent || !character) return; @@ -89,18 +89,18 @@ void RocketLaunchpadControlComponent::OnUse(Entity* originator) { // instead we let their OnUse handlers do their things // which components of an Object have their OnUse called when using them // so we don't need to call it here - auto* propertyEntrance = m_OwningEntity->GetComponent(); + auto propertyEntrance = m_OwningEntity->GetComponent(); if (propertyEntrance) { return; } - auto* rocketLaunchLUP = m_OwningEntity->GetComponent(); + auto rocketLaunchLUP = m_OwningEntity->GetComponent(); if (rocketLaunchLUP) { return; } // No rocket no launch - auto* rocket = originator->GetComponent()->RocketEquip(originator); + auto rocket = originator->GetComponent()->RocketEquip(originator); if (!rocket) { return; } diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index 88cc726c6..c74c77c74 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -53,7 +53,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit } } - auto* destroyableComponent = m_OwningEntity->GetComponent(); + auto destroyableComponent = m_OwningEntity->GetComponent(); if (destroyableComponent) { // check for LMIs and set the loot LMIs @@ -305,7 +305,7 @@ bool ScriptedActivityComponent::IsValidActivity(Entity* player) { // Makes it so that scripted activities with an unimplemented map cannot be joined /*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) { if (m_OwningEntity->GetLOT() == 4860) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); missionComponent->CompleteMission(229); } @@ -354,7 +354,7 @@ bool ScriptedActivityComponent::TakeCost(Entity* player) const { if (m_ActivityInfo.optionalCostLOT <= 0 || m_ActivityInfo.optionalCostCount <= 0) return true; - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (inventoryComponent == nullptr) return false; @@ -555,7 +555,7 @@ void ActivityInstance::StartZone() { } void ActivityInstance::RewardParticipant(Entity* participant) { - auto* missionComponent = participant->GetComponent(); + auto missionComponent = participant->GetComponent(); if (missionComponent) { missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityInfo.ActivityID); } diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index 95cbe3cd1..7834674ee 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -193,7 +193,7 @@ void SkillComponent::Reset() { void SkillComponent::Interrupt() { // TODO: need to check immunities on the destroyable component, but they aren't implemented - auto* combat = m_OwningEntity->GetComponent(); + auto combat = m_OwningEntity->GetComponent(); if (combat != nullptr && combat->GetStunImmune()) return; for (const auto& behavior : this->m_managedBehaviors) { diff --git a/dGame/dComponents/SwitchComponent.h b/dGame/dComponents/SwitchComponent.h index fde3cfc0e..eea08e51d 100644 --- a/dGame/dComponents/SwitchComponent.h +++ b/dGame/dComponents/SwitchComponent.h @@ -75,7 +75,7 @@ class SwitchComponent : public Component { /** * Attached rebuild component. */ - RebuildComponent* m_Rebuild; + std::shared_ptr m_Rebuild; /** * If the switch is on or off. diff --git a/dGame/dComponents/TriggerComponent.cpp b/dGame/dComponents/TriggerComponent.cpp index fe141a4dc..ca995c245 100644 --- a/dGame/dComponents/TriggerComponent.cpp +++ b/dGame/dComponents/TriggerComponent.cpp @@ -196,7 +196,7 @@ void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string arg } void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){ - auto* triggerComponent = targetEntity->GetComponent(); + auto triggerComponent = targetEntity->GetComponent(); if (!triggerComponent) { Game::logger->LogDebug("TriggerComponent::HandleToggleTrigger", "Trigger component not found!"); return; @@ -205,7 +205,7 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg } void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){ - auto* rebuildComponent = targetEntity->GetComponent(); + auto rebuildComponent = targetEntity->GetComponent(); if (!rebuildComponent) { Game::logger->LogDebug("TriggerComponent::HandleResetRebuild", "Rebuild component not found!"); return; @@ -237,7 +237,7 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector argArray){ if (argArray.size() < 3) return; - auto* phantomPhysicsComponent = m_OwningEntity->GetComponent(); + auto phantomPhysicsComponent = m_OwningEntity->GetComponent(); if (!phantomPhysicsComponent) { Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!"); return; @@ -254,7 +254,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vectorGetComponent(); + auto phantomPhysicsComponent = m_OwningEntity->GetComponent(); if (!phantomPhysicsComponent) { Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!"); return; @@ -334,7 +334,7 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vectorGetComponent(); + auto missionComponent = targetEntity->GetComponent(); if (!missionComponent){ Game::logger->LogDebug("TriggerComponent::HandleUpdateMission", "Mission component not found!"); return; @@ -353,7 +353,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vectorGetComponent(); + auto skillComponent = targetEntity->GetComponent(); if (!skillComponent) { Game::logger->LogDebug("TriggerComponent::HandleCastSkill", "Skill component not found!"); return; @@ -364,7 +364,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){ } void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::vector argArray) { - auto* phantomPhysicsComponent = targetEntity->GetComponent(); + auto phantomPhysicsComponent = targetEntity->GetComponent(); if (!phantomPhysicsComponent) { Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); return; @@ -399,7 +399,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v } void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) { - auto* phantomPhysicsComponent = targetEntity->GetComponent(); + auto phantomPhysicsComponent = targetEntity->GetComponent(); if (!phantomPhysicsComponent) { Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); return; diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index be7515989..3b10b3500 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -110,7 +110,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System player->ConstructLimboEntities(); } - InventoryComponent* inv = entity->GetComponent(); + auto inv = entity->GetComponent(); if (inv) { auto items = inv->GetEquippedItems(); for (auto pair : items) { @@ -120,13 +120,13 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System } } - auto* destroyable = entity->GetComponent(); + auto destroyable = entity->GetComponent(); destroyable->SetImagination(destroyable->GetImagination()); EntityManager::Instance()->SerializeEntity(entity); std::vector racingControllers = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL); for (Entity* racingController : racingControllers) { - auto* racingComponent = racingController->GetComponent(); + auto racingComponent = racingController->GetComponent(); if (racingComponent != nullptr) { racingComponent->OnPlayerLoaded(entity); } @@ -243,13 +243,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System case eGameMessageType::REQUEST_RESURRECT: { GameMessages::SendResurrect(entity); - /*auto* dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); - if (dest) { - dest->SetHealth(4); - dest->SetArmor(0); - dest->SetImagination(6); - EntityManager::Instance()->SerializeEntity(entity); - }*/ break; } case eGameMessageType::HANDLE_HOT_PROPERTY_DATA: { @@ -263,7 +256,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System message.Deserialize(inStream); - auto* skill_component = entity->GetComponent(); + auto skill_component = entity->GetComponent(); if (skill_component != nullptr) { auto* bs = new RakNet::BitStream((unsigned char*)message.sBitStream.c_str(), message.sBitStream.size(), false); @@ -282,7 +275,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System if (startSkill.skillID == 1561 || startSkill.skillID == 1562 || startSkill.skillID == 1541) return; - MissionComponent* comp = entity->GetComponent(); + auto comp = entity->GetComponent(); if (comp) { comp->Progress(eMissionTaskType::USE_SKILL, startSkill.skillID); } @@ -295,12 +288,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System if (behaviorId > 0) { RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false); - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); success = skillComponent->CastPlayerSkill(behaviorId, startSkill.uiSkillHandle, bs, startSkill.optionalTargetID, startSkill.skillID); if (success && entity->GetCharacter()) { - DestroyableComponent* destComp = entity->GetComponent(); + auto destComp = entity->GetComponent(); destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost); } @@ -357,7 +350,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System if (usr != nullptr) { RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false); - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, bs); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 12d1a5ef5..0d3b192d2 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -935,10 +935,10 @@ void GameMessages::SendResurrect(Entity* entity) { // and just make sure the client has time to be ready. constexpr float respawnTime = 3.66700005531311f + 0.5f; entity->AddCallbackTimer(respawnTime, [=]() { - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); if (destroyableComponent != nullptr && entity->GetLOT() == 1) { - auto* levelComponent = entity->GetComponent(); + auto levelComponent = entity->GetComponent(); if (levelComponent) { int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4; if (healthToRestore > destroyableComponent->GetMaxHealth()) healthToRestore = destroyableComponent->GetMaxHealth(); @@ -952,7 +952,7 @@ void GameMessages::SendResurrect(Entity* entity) { }); - auto cont = static_cast(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); + auto cont = entity->GetComponent(); if (cont && entity->GetLOT() == 1) { cont->SetPosition(entity->GetRespawnPosition()); cont->SetRotation(entity->GetRespawnRotation()); @@ -1149,7 +1149,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo bitStream.Write(position.y); bitStream.Write(position.z); - auto con = static_cast(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); + auto con = entity->GetComponent(); if (con) { auto rot = con->GetRotation(); bitStream.Write(rot.x); @@ -1284,7 +1284,7 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s CBITSTREAM; CMSGHEADER; - VendorComponent* vendor = static_cast(entity->GetComponent(eReplicaComponentType::VENDOR)); + auto vendor = entity->GetComponent(); if (!vendor) return; std::map vendorItems = vendor->GetInventory(); @@ -1406,7 +1406,7 @@ void GameMessages::SendMoveInventoryBatch(Entity* entity, uint32_t stackCount, i CBITSTREAM; CMSGHEADER; - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; Item* itemStack = inv->FindItemById(iObjID); @@ -2182,7 +2182,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, LWOOBJID objIdToAddToInventory{}; inStream->Read(unknown); inStream->Read(objIdToAddToInventory); - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent) { auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS_IN_BBB); auto* item = inventory->FindItemById(objIdToAddToInventory); @@ -2244,7 +2244,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* entity = entites[0]; */ - auto* propertyVendorComponent = static_cast(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR)); + auto propertyVendorComponent = entity->GetComponent(); if (propertyVendorComponent != nullptr) { propertyVendorComponent->OnQueryPropertyData(entity, sysAddr); @@ -2256,7 +2256,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* entity = entites[0]; */ - auto* propertyManagerComponent = static_cast(entity->GetComponent(eReplicaComponentType::PROPERTY_MANAGEMENT)); + auto propertyManagerComponent = entity->GetComponent(); if (propertyManagerComponent != nullptr) { propertyManagerComponent->OnQueryPropertyData(entity, sysAddr); @@ -2422,7 +2422,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* Game::logger->Log("BBB", "Load item request for: %lld", previousItemID); LWOOBJID newId = previousItemID; - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent) { auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS); auto* itemToMove = inventory->FindItemById(previousItemID); @@ -2776,7 +2776,7 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit auto* player = Player::GetPlayer(sysAddr); - auto* entranceComponent = entity->GetComponent(); + auto entranceComponent = entity->GetComponent(); if (entranceComponent == nullptr) return; @@ -2803,7 +2803,7 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti auto* player = Player::GetPlayer(sysAddr); - auto* entranceComponent = entity->GetComponent(); + auto entranceComponent = entity->GetComponent(); if (entranceComponent != nullptr) { entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr); return; @@ -2820,7 +2820,7 @@ void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* inStream->Read(lot); - auto* inventory = entity->GetComponent(); + auto inventory = entity->GetComponent(); if (inventory == nullptr) return; @@ -3719,7 +3719,7 @@ void GameMessages::SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatu void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { bool bVoluntaryExit = inStream->ReadBit(); - auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); + auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); if (petComponent == nullptr) { return; @@ -3729,7 +3729,7 @@ void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, E } void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); + auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); if (petComponent == nullptr) { return; @@ -3757,7 +3757,7 @@ void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity* clientFailed = inStream->ReadBit(); - auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); + auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); if (petComponent == nullptr) { return; @@ -3771,7 +3771,7 @@ void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, E inStream->Read(position); - auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); + auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); if (petComponent == nullptr) { return; @@ -3792,7 +3792,7 @@ void GameMessages::HandleRequestSetPetName(RakNet::BitStream* inStream, Entity* name.push_back(character); } - auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); + auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID()); if (petComponent == nullptr) { petComponent = PetComponent::GetActivePet(entity->GetObjectID()); @@ -3818,7 +3818,7 @@ void GameMessages::HandleCommandPet(RakNet::BitStream* inStream, Entity* entity, inStream->Read(iTypeID); overrideObey = inStream->ReadBit(); - auto* petComponent = entity->GetComponent(); + auto petComponent = entity->GetComponent(); if (petComponent == nullptr) { return; @@ -3832,7 +3832,7 @@ void GameMessages::HandleDespawnPet(RakNet::BitStream* inStream, Entity* entity, bDeletePet = inStream->ReadBit(); - auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID()); + auto petComponent = PetComponent::GetActivePet(entity->GetObjectID()); if (petComponent == nullptr) { return; @@ -3884,13 +3884,13 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity* entity->OnMessageBoxResponse(userEntity, iButton, identifier, userData); - auto* scriptedActivityComponent = entity->GetComponent(); + auto scriptedActivityComponent = entity->GetComponent(); if (scriptedActivityComponent != nullptr) { scriptedActivityComponent->HandleMessageBoxResponse(userEntity, GeneralUtils::UTF16ToWTF8(identifier)); } - auto* racingControlComponent = entity->GetComponent(); + auto racingControlComponent = entity->GetComponent(); if (racingControlComponent != nullptr) { racingControlComponent->HandleMessageBoxResponse(userEntity, iButton, GeneralUtils::UTF16ToWTF8(identifier)); @@ -4056,7 +4056,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e // If we aren't possessing somethings, the don't do anything if (objectId != LWOOBJID_EMPTY) { - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); auto* mount = EntityManager::Instance()->GetEntity(objectId); // make sure we have the things we need and they aren't null if (possessorComponent && mount) { @@ -4066,7 +4066,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e possessorComponent->SetPossessableType(ePossessionType::NO_POSSESSION); // character related things - auto* character = entity->GetComponent(); + auto character = entity->GetComponent(); if (character) { // If we had an active item turn it off if (possessorComponent->GetMountItemID() != LWOOBJID_EMPTY) GameMessages::SendMarkInventoryItemAsActive(entity->GetObjectID(), false, eUnequippableActiveType::MOUNT, possessorComponent->GetMountItemID(), entity->GetSystemAddress()); @@ -4074,11 +4074,11 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e } // Set that the controllabel phsyics comp is teleporting - auto* controllablePhysicsComponent = entity->GetComponent(); + auto controllablePhysicsComponent = entity->GetComponent(); if (controllablePhysicsComponent) controllablePhysicsComponent->SetIsTeleporting(true); // Call dismoint on the possessable comp to let it handle killing the possessable - auto* possessableComponent = mount->GetComponent(); + auto possessableComponent = mount->GetComponent(); if (possessableComponent) possessableComponent->Dismount(); // Update the entity that was possessing @@ -4102,7 +4102,7 @@ void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Enti //Racing void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - auto* moduleAssemblyComponent = entity->GetComponent(); + auto moduleAssemblyComponent = entity->GetComponent(); Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i", entity->GetLOT()); @@ -4138,7 +4138,7 @@ void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity* return; } - auto* racingControlComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent(); + auto racingControlComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent(); if (racingControlComponent == nullptr) { return; @@ -4188,12 +4188,12 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); - auto* racingControlComponent = zoneController->GetComponent(); + auto racingControlComponent = zoneController->GetComponent(); Game::logger->Log("HandleRequestDie", "Got die request: %i", entity->GetLOT()); if (racingControlComponent != nullptr) { - auto* possessableComponent = entity->GetComponent(); + auto possessableComponent = entity->GetComponent(); if (possessableComponent != nullptr) { entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); @@ -4231,7 +4231,7 @@ void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStre auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); - auto* racingControlComponent = zoneController->GetComponent(); + auto racingControlComponent = zoneController->GetComponent(); Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i", entity->GetLOT()); @@ -4293,7 +4293,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in return; } - auto* possessableComponent = entity->GetComponent(); + auto possessableComponent = entity->GetComponent(); if (possessableComponent != nullptr) { entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); @@ -4303,7 +4303,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in } } - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(RacingImaginationPowerUpsCollected); } @@ -4630,7 +4630,7 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* return; } - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent != nullptr) { if (itemID != LWOOBJID_EMPTY) { @@ -4639,7 +4639,7 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* if (!item) return; // Despawn the pet if we are moving that pet to the vault. - auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID()); + auto petComponent = PetComponent::GetActivePet(entity->GetObjectID()); if (petComponent && petComponent->GetDatabaseId() == item->GetSubKey()) { inventoryComponent->DespawnPet(); } @@ -4723,7 +4723,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); if (!player) return; - auto* propertyVendorComponent = static_cast(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR)); + auto propertyVendorComponent = entity->GetComponent(); if (propertyVendorComponent != nullptr) { propertyVendorComponent->OnBuyFromVendor(player, bConfirmed, item, count); @@ -4733,10 +4733,10 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti const auto isCommendationVendor = entity->GetLOT() == 13806; - auto* vend = entity->GetComponent(); + auto vend = entity->GetComponent(); if (!vend && !isCommendationVendor) return; - auto* inv = player->GetComponent(); + auto inv = player->GetComponent(); if (!inv) return; if (!isCommendationVendor && !vend->SellsItem(item)) { @@ -4764,7 +4764,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti return; } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) { return; @@ -4827,10 +4827,10 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit if (!player) return; Character* character = player->GetCharacter(); if (!character) return; - InventoryComponent* inv = static_cast(player->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = player->GetComponent(); if (!inv) return; - VendorComponent* vend = static_cast(entity->GetComponent(eReplicaComponentType::VENDOR)); + auto vend = entity->GetComponent(); if (!vend) return; Item* item = inv->FindItemById(iObjID); @@ -4877,10 +4877,10 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* if (!player) return; Character* character = player->GetCharacter(); if (!character) return; - InventoryComponent* inv = static_cast(player->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = player->GetComponent(); if (!inv) return; - VendorComponent* vend = static_cast(entity->GetComponent(eReplicaComponentType::VENDOR)); + auto vend = entity->GetComponent(); if (!vend) return; Item* item = inv->FindItemById(iObjID); @@ -4974,7 +4974,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity LWOCLONEID cloneId = 0; LWOMAPID mapId = 0; - auto* rocketPad = entity->GetComponent(); + auto rocketPad = entity->GetComponent(); if (rocketPad == nullptr) return; @@ -5031,7 +5031,7 @@ void GameMessages::HandleRebuildCancel(RakNet::BitStream* inStream, Entity* enti inStream->Read(bEarlyRelease); inStream->Read(userID); - RebuildComponent* rebComp = static_cast(entity->GetComponent(eReplicaComponentType::QUICK_BUILD)); + auto rebComp = entity->GetComponent(); if (!rebComp) return; rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY); @@ -5064,7 +5064,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, if (bIsMultiInteractUse) { if (multiInteractType == 0) { - auto* missionOfferComponent = static_cast(interactedObject->GetComponent(eReplicaComponentType::MISSION_OFFER)); + auto missionOfferComponent = interactedObject->GetComponent(); if (missionOfferComponent != nullptr) { missionOfferComponent->OfferMissions(entity, multiInteractID); @@ -5077,7 +5077,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, } //Perform use task if possible: - auto missionComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = entity->GetComponent(); if (missionComponent == nullptr) return; @@ -5099,7 +5099,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) if (emoteID == 0) return; std::string sAnimationName = "deaded"; //Default name in case we fail to get the emote - MissionComponent* missionComponent = entity->GetComponent(); + auto missionComponent = entity->GetComponent(); if (!missionComponent) return; if (targetID != LWOOBJID_EMPTY) { @@ -5143,7 +5143,7 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E if (!user) return; Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); if (!character) return; - InventoryComponent* inv = static_cast(character->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = character->GetComponent(); if (!inv) return; auto* item = inv->FindItemById(modelID); @@ -5186,7 +5186,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e inStream->Read(isDefaultReward); if (isDefaultReward) inStream->Read(reward); - MissionComponent* missionComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = entity->GetComponent(); if (!missionComponent) { Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission", playerID); return; @@ -5229,7 +5229,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en } // Get the player's mission component - MissionComponent* missionComponent = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = player->GetComponent(); if (!missionComponent) { Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID()); return; @@ -5253,7 +5253,7 @@ void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entit auto* player = EntityManager::Instance()->GetEntity(playerId); - auto* missionOfferComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION_OFFER)); + auto missionOfferComponent = entity->GetComponent(); if (missionOfferComponent != nullptr) { missionOfferComponent->OfferMissions(player, 0); @@ -5267,16 +5267,16 @@ void GameMessages::HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* e Entity* player = EntityManager::Instance()->GetEntity(playerID); if (!player || !entity || entity->GetCollectibleID() == 0) return; - MissionComponent* missionComponent = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = player->GetComponent(); if (missionComponent) { missionComponent->Progress(eMissionTaskType::COLLECTION, entity->GetLOT(), entity->GetObjectID()); } } void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity) { - auto* levelComp = entity->GetComponent(); + auto levelComp = entity->GetComponent(); if (!levelComp) return; - auto* character = entity->GetComponent(); + auto character = entity->GetComponent(); if (!character) return; //Update our character's level in memory: @@ -5284,7 +5284,7 @@ void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* levelComp->HandleLevelUp(); - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent != nullptr) { auto* inventory = inventoryComponent->GetInventory(ITEMS); @@ -5370,7 +5370,7 @@ void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity) inStream->Read(immediate); //twice? inStream->Read(objectID); - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; Item* item = inv->FindItemById(objectID); @@ -5389,7 +5389,7 @@ void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity inStream->Read(immediate); inStream->Read(objectID); - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; auto* item = inv->FindItemById(objectID); @@ -5464,7 +5464,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En inStream->Read(iTradeIDIsDefault); if (iTradeIDIsDefault) inStream->Read(iTradeID); - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; auto* item = inv->FindItemById(iObjID); @@ -5485,7 +5485,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En item->SetCount(item->GetCount() - iStackCount, true); EntityManager::Instance()->SerializeEntity(entity); - auto* missionComponent = entity->GetComponent(); + auto missionComponent = entity->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount); @@ -5507,7 +5507,7 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity inStream->Read(responseCode); inStream->Read(slot); - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; auto* item = inv->FindItemById(iObjID); @@ -5584,7 +5584,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* if (!user) return; Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); if (!character) return; - InventoryComponent* inv = static_cast(character->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = character->GetComponent(); if (!inv) return; Game::logger->Log("GameMessages", "Build finished"); @@ -5639,7 +5639,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config); } - auto* missionComponent = character->GetComponent(); + auto missionComponent = character->GetComponent(); if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) { if (missionComponent != nullptr) { @@ -5649,7 +5649,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* } } - ScriptComponent* script = static_cast(entity->GetComponent(eReplicaComponentType::SCRIPT)); + auto script = entity->GetComponent(); for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) { script->OnModularBuildExit(entity, character, count >= 3, modList); @@ -5672,7 +5672,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti if (!user) return; Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar()); if (!character) return; - InventoryComponent* inv = static_cast(character->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = character->GetComponent(); if (!inv) return; /** @@ -5790,7 +5790,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E inStream->Read(templateID); - InventoryComponent* inv = static_cast(character->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = character->GetComponent(); if (!inv) return; auto* item = inv->FindItemByLot(templateID, TEMP_MODELS); @@ -5842,13 +5842,13 @@ void GameMessages::HandleResurrect(RakNet::BitStream* inStream, Entity* entity) } void GameMessages::HandlePushEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) { - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; inv->PushEquippedItems(); } void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) { - InventoryComponent* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; inv->PopEquippedItems(); EntityManager::Instance()->SerializeEntity(entity); // so it updates on client side @@ -5860,7 +5860,7 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity* inStream->Read(itemConsumed); - auto* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inventory = entity->GetComponent(); if (inventory == nullptr) { return; @@ -5874,7 +5874,7 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity* item->Consume(); - auto* missions = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto missions = entity->GetComponent(); if (missions != nullptr) { missions->Progress(eMissionTaskType::USE_ITEM, itemLot); } @@ -5886,7 +5886,7 @@ void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity inStream->Read(itemConsumed); - auto* inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; @@ -5921,7 +5921,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit if (type == 0) { // join if (value != 0) { for (Entity* scriptedAct : scriptedActs) { - ScriptedActivityComponent* comp = static_cast(scriptedAct->GetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY)); + auto comp = scriptedAct->GetComponent(); if (!comp) continue; if (comp->GetActivityID() == value) { comp->PlayerJoin(entity); @@ -5932,7 +5932,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit } } else if (type == 1) { // ready/unready for (Entity* scriptedAct : scriptedActs) { - ScriptedActivityComponent* comp = static_cast(scriptedAct->GetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY)); + auto comp = scriptedAct->GetComponent(); if (!comp) continue; if (comp->PlayerIsInQueue(entity)) { comp->PlayerReady(entity, value); @@ -6052,7 +6052,7 @@ void GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); for (const auto* possibleRail : possibleRails) { - const auto* rail = possibleRail->GetComponent(); + const auto rail = possibleRail->GetComponent(); if (rail != nullptr) { rail->OnRailMovementReady(entity); } @@ -6064,7 +6064,7 @@ void GameMessages::HandleCancelRailMovement(RakNet::BitStream* inStream, Entity* const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); for (const auto* possibleRail : possibleRails) { - auto* rail = possibleRail->GetComponent(); + auto rail = possibleRail->GetComponent(); if (rail != nullptr) { rail->OnCancelRailMovement(entity); } @@ -6113,7 +6113,7 @@ void GameMessages::HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream, } // Notify the character component that something's changed - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (characterComponent != nullptr) { characterComponent->HandleZoneStatisticsUpdate(zone, statisticsName, value); } @@ -6130,7 +6130,7 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti updateValue = 1; } - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0))); } diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 6f3af0731..c47cf5209 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -92,7 +92,7 @@ Item::Item( inventory->AddManagedItem(this); - auto* entity = inventory->GetComponent()->GetOwningEntity(); + auto entity = inventory->GetComponent()->GetOwningEntity(); GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast(this->count), subKey, lootSourceType); if (isModMoveAndEquip) { @@ -166,7 +166,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem } if (!silent) { - auto* entity = inventory->GetComponent()->GetOwningEntity(); + auto entity = inventory->GetComponent()->GetOwningEntity(); if (value > count) { GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType); @@ -231,7 +231,7 @@ void Item::UnEquip() { } bool Item::IsEquipped() const { - auto* component = inventory->GetComponent(); + auto component = inventory->GetComponent(); for (const auto& pair : component->GetEquippedItems()) { const auto item = pair.second; @@ -278,7 +278,7 @@ void Item::UseNonEquip(Item* item) { return; } - auto* playerInventoryComponent = GetInventory()->GetComponent(); + auto playerInventoryComponent = GetInventory()->GetComponent(); if (!playerInventoryComponent) { Game::logger->LogDebug("Item", "no inventory component attached to item id %llu lot %i", this->GetId(), this->GetLot()); return; diff --git a/dGame/dInventory/ItemSet.cpp b/dGame/dInventory/ItemSet.cpp index 4dd3650be..055a96a8c 100644 --- a/dGame/dInventory/ItemSet.cpp +++ b/dGame/dInventory/ItemSet.cpp @@ -125,8 +125,8 @@ void ItemSet::OnEquip(const LOT lot) { return; } - auto* skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); - auto* missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); + auto skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); + auto missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); for (const auto skill : skillSet) { auto* skillTable = CDClientManager::Instance().GetTable(); diff --git a/dGame/dInventory/ItemSetPassiveAbility.cpp b/dGame/dInventory/ItemSetPassiveAbility.cpp index bf7c19cba..91f7c916b 100644 --- a/dGame/dInventory/ItemSetPassiveAbility.cpp +++ b/dGame/dInventory/ItemSetPassiveAbility.cpp @@ -37,8 +37,8 @@ void ItemSetPassiveAbility::Activate(Entity* target) { return; } - auto* destroyableComponent = m_Parent->GetComponent(); - auto* skillComponent = m_Parent->GetComponent(); + auto destroyableComponent = m_Parent->GetComponent(); + auto skillComponent = m_Parent->GetComponent(); if (destroyableComponent == nullptr || skillComponent == nullptr) { return; @@ -196,8 +196,8 @@ std::vector ItemSetPassiveAbility::FindAbilities(uint32_t } void ItemSetPassiveAbility::OnEnemySmshed(Entity* target) { - auto* destroyableComponent = m_Parent->GetComponent(); - auto* skillComponent = m_Parent->GetComponent(); + auto destroyableComponent = m_Parent->GetComponent(); + auto skillComponent = m_Parent->GetComponent(); if (destroyableComponent == nullptr || skillComponent == nullptr) { return; diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index afde876cd..9f77ad5e6 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -319,12 +319,12 @@ void Mission::Complete(const bool yieldRewards) { return; } - auto* characterComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackMissionCompletion(!info->isMission); } - auto* missionComponent = entity->GetComponent(); + auto missionComponent = entity->GetComponent(); missionComponent->Progress(eMissionTaskType::META, info->id); @@ -372,7 +372,7 @@ void Mission::CheckCompletion() { void Mission::Catchup() { auto* entity = GetAssociate(); - auto* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inventory = entity->GetComponent(); for (auto* task : m_Tasks) { const auto type = task->GetType(); @@ -414,11 +414,11 @@ void Mission::YieldRewards() { auto* character = GetUser()->GetLastUsedChar(); - auto* inventoryComponent = entity->GetComponent(); - auto* levelComponent = entity->GetComponent(); - auto* characterComponent = entity->GetComponent(); - auto* destroyableComponent = entity->GetComponent(); - auto* missionComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); + auto levelComponent = entity->GetComponent(); + auto characterComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); + auto missionComponent = entity->GetComponent(); // Remove mission items for (auto* task : m_Tasks) { diff --git a/dGame/dMission/MissionTask.cpp b/dGame/dMission/MissionTask.cpp index 344427c6b..6bd29bb0d 100644 --- a/dGame/dMission/MissionTask.cpp +++ b/dGame/dMission/MissionTask.cpp @@ -194,7 +194,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& return; } - auto* inventoryComponent = mission->GetAssociate()->GetComponent(); + auto inventoryComponent = mission->GetAssociate()->GetComponent(); if (inventoryComponent != nullptr) { int32_t itemCount = inventoryComponent->GetLotCountNonTransfer(value); @@ -213,7 +213,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& } Entity* entity; - ScriptedActivityComponent* activity; + std::shared_ptr activity; uint32_t activityId; uint32_t lot; uint32_t collectionId; @@ -238,7 +238,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& break; } - activity = static_cast(entity->GetComponent(eReplicaComponentType::QUICK_BUILD)); + activity = entity->GetComponent(); if (activity == nullptr) { break; } @@ -308,7 +308,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& int32_t gameID = minigameManager->GetLOT(); - auto* sac = minigameManager->GetComponent(); + auto sac = minigameManager->GetComponent(); if (sac != nullptr) { gameID = sac->GetActivityID(); } @@ -368,7 +368,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& if (entity == nullptr) break; - auto* missionComponent = entity->GetComponent(); + auto missionComponent = entity->GetComponent(); if (missionComponent == nullptr) break; diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index c4d4a2aa8..5e7b5c008 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -30,7 +30,7 @@ #include "UpdateActionMessage.h" #include "UpdateStripUiMessage.h" -void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) { +void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, std::shared_ptr modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) { // auto behavior = modelComponent->FindBehavior(behaviorID); // if (behavior->GetBehaviorID() == -1 || behavior->GetShouldSetNewID()) { // ObjectIDManager::Instance()->RequestPersistentID( @@ -57,7 +57,7 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* mode } void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner) { - auto* modelComponent = modelEntity->GetComponent(); + auto modelComponent = modelEntity->GetComponent(); if (!modelComponent) return; @@ -79,7 +79,7 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize); } -void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, ModelComponent* ModelComponent) { +void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr ModelComponent) { auto* modelTypeAmf = arguments->Get("ModelType"); if (!modelTypeAmf) return; @@ -137,7 +137,7 @@ void ControlBehaviors::Rename(Entity* modelEntity, const SystemAddress& sysAddr, } // TODO This is also supposed to serialize the state of the behaviors in progress but those aren't implemented yet -void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { +void ControlBehaviors::SendBehaviorBlocksToClient(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { // uint32_t behaviorID = ControlBehaviors::GetBehaviorIDFromArgument(arguments); // auto modelBehavior = modelComponent->FindBehavior(behaviorID); @@ -266,7 +266,7 @@ void ControlBehaviors::UpdateAction(AMFArrayValue* arguments) { } } -void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { +void ControlBehaviors::MoveToInventory(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { // This closes the UI menu should it be open while the player is removing behaviors AMFArrayValue args; @@ -281,7 +281,7 @@ void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const Sys void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& sysAddr, AMFArrayValue* arguments, std::string command, Entity* modelOwner) { if (!isInitialized || !modelEntity || !modelOwner || !arguments) return; - auto* modelComponent = modelEntity->GetComponent(); + auto modelComponent = modelEntity->GetComponent(); if (!modelComponent) return; diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.h b/dGame/dPropertyBehaviors/ControlBehaviors.h index a562aafeb..f00662580 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.h +++ b/dGame/dPropertyBehaviors/ControlBehaviors.h @@ -41,9 +41,9 @@ class ControlBehaviors: public Singleton { */ BlockDefinition* GetBlockInfo(const BlockName& blockName); private: - void RequestUpdatedID(int32_t behaviorID, ModelComponent* modelComponent, Entity* modelOwner, const SystemAddress& sysAddr); + void RequestUpdatedID(int32_t behaviorID, std::shared_ptr modelComponent, Entity* modelOwner, const SystemAddress& sysAddr); void SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner); - void ModelTypeChanged(AMFArrayValue* arguments, ModelComponent* ModelComponent); + void ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr ModelComponent); void ToggleExecutionUpdates(); void AddStrip(AMFArrayValue* arguments); void RemoveStrip(AMFArrayValue* arguments); @@ -56,9 +56,9 @@ class ControlBehaviors: public Singleton { void Add(AMFArrayValue* arguments); void RemoveActions(AMFArrayValue* arguments); void Rename(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); - void SendBehaviorBlocksToClient(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); + void SendBehaviorBlocksToClient(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); void UpdateAction(AMFArrayValue* arguments); - void MoveToInventory(ModelComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); + void MoveToInventory(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments); std::map blockTypes{}; // If false, property behaviors will not be able to be edited. diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index c788c0164..217a614c0 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -137,7 +137,7 @@ LootGenerator::LootGenerator() { } std::unordered_map LootGenerator::RollLootMatrix(Entity* player, uint32_t matrixIndex) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); std::unordered_map drops; @@ -283,7 +283,7 @@ void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceTy void LootGenerator::GiveLoot(Entity* player, std::unordered_map& result, eLootSourceType lootSourceType) { player = player->GetOwner(); // if the owner is overwritten, we collect that here - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (!inventoryComponent) return; @@ -330,7 +330,7 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) { player = player->GetOwner(); // if the owner is overwritten, we collect that here - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (!inventoryComponent) return; @@ -343,7 +343,7 @@ void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matr void LootGenerator::DropLoot(Entity* player, Entity* killedObject, std::unordered_map& result, uint32_t minCoins, uint32_t maxCoins) { player = player->GetOwner(); // if the owner is overwritten, we collect that here - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (!inventoryComponent) return; diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index 5dc55765f..e538a47a6 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -197,7 +197,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd //Inventory::InventoryType itemType; int mailCost = dZoneManager::Instance()->GetWorldConfig()->mailBaseFee; int stackSize = 0; - auto inv = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = entity->GetComponent(); Item* item = nullptr; if (itemID > 0 && attachmentCount > 0 && inv) { @@ -267,7 +267,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd Game::logger->Log("Mail", "Trying to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); inv->RemoveItem(itemLOT, attachmentCount, INVALID, true); - auto* missionCompoent = entity->GetComponent(); + auto missionCompoent = entity->GetComponent(); if (missionCompoent != nullptr) { missionCompoent->Progress(eMissionTaskType::GATHER, itemLOT, LWOOBJID_EMPTY, "", -attachmentCount); @@ -356,7 +356,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres attachmentCount = res->getInt(2); } - auto inv = static_cast(player->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = player->GetComponent(); if (!inv) return; inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::MAIL); diff --git a/dGame/dUtilities/Preconditions.cpp b/dGame/dUtilities/Preconditions.cpp index 8602586cb..48a95ee2c 100644 --- a/dGame/dUtilities/Preconditions.cpp +++ b/dGame/dUtilities/Preconditions.cpp @@ -115,10 +115,10 @@ bool Precondition::Check(Entity* player, bool evaluateCosts) const { bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluateCosts) const { - auto* missionComponent = player->GetComponent(); - auto* inventoryComponent = player->GetComponent(); - auto* destroyableComponent = player->GetComponent(); - auto* levelComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); + auto levelComponent = player->GetComponent(); auto* character = player->GetCharacter(); Mission* mission; diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index b65bf7231..97aec5e5d 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -176,7 +176,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (chatCommand == "pvp") { - auto* character = entity->GetComponent(); + auto character = entity->GetComponent(); if (character == nullptr) { Game::logger->Log("SlashCommandHandler", "Failed to find character component!"); @@ -227,9 +227,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (chatCommand == "fix-stats") { // Reset skill component and buff component - auto* skillComponent = entity->GetComponent(); - auto* buffComponent = entity->GetComponent(); - auto* destroyableComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); // If any of the components are nullptr, return if (skillComponent == nullptr || buffComponent == nullptr || destroyableComponent == nullptr) { @@ -336,7 +336,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "resurrect") { - ScriptedActivityComponent* scriptedActivityComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent(); + auto scriptedActivityComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent(); if (scriptedActivityComponent) { // check if user is in activity world and if so, they can't resurrect ChatPackets::SendSystemMessage(sysAddr, u"You cannot resurrect in an activity world."); @@ -373,7 +373,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } EntityManager::Instance()->DestructEntity(entity, sysAddr); - auto* charComp = entity->GetComponent(); + auto charComp = entity->GetComponent(); std::string lowerName = args[0]; if (lowerName.empty()) return; std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower); @@ -413,7 +413,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size()); RenderComponent::PlayAnimation(entity, anim); - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); if (possessorComponent) { auto* possessedComponent = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); if (possessedComponent) RenderComponent::PlayAnimation(possessedComponent, anim); @@ -468,7 +468,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - auto* controllablePhysicsComponent = entity->GetComponent(); + auto controllablePhysicsComponent = entity->GetComponent(); if (!controllablePhysicsComponent) return; controllablePhysicsComponent->SetSpeedMultiplier(boost); @@ -480,7 +480,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (possessedID != LWOOBJID_EMPTY) { auto possessable = EntityManager::Instance()->GetEntity(possessedID); if (possessable) { - auto* possessControllablePhysicsComponent = possessable->GetComponent(); + auto possessControllablePhysicsComponent = possessable->GetComponent(); if (possessControllablePhysicsComponent) { possessControllablePhysicsComponent->SetSpeedMultiplier(boost); } @@ -579,7 +579,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit GeneralUtils::to_u16string(size)); } else ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory ITEMS to size " + GeneralUtils::to_u16string(size)); - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent) { auto* inventory = inventoryComponent->GetInventory(selectedInventory); @@ -629,7 +629,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - auto comp = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto comp = entity->GetComponent(); if (comp) comp->AcceptMission(missionID, true); return; } @@ -644,7 +644,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - auto comp = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto comp = entity->GetComponent(); if (comp) comp->CompleteMission(missionID, true); return; } @@ -694,7 +694,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - auto* comp = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); + auto comp = entity->GetComponent(); if (comp == nullptr) { return; @@ -771,7 +771,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "getnavmeshheight" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto control = static_cast(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); + auto control = entity->GetComponent(); if (!control) return; float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(control->GetPosition()); @@ -788,7 +788,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - InventoryComponent* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inventory = entity->GetComponent(); inventory->AddItem(itemLOT, 1, eLootSourceType::MODERATION); } else if (args.size() == 2) { @@ -806,7 +806,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - InventoryComponent* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); + auto inventory = entity->GetComponent(); inventory->AddItem(itemLOT, count, eLootSourceType::MODERATION); } else { @@ -935,12 +935,12 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); if (possessorComponent) { auto* possassableEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); if (possassableEntity != nullptr) { - auto* vehiclePhysicsComponent = possassableEntity->GetComponent(); + auto vehiclePhysicsComponent = possassableEntity->GetComponent(); if (vehiclePhysicsComponent) { vehiclePhysicsComponent->SetPosition(pos); EntityManager::Instance()->SerializeEntity(possassableEntity); @@ -962,7 +962,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "dismount" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); if (possessorComponent) { auto possessableId = possessorComponent->GetPossessable(); if (possessableId != LWOOBJID_EMPTY) { @@ -1171,7 +1171,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit //------------------------------------------------- if (chatCommand == "buffme" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto dest = entity->GetComponent(); if (dest) { dest->SetHealth(999); dest->SetMaxHealth(999.0f); @@ -1195,7 +1195,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "buffmed" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto dest = entity->GetComponent(); if (dest) { dest->SetHealth(9); dest->SetMaxHealth(9.0f); @@ -1209,7 +1209,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (chatCommand == "refillstats" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto dest = entity->GetComponent(); if (dest) { dest->SetHealth((int)dest->GetMaxHealth()); dest->SetArmor((int)dest->GetMaxArmor()); @@ -1242,7 +1242,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "spawn" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) { - ControllablePhysicsComponent* comp = static_cast(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); + auto comp = entity->GetComponent(); if (!comp) return; uint32_t lot; @@ -1341,7 +1341,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - CharacterComponent* character = entity->GetComponent(); + auto character = entity->GetComponent(); if (character) character->SetUScore(character->GetUScore() + uscore); // MODERATION should work but it doesn't. Relog to see uscore changes @@ -1486,7 +1486,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "gmimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); int32_t state = false; @@ -1503,7 +1503,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "buff" && args.size() >= 2 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto* buffComponent = entity->GetComponent(); + auto buffComponent = entity->GetComponent(); int32_t id = 0; int32_t duration = 0; @@ -1615,7 +1615,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if ((chatCommand == "boost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); if (possessorComponent == nullptr) { return; @@ -1647,7 +1647,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if ((chatCommand == "unboost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - auto* possessorComponent = entity->GetComponent(); + auto possessorComponent = entity->GetComponent(); if (possessorComponent == nullptr) return; auto* vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); @@ -1674,7 +1674,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit //Go tell physics to spawn all the vertices: auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PHANTOM_PHYSICS); for (auto en : entities) { - auto phys = static_cast(en->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS)); + auto phys = en->GetComponent(); if (phys) phys->SpawnVertices(); } @@ -1683,7 +1683,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (chatCommand == "reportproxphys" && entity->GetGMLevel() >= eGameMasterLevel::JUNIOR_DEVELOPER) { auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PROXIMITY_MONITOR); for (auto en : entities) { - auto phys = static_cast(en->GetComponent(eReplicaComponentType::PROXIMITY_MONITOR)); + auto phys = en->GetComponent(); if (phys) { for (auto prox : phys->GetProximitiesData()) { if (!prox.second) continue; @@ -1717,7 +1717,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (!GeneralUtils::TryParse(args[0], baseItem)) return; if (!GeneralUtils::TryParse(args[1], reforgedItem)) return; - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent == nullptr) return; @@ -1779,7 +1779,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit dpWorld::Instance().Reload(); auto entities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); for (auto entity : entities) { - auto* scriptedActivityComponent = entity->GetComponent(); + auto scriptedActivityComponent = entity->GetComponent(); if (!scriptedActivityComponent) continue; scriptedActivityComponent->ReloadConfig(); @@ -1842,7 +1842,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (!inventoryComponent) return; auto* inventoryToDelete = inventoryComponent->GetInventory(inventoryType); @@ -1930,7 +1930,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (args.size() >= 2) { if (args[1] == "-m" && args.size() >= 3) { - auto* movingPlatformComponent = closest->GetComponent(); + auto movingPlatformComponent = closest->GetComponent(); int32_t value = 0; @@ -1964,7 +1964,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit GeneralUtils::ASCIIToUTF16("< " + std::to_string(postion.x) + ", " + std::to_string(postion.y) + ", " + std::to_string(postion.z) + " >") ); } else if (args[1] == "-f") { - auto* destuctable = closest->GetComponent(); + auto destuctable = closest->GetComponent(); if (destuctable == nullptr) { ChatPackets::SendSystemMessage(sysAddr, u"No destroyable component on this entity!"); @@ -1993,7 +1993,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit destuctable->AddFaction(faction, true); } } else if (args[1] == "-t") { - auto* phantomPhysicsComponent = closest->GetComponent(); + auto phantomPhysicsComponent = closest->GetComponent(); if (phantomPhysicsComponent != nullptr) { ChatPackets::SendSystemMessage(sysAddr, u"Type: " + (GeneralUtils::to_u16string(static_cast(phantomPhysicsComponent->GetEffectType())))); @@ -2003,7 +2003,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit ChatPackets::SendSystemMessage(sysAddr, u"Active: " + (GeneralUtils::to_u16string(phantomPhysicsComponent->GetPhysicsEffectActive()))); } - auto* triggerComponent = closest->GetComponent(); + auto triggerComponent = closest->GetComponent(); if (triggerComponent) { auto trigger = triggerComponent->GetTrigger(); if (trigger) { diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index 7fabfbce0..0bb8dfa85 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -117,7 +117,7 @@ void VanityUtilities::SpawnVanity() { npcEntity->SetVar>(u"chats", npc.m_Phrases); - auto* scriptComponent = npcEntity->GetComponent(); + auto scriptComponent = npcEntity->GetComponent(); if (scriptComponent != nullptr) { scriptComponent->SetScript(npc.m_Script); @@ -161,13 +161,13 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin auto* entity = EntityManager::Instance()->CreateEntity(info); entity->SetVar(u"npcName", name); - auto* inventoryComponent = entity->GetComponent(); + auto inventoryComponent = entity->GetComponent(); if (inventoryComponent != nullptr) { inventoryComponent->SetNPCItems(inventory); } - auto* destroyableComponent = entity->GetComponent(); + auto destroyableComponent = entity->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetIsGMImmune(true); @@ -519,7 +519,7 @@ void VanityUtilities::SetupNPCTalk(Entity* npc) { } void VanityUtilities::NPCTalk(Entity* npc) { - auto* proximityMonitorComponent = npc->GetComponent(); + auto proximityMonitorComponent = npc->GetComponent(); if (!proximityMonitorComponent->GetProximityObjects("talk").empty()) { const auto& chats = npc->GetVar>(u"chats"); diff --git a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp index a51af03ad..33caa4741 100644 --- a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp +++ b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp @@ -29,9 +29,9 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) { //self:SetStatusImmunity{ StateChangeType = "PUSH", bImmuneToPullToPoint = true, bImmuneToKnockback = true, bImmuneToInterrupt = true } //Get our components: - destroyable = static_cast(self->GetComponent(eReplicaComponentType::DESTROYABLE)); - controllable = static_cast(self->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); - combat = static_cast(self->GetComponent(eReplicaComponentType::BASE_COMBAT_AI)); + auto destroyable = self->GetComponent(); + auto controllable = self->GetComponent(); + auto combat = self->GetComponent(); if (!destroyable || !controllable) return; @@ -53,7 +53,7 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) { void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) { if (dZoneManager::Instance()->GetZoneID().GetMapID() == instanceZoneID) { - auto* missionComponent = killer->GetComponent(); + auto missionComponent = killer->GetComponent(); if (missionComponent == nullptr) return; @@ -99,7 +99,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra EntityManager::Instance()->SerializeEntity(self); - auto* baseCombatAi = self->GetComponent(); + auto baseCombatAi = self->GetComponent(); baseCombatAi->SetDisabled(true); @@ -123,7 +123,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra //Cancel all remaining timers for say idle anims: self->CancelAllTimers(); - auto* baseCombatAi = self->GetComponent(); + auto baseCombatAi = self->GetComponent(); baseCombatAi->SetDisabled(false); @@ -314,7 +314,7 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self) { return; } - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); if (skillComponent == nullptr) { Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact skill component!"); @@ -347,7 +347,7 @@ void BossSpiderQueenEnemyServer::RapidFireShooterManager(Entity* self) { const auto target = attackTargetTable[0]; - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); skillComponent->CalculateBehavior(1394, 32612, target, true); @@ -381,7 +381,7 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) { attackTargetTable.push_back(attackFocus); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); skillComponent->CalculateBehavior(1480, 36652, attackFocus, true); @@ -493,14 +493,14 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim auto landingTarget = self->GetI64(u"LandingTarget"); auto landingEntity = EntityManager::Instance()->GetEntity(landingTarget); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY); } if (landingEntity) { - auto* landingSkill = landingEntity->GetComponent(); + auto landingSkill = landingEntity->GetComponent(); if (landingSkill != nullptr) { landingSkill->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY, true); diff --git a/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp b/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp index ff30f8e84..19dfc4f15 100644 --- a/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp +++ b/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp @@ -12,7 +12,7 @@ void AmDarklingDragon::OnStartup(Entity* self) { self->SetVar(u"weakspot", 0); - auto* baseCombatAIComponent = self->GetComponent(); + auto baseCombatAIComponent = self->GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->SetStunImmune(true); @@ -46,7 +46,7 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t } } - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr) { if (destroyableComponent->GetArmor() > 0) return; @@ -56,8 +56,8 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t if (weakpoint == 0) { self->AddTimer("ReviveTimer", 12); - auto* baseCombatAIComponent = self->GetComponent(); - auto* skillComponent = self->GetComponent(); + auto baseCombatAIComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->SetDisabled(true); @@ -127,8 +127,8 @@ void AmDarklingDragon::OnTimerDone(Entity* self, std::string timerName) { RenderComponent::PlayAnimation(self, u"stunend", 2.0f); self->AddTimer("backToAttack", 1); } else if (timerName == "backToAttack") { - auto* baseCombatAIComponent = self->GetComponent(); - auto* skillComponent = self->GetComponent(); + auto baseCombatAIComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->SetDisabled(false); baseCombatAIComponent->SetStunned(false); diff --git a/dScripts/02_server/Enemy/AM/AmSkeletonEngineer.cpp b/dScripts/02_server/Enemy/AM/AmSkeletonEngineer.cpp index a49727295..af1fc481f 100644 --- a/dScripts/02_server/Enemy/AM/AmSkeletonEngineer.cpp +++ b/dScripts/02_server/Enemy/AM/AmSkeletonEngineer.cpp @@ -3,8 +3,8 @@ #include "SkillComponent.h" void AmSkeletonEngineer::OnHit(Entity* self, Entity* attacker) { - auto* destroyableComponent = self->GetComponent(); - auto* skillComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (destroyableComponent == nullptr || skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp b/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp index 664d8b67e..5be38acef 100644 --- a/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp +++ b/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp @@ -10,7 +10,7 @@ void FvMaelstromDragon::OnStartup(Entity* self) { self->SetVar(u"weakspot", 0); - auto* baseCombatAIComponent = self->GetComponent(); + auto baseCombatAIComponent = self->GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->SetStunImmune(true); @@ -59,7 +59,7 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_ } } - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr) { if (destroyableComponent->GetArmor() > 0) return; @@ -71,8 +71,8 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_ self->AddTimer("ReviveTimer", 12); - auto* baseCombatAIComponent = self->GetComponent(); - auto* skillComponent = self->GetComponent(); + auto baseCombatAIComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->SetDisabled(true); @@ -143,8 +143,8 @@ void FvMaelstromDragon::OnTimerDone(Entity* self, std::string timerName) { RenderComponent::PlayAnimation(self, u"stunend", 2.0f); self->AddTimer("backToAttack", 1.0f); } else if (timerName == "backToAttack") { - auto* baseCombatAIComponent = self->GetComponent(); - auto* skillComponent = self->GetComponent(); + auto baseCombatAIComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->SetDisabled(false); diff --git a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp index 19a6490a1..029cf6331 100644 --- a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp +++ b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp @@ -31,11 +31,11 @@ void BaseEnemyApe::OnSkillCast(Entity* self, uint32_t skillID) { } void BaseEnemyApe::OnHit(Entity* self, Entity* attacker) { - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr && destroyableComponent->GetArmor() < 1 && !self->GetBoolean(u"knockedOut")) { StunApe(self, true); self->CancelTimer("spawnQBTime"); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent) { skillComponent->Reset(); } @@ -52,7 +52,7 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) { // Revives the ape, giving it back some armor const auto timesStunned = self->GetVar(u"timesStunned"); - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor() / timesStunned); } @@ -104,7 +104,7 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) { return; } - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(1273, 29446, self->GetObjectID(), true, false, player->GetObjectID()); } @@ -123,12 +123,12 @@ void BaseEnemyApe::OnFireEventServerSide(Entity* self, Entity* sender, std::stri } void BaseEnemyApe::StunApe(Entity* self, bool stunState) { - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(stunState); combatAIComponent->SetStunned(stunState); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->Interrupt(); } diff --git a/dScripts/02_server/Enemy/General/BaseEnemyMech.cpp b/dScripts/02_server/Enemy/General/BaseEnemyMech.cpp index ce42585c2..5ab92a46a 100644 --- a/dScripts/02_server/Enemy/General/BaseEnemyMech.cpp +++ b/dScripts/02_server/Enemy/General/BaseEnemyMech.cpp @@ -9,14 +9,14 @@ #include "eReplicaComponentType.h" void BaseEnemyMech::OnStartup(Entity* self) { - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetFaction(4); } } void BaseEnemyMech::OnDie(Entity* self, Entity* killer) { - ControllablePhysicsComponent* controlPhys = static_cast(self->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); + auto controlPhys = self->GetComponent(); if (!controlPhys) return; NiPoint3 newLoc = { controlPhys->GetPosition().x, dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(controlPhys->GetPosition()), controlPhys->GetPosition().z }; diff --git a/dScripts/02_server/Enemy/General/EnemyNjBuff.cpp b/dScripts/02_server/Enemy/General/EnemyNjBuff.cpp index 07b2d8991..949f3eaff 100644 --- a/dScripts/02_server/Enemy/General/EnemyNjBuff.cpp +++ b/dScripts/02_server/Enemy/General/EnemyNjBuff.cpp @@ -2,7 +2,7 @@ #include "SkillComponent.h" void EnemyNjBuff::OnStartup(Entity* self) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Enemy/General/TreasureChestDragonServer.cpp b/dScripts/02_server/Enemy/General/TreasureChestDragonServer.cpp index 197886772..de42cfc98 100644 --- a/dScripts/02_server/Enemy/General/TreasureChestDragonServer.cpp +++ b/dScripts/02_server/Enemy/General/TreasureChestDragonServer.cpp @@ -15,7 +15,7 @@ void TreasureChestDragonServer::OnUse(Entity* self, Entity* user) { self->SetVar(u"bUsed", true); - auto* scriptedActivityComponent = self->GetComponent(); + auto scriptedActivityComponent = self->GetComponent(); if (scriptedActivityComponent == nullptr) { return; diff --git a/dScripts/02_server/Enemy/Survival/AgSurvivalMech.cpp b/dScripts/02_server/Enemy/Survival/AgSurvivalMech.cpp index 99f40b8b8..d1df92f44 100644 --- a/dScripts/02_server/Enemy/Survival/AgSurvivalMech.cpp +++ b/dScripts/02_server/Enemy/Survival/AgSurvivalMech.cpp @@ -4,7 +4,7 @@ void AgSurvivalMech::OnStartup(Entity* self) { BaseWavesGenericEnemy::OnStartup(self); - auto* destroyable = self->GetComponent(); + auto destroyable = self->GetComponent(); if (destroyable != nullptr) { destroyable->SetFaction(4); } diff --git a/dScripts/02_server/Enemy/Survival/AgSurvivalSpiderling.cpp b/dScripts/02_server/Enemy/Survival/AgSurvivalSpiderling.cpp index 8e2c173cb..82bee2b59 100644 --- a/dScripts/02_server/Enemy/Survival/AgSurvivalSpiderling.cpp +++ b/dScripts/02_server/Enemy/Survival/AgSurvivalSpiderling.cpp @@ -4,7 +4,7 @@ void AgSurvivalSpiderling::OnStartup(Entity* self) { BaseWavesGenericEnemy::OnStartup(self); - auto* combatAI = self->GetComponent(); + auto combatAI = self->GetComponent(); if (combatAI != nullptr) { combatAI->SetStunImmune(true); } diff --git a/dScripts/02_server/Enemy/Waves/WaveBossApe.cpp b/dScripts/02_server/Enemy/Waves/WaveBossApe.cpp index 7c26cec15..359b37eec 100644 --- a/dScripts/02_server/Enemy/Waves/WaveBossApe.cpp +++ b/dScripts/02_server/Enemy/Waves/WaveBossApe.cpp @@ -11,7 +11,7 @@ void WaveBossApe::OnStartup(Entity* self) { self->SetVar(u"AnchorDamageDelayTime", 0.5f); self->SetVar(u"spawnQBTime", 5.0f); - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(true); combatAIComponent->SetStunImmune(true); @@ -30,7 +30,7 @@ void WaveBossApe::OnDie(Entity* self, Entity* killer) { void WaveBossApe::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "startAI") { - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(false); combatAIComponent->SetStunImmune(false); diff --git a/dScripts/02_server/Enemy/Waves/WaveBossHammerling.cpp b/dScripts/02_server/Enemy/Waves/WaveBossHammerling.cpp index 4fa780879..fcbe1d4c4 100644 --- a/dScripts/02_server/Enemy/Waves/WaveBossHammerling.cpp +++ b/dScripts/02_server/Enemy/Waves/WaveBossHammerling.cpp @@ -5,7 +5,7 @@ void WaveBossHammerling::OnStartup(Entity* self) { BaseWavesGenericEnemy::OnStartup(self); - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(true); combatAIComponent->SetStunImmune(true); @@ -17,7 +17,7 @@ void WaveBossHammerling::OnStartup(Entity* self) { void WaveBossHammerling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "startAI") { - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(false); } diff --git a/dScripts/02_server/Enemy/Waves/WaveBossHorsemen.cpp b/dScripts/02_server/Enemy/Waves/WaveBossHorsemen.cpp index 238544ab7..fb685ef8f 100644 --- a/dScripts/02_server/Enemy/Waves/WaveBossHorsemen.cpp +++ b/dScripts/02_server/Enemy/Waves/WaveBossHorsemen.cpp @@ -5,7 +5,7 @@ void WaveBossHorsemen::OnStartup(Entity* self) { BaseWavesGenericEnemy::OnStartup(self); - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(true); combatAIComponent->SetStunImmune(true); @@ -18,7 +18,7 @@ void WaveBossHorsemen::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "startAI") { - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(false); } diff --git a/dScripts/02_server/Enemy/Waves/WaveBossSpiderling.cpp b/dScripts/02_server/Enemy/Waves/WaveBossSpiderling.cpp index ec282ff44..908d29b7e 100644 --- a/dScripts/02_server/Enemy/Waves/WaveBossSpiderling.cpp +++ b/dScripts/02_server/Enemy/Waves/WaveBossSpiderling.cpp @@ -5,7 +5,7 @@ void WaveBossSpiderling::OnStartup(Entity* self) { BaseWavesGenericEnemy::OnStartup(self); - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(true); combatAIComponent->SetStunImmune(true); @@ -17,7 +17,7 @@ void WaveBossSpiderling::OnStartup(Entity* self) { void WaveBossSpiderling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "startAI") { - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(false); combatAIComponent->SetStunImmune(false); diff --git a/dScripts/02_server/Equipment/BootyDigServer.cpp b/dScripts/02_server/Equipment/BootyDigServer.cpp index 190c232b0..d13557819 100644 --- a/dScripts/02_server/Equipment/BootyDigServer.cpp +++ b/dScripts/02_server/Equipment/BootyDigServer.cpp @@ -35,13 +35,13 @@ BootyDigServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string // Make sure players only dig up one booty per instance player->SetVar(u"bootyDug", true); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { auto* mission = missionComponent->GetMission(1881); if (mission != nullptr && (mission->GetMissionState() == eMissionState::ACTIVE || mission->GetMissionState() == eMissionState::COMPLETE_ACTIVE)) { mission->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) renderComponent->PlayEffect(7730, u"cast", "bootyshine"); diff --git a/dScripts/02_server/Map/AG/AgBugsprayer.cpp b/dScripts/02_server/Map/AG/AgBugsprayer.cpp index d4ab7aa3e..c3da26384 100644 --- a/dScripts/02_server/Map/AG/AgBugsprayer.cpp +++ b/dScripts/02_server/Map/AG/AgBugsprayer.cpp @@ -8,7 +8,7 @@ void AgBugsprayer::OnRebuildComplete(Entity* self, Entity* target) { void AgBugsprayer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "castSkill") { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) return; diff --git a/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp b/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp index 13c9c04b6..b732a7f4e 100644 --- a/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp +++ b/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp @@ -21,7 +21,7 @@ void AgCagedBricksServer::OnUse(Entity* self, Entity* user) { character->SetPlayerFlag(ePlayerFlag::CAGED_SPIDER, true); //Remove the maelstrom cube: - auto inv = static_cast(user->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = user->GetComponent(); if (inv) { inv->RemoveItem(14553, 1); diff --git a/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp b/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp index 7fcea9fa9..effc523b8 100644 --- a/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp +++ b/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp @@ -8,7 +8,7 @@ void AgLaserSensorServer::OnStartup(Entity* self) { self->SetBoolean(u"active", true); auto repelForce = self->GetVarAs(u"repelForce"); if (!repelForce) repelForce = m_RepelForce; - auto* phantomPhysicsComponent = self->GetComponent(); + auto phantomPhysicsComponent = self->GetComponent(); if (!phantomPhysicsComponent) return; phantomPhysicsComponent->SetPhysicsEffectActive(true); phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE); @@ -22,7 +22,7 @@ void AgLaserSensorServer::OnCollisionPhantom(Entity* self, Entity* target) { if (!active) return; auto skillCastID = self->GetVarAs(u"skillCastID"); if (skillCastID == 0) skillCastID = m_SkillCastID; - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (!skillComponent) return; skillComponent->CastSkill(m_SkillCastID, target->GetObjectID()); } diff --git a/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp b/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp index d2cc647e6..7f8f97ec4 100644 --- a/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp +++ b/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp @@ -13,7 +13,7 @@ void NpcAgCourseStarter::OnStartup(Entity* self) { } void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) { - auto* scriptedActivityComponent = self->GetComponent(); + auto scriptedActivityComponent = self->GetComponent(); if (scriptedActivityComponent == nullptr) { return; @@ -27,7 +27,7 @@ void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) { } void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { - auto* scriptedActivityComponent = self->GetComponent(); + auto scriptedActivityComponent = self->GetComponent(); if (scriptedActivityComponent == nullptr) { return; @@ -70,7 +70,7 @@ void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int3 void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { - auto* scriptedActivityComponent = self->GetComponent(); + auto scriptedActivityComponent = self->GetComponent(); if (scriptedActivityComponent == nullptr) return; @@ -88,7 +88,7 @@ void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std data->values[2] = *(float*)&finish; - auto* missionComponent = sender->GetComponent(); + auto missionComponent = sender->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgressTaskType(1884, 1, 1, false); missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, -finish, self->GetObjectID(), diff --git a/dScripts/02_server/Map/AG/NpcCowboyServer.cpp b/dScripts/02_server/Map/AG/NpcCowboyServer.cpp index 6dd212a46..ee42ffd36 100644 --- a/dScripts/02_server/Map/AG/NpcCowboyServer.cpp +++ b/dScripts/02_server/Map/AG/NpcCowboyServer.cpp @@ -7,7 +7,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss return; } - auto* inventoryComponent = target->GetComponent(); + auto inventoryComponent = target->GetComponent(); if (inventoryComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AG/NpcNjAssistantServer.cpp b/dScripts/02_server/Map/AG/NpcNjAssistantServer.cpp index 8ee2e9889..a606c5810 100644 --- a/dScripts/02_server/Map/AG/NpcNjAssistantServer.cpp +++ b/dScripts/02_server/Map/AG/NpcNjAssistantServer.cpp @@ -12,7 +12,7 @@ void NpcNjAssistantServer::OnMissionDialogueOK(Entity* self, Entity* target, int if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"switch", 0, 0, LWOOBJID_EMPTY, "", target->GetSystemAddress()); - auto* inv = static_cast(target->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = target->GetComponent(); // If we are ready to complete our missions, we take the kit from you: if (inv && missionState == eMissionState::READY_TO_COMPLETE) { @@ -23,7 +23,7 @@ void NpcNjAssistantServer::OnMissionDialogueOK(Entity* self, Entity* target, int } } } else if (missionState == eMissionState::AVAILABLE) { - auto* missionComponent = static_cast(target->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = target->GetComponent(); missionComponent->CompleteMission(mailAchievement, true); } } diff --git a/dScripts/02_server/Map/AG/NpcPirateServer.cpp b/dScripts/02_server/Map/AG/NpcPirateServer.cpp index cad0d64c6..2bda80a27 100644 --- a/dScripts/02_server/Map/AG/NpcPirateServer.cpp +++ b/dScripts/02_server/Map/AG/NpcPirateServer.cpp @@ -3,7 +3,7 @@ #include "InventoryComponent.h" void NpcPirateServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { - auto* inventory = target->GetComponent(); + auto inventory = target->GetComponent(); if (inventory != nullptr && missionID == 1881) { auto* luckyShovel = inventory->FindItemByLot(14591); diff --git a/dScripts/02_server/Map/AG/NpcWispServer.cpp b/dScripts/02_server/Map/AG/NpcWispServer.cpp index 84196c8c0..2ab6f7a07 100644 --- a/dScripts/02_server/Map/AG/NpcWispServer.cpp +++ b/dScripts/02_server/Map/AG/NpcWispServer.cpp @@ -9,7 +9,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio if (missionID != 1849 && missionID != 1883) return; - auto* inventory = target->GetComponent(); + auto inventory = target->GetComponent(); if (inventory == nullptr) return; diff --git a/dScripts/02_server/Map/AG/RemoveRentalGear.cpp b/dScripts/02_server/Map/AG/RemoveRentalGear.cpp index f9bdf1ce0..1ee305ec7 100644 --- a/dScripts/02_server/Map/AG/RemoveRentalGear.cpp +++ b/dScripts/02_server/Map/AG/RemoveRentalGear.cpp @@ -23,7 +23,7 @@ void RemoveRentalGear::OnMissionDialogueOK(Entity* self, Entity* target, int mis if (missionID != defaultMission && missionID != 313) return; if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) { - auto inv = static_cast(target->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = target->GetComponent(); if (!inv) return; //remove the inventory items diff --git a/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp b/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp index 2711b179d..29e068a73 100644 --- a/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp +++ b/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp @@ -28,7 +28,7 @@ void ZoneAgSpiderQueen::BasePlayerLoaded(Entity* self, Entity* player) { ActivityManager::TakeActivityCost(self, player->GetObjectID()); // Make sure the player has full stats when they join - auto* playerDestroyableComponent = player->GetComponent(); + auto playerDestroyableComponent = player->GetComponent(); if (playerDestroyableComponent != nullptr) { playerDestroyableComponent->SetImagination(playerDestroyableComponent->GetMaxImagination()); playerDestroyableComponent->SetArmor(playerDestroyableComponent->GetMaxArmor()); diff --git a/dScripts/02_server/Map/AM/AmBlueX.cpp b/dScripts/02_server/Map/AM/AmBlueX.cpp index 8e32694c6..4e9426eeb 100644 --- a/dScripts/02_server/Map/AM/AmBlueX.cpp +++ b/dScripts/02_server/Map/AM/AmBlueX.cpp @@ -5,7 +5,7 @@ #include "Character.h" void AmBlueX::OnUse(Entity* self, Entity* user) { - auto* skillComponent = user->GetComponent(); + auto skillComponent = user->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(m_SwordSkill, m_SwordBehavior, self->GetObjectID()); } @@ -37,7 +37,7 @@ void AmBlueX::OnSkillEventFired(Entity* self, Entity* caster, const std::string& self->AddCallbackTimer(m_BombTime, [this, self, fxObjectID, playerID]() { auto* fxObject = EntityManager::Instance()->GetEntity(fxObjectID); auto* player = EntityManager::Instance()->GetEntity(playerID); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) return; diff --git a/dScripts/02_server/Map/AM/AmDrawBridge.cpp b/dScripts/02_server/Map/AM/AmDrawBridge.cpp index 3c4dcce69..a18315622 100644 --- a/dScripts/02_server/Map/AM/AmDrawBridge.cpp +++ b/dScripts/02_server/Map/AM/AmDrawBridge.cpp @@ -60,7 +60,7 @@ void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) { self->SetNetworkVar(u"BridgeLeaving", false); - auto* simplePhysicsComponent = bridge->GetComponent(); + auto simplePhysicsComponent = bridge->GetComponent(); if (simplePhysicsComponent == nullptr) { return; @@ -87,7 +87,7 @@ void AmDrawBridge::OnNotifyObject(Entity* self, Entity* sender, const std::strin } void AmDrawBridge::MoveBridgeDown(Entity* self, Entity* bridge, bool down) { - auto* simplePhysicsComponent = bridge->GetComponent(); + auto simplePhysicsComponent = bridge->GetComponent(); if (simplePhysicsComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AM/AmDropshipComputer.cpp b/dScripts/02_server/Map/AM/AmDropshipComputer.cpp index f23fa93fb..d5c28eac1 100644 --- a/dScripts/02_server/Map/AM/AmDropshipComputer.cpp +++ b/dScripts/02_server/Map/AM/AmDropshipComputer.cpp @@ -10,14 +10,14 @@ void AmDropshipComputer::OnStartup(Entity* self) { } void AmDropshipComputer::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { return; } - auto* missionComponent = user->GetComponent(); - auto* inventoryComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); + auto inventoryComponent = user->GetComponent(); if (missionComponent == nullptr || inventoryComponent == nullptr) { return; @@ -70,7 +70,7 @@ void AmDropshipComputer::OnDie(Entity* self, Entity* killer) { } void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AM/AmScrollReaderServer.cpp b/dScripts/02_server/Map/AM/AmScrollReaderServer.cpp index cb8a7dba6..cb7aabd15 100644 --- a/dScripts/02_server/Map/AM/AmScrollReaderServer.cpp +++ b/dScripts/02_server/Map/AM/AmScrollReaderServer.cpp @@ -3,7 +3,7 @@ void AmScrollReaderServer::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { if (identifier == u"story_end") { - auto* missionComponent = sender->GetComponent(); + auto missionComponent = sender->GetComponent(); if (missionComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AM/AmShieldGenerator.cpp b/dScripts/02_server/Map/AM/AmShieldGenerator.cpp index 5d1b7d086..977159546 100644 --- a/dScripts/02_server/Map/AM/AmShieldGenerator.cpp +++ b/dScripts/02_server/Map/AM/AmShieldGenerator.cpp @@ -15,7 +15,7 @@ void AmShieldGenerator::OnStartup(Entity* self) { } void AmShieldGenerator::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - auto* destroyableComponent = entering->GetComponent(); + auto destroyableComponent = entering->GetComponent(); if (status == "ENTER" && name == "shield") { if (destroyableComponent->HasFaction(4)) { @@ -102,7 +102,7 @@ void AmShieldGenerator::StartShield(Entity* self) { } void AmShieldGenerator::BuffPlayers(Entity* self) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) { return; @@ -122,8 +122,8 @@ void AmShieldGenerator::BuffPlayers(Entity* self) { } void AmShieldGenerator::EnemyEnteredShield(Entity* self, Entity* intruder) { - auto* baseCombatAIComponent = intruder->GetComponent(); - auto* movementAIComponent = intruder->GetComponent(); + auto baseCombatAIComponent = intruder->GetComponent(); + auto movementAIComponent = intruder->GetComponent(); if (baseCombatAIComponent == nullptr || movementAIComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp index 381c13bcb..09c5e18e5 100644 --- a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp +++ b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp @@ -15,7 +15,7 @@ void AmShieldGeneratorQuickbuild::OnStartup(Entity* self) { } void AmShieldGeneratorQuickbuild::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - auto* destroyableComponent = entering->GetComponent(); + auto destroyableComponent = entering->GetComponent(); if (name == "shield") { if (!destroyableComponent->HasFaction(4) || entering->IsPlayer()) { @@ -122,7 +122,7 @@ void AmShieldGeneratorQuickbuild::OnRebuildComplete(Entity* self, Entity* target continue; } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) { return; @@ -154,7 +154,7 @@ void AmShieldGeneratorQuickbuild::StartShield(Entity* self) { } void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) { return; @@ -174,14 +174,14 @@ void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) { } void AmShieldGeneratorQuickbuild::EnemyEnteredShield(Entity* self, Entity* intruder) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { return; } - auto* baseCombatAIComponent = intruder->GetComponent(); - auto* movementAIComponent = intruder->GetComponent(); + auto baseCombatAIComponent = intruder->GetComponent(); + auto movementAIComponent = intruder->GetComponent(); if (baseCombatAIComponent == nullptr || movementAIComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp index e35c700d9..7ad75862f 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp @@ -14,7 +14,7 @@ void AmSkullkinDrill::OnStartup(Entity* self) { GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"spin", "active"); - auto* movingPlatformComponent = self->GetComponent(); + auto movingPlatformComponent = self->GetComponent(); if (movingPlatformComponent == nullptr) { return; @@ -58,7 +58,7 @@ void AmSkullkinDrill::OnSkillEventFired(Entity* self, Entity* caster, const std: return; } - auto* proximityMonitorComponent = self->GetComponent(); + auto proximityMonitorComponent = self->GetComponent(); if (proximityMonitorComponent == nullptr || !proximityMonitorComponent->IsInProximity("spin_distance", caster->GetObjectID())) { return; @@ -82,7 +82,7 @@ void AmSkullkinDrill::TriggerDrill(Entity* self) { standObj->SetVar(u"bActive", false); } - auto* movingPlatformComponent = self->GetComponent(); + auto movingPlatformComponent = self->GetComponent(); if (movingPlatformComponent == nullptr) { return; @@ -223,7 +223,7 @@ void AmSkullkinDrill::PlayAnim(Entity* self, Entity* player, const std::string& } void AmSkullkinDrill::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) { - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent == nullptr || !attacker->IsPlayer()) { return; @@ -239,7 +239,7 @@ void AmSkullkinDrill::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t // TODO: Missions if (activator != nullptr) { - auto* missionComponent = activator->GetComponent(); + auto missionComponent = activator->GetComponent(); if (missionComponent != nullptr) { for (const auto missionID : m_MissionsToUpdate) { @@ -279,7 +279,7 @@ void AmSkullkinDrill::OnTimerDone(Entity* self, std::string timerName) { standObj->SetVar(u"bActive", true); } - auto* movingPlatformComponent = self->GetComponent(); + auto movingPlatformComponent = self->GetComponent(); if (movingPlatformComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/AM/AmSkullkinTower.cpp b/dScripts/02_server/Map/AM/AmSkullkinTower.cpp index f7825f8f4..da76c10b6 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinTower.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinTower.cpp @@ -12,7 +12,7 @@ void AmSkullkinTower::OnStartup(Entity* self) { // onPhysicsComponentReady - auto* movingPlatformComponent = self->GetComponent(); + auto movingPlatformComponent = self->GetComponent(); if (movingPlatformComponent != nullptr) { movingPlatformComponent->StopPathing(); @@ -82,7 +82,7 @@ void AmSkullkinTower::OnChildLoaded(Entity* self, Entity* child) { child->AddDieCallback([this, selfID, child]() { auto* self = EntityManager::Instance()->GetEntity(selfID); - auto* destroyableComponent = child->GetComponent(); + auto destroyableComponent = child->GetComponent(); if (destroyableComponent == nullptr || self == nullptr) { return; @@ -163,7 +163,7 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) { continue; } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) { continue; diff --git a/dScripts/02_server/Map/AM/AmTeapotServer.cpp b/dScripts/02_server/Map/AM/AmTeapotServer.cpp index 93f05326a..68c7fda35 100644 --- a/dScripts/02_server/Map/AM/AmTeapotServer.cpp +++ b/dScripts/02_server/Map/AM/AmTeapotServer.cpp @@ -5,7 +5,7 @@ #include "eTerminateType.h" void AmTeapotServer::OnUse(Entity* self, Entity* user) { - auto* inventoryComponent = user->GetComponent(); + auto inventoryComponent = user->GetComponent(); if (!inventoryComponent) return; auto* blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::ITEMS); diff --git a/dScripts/02_server/Map/AM/AmTemplateSkillVolume.cpp b/dScripts/02_server/Map/AM/AmTemplateSkillVolume.cpp index 3acc9063a..380464070 100644 --- a/dScripts/02_server/Map/AM/AmTemplateSkillVolume.cpp +++ b/dScripts/02_server/Map/AM/AmTemplateSkillVolume.cpp @@ -6,7 +6,7 @@ void AmTemplateSkillVolume::OnSkillEventFired(Entity* self, Entity* caster, cons return; } - auto* missionComponent = caster->GetComponent(); + auto missionComponent = caster->GetComponent(); const auto missionIDsVariable = GeneralUtils::UTF16ToWTF8(self->GetVar(u"missions")); const auto missionIDs = GeneralUtils::SplitString(missionIDsVariable, '_'); diff --git a/dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp b/dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp index cfc58fa02..e33fa417b 100644 --- a/dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp +++ b/dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp @@ -10,7 +10,7 @@ void EnemyRoninSpawner::OnStartup(Entity* self) { void EnemyRoninSpawner::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "hatchTime") { - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->PlayEffect(644, u"create", "BurstFX1"); @@ -42,7 +42,7 @@ void EnemyRoninSpawner::OnProximityUpdate(Entity* self, Entity* entering, std::s if (entering->IsPlayer() && name == "ronin" && status == "ENTER" && !self->GetVar(u"hatching")) { StartHatching(self); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(305, 3568, LWOOBJID_EMPTY); @@ -59,7 +59,7 @@ void EnemyRoninSpawner::OnHit(Entity* self, Entity* attacker) { void EnemyRoninSpawner::StartHatching(Entity* self) { self->SetVar(u"hatching", true); - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->PlayEffect(2260, u"rebuild_medium", "WakeUpFX1"); diff --git a/dScripts/02_server/Map/FV/FvCandle.cpp b/dScripts/02_server/Map/FV/FvCandle.cpp index 0c4344d03..30365fcea 100644 --- a/dScripts/02_server/Map/FV/FvCandle.cpp +++ b/dScripts/02_server/Map/FV/FvCandle.cpp @@ -6,7 +6,7 @@ std::vector FvCandle::m_Missions = { 850, 1431, 1529, 1566, 1603 }; void FvCandle::OnStartup(Entity* self) { - auto* render = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto render = self->GetComponent(); if (render == nullptr) return; @@ -23,11 +23,11 @@ void FvCandle::BlowOutCandle(Entity* self, Entity* blower) { if (self->GetBoolean(u"AmHit")) return; - auto* render = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto render = self->GetComponent(); if (render == nullptr) return; - auto* missionComponent = blower->GetComponent(); + auto missionComponent = blower->GetComponent(); if (missionComponent != nullptr) { for (const auto mission : m_Missions) { @@ -47,7 +47,7 @@ void FvCandle::BlowOutCandle(Entity* self, Entity* blower) { void FvCandle::OnTimerDone(Entity* self, std::string timerName) { self->SetBoolean(u"AmHit", false); - auto* render = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto render = self->GetComponent(); if (render == nullptr) return; diff --git a/dScripts/02_server/Map/FV/FvHorsemenTrigger.cpp b/dScripts/02_server/Map/FV/FvHorsemenTrigger.cpp index e87d9629a..cb86d92b9 100644 --- a/dScripts/02_server/Map/FV/FvHorsemenTrigger.cpp +++ b/dScripts/02_server/Map/FV/FvHorsemenTrigger.cpp @@ -39,7 +39,7 @@ FvHorsemenTrigger::OnFireEventServerSide(Entity* self, Entity* sender, std::stri continue; } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) { continue; diff --git a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp index 7d86cc738..d23ac6ce8 100644 --- a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp +++ b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp @@ -19,7 +19,7 @@ void ImgBrickConsoleQB::OnStartup(Entity* self) { } void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { if (!self->GetNetworkVar(u"used")) { @@ -28,7 +28,7 @@ void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { auto bothBuilt = false; for (auto* console : consoles) { - auto* consoleRebuildComponent = console->GetComponent(); + auto consoleRebuildComponent = console->GetComponent(); if (consoleRebuildComponent->GetState() != eRebuildState::COMPLETED) { continue; @@ -69,8 +69,8 @@ void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { auto* player = user; - auto* missionComponent = player->GetComponent(); - auto* inventoryComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); if (missionComponent != nullptr && inventoryComponent != nullptr) { if (missionComponent->GetMissionState(1302) == eMissionState::ACTIVE) { @@ -145,7 +145,7 @@ void ImgBrickConsoleQB::OnRebuildComplete(Entity* self, Entity* target) { const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console"); for (auto* console : consoles) { - auto* consoleRebuildComponent = console->GetComponent(); + auto consoleRebuildComponent = console->GetComponent(); if (consoleRebuildComponent->GetState() != eRebuildState::COMPLETED) { continue; @@ -166,7 +166,7 @@ void ImgBrickConsoleQB::OnDie(Entity* self, Entity* killer) { self->SetVar(u"Died", true); - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { auto offFX = 0; @@ -227,7 +227,7 @@ void ImgBrickConsoleQB::OnDie(Entity* self, Entity* killer) { void ImgBrickConsoleQB::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent->GetState() == eRebuildState::OPEN) { self->Smash(self->GetObjectID(), eKillType::SILENT); diff --git a/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp b/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp index 155be92b0..6ec3d0b94 100644 --- a/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp +++ b/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp @@ -23,7 +23,7 @@ void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std: return; } - auto* possessableComponent = entering->GetComponent(); + auto possessableComponent = entering->GetComponent(); Entity* vehicle; Entity* player; @@ -37,7 +37,7 @@ void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std: vehicle = entering; } else if (entering->IsPlayer()) { - auto* possessorComponent = entering->GetComponent(); + auto possessorComponent = entering->GetComponent(); if (possessorComponent == nullptr) { return; @@ -59,7 +59,7 @@ void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std: auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); - auto* racingControlComponent = zoneController->GetComponent(); + auto racingControlComponent = zoneController->GetComponent(); if (racingControlComponent != nullptr) { racingControlComponent->OnRequestDie(player); diff --git a/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp b/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp index c366d0fbf..2a0a49d52 100644 --- a/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp +++ b/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp @@ -75,7 +75,7 @@ void GfCaptainsCannon::OnTimerDone(Entity* self, std::string timerName) { GameMessages::SendStopFXEffect(player, true, "hook"); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgress(601, 910, 1); diff --git a/dScripts/02_server/Map/GF/GfTikiTorch.cpp b/dScripts/02_server/Map/GF/GfTikiTorch.cpp index 5d944f0f5..bfeec36bb 100644 --- a/dScripts/02_server/Map/GF/GfTikiTorch.cpp +++ b/dScripts/02_server/Map/GF/GfTikiTorch.cpp @@ -45,7 +45,7 @@ void GfTikiTorch::OnTimerDone(Entity* self, std::string timerName) { } void GfTikiTorch::LightTorch(Entity* self) { - auto* renderComponent = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto renderComponent = self->GetComponent(); if (renderComponent == nullptr) return; @@ -59,14 +59,14 @@ void GfTikiTorch::OnSkillEventFired(Entity* self, Entity* caster, const std::str if (self->GetBoolean(u"isBurning") && message == "waterspray") { RenderComponent::PlayAnimation(self, u"water"); - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("tikitorch"); renderComponent->PlayEffect(611, u"water", "water"); renderComponent->PlayEffect(611, u"steam", "steam"); } - auto* casterMissionComponent = caster->GetComponent(); + auto casterMissionComponent = caster->GetComponent(); if (casterMissionComponent != nullptr) { for (const auto missionID : m_missions) { casterMissionComponent->ForceProgressTaskType(missionID, static_cast(eMissionTaskType::SCRIPT), 1); diff --git a/dScripts/02_server/Map/GF/MastTeleport.cpp b/dScripts/02_server/Map/GF/MastTeleport.cpp index 311da34a5..b2929c144 100644 --- a/dScripts/02_server/Map/GF/MastTeleport.cpp +++ b/dScripts/02_server/Map/GF/MastTeleport.cpp @@ -23,7 +23,7 @@ void MastTeleport::OnRebuildComplete(Entity* self, Entity* target) { GameMessages::SendSetStunned(target->GetObjectID(), eStateChangeType::PUSH, target->GetSystemAddress(), LWOOBJID_EMPTY, true, true, true, true, true, true, true ); - auto* destroyableComponent = target->GetComponent(); + auto destroyableComponent = target->GetComponent(); if (destroyableComponent) destroyableComponent->SetStatusImmunity(eStateChangeType::PUSH, true, true, true, true, true, false, false, true, true); self->AddTimer("Start", 3); @@ -94,7 +94,7 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) { GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY, true, true, true, true, true, true, true ); - auto* destroyableComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); if (destroyableComponent) destroyableComponent->SetStatusImmunity(eStateChangeType::POP, true, true, true, true, true, false, false, true, true); EntityManager::Instance()->SerializeEntity(player); } diff --git a/dScripts/02_server/Map/General/ExplodingAsset.cpp b/dScripts/02_server/Map/General/ExplodingAsset.cpp index ee8f8e68e..f0f35eed9 100644 --- a/dScripts/02_server/Map/General/ExplodingAsset.cpp +++ b/dScripts/02_server/Map/General/ExplodingAsset.cpp @@ -24,7 +24,7 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) { if (en->GetObjectID() == attacker->GetObjectID()) { if (Vector3::DistanceSquared(en->GetPosition(), self->GetPosition()) > 10 * 10) continue; - auto* destroyable = en->GetComponent(); + auto destroyable = en->GetComponent(); if (destroyable == nullptr) { continue; } @@ -40,7 +40,7 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) { GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake", self->GetObjectID(), 16); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(147, 4721, LWOOBJID_EMPTY, true); } @@ -49,7 +49,7 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) { auto achievementIDs = self->GetVar(u"achieveID"); // Progress all scripted missions related to this asset - auto* missionComponent = attacker->GetComponent(); + auto missionComponent = attacker->GetComponent(); if (missionComponent != nullptr) { if (missionID != 0) { missionComponent->ForceProgressValue(missionID, @@ -70,7 +70,7 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) { } void ExplodingAsset::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - auto* destuctableComponent = entering->GetComponent(); + auto destuctableComponent = entering->GetComponent(); if (destuctableComponent == nullptr) return; diff --git a/dScripts/02_server/Map/General/ForceVolumeServer.cpp b/dScripts/02_server/Map/General/ForceVolumeServer.cpp index ed9024c11..693e0cdc5 100644 --- a/dScripts/02_server/Map/General/ForceVolumeServer.cpp +++ b/dScripts/02_server/Map/General/ForceVolumeServer.cpp @@ -4,7 +4,7 @@ #include "ePhysicsEffectType.h" void ForceVolumeServer::OnStartup(Entity* self) { - auto* phantomPhysicsComponent = self->GetComponent(); + auto phantomPhysicsComponent = self->GetComponent(); if (phantomPhysicsComponent == nullptr) return; diff --git a/dScripts/02_server/Map/General/GrowingFlower.cpp b/dScripts/02_server/Map/General/GrowingFlower.cpp index ad88528f5..53da85ff3 100644 --- a/dScripts/02_server/Map/General/GrowingFlower.cpp +++ b/dScripts/02_server/Map/General/GrowingFlower.cpp @@ -15,7 +15,7 @@ void GrowingFlower::OnSkillEventFired(Entity* self, Entity* target, const std::s LootGenerator::Instance().DropActivityLoot(target, self, self->GetLOT(), 0); - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent != nullptr) { for (const auto mission : achievementIDs) missionComponent->ForceProgressTaskType(mission, static_cast(eMissionTaskType::SCRIPT), 1); diff --git a/dScripts/02_server/Map/General/ImaginationBackpackHealServer.cpp b/dScripts/02_server/Map/General/ImaginationBackpackHealServer.cpp index 8b3da9fa7..fc3a885e7 100644 --- a/dScripts/02_server/Map/General/ImaginationBackpackHealServer.cpp +++ b/dScripts/02_server/Map/General/ImaginationBackpackHealServer.cpp @@ -12,7 +12,7 @@ void ImaginationBackpackHealServer::OnSkillEventFired(Entity* self, Entity* cast if (healMission == 0) return; - auto* missionComponent = caster->GetComponent(); + auto missionComponent = caster->GetComponent(); if (missionComponent != nullptr && missionComponent->GetMissionState(healMission) == eMissionState::ACTIVE) { missionComponent->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"ClearMaelstrom", 0, 0, diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp b/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp index 5ca726afc..a38f15aca 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp @@ -4,7 +4,7 @@ void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) { const auto flag = self->GetVar(u"RailFlagNum"); - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); // Only allow use if this is not a quick build or the quick build is built if (rebuildComponent == nullptr || rebuildComponent->GetState() == eRebuildState::COMPLETED) { diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp index 2c435705b..85d7b3f00 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp @@ -3,7 +3,7 @@ #include "EntityManager.h" void NjRailPostServer::OnStartup(Entity* self) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent != nullptr) { self->SetNetworkVar(NetworkNotActiveVariable, true); } diff --git a/dScripts/02_server/Map/General/PetDigServer.cpp b/dScripts/02_server/Map/General/PetDigServer.cpp index 8c819a8d0..6d55f3734 100644 --- a/dScripts/02_server/Map/General/PetDigServer.cpp +++ b/dScripts/02_server/Map/General/PetDigServer.cpp @@ -125,7 +125,7 @@ void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pe // If the player doesn't have the flag yet if (playerFlag != 0 && !player->GetPlayerFlag(playerFlag)) { - auto* petComponent = pet->GetComponent(); + auto petComponent = pet->GetComponent(); if (petComponent != nullptr) { // TODO: Pet state = 9 ?? } @@ -159,7 +159,7 @@ void PetDigServer::HandleBouncerDig(const Entity* self, const Entity* owner) { * \param owner the owner that just made a pet dig something up */ void PetDigServer::ProgressPetDigMissions(const Entity* owner, const Entity* chest) { - auto* missionComponent = owner->GetComponent(); + auto missionComponent = owner->GetComponent(); if (missionComponent != nullptr) { // Can You Dig It progress @@ -193,7 +193,7 @@ void PetDigServer::ProgressPetDigMissions(const Entity* owner, const Entity* che void PetDigServer::SpawnPet(Entity* self, const Entity* owner, const DigInfo digInfo) { // Some treasures require a mission to be active if (digInfo.requiredMission >= 0) { - auto* missionComponent = owner->GetComponent(); + auto missionComponent = owner->GetComponent(); if (missionComponent != nullptr && missionComponent->GetMissionState(digInfo.requiredMission) < eMissionState::ACTIVE) { return; } diff --git a/dScripts/02_server/Map/General/PropertyDevice.cpp b/dScripts/02_server/Map/General/PropertyDevice.cpp index 0ad9f5c94..b0bd3fc28 100644 --- a/dScripts/02_server/Map/General/PropertyDevice.cpp +++ b/dScripts/02_server/Map/General/PropertyDevice.cpp @@ -16,7 +16,7 @@ void PropertyDevice::OnRebuildComplete(Entity* self, Entity* target) { if (propertyOwnerID == std::to_string(LWOOBJID_EMPTY)) return; - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent != nullptr) { if (missionComponent->GetMissionState(m_PropertyMissionID) == eMissionState::ACTIVE) { GameMessages::SendPlayFXEffect(self->GetObjectID(), 641, u"create", "callhome"); diff --git a/dScripts/02_server/Map/General/PropertyPlatform.cpp b/dScripts/02_server/Map/General/PropertyPlatform.cpp index 7016db94c..a26d74734 100644 --- a/dScripts/02_server/Map/General/PropertyPlatform.cpp +++ b/dScripts/02_server/Map/General/PropertyPlatform.cpp @@ -4,7 +4,7 @@ #include "MovingPlatformComponent.h" void PropertyPlatform::OnRebuildComplete(Entity* self, Entity* target) { - // auto* movingPlatform = self->GetComponent(); + // auto movingPlatform = self->GetComponent(); // if (movingPlatform != nullptr) { // movingPlatform->StopPathing(); // movingPlatform->SetNoAutoStart(true); @@ -14,9 +14,9 @@ void PropertyPlatform::OnRebuildComplete(Entity* self, Entity* target) { } void PropertyPlatform::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::COMPLETED) { - // auto* movingPlatform = self->GetComponent(); + // auto movingPlatform = self->GetComponent(); // if (movingPlatform != nullptr) { // movingPlatform->GotoWaypoint(1); // } diff --git a/dScripts/02_server/Map/General/QbEnemyStunner.cpp b/dScripts/02_server/Map/General/QbEnemyStunner.cpp index 441d743cd..dc7742f3e 100644 --- a/dScripts/02_server/Map/General/QbEnemyStunner.cpp +++ b/dScripts/02_server/Map/General/QbEnemyStunner.cpp @@ -7,7 +7,7 @@ #include "CDSkillBehaviorTable.h" void QbEnemyStunner::OnRebuildComplete(Entity* self, Entity* target) { - auto* destroyable = self->GetComponent(); + auto destroyable = self->GetComponent(); if (destroyable != nullptr) { destroyable->SetFaction(115); @@ -51,7 +51,7 @@ void QbEnemyStunner::OnTimerDone(Entity* self, std::string timerName) { self->AddTimer("DieTime", 5.0f); } else if (timerName == "TickTime") { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { auto skillBehaviorMap = self->GetVar>(u"skillBehaviorMap"); diff --git a/dScripts/02_server/Map/General/QbSpawner.cpp b/dScripts/02_server/Map/General/QbSpawner.cpp index d5c9d0016..7825e310e 100644 --- a/dScripts/02_server/Map/General/QbSpawner.cpp +++ b/dScripts/02_server/Map/General/QbSpawner.cpp @@ -115,14 +115,14 @@ void QbSpawner::OnChildRemoved(Entity* self, Entity* child) { } void QbSpawner::AggroTargetObject(Entity* self, Entity* enemy) { - auto* baseCombatAIComponent = enemy->GetComponent(); + auto baseCombatAIComponent = enemy->GetComponent(); if (!baseCombatAIComponent) return; auto gateObjID = self->GetVar(u"gateObj"); if (gateObjID) { auto* gate = EntityManager::Instance()->GetEntity(gateObjID); if (gate) { - auto* movementAIComponent = enemy->GetComponent(); + auto movementAIComponent = enemy->GetComponent(); if (movementAIComponent) movementAIComponent->SetDestination(gate->GetPosition()); baseCombatAIComponent->Taunt(gateObjID, 1000); } diff --git a/dScripts/02_server/Map/General/TokenConsoleServer.cpp b/dScripts/02_server/Map/General/TokenConsoleServer.cpp index e13011cb9..3ccd68997 100644 --- a/dScripts/02_server/Map/General/TokenConsoleServer.cpp +++ b/dScripts/02_server/Map/General/TokenConsoleServer.cpp @@ -9,7 +9,7 @@ //2021-05-03 - max - added script, omitted some parts related to inheritance in lua which we don't need void TokenConsoleServer::OnUse(Entity* self, Entity* user) { - auto* inv = static_cast(user->GetComponent(eReplicaComponentType::INVENTORY)); + auto inv = user->GetComponent(); //make sure the user has the required amount of infected bricks if (inv && inv->GetLotCount(6194) >= bricksToTake) { diff --git a/dScripts/02_server/Map/General/TouchMissionUpdateServer.cpp b/dScripts/02_server/Map/General/TouchMissionUpdateServer.cpp index 7b2495d02..0e6780b9e 100644 --- a/dScripts/02_server/Map/General/TouchMissionUpdateServer.cpp +++ b/dScripts/02_server/Map/General/TouchMissionUpdateServer.cpp @@ -17,7 +17,7 @@ void TouchMissionUpdateServer::OnCollisionPhantom(Entity* self, Entity* target) return; } - auto* missionComponent = static_cast(target->GetComponent(eReplicaComponentType::MISSION)); + auto missionComponent = target->GetComponent(); if (missionComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/General/WishingWellServer.cpp b/dScripts/02_server/Map/General/WishingWellServer.cpp index 58ce1c722..7704a3f3b 100644 --- a/dScripts/02_server/Map/General/WishingWellServer.cpp +++ b/dScripts/02_server/Map/General/WishingWellServer.cpp @@ -9,7 +9,7 @@ void WishingWellServer::OnStartup(Entity* self) { } void WishingWellServer::OnUse(Entity* self, Entity* user) { - auto* scriptedActivity = self->GetComponent(); + auto scriptedActivity = self->GetComponent(); if (!scriptedActivity->TakeCost(user)) { return; diff --git a/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp b/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp index 326842d25..269e9d6a3 100644 --- a/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp +++ b/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp @@ -12,7 +12,7 @@ void NsTokenConsoleServer::OnStartup(Entity* self) { } void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent == nullptr) { return; @@ -22,8 +22,8 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) { return; } - auto* inventoryComponent = user->GetComponent(); - auto* missionComponent = user->GetComponent(); + auto inventoryComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); auto* character = user->GetCharacter(); if (inventoryComponent == nullptr || missionComponent == nullptr || character == nullptr) { diff --git a/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp b/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp index 99bc0de56..9b7e12486 100644 --- a/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp +++ b/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp @@ -24,7 +24,7 @@ void NtAssemblyTubeServer::OnProximityUpdate(Entity* self, Entity* entering, std RunAssemblyTube(self, player); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); diff --git a/dScripts/02_server/Map/NT/NtCombatChallengeServer.cpp b/dScripts/02_server/Map/NT/NtCombatChallengeServer.cpp index d27ac1f6f..30366b55e 100644 --- a/dScripts/02_server/Map/NT/NtCombatChallengeServer.cpp +++ b/dScripts/02_server/Map/NT/NtCombatChallengeServer.cpp @@ -48,7 +48,7 @@ void NtCombatChallengeServer::OnMessageBoxResponse(Entity* self, Entity* sender, self->SetVar(u"playerID", sender->GetObjectID()); - auto* inventoryComponent = sender->GetComponent(); + auto inventoryComponent = sender->GetComponent(); if (inventoryComponent != nullptr) { inventoryComponent->RemoveItem(3039, 1); @@ -133,7 +133,7 @@ void NtCombatChallengeServer::ResetGame(Entity* self) { auto* player = EntityManager::Instance()->GetEntity(playerID); if (player != nullptr) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { for (const auto& mission : tMissions) { diff --git a/dScripts/02_server/Map/NT/NtDarkitectRevealServer.cpp b/dScripts/02_server/Map/NT/NtDarkitectRevealServer.cpp index 80ceb91eb..b207ae56a 100644 --- a/dScripts/02_server/Map/NT/NtDarkitectRevealServer.cpp +++ b/dScripts/02_server/Map/NT/NtDarkitectRevealServer.cpp @@ -6,7 +6,7 @@ void NtDarkitectRevealServer::OnUse(Entity* self, Entity* user) { Darkitect Baron; Baron.Reveal(self, user); - auto* missionComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgressTaskType(1344, 1, 14293); diff --git a/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp b/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp index 92175deac..80935943c 100644 --- a/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp +++ b/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp @@ -30,7 +30,7 @@ void NtDirtCloudServer::OnSkillEventFired(Entity* self, Entity* caster, const st const auto& myMis = m_Missions[mySpawner]; - auto* missionComponent = caster->GetComponent(); + auto missionComponent = caster->GetComponent(); if (missionComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/NT/NtDukeServer.cpp b/dScripts/02_server/Map/NT/NtDukeServer.cpp index 07d17e961..352fe4e15 100644 --- a/dScripts/02_server/Map/NT/NtDukeServer.cpp +++ b/dScripts/02_server/Map/NT/NtDukeServer.cpp @@ -24,8 +24,8 @@ void NtDukeServer::SetVariables(Entity* self) { void NtDukeServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { // Handles adding and removing the sword for the Crux Prime Sword mission - auto* missionComponent = target->GetComponent(); - auto* inventoryComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); + auto inventoryComponent = target->GetComponent(); if (missionComponent != nullptr && inventoryComponent != nullptr) { auto state = missionComponent->GetMissionState(m_SwordMissionID); diff --git a/dScripts/02_server/Map/NT/NtImagBeamBuffer.cpp b/dScripts/02_server/Map/NT/NtImagBeamBuffer.cpp index d98a7403b..7ed610d50 100644 --- a/dScripts/02_server/Map/NT/NtImagBeamBuffer.cpp +++ b/dScripts/02_server/Map/NT/NtImagBeamBuffer.cpp @@ -33,7 +33,7 @@ void NtImagBeamBuffer::OnTimerDone(Entity* self, std::string timerName) { return; } - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp b/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp index dcae84d2f..031269474 100644 --- a/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp +++ b/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp @@ -15,7 +15,7 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) { self->SetVar(u"bActive", true); - auto* missionComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); const auto playerID = user->GetObjectID(); diff --git a/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp b/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp index 687a3477e..3c07091cf 100644 --- a/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp +++ b/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp @@ -43,7 +43,7 @@ void NtParadoxTeleServer::OnProximityUpdate(Entity* self, Entity* entering, std: }); } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); diff --git a/dScripts/02_server/Map/NT/NtSentinelWalkwayServer.cpp b/dScripts/02_server/Map/NT/NtSentinelWalkwayServer.cpp index 257bf6da9..ce3249bd5 100644 --- a/dScripts/02_server/Map/NT/NtSentinelWalkwayServer.cpp +++ b/dScripts/02_server/Map/NT/NtSentinelWalkwayServer.cpp @@ -6,7 +6,7 @@ #include "ePhysicsEffectType.h" void NtSentinelWalkwayServer::OnStartup(Entity* self) { - auto* phantomPhysicsComponent = self->GetComponent(); + auto phantomPhysicsComponent = self->GetComponent(); if (phantomPhysicsComponent == nullptr) { return; @@ -37,7 +37,7 @@ void NtSentinelWalkwayServer::OnProximityUpdate(Entity* self, Entity* entering, auto* player = entering; - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); diff --git a/dScripts/02_server/Map/NT/NtSleepingGuard.cpp b/dScripts/02_server/Map/NT/NtSleepingGuard.cpp index 92a805825..b05903fcb 100644 --- a/dScripts/02_server/Map/NT/NtSleepingGuard.cpp +++ b/dScripts/02_server/Map/NT/NtSleepingGuard.cpp @@ -20,7 +20,7 @@ void NtSleepingGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* RenderComponent::PlayAnimation(self, u"greet"); - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent != nullptr) { missionComponent->CompleteMission(1346); diff --git a/dScripts/02_server/Map/NT/NtVandaServer.cpp b/dScripts/02_server/Map/NT/NtVandaServer.cpp index 7750d5664..bd49e47af 100644 --- a/dScripts/02_server/Map/NT/NtVandaServer.cpp +++ b/dScripts/02_server/Map/NT/NtVandaServer.cpp @@ -6,7 +6,7 @@ void NtVandaServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio // Removes the alien parts after completing the mission if (missionID == m_AlienPartMissionID && missionState == eMissionState::READY_TO_COMPLETE) { - auto* inventoryComponent = target->GetComponent(); + auto inventoryComponent = target->GetComponent(); for (const auto& alienPartLot : m_AlienPartLots) { inventoryComponent->RemoveItem(alienPartLot, 1); } diff --git a/dScripts/02_server/Map/NT/NtVentureSpeedPadServer.cpp b/dScripts/02_server/Map/NT/NtVentureSpeedPadServer.cpp index 07d33555c..375d525fa 100644 --- a/dScripts/02_server/Map/NT/NtVentureSpeedPadServer.cpp +++ b/dScripts/02_server/Map/NT/NtVentureSpeedPadServer.cpp @@ -15,13 +15,13 @@ void NtVentureSpeedPadServer::OnProximityUpdate(Entity* self, Entity* entering, auto* player = entering; - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); } - auto* skillComponent = player->GetComponent(); + auto skillComponent = player->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(927, 18913, player->GetObjectID(), true); diff --git a/dScripts/02_server/Map/NT/NtXRayServer.cpp b/dScripts/02_server/Map/NT/NtXRayServer.cpp index 3b281b799..adef550d4 100644 --- a/dScripts/02_server/Map/NT/NtXRayServer.cpp +++ b/dScripts/02_server/Map/NT/NtXRayServer.cpp @@ -2,7 +2,7 @@ #include "SkillComponent.h" void NtXRayServer::OnCollisionPhantom(Entity* self, Entity* target) { - auto* skillComponent = target->GetComponent(); + auto skillComponent = target->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp b/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp index cf635fe47..755c6a68a 100644 --- a/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp +++ b/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp @@ -14,8 +14,8 @@ void SpawnGryphonServer::SetVariables(Entity* self) { } void SpawnGryphonServer::OnUse(Entity* self, Entity* user) { - auto* missionComponent = user->GetComponent(); - auto* inventoryComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); + auto inventoryComponent = user->GetComponent(); // Little extra for handling the case of the egg being placed the first time if (missionComponent != nullptr && inventoryComponent != nullptr diff --git a/dScripts/02_server/Map/Property/AG_Small/EnemySpiderSpawner.cpp b/dScripts/02_server/Map/Property/AG_Small/EnemySpiderSpawner.cpp index 0d4f568ea..07db9a3af 100644 --- a/dScripts/02_server/Map/Property/AG_Small/EnemySpiderSpawner.cpp +++ b/dScripts/02_server/Map/Property/AG_Small/EnemySpiderSpawner.cpp @@ -15,7 +15,7 @@ void EnemySpiderSpawner::OnFireEventServerSide(Entity* self, Entity* sender, std GameMessages::SendPlayFXEffect(self->GetObjectID(), 2856, u"maelstrom", "test", LWOOBJID_EMPTY, 1.0f, 1.0f, true); // Make indestructible - auto dest = static_cast(self->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto dest = self->GetComponent(); if (dest) { dest->SetFaction(-1); } @@ -54,7 +54,7 @@ void EnemySpiderSpawner::OnTimerDone(Entity* self, std::string timerName) { newEntity->GetGroups().push_back("BabySpider"); /* - auto* movementAi = newEntity->GetComponent(); + auto movementAi = newEntity->GetComponent(); movementAi->SetDestination(newEntity->GetPosition()); */ diff --git a/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp b/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp index 6bf917681..22600430b 100644 --- a/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp +++ b/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp @@ -75,7 +75,7 @@ void ZoneAgProperty::OnPlayerLoaded(Entity* self, Entity* player) { } void ZoneAgProperty::PropGuardCheck(Entity* self, Entity* player) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) return; @@ -211,7 +211,7 @@ void ZoneAgProperty::BaseTimerDone(Entity* self, const std::string& timerName) { KillGuard(self); } else if (timerName == "tornadoOff") { for (auto* entity : EntityManager::Instance()->GetEntitiesInGroup(self->GetVar(FXManagerGroup))) { - auto* renderComponent = entity->GetComponent(); + auto renderComponent = entity->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("TornadoDebris", false); renderComponent->StopEffect("TornadoVortex", false); @@ -223,7 +223,7 @@ void ZoneAgProperty::BaseTimerDone(Entity* self, const std::string& timerName) { self->AddTimer("ShowClearEffects", 2); } else if (timerName == "ShowClearEffects") { for (auto* entity : EntityManager::Instance()->GetEntitiesInGroup(self->GetVar(FXManagerGroup))) { - auto* renderComponent = entity->GetComponent(); + auto renderComponent = entity->GetComponent(); if (renderComponent != nullptr) { renderComponent->PlayEffect(-1, u"beamOn", "beam"); } @@ -275,7 +275,7 @@ void ZoneAgProperty::BaseTimerDone(Entity* self, const std::string& timerName) { StartTornadoFx(self); } else if (timerName == "killFXObject") { for (auto* entity : EntityManager::Instance()->GetEntitiesInGroup(self->GetVar(FXManagerGroup))) { - auto* renderComponent = entity->GetComponent(); + auto renderComponent = entity->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("beam"); } @@ -301,7 +301,7 @@ void ZoneAgProperty::OnZonePropertyRented(Entity* self, Entity* player) { void ZoneAgProperty::OnZonePropertyModelPlaced(Entity* self, Entity* player) { auto* character = player->GetCharacter(); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (!character->GetPlayerFlag(101)) { BaseZonePropertyModelPlaced(self, player); @@ -329,7 +329,7 @@ void ZoneAgProperty::OnZonePropertyModelPlaced(Entity* self, Entity* player) { void ZoneAgProperty::OnZonePropertyModelPickedUp(Entity* self, Entity* player) { auto* character = player->GetCharacter(); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (!character->GetPlayerFlag(109)) { character->SetPlayerFlag(109, true); @@ -350,7 +350,7 @@ void ZoneAgProperty::OnZonePropertyModelRemovedWhileEquipped(Entity* self, Entit void ZoneAgProperty::OnZonePropertyModelRotated(Entity* self, Entity* player) { auto* character = player->GetCharacter(); - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (!character->GetPlayerFlag(110)) { character->SetPlayerFlag(110, true); diff --git a/dScripts/02_server/Map/SS/SsModularBuildServer.cpp b/dScripts/02_server/Map/SS/SsModularBuildServer.cpp index dfb291682..2c395f9b3 100644 --- a/dScripts/02_server/Map/SS/SsModularBuildServer.cpp +++ b/dScripts/02_server/Map/SS/SsModularBuildServer.cpp @@ -7,7 +7,7 @@ void SsModularBuildServer::OnModularBuildExit(Entity* self, Entity* player, bool int missionNum = 1732; if (bCompleted) { - MissionComponent* mission = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); + auto mission = self->GetComponent(); Mission* rocketMission = mission->GetMission(missionNum); if (rocketMission->GetMissionState() == eMissionState::ACTIVE) { diff --git a/dScripts/02_server/Map/VE/VeBricksampleServer.cpp b/dScripts/02_server/Map/VE/VeBricksampleServer.cpp index 0ead6a87f..e0f3441e7 100644 --- a/dScripts/02_server/Map/VE/VeBricksampleServer.cpp +++ b/dScripts/02_server/Map/VE/VeBricksampleServer.cpp @@ -6,10 +6,10 @@ #include "eMissionState.h" void VeBricksampleServer::OnUse(Entity* self, Entity* user) { - auto* missionComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); if (missionComponent != nullptr && missionComponent->GetMissionState(1183) == eMissionState::ACTIVE) { const auto loot = self->GetVar(m_LootVariable); - auto* inventoryComponent = user->GetComponent(); + auto inventoryComponent = user->GetComponent(); if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) { inventoryComponent->AddItem(loot, 1, eLootSourceType::ACTIVITY); diff --git a/dScripts/02_server/Map/VE/VeMissionConsole.cpp b/dScripts/02_server/Map/VE/VeMissionConsole.cpp index 35061bdf1..b1694912f 100644 --- a/dScripts/02_server/Map/VE/VeMissionConsole.cpp +++ b/dScripts/02_server/Map/VE/VeMissionConsole.cpp @@ -8,7 +8,7 @@ void VeMissionConsole::OnUse(Entity* self, Entity* user) { LootGenerator::Instance().DropActivityLoot(user, self, 12551); - auto* inventoryComponent = user->GetComponent(); + auto inventoryComponent = user->GetComponent(); if (inventoryComponent != nullptr) { inventoryComponent->AddItem(12547, 1, eLootSourceType::ACTIVITY); // Add the panel required for pickup } diff --git a/dScripts/02_server/Map/njhub/BurningTile.cpp b/dScripts/02_server/Map/njhub/BurningTile.cpp index 8ac3dc5d4..acda97846 100644 --- a/dScripts/02_server/Map/njhub/BurningTile.cpp +++ b/dScripts/02_server/Map/njhub/BurningTile.cpp @@ -3,7 +3,7 @@ void BurningTile::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "PlayerEntered") { - auto* skillComponent = sender->GetComponent(); + auto skillComponent = sender->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp index d04fc03d8..7c7a2e035 100644 --- a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp +++ b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp @@ -68,7 +68,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) { self->SetVar(u"Counterweight", counterweight->GetObjectID()); - auto* rebuildComponent = counterweight->GetComponent(); + auto rebuildComponent = counterweight->GetComponent(); if (rebuildComponent != nullptr) { rebuildComponent->AddRebuildStateCallback([this, self](eRebuildState state) { diff --git a/dScripts/02_server/Map/njhub/EnemySkeletonSpawner.cpp b/dScripts/02_server/Map/njhub/EnemySkeletonSpawner.cpp index 0e2e4005d..e01132fd0 100644 --- a/dScripts/02_server/Map/njhub/EnemySkeletonSpawner.cpp +++ b/dScripts/02_server/Map/njhub/EnemySkeletonSpawner.cpp @@ -7,7 +7,7 @@ void EnemySkeletonSpawner::OnStartup(Entity* self) { self->SetProximityRadius(15, "ronin"); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(1127, 24812, LWOOBJID_EMPTY, true); @@ -16,7 +16,7 @@ void EnemySkeletonSpawner::OnStartup(Entity* self) { void EnemySkeletonSpawner::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "hatchTime") { - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->PlayEffect(644, u"create", "BurstFX1"); @@ -48,7 +48,7 @@ void EnemySkeletonSpawner::OnProximityUpdate(Entity* self, Entity* entering, std if (entering->IsPlayer() && name == "ronin" && status == "ENTER" && !self->GetVar(u"hatching")) { StartHatching(self); - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(305, 3568, LWOOBJID_EMPTY); @@ -65,7 +65,7 @@ void EnemySkeletonSpawner::OnHit(Entity* self, Entity* attacker) { void EnemySkeletonSpawner::StartHatching(Entity* self) { self->SetVar(u"hatching", true); - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->PlayEffect(9017, u"cast", "WakeUpFX1"); diff --git a/dScripts/02_server/Map/njhub/FallingTile.cpp b/dScripts/02_server/Map/njhub/FallingTile.cpp index 7804c8bcb..3dda9030f 100644 --- a/dScripts/02_server/Map/njhub/FallingTile.cpp +++ b/dScripts/02_server/Map/njhub/FallingTile.cpp @@ -3,7 +3,7 @@ #include "GameMessages.h" void FallingTile::OnStartup(Entity* self) { - auto* movingPlatfromComponent = self->GetComponent(); + auto movingPlatfromComponent = self->GetComponent(); if (movingPlatfromComponent == nullptr) { return; @@ -31,7 +31,7 @@ void FallingTile::OnWaypointReached(Entity* self, uint32_t waypointIndex) { } void FallingTile::OnTimerDone(Entity* self, std::string timerName) { - auto* movingPlatfromComponent = self->GetComponent(); + auto movingPlatfromComponent = self->GetComponent(); if (movingPlatfromComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/FlameJetServer.cpp b/dScripts/02_server/Map/njhub/FlameJetServer.cpp index 771dd8414..32e2a0ea7 100644 --- a/dScripts/02_server/Map/njhub/FlameJetServer.cpp +++ b/dScripts/02_server/Map/njhub/FlameJetServer.cpp @@ -19,7 +19,7 @@ void FlameJetServer::OnCollisionPhantom(Entity* self, Entity* target) { return; } - auto* skillComponent = target->GetComponent(); + auto skillComponent = target->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp b/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp index 1fbfad983..79022586b 100644 --- a/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp +++ b/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp @@ -3,7 +3,7 @@ void ImaginationShrineServer::OnUse(Entity* self, Entity* user) { // If the rebuild component is complete, use the shrine - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/Lieutenant.cpp b/dScripts/02_server/Map/njhub/Lieutenant.cpp index d3b0fc1f2..26b5f85d3 100644 --- a/dScripts/02_server/Map/njhub/Lieutenant.cpp +++ b/dScripts/02_server/Map/njhub/Lieutenant.cpp @@ -3,7 +3,7 @@ #include "dZoneManager.h" void Lieutenant::OnStartup(Entity* self) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/NjColeNPC.cpp b/dScripts/02_server/Map/njhub/NjColeNPC.cpp index b989f3ee4..dc33595bd 100644 --- a/dScripts/02_server/Map/njhub/NjColeNPC.cpp +++ b/dScripts/02_server/Map/njhub/NjColeNPC.cpp @@ -8,7 +8,7 @@ void NjColeNPC::OnEmoteReceived(Entity* self, int32_t emote, Entity* target) { return; } - auto* inventoryComponent = target->GetComponent(); + auto inventoryComponent = target->GetComponent(); if (inventoryComponent == nullptr) { return; @@ -18,7 +18,7 @@ void NjColeNPC::OnEmoteReceived(Entity* self, int32_t emote, Entity* target) { return; } - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent == nullptr) { return; @@ -31,8 +31,8 @@ void NjColeNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, NjNPCMissionSpinjitzuServer::OnMissionDialogueOK(self, target, missionID, missionState); if (missionID == 1818 && missionState >= eMissionState::READY_TO_COMPLETE) { - auto* missionComponent = target->GetComponent(); - auto* inventoryComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); + auto inventoryComponent = target->GetComponent(); if (missionComponent == nullptr || inventoryComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp b/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp index 931cfe56c..cb2bd9bef 100644 --- a/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp +++ b/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp @@ -12,7 +12,7 @@ void NjDragonEmblemChestServer::OnUse(Entity* self, Entity* user) { character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, false); } - auto* destroyable = self->GetComponent(); + auto destroyable = self->GetComponent(); if (destroyable != nullptr) { LootGenerator::Instance().DropLoot(user, self, destroyable->GetLootMatrixID(), 0, 0); } diff --git a/dScripts/02_server/Map/njhub/NjEarthPetServer.cpp b/dScripts/02_server/Map/njhub/NjEarthPetServer.cpp index 36655c631..b8bdaf694 100644 --- a/dScripts/02_server/Map/njhub/NjEarthPetServer.cpp +++ b/dScripts/02_server/Map/njhub/NjEarthPetServer.cpp @@ -2,7 +2,7 @@ #include "PetComponent.h" void NjEarthPetServer::OnStartup(Entity* self) { - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwnerId() != LWOOBJID_EMPTY) return; diff --git a/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp b/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp index 7156b3687..9432161de 100644 --- a/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp +++ b/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp @@ -5,7 +5,7 @@ void NjScrollChestServer::OnUse(Entity* self, Entity* user) { const auto keyLOT = self->GetVar(u"KeyNum"); const auto rewardItemLOT = self->GetVar(u"openItemID"); - auto* playerInventory = user->GetComponent(); + auto playerInventory = user->GetComponent(); if (playerInventory != nullptr && playerInventory->GetLotCount(keyLOT) == 1) { // Check for the key and remove diff --git a/dScripts/02_server/Map/njhub/NjWuNPC.cpp b/dScripts/02_server/Map/njhub/NjWuNPC.cpp index f4969074e..cc1fcad89 100644 --- a/dScripts/02_server/Map/njhub/NjWuNPC.cpp +++ b/dScripts/02_server/Map/njhub/NjWuNPC.cpp @@ -11,7 +11,7 @@ void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, e // The Dragon statue daily mission if (missionID == m_MainDragonMissionID) { auto* character = target->GetCharacter(); - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (character == nullptr || missionComponent == nullptr) return; diff --git a/dScripts/02_server/Map/njhub/RainOfArrows.cpp b/dScripts/02_server/Map/njhub/RainOfArrows.cpp index b7c4c074e..10f5c4a4e 100644 --- a/dScripts/02_server/Map/njhub/RainOfArrows.cpp +++ b/dScripts/02_server/Map/njhub/RainOfArrows.cpp @@ -43,7 +43,7 @@ void RainOfArrows::OnTimerDone(Entity* self, std::string timerName) { return; } - auto* skillComponent = child->GetComponent(); + auto skillComponent = child->GetComponent(); if (skillComponent == nullptr) { return; diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index 9f129ce35..8e676167f 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -51,7 +51,7 @@ void NjMonastryBossInstance::OnPlayerLoaded(Entity* self, Entity* player) { UpdatePlayer(self, player->GetObjectID()); // Buff the player - auto* destroyableComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetHealth((int32_t)destroyableComponent->GetMaxHealth()); destroyableComponent->SetArmor((int32_t)destroyableComponent->GetMaxArmor()); @@ -147,7 +147,7 @@ void NjMonastryBossInstance::OnActivityTimerDone(Entity* self, const std::string } else if (timerName + TimerSplitChar == UnstunTimer) { auto* entity = EntityManager::Instance()->GetEntity(objectID); if (entity != nullptr) { - auto* combatAI = entity->GetComponent(); + auto combatAI = entity->GetComponent(); if (combatAI != nullptr) { combatAI->SetDisabled(false); } @@ -221,7 +221,7 @@ void NjMonastryBossInstance::HandleLedgedFrakjawSpawned(Entity* self, Entity* le } void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* counterWeight) { - auto* rebuildComponent = counterWeight->GetComponent(); + auto rebuildComponent = counterWeight->GetComponent(); if (rebuildComponent != nullptr) { rebuildComponent->AddRebuildStateCallback([this, self, counterWeight](eRebuildState state) { @@ -257,7 +257,7 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co return; } - auto* skillComponent = frakjaw->GetComponent(); + auto skillComponent = frakjaw->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(1635, 39097, frakjaw->GetObjectID(), true, false); } @@ -285,12 +285,12 @@ void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* low RenderComponent::PlayAnimation(lowerFrakjaw, TeleportInAnimation); self->SetVar(LowerFrakjawVariable, lowerFrakjaw->GetObjectID()); - auto* combatAI = lowerFrakjaw->GetComponent(); + auto combatAI = lowerFrakjaw->GetComponent(); if (combatAI != nullptr) { combatAI->SetDisabled(true); } - auto* destroyableComponent = lowerFrakjaw->GetComponent(); + auto destroyableComponent = lowerFrakjaw->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->AddOnHitCallback([this, self, lowerFrakjaw](Entity* attacker) { NjMonastryBossInstance::HandleLowerFrakjawHit(self, lowerFrakjaw, attacker); @@ -323,7 +323,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* low } void NjMonastryBossInstance::HandleLowerFrakjawHit(Entity* self, Entity* lowerFrakjaw, Entity* attacker) { - auto* destroyableComponent = lowerFrakjaw->GetComponent(); + auto destroyableComponent = lowerFrakjaw->GetComponent(); if (destroyableComponent == nullptr) return; @@ -332,7 +332,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawHit(Entity* self, Entity* lowerFr self->SetVar(OnLastWaveVarbiale, true); // Stun frakjaw during the cinematic - auto* combatAI = lowerFrakjaw->GetComponent(); + auto combatAI = lowerFrakjaw->GetComponent(); if (combatAI != nullptr) { combatAI->SetDisabled(true); } @@ -347,7 +347,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawHit(Entity* self, Entity* lowerFr newTrashMobs.push_back(trashMobID); // Stun all the enemies until the cinematic is over - auto* trashMobCombatAI = trashMob->GetComponent(); + auto trashMobCombatAI = trashMob->GetComponent(); if (trashMobCombatAI != nullptr) { trashMobCombatAI->SetDisabled(true); } @@ -375,7 +375,7 @@ void NjMonastryBossInstance::HandleWaveEnemySpawned(Entity* self, Entity* waveEn waveEnemies.push_back(waveEnemy->GetObjectID()); self->SetVar>(TrashMobsAliveVariable, waveEnemies); - auto* combatAI = waveEnemy->GetComponent(); + auto combatAI = waveEnemy->GetComponent(); if (combatAI != nullptr) { combatAI->SetDisabled(true); ActivityTimerStart(self, UnstunTimer + std::to_string(waveEnemy->GetObjectID()), 3.0f, 3.0f); @@ -436,7 +436,7 @@ void NjMonastryBossInstance::RemovePoison(Entity* self) { auto* player = EntityManager::Instance()->GetEntity(playerID); if (player != nullptr) { - auto* buffComponent = player->GetComponent(); + auto buffComponent = player->GetComponent(); if (buffComponent != nullptr) { buffComponent->RemoveBuff(PoisonBuff); } diff --git a/dScripts/02_server/Minigame/General/MinigameTreasureChestServer.cpp b/dScripts/02_server/Minigame/General/MinigameTreasureChestServer.cpp index 7df8fc123..f944b343a 100644 --- a/dScripts/02_server/Minigame/General/MinigameTreasureChestServer.cpp +++ b/dScripts/02_server/Minigame/General/MinigameTreasureChestServer.cpp @@ -6,7 +6,7 @@ #include "Loot.h" void MinigameTreasureChestServer::OnUse(Entity* self, Entity* user) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) return; @@ -57,7 +57,7 @@ void MinigameTreasureChestServer::OnStartup(Entity* self) { // BONS treasure chest thinks it's on FV, causing it to start a lobby if (dZoneManager::Instance()->GetZoneID().GetMapID() == 1204) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac != nullptr) { sac->SetInstanceMapID(1204); } diff --git a/dScripts/02_server/Pets/DamagingPets.cpp b/dScripts/02_server/Pets/DamagingPets.cpp index 6fd8c560e..5d4bf0ea1 100644 --- a/dScripts/02_server/Pets/DamagingPets.cpp +++ b/dScripts/02_server/Pets/DamagingPets.cpp @@ -8,7 +8,7 @@ void DamagingPets::OnStartup(Entity* self) { // Make the pet hostile or non-hostile based on whether or not it is tamed - const auto* petComponent = self->GetComponent(); + const auto petComponent = self->GetComponent(); if (petComponent != nullptr && petComponent->GetOwner() == nullptr) { self->AddTimer("GoEvil", 0.5f); } @@ -19,9 +19,9 @@ void DamagingPets::OnPlayerLoaded(Entity* self, Entity* player) { // Makes it so that new players also see the effect self->AddCallbackTimer(2.5f, [self]() { if (self != nullptr) { - const auto* petComponent = self->GetComponent(); + const auto petComponent = self->GetComponent(); if (petComponent != nullptr && petComponent->GetOwner() == nullptr && self->GetVar(u"IsEvil")) { - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { auto counter = 1; for (const auto petEffect : GetPetInfo(self).effect) { @@ -58,7 +58,7 @@ void DamagingPets::OnSkillEventFired(Entity* self, Entity* caster, const std::st if (infoForPet.skill == message) { // Only make pets tamable that aren't tamed yet - const auto* petComponent = self->GetComponent(); + const auto petComponent = self->GetComponent(); if (petComponent != nullptr && petComponent->GetOwner() == nullptr && self->GetVar(u"IsEvil")) { ClearEffects(self); self->AddTimer("GoEvil", 30.0f); @@ -74,7 +74,7 @@ void DamagingPets::OnTimerDone(Entity* self, std::string message) { } void DamagingPets::MakeUntamable(Entity* self) { - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); // If the pet is currently not being tamed, make it hostile if (petComponent != nullptr && petComponent->GetStatus() != 5) { @@ -82,19 +82,19 @@ void DamagingPets::MakeUntamable(Entity* self) { self->SetVar(u"IsEvil", true); petComponent->SetStatus(1); - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(false); } // Special faction that can attack the player but the player can't attack - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetFaction(114); destroyableComponent->SetHealth(5); } - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { auto counter = 1; for (const auto petEffect : GetPetInfo(self).effect) { @@ -108,22 +108,22 @@ void DamagingPets::MakeUntamable(Entity* self) { void DamagingPets::ClearEffects(Entity* self) { self->SetVar(u"IsEvil", false); - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent != nullptr) { petComponent->SetStatus(67108866); } - auto* combatAIComponent = self->GetComponent(); + auto combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(true); } - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetFaction(99); } - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { auto counter = 1; for (const auto petEffect : GetPetInfo(self).effect) { diff --git a/dScripts/02_server/Pets/PetFromDigServer.cpp b/dScripts/02_server/Pets/PetFromDigServer.cpp index 525f3e946..6ffb6192f 100644 --- a/dScripts/02_server/Pets/PetFromDigServer.cpp +++ b/dScripts/02_server/Pets/PetFromDigServer.cpp @@ -3,7 +3,7 @@ #include "ePetTamingNotifyType.h" void PetFromDigServer::OnStartup(Entity* self) { - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; @@ -21,7 +21,7 @@ void PetFromDigServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "killself") { // Don't accidentally kill a pet that is already owned - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; @@ -35,7 +35,7 @@ void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eP } else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) { self->Smash(self->GetObjectID(), eKillType::SILENT); } else if (type == ePetTamingNotifyType::SUCCESS) { - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr) return; // TODO: Remove custom group? diff --git a/dScripts/02_server/Pets/PetFromObjectServer.cpp b/dScripts/02_server/Pets/PetFromObjectServer.cpp index 0a78d7ecd..e362c3f72 100644 --- a/dScripts/02_server/Pets/PetFromObjectServer.cpp +++ b/dScripts/02_server/Pets/PetFromObjectServer.cpp @@ -9,7 +9,7 @@ void PetFromObjectServer::OnStartup(Entity* self) { void PetFromObjectServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "killSelf") { - const auto* petComponent = self->GetComponent(); + const auto petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; self->Smash(self->GetObjectID(), eKillType::SILENT); diff --git a/dScripts/ActivityManager.cpp b/dScripts/ActivityManager.cpp index 078a7a02e..46653a945 100644 --- a/dScripts/ActivityManager.cpp +++ b/dScripts/ActivityManager.cpp @@ -8,12 +8,12 @@ #include "Loot.h" bool ActivityManager::IsPlayerInActivity(Entity* self, LWOOBJID playerID) { - const auto* sac = self->GetComponent(); + const auto sac = self->GetComponent(); return sac != nullptr && sac->IsPlayedBy(playerID); } void ActivityManager::UpdatePlayer(Entity* self, LWOOBJID playerID, const bool remove) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) return; @@ -34,7 +34,7 @@ void ActivityManager::SetActivityScore(Entity* self, LWOOBJID playerID, uint32_t void ActivityManager::SetActivityValue(Entity* self, const LWOOBJID playerID, const uint32_t valueIndex, const float_t value) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) return; @@ -42,7 +42,7 @@ void ActivityManager::SetActivityValue(Entity* self, const LWOOBJID playerID, co } float_t ActivityManager::GetActivityValue(Entity* self, const LWOOBJID playerID, const uint32_t valueIndex) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) return -1.0f; @@ -53,7 +53,7 @@ void ActivityManager::StopActivity(Entity* self, const LWOOBJID playerID, const const uint32_t value1, const uint32_t value2, bool quit) { int32_t gameID = 0; - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) { gameID = self->GetLOT(); } else { @@ -92,7 +92,7 @@ void ActivityManager::StopActivity(Entity* self, const LWOOBJID playerID, const } bool ActivityManager::TakeActivityCost(const Entity* self, const LWOOBJID playerID) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) return false; @@ -104,7 +104,7 @@ bool ActivityManager::TakeActivityCost(const Entity* self, const LWOOBJID player } uint32_t ActivityManager::CalculateActivityRating(Entity* self, const LWOOBJID playerID) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) return 0; @@ -112,7 +112,7 @@ uint32_t ActivityManager::CalculateActivityRating(Entity* self, const LWOOBJID p } uint32_t ActivityManager::GetActivityID(const Entity* self) { - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); return sac != nullptr ? sac->GetActivityID() : 0; } @@ -147,7 +147,7 @@ float_t ActivityManager::ActivityTimerGetCurrentTime(Entity* self, const std::st int32_t ActivityManager::GetGameID(Entity* self) const { int32_t gameID = 0; - auto* sac = self->GetComponent(); + auto sac = self->GetComponent(); if (sac == nullptr) { gameID = self->GetLOT(); } else { diff --git a/dScripts/BasePropertyServer.cpp b/dScripts/BasePropertyServer.cpp index 72cce09f7..618e6fd42 100644 --- a/dScripts/BasePropertyServer.cpp +++ b/dScripts/BasePropertyServer.cpp @@ -95,7 +95,7 @@ void BasePropertyServer::BasePlayerLoaded(Entity* self, Entity* player) { const auto& mapID = dZoneManager::Instance()->GetZone()->GetZoneID(); if (propertyOwner > 0) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress( @@ -149,7 +149,7 @@ void BasePropertyServer::BasePlayerLoaded(Entity* self, Entity* player) { } void BasePropertyServer::PropGuardCheck(Entity* self, Entity* player) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr && missionComponent->GetMissionState(self->GetVar(guardMissionFlag)) != eMissionState::COMPLETE) { @@ -241,7 +241,7 @@ void BasePropertyServer::StartTornadoFx(Entity* self) const { } for (auto* entity : entities) { - auto* renderComponent = entity->GetComponent(); + auto renderComponent = entity->GetComponent(); if (renderComponent != nullptr) { renderComponent->PlayEffect(-1, u"debrisOn", "TornadoDebris"); renderComponent->PlayEffect(-1, u"VortexOn", "TornadoVortex"); @@ -270,7 +270,7 @@ void BasePropertyServer::KillGuard(Entity* self) { } void BasePropertyServer::RequestDie(Entity* self, Entity* other) { - auto* destroyable = other->GetComponent(); + auto destroyable = other->GetComponent(); if (destroyable == nullptr) return; @@ -344,7 +344,7 @@ void BasePropertyServer::BaseTimerDone(Entity* self, const std::string& timerNam auto fxManagers = EntityManager::Instance()->GetEntitiesInGroup(self->GetVar(FXManagerGroup)); for (auto* fxManager : fxManagers) { - auto* renderComponent = fxManager->GetComponent(); + auto renderComponent = fxManager->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("TornadoDebris", false); renderComponent->StopEffect("TornadoVortex", false); @@ -357,7 +357,7 @@ void BasePropertyServer::BaseTimerDone(Entity* self, const std::string& timerNam auto fxManagers = EntityManager::Instance()->GetEntitiesInGroup(self->GetVar(FXManagerGroup)); for (auto* fxManager : fxManagers) { - auto* renderComponent = fxManager->GetComponent(); + auto renderComponent = fxManager->GetComponent(); if (renderComponent != nullptr) renderComponent->PlayEffect(-1, u"beamOn", "beam"); } @@ -423,7 +423,7 @@ void BasePropertyServer::BaseTimerDone(Entity* self, const std::string& timerNam } for (auto* fxManager : fxManagers) { - auto* renderComponent = fxManager->GetComponent(); + auto renderComponent = fxManager->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("beam"); } diff --git a/dScripts/BaseSurvivalServer.cpp b/dScripts/BaseSurvivalServer.cpp index 3d72628dc..fb9f34841 100644 --- a/dScripts/BaseSurvivalServer.cpp +++ b/dScripts/BaseSurvivalServer.cpp @@ -225,7 +225,7 @@ void BaseSurvivalServer::ResetStats(LWOOBJID playerID) { if (player != nullptr) { // Boost all the player stats when loading in - auto* destroyableComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetHealth(destroyableComponent->GetMaxHealth()); destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor()); @@ -360,7 +360,7 @@ void BaseSurvivalServer::GameOver(Entity* self) { player->Resurrect(); // Update all mission progression - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, time, self->GetObjectID(), self->GetVar(MissionTypeVariable)); diff --git a/dScripts/BaseWavesServer.cpp b/dScripts/BaseWavesServer.cpp index 00340bd02..c3114cd05 100644 --- a/dScripts/BaseWavesServer.cpp +++ b/dScripts/BaseWavesServer.cpp @@ -228,7 +228,7 @@ void BaseWavesServer::ResetStats(LWOOBJID playerID) { if (player != nullptr) { // Boost all the player stats when loading in - auto* destroyableComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetHealth(destroyableComponent->GetMaxHealth()); destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor()); @@ -372,7 +372,7 @@ void BaseWavesServer::GameOver(Entity* self, bool won) { } // Update all mission progression - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, time, self->GetObjectID(), self->GetVar(MissionTypeVariable)); } @@ -505,7 +505,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3 SetActivityValue(self, playerID, 2, state.waveNumber); // Update player missions - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { for (const auto& missionID : waveMission) { // Get the mission state @@ -560,7 +560,7 @@ void BaseWavesServer::UpdateMissionForAllPlayers(Entity* self, uint32_t missionI for (const auto& playerID : state.players) { auto* player = EntityManager::Instance()->GetEntity(playerID); if (player != nullptr) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent == nullptr) return; // Get the mission state auto missionState = missionComponent->GetMissionState(missionID); diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 5459fd370..c8e64498a 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -944,8 +944,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr std::vector CppScripts::GetEntityScripts(Entity* entity) { std::vector scripts; - std::vector comps = entity->GetScriptComponents(); - for (ScriptComponent* scriptComp : comps) { + auto comps = entity->GetScriptComponents(); + for (auto& scriptComp : comps) { if (scriptComp != nullptr) { scripts.push_back(scriptComp->GetScript()); } diff --git a/dScripts/Darkitect.cpp b/dScripts/Darkitect.cpp index b4364332e..0ad0b549f 100644 --- a/dScripts/Darkitect.cpp +++ b/dScripts/Darkitect.cpp @@ -16,8 +16,8 @@ void Darkitect::Reveal(Entity* self, Entity* player) { if (!player) return; - auto* destroyableComponent = player->GetComponent(); - auto* missionComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); auto* character = player->GetCharacter(); if (destroyableComponent != nullptr && missionComponent != nullptr && character != nullptr) { diff --git a/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp b/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp index 3db214b5e..cd68ae1cd 100644 --- a/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp +++ b/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp @@ -3,7 +3,7 @@ void BuccaneerValiantShip::OnStartup(Entity* self) { self->AddCallbackTimer(1.0F, [self]() { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); auto* owner = self->GetOwner(); if (skillComponent != nullptr && owner != nullptr) { diff --git a/dScripts/EquipmentScripts/PersonalFortress.cpp b/dScripts/EquipmentScripts/PersonalFortress.cpp index f1fe73ee0..2001f579b 100644 --- a/dScripts/EquipmentScripts/PersonalFortress.cpp +++ b/dScripts/EquipmentScripts/PersonalFortress.cpp @@ -10,13 +10,13 @@ void PersonalFortress::OnStartup(Entity* self) { auto* owner = self->GetOwner(); self->AddTimer("FireSkill", 1.5); - auto* destroyableComponent = owner->GetComponent(); + auto destroyableComponent = owner->GetComponent(); if (destroyableComponent) destroyableComponent->SetStatusImmunity( eStateChangeType::PUSH, true, true, true, true, true, false, true, false, false ); - auto* controllablePhysicsComponent = owner->GetComponent(); + auto controllablePhysicsComponent = owner->GetComponent(); if (controllablePhysicsComponent) controllablePhysicsComponent->SetStunImmunity( eStateChangeType::PUSH, LWOOBJID_EMPTY, true, true, true, true, true, true @@ -31,13 +31,13 @@ void PersonalFortress::OnStartup(Entity* self) { void PersonalFortress::OnDie(Entity* self, Entity* killer) { auto* owner = self->GetOwner(); - auto* destroyableComponent = owner->GetComponent(); + auto destroyableComponent = owner->GetComponent(); if (destroyableComponent) destroyableComponent->SetStatusImmunity( eStateChangeType::POP, true, true, true, true, true, false, true, false, false ); - auto* controllablePhysicsComponent = owner->GetComponent(); + auto controllablePhysicsComponent = owner->GetComponent(); if (controllablePhysicsComponent) controllablePhysicsComponent->SetStunImmunity( eStateChangeType::POP, LWOOBJID_EMPTY, true, true, true, true, true, true @@ -52,7 +52,7 @@ void PersonalFortress::OnDie(Entity* self, Entity* killer) { void PersonalFortress::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "FireSkill") { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent) skillComponent->CalculateBehavior(650, 13364, LWOOBJID_EMPTY, true, false); } } diff --git a/dScripts/EquipmentScripts/StunImmunity.cpp b/dScripts/EquipmentScripts/StunImmunity.cpp index 0ec956f07..bbb8420e3 100644 --- a/dScripts/EquipmentScripts/StunImmunity.cpp +++ b/dScripts/EquipmentScripts/StunImmunity.cpp @@ -4,14 +4,14 @@ #include "eStateChangeType.h" void StunImmunity::OnStartup(Entity* self) { - auto* destroyableComponent = self->GetComponent(); + auto destroyableComponent = self->GetComponent(); if (destroyableComponent) { destroyableComponent->SetStatusImmunity( eStateChangeType::PUSH, false, false, true, true, false, false, false, false, true ); } - auto* controllablePhysicsComponent = self->GetComponent(); + auto controllablePhysicsComponent = self->GetComponent(); if (controllablePhysicsComponent) { controllablePhysicsComponent->SetStunImmunity( eStateChangeType::PUSH, self->GetObjectID(), true diff --git a/dScripts/EquipmentTriggers/CoilBackpackBase.cpp b/dScripts/EquipmentTriggers/CoilBackpackBase.cpp index 4e323a086..decf22825 100644 --- a/dScripts/EquipmentTriggers/CoilBackpackBase.cpp +++ b/dScripts/EquipmentTriggers/CoilBackpackBase.cpp @@ -12,7 +12,7 @@ void CoilBackpackBase::NotifyHitOrHealResult(Entity* self, Entity* attacker, int if (damage > 0) { self->SetVar(u"coilCount", self->GetVar(u"coilCount") + 1); if (self->GetVar(u"coilCount") > 4) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (!skillComponent) return; skillComponent->CastSkill(m_SkillId); self->SetVar(u"coilCount", 0); diff --git a/dScripts/NPCAddRemoveItem.cpp b/dScripts/NPCAddRemoveItem.cpp index 13677072c..6a9c7c138 100644 --- a/dScripts/NPCAddRemoveItem.cpp +++ b/dScripts/NPCAddRemoveItem.cpp @@ -3,7 +3,7 @@ #include "eMissionState.h" void NPCAddRemoveItem::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { - auto* inventory = target->GetComponent(); + auto inventory = target->GetComponent(); if (inventory == nullptr) return; diff --git a/dScripts/NtFactionSpyServer.cpp b/dScripts/NtFactionSpyServer.cpp index 5c3d689bd..b3cb8e2b6 100644 --- a/dScripts/NtFactionSpyServer.cpp +++ b/dScripts/NtFactionSpyServer.cpp @@ -47,8 +47,8 @@ bool NtFactionSpyServer::IsSpy(Entity* self, Entity* possibleSpy) { if (!spyData.missionID || !spyData.flagID || !spyData.itemID) return false; - auto* missionComponent = possibleSpy->GetComponent(); - auto* inventoryComponent = possibleSpy->GetComponent(); + auto missionComponent = possibleSpy->GetComponent(); + auto inventoryComponent = possibleSpy->GetComponent(); auto* character = possibleSpy->GetCharacter(); // A player is a spy if they have the spy mission, have the spy equipment equipped and don't have the spy flag set yet diff --git a/dScripts/ScriptedPowerupSpawner.cpp b/dScripts/ScriptedPowerupSpawner.cpp index 3c1d1cca1..c1ceb338b 100644 --- a/dScripts/ScriptedPowerupSpawner.cpp +++ b/dScripts/ScriptedPowerupSpawner.cpp @@ -23,7 +23,7 @@ void ScriptedPowerupSpawner::OnTimerDone(Entity* self, std::string message) { // Spawn the required number of powerups auto* owner = EntityManager::Instance()->GetEntity(self->GetSpawnerID()); if (owner != nullptr) { - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); for (auto i = 0; i < self->GetVar(u"numberOfPowerups"); i++) { if (renderComponent != nullptr) { renderComponent->PlayEffect(0, u"cast", "N_cast"); diff --git a/dScripts/SpawnPetBaseServer.cpp b/dScripts/SpawnPetBaseServer.cpp index 75b46382d..94859d3a0 100644 --- a/dScripts/SpawnPetBaseServer.cpp +++ b/dScripts/SpawnPetBaseServer.cpp @@ -61,7 +61,7 @@ bool SpawnPetBaseServer::CheckNumberOfPets(Entity* self, Entity* user) { if (spawnedPet == nullptr) continue; - const auto* petComponent = spawnedPet->GetComponent(); + const auto petComponent = spawnedPet->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) continue; diff --git a/dScripts/ai/ACT/ActMine.cpp b/dScripts/ai/ACT/ActMine.cpp index 9651e13d1..13ab27df7 100644 --- a/dScripts/ai/ACT/ActMine.cpp +++ b/dScripts/ai/ACT/ActMine.cpp @@ -10,7 +10,7 @@ void ActMine::OnStartup(Entity* self) { void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) { if (state == eRebuildState::COMPLETED) { - auto* rebuild = self->GetComponent(); + auto rebuild = self->GetComponent(); if (rebuild) { auto* builder = rebuild->GetBuilder(); self->SetVar(u"Builder", builder->GetObjectID()); @@ -24,7 +24,7 @@ void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) { } void ActMine::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - auto* detroyable = self->GetComponent(); + auto detroyable = self->GetComponent(); if (!detroyable) return; if (status == "ENTER" && self->GetVar(u"RebuildComplete") == true && detroyable->IsEnemy(entering)) { GameMessages::SendPlayFXEffect(self->GetObjectID(), 242, u"orange", "sirenlight_B"); @@ -35,7 +35,7 @@ void ActMine::OnProximityUpdate(Entity* self, Entity* entering, std::string name void ActMine::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "Tick") { if (self->GetVar(u"NumWarnings") >= MAX_WARNINGS) { - auto* skill = self->GetComponent(); + auto skill = self->GetComponent(); if (!skill) return; skill->CalculateBehavior(SKILL_ID, BEHAVIOR_ID, LWOOBJID_EMPTY); self->AddTimer("BlowedUp", BLOWED_UP_TIME); diff --git a/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp b/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp index 76c0289e9..c841a39f2 100644 --- a/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp +++ b/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp @@ -8,7 +8,7 @@ void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { - auto* possessableComponent = target->GetComponent(); + auto possessableComponent = target->GetComponent(); Entity* vehicle; Entity* player; @@ -22,7 +22,7 @@ void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { return; } else if (target->IsPlayer()) { - auto* possessorComponent = target->GetComponent(); + auto possessorComponent = target->GetComponent(); if (possessorComponent == nullptr) { return; @@ -44,7 +44,7 @@ void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); - auto* racingControlComponent = zoneController->GetComponent(); + auto racingControlComponent = zoneController->GetComponent(); if (racingControlComponent != nullptr) { racingControlComponent->OnRequestDie(player); diff --git a/dScripts/ai/AG/AgBusDoor.cpp b/dScripts/ai/AG/AgBusDoor.cpp index 4910d0c50..691e5b94c 100644 --- a/dScripts/ai/AG/AgBusDoor.cpp +++ b/dScripts/ai/AG/AgBusDoor.cpp @@ -16,7 +16,7 @@ void AgBusDoor::OnProximityUpdate(Entity* self, Entity* entering, std::string na // Make sure only humans are taken into account if (!entering->GetCharacter()) return; - auto* proximityMonitorComponent = self->GetComponent(); + auto proximityMonitorComponent = self->GetComponent(); if (proximityMonitorComponent == nullptr) return; diff --git a/dScripts/ai/AG/AgDarkSpiderling.cpp b/dScripts/ai/AG/AgDarkSpiderling.cpp index 5dbd350a0..5ffc5ec74 100644 --- a/dScripts/ai/AG/AgDarkSpiderling.cpp +++ b/dScripts/ai/AG/AgDarkSpiderling.cpp @@ -2,7 +2,7 @@ #include "BaseCombatAIComponent.h" void AgDarkSpiderling::OnStartup(Entity* self) { - auto* combatAI = self->GetComponent(); + auto combatAI = self->GetComponent(); if (combatAI != nullptr) { combatAI->SetStunImmune(true); } diff --git a/dScripts/ai/AG/AgFans.cpp b/dScripts/ai/AG/AgFans.cpp index aaff9c0dd..1639bb53b 100644 --- a/dScripts/ai/AG/AgFans.cpp +++ b/dScripts/ai/AG/AgFans.cpp @@ -14,7 +14,7 @@ void AgFans::OnStartup(Entity* self) { ToggleFX(self, false); - auto* renderComponent = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto renderComponent = self->GetComponent(); if (renderComponent == nullptr) { return; @@ -27,7 +27,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) { std::string fanGroup = self->GetGroups()[0]; std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); - auto* renderComponent = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto renderComponent = self->GetComponent(); if (renderComponent == nullptr) { return; @@ -42,7 +42,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) { self->SetVar(u"on", false); for (Entity* volume : fanVolumes) { - PhantomPhysicsComponent* volumePhys = static_cast(volume->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS)); + auto volumePhys = volume->GetComponent(); if (!volumePhys) continue; volumePhys->SetPhysicsEffectActive(false); EntityManager::Instance()->SerializeEntity(volume); @@ -58,7 +58,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) { self->SetVar(u"on", true); for (Entity* volume : fanVolumes) { - PhantomPhysicsComponent* volumePhys = static_cast(volume->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS)); + auto volumePhys = volume->GetComponent(); if (!volumePhys) continue; volumePhys->SetPhysicsEffectActive(true); EntityManager::Instance()->SerializeEntity(volume); diff --git a/dScripts/ai/AG/AgImagSmashable.cpp b/dScripts/ai/AG/AgImagSmashable.cpp index 5e8331b18..6cd201d9b 100644 --- a/dScripts/ai/AG/AgImagSmashable.cpp +++ b/dScripts/ai/AG/AgImagSmashable.cpp @@ -10,7 +10,7 @@ void AgImagSmashable::OnDie(Entity* self, Entity* killer) { bool maxImagGreaterThanZero = false; if (killer) { - DestroyableComponent* dest = static_cast(killer->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto dest = killer->GetComponent(); if (dest) { maxImagGreaterThanZero = dest->GetMaxImagination() > 0; } diff --git a/dScripts/ai/AG/AgJetEffectServer.cpp b/dScripts/ai/AG/AgJetEffectServer.cpp index 0a26069e2..d8cb2cdde 100644 --- a/dScripts/ai/AG/AgJetEffectServer.cpp +++ b/dScripts/ai/AG/AgJetEffectServer.cpp @@ -49,7 +49,7 @@ void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName) { // so we give proper credit to the builder for the kills from this skill mortar->SetOwnerOverride(builder); - auto* skillComponent = mortar->GetComponent(); + auto skillComponent = mortar->GetComponent(); if (skillComponent) skillComponent->CastSkill(318); } else if (timerName == "CineDone") { GameMessages::SendNotifyClientObject( diff --git a/dScripts/ai/AG/AgStagePlatforms.cpp b/dScripts/ai/AG/AgStagePlatforms.cpp index 9ba4c4b7a..03ed41e8d 100644 --- a/dScripts/ai/AG/AgStagePlatforms.cpp +++ b/dScripts/ai/AG/AgStagePlatforms.cpp @@ -2,7 +2,7 @@ #include "MovingPlatformComponent.h" void AgStagePlatforms::OnStartup(Entity* self) { - auto* component = self->GetComponent(); + auto component = self->GetComponent(); if (component) { component->SetNoAutoStart(true); component->StopPathing(); @@ -10,7 +10,7 @@ void AgStagePlatforms::OnStartup(Entity* self) { } void AgStagePlatforms::OnWaypointReached(Entity* self, uint32_t waypointIndex) { - auto* component = self->GetComponent(); + auto component = self->GetComponent(); if (waypointIndex == 0 && component) component->StopPathing(); } diff --git a/dScripts/ai/FV/ActParadoxPipeFix.cpp b/dScripts/ai/FV/ActParadoxPipeFix.cpp index 10a1e6523..99d0a43dc 100644 --- a/dScripts/ai/FV/ActParadoxPipeFix.cpp +++ b/dScripts/ai/FV/ActParadoxPipeFix.cpp @@ -19,7 +19,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { continue; } - auto* rebuildComponent = object->GetComponent(); + auto rebuildComponent = object->GetComponent(); if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { indexCount++; @@ -37,7 +37,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { auto* player = EntityManager::Instance()->GetEntity(object->GetVar(u"PlayerID")); if (player != nullptr) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgressTaskType(769, 1, 1, false); diff --git a/dScripts/ai/FV/FvBrickPuzzleServer.cpp b/dScripts/ai/FV/FvBrickPuzzleServer.cpp index 887b9a4d9..a3673bd82 100644 --- a/dScripts/ai/FV/FvBrickPuzzleServer.cpp +++ b/dScripts/ai/FV/FvBrickPuzzleServer.cpp @@ -59,7 +59,7 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) { void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::OPEN) { self->Smash(self->GetObjectID(), eKillType::SILENT); diff --git a/dScripts/ai/FV/FvFlyingCreviceDragon.cpp b/dScripts/ai/FV/FvFlyingCreviceDragon.cpp index cb0fe3d0e..c6dbc4881 100644 --- a/dScripts/ai/FV/FvFlyingCreviceDragon.cpp +++ b/dScripts/ai/FV/FvFlyingCreviceDragon.cpp @@ -40,7 +40,7 @@ void FvFlyingCreviceDragon::OnTimerDone(Entity* self, std::string timerName) { return; } - auto* skillComponent = group[0]->GetComponent(); + auto skillComponent = group[0]->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY, true); @@ -79,7 +79,7 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) { return; } - auto* skillComponent = group2[0]->GetComponent(); + auto skillComponent = group2[0]->GetComponent(); if (skillComponent != nullptr) { skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY); diff --git a/dScripts/ai/FV/FvFreeGfNinjas.cpp b/dScripts/ai/FV/FvFreeGfNinjas.cpp index d690a6f7d..c8c2c0af6 100644 --- a/dScripts/ai/FV/FvFreeGfNinjas.cpp +++ b/dScripts/ai/FV/FvFreeGfNinjas.cpp @@ -5,7 +5,7 @@ void FvFreeGfNinjas::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { if (missionID == 705 && missionState == eMissionState::AVAILABLE) { - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent == nullptr) return; @@ -26,7 +26,7 @@ void FvFreeGfNinjas::OnMissionDialogueOK(Entity* self, Entity* target, int missi void FvFreeGfNinjas::OnUse(Entity* self, Entity* user) { // To allow player who already have the mission to progress. - auto* missionComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); if (missionComponent == nullptr) return; diff --git a/dScripts/ai/FV/FvMaelstromGeyser.cpp b/dScripts/ai/FV/FvMaelstromGeyser.cpp index 66aa43dc8..736de10e4 100644 --- a/dScripts/ai/FV/FvMaelstromGeyser.cpp +++ b/dScripts/ai/FV/FvMaelstromGeyser.cpp @@ -8,7 +8,7 @@ void FvMaelstromGeyser::OnStartup(Entity* self) { void FvMaelstromGeyser::OnTimerDone(Entity* self, std::string timerName) { if (timerName == m_StartSkillTimerName) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); skillComponent->CalculateBehavior(m_SkillID, m_BehaviorID, LWOOBJID_EMPTY, true); } if (timerName == m_KillSelfTimerName) { diff --git a/dScripts/ai/FV/FvPandaServer.cpp b/dScripts/ai/FV/FvPandaServer.cpp index f29f7f2ee..0d661d53e 100644 --- a/dScripts/ai/FV/FvPandaServer.cpp +++ b/dScripts/ai/FV/FvPandaServer.cpp @@ -4,7 +4,7 @@ #include "ePetTamingNotifyType.h" void FvPandaServer::OnStartup(Entity* self) { - const auto* petComponent = self->GetComponent(); + const auto petComponent = self->GetComponent(); if (petComponent != nullptr && petComponent->GetOwner() == nullptr) { self->SetNetworkVar(u"pandatamer", std::to_string(self->GetVar(u"tamer"))); self->AddTimer("killSelf", 45); @@ -28,7 +28,7 @@ void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetT void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "killSelf") { - const auto* petComponent = self->GetComponent(); + const auto petComponent = self->GetComponent(); if (petComponent != nullptr && petComponent->GetOwner() == nullptr) { self->Smash(self->GetObjectID(), eKillType::SILENT); } diff --git a/dScripts/ai/FV/FvPandaSpawnerServer.cpp b/dScripts/ai/FV/FvPandaSpawnerServer.cpp index d7dcabcdc..3acea410d 100644 --- a/dScripts/ai/FV/FvPandaSpawnerServer.cpp +++ b/dScripts/ai/FV/FvPandaSpawnerServer.cpp @@ -14,7 +14,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) { return; // Check if the player is currently in a footrace - auto* scriptedActivityComponent = raceObjects.at(0)->GetComponent(); + auto scriptedActivityComponent = raceObjects.at(0)->GetComponent(); if (scriptedActivityComponent == nullptr || !scriptedActivityComponent->IsPlayedBy(target)) return; diff --git a/dScripts/ai/FV/TriggerGas.cpp b/dScripts/ai/FV/TriggerGas.cpp index 7e9762e3c..fa70b0ae6 100644 --- a/dScripts/ai/FV/TriggerGas.cpp +++ b/dScripts/ai/FV/TriggerGas.cpp @@ -36,7 +36,7 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) { auto inventoryComponent = player->GetComponent(); if (inventoryComponent) { if (!inventoryComponent->IsEquipped(this->m_MaelstromHelmet)) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (skillComponent) { skillComponent->CastSkill(this->m_FogDamageSkill, player->GetObjectID()); } diff --git a/dScripts/ai/GENERAL/LegoDieRoll.cpp b/dScripts/ai/GENERAL/LegoDieRoll.cpp index 763a47043..d790e0f96 100644 --- a/dScripts/ai/GENERAL/LegoDieRoll.cpp +++ b/dScripts/ai/GENERAL/LegoDieRoll.cpp @@ -37,7 +37,7 @@ void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) { RenderComponent::PlayAnimation(self, u"roll-die-6"); // tracking the It's Truly Random Achievement auto* owner = self->GetOwner(); - auto* missionComponent = owner->GetComponent(); + auto missionComponent = owner->GetComponent(); if (missionComponent != nullptr) { const auto rollMissionState = missionComponent->GetMissionState(756); diff --git a/dScripts/ai/GF/GfArchway.cpp b/dScripts/ai/GF/GfArchway.cpp index 429f62aed..0154c3b56 100644 --- a/dScripts/ai/GF/GfArchway.cpp +++ b/dScripts/ai/GF/GfArchway.cpp @@ -3,6 +3,6 @@ #include "SkillComponent.h" void GfArchway::OnRebuildComplete(Entity* self, Entity* target) { - auto* skillComponent = target->GetComponent(); + auto skillComponent = target->GetComponent(); if (skillComponent) skillComponent->CalculateBehavior(SHIELDING_SKILL, SHIELDING_BEHAVIOR, target->GetObjectID(), true); } diff --git a/dScripts/ai/GF/GfBanana.cpp b/dScripts/ai/GF/GfBanana.cpp index 95a831cd2..0c233e864 100644 --- a/dScripts/ai/GF/GfBanana.cpp +++ b/dScripts/ai/GF/GfBanana.cpp @@ -38,7 +38,7 @@ void GfBanana::OnStartup(Entity* self) { } void GfBanana::OnHit(Entity* self, Entity* attacker) { - auto* destroyable = self->GetComponent(); + auto destroyable = self->GetComponent(); destroyable->SetHealth(9999); @@ -58,7 +58,7 @@ void GfBanana::OnHit(Entity* self, Entity* attacker) { bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3::UNIT_Y * 8); - auto* bananaDestroyable = bananaEntity->GetComponent(); + auto bananaDestroyable = bananaEntity->GetComponent(); bananaDestroyable->SetHealth(0); diff --git a/dScripts/ai/GF/GfCampfire.cpp b/dScripts/ai/GF/GfCampfire.cpp index 6a10b39ee..8e7e28a1e 100644 --- a/dScripts/ai/GF/GfCampfire.cpp +++ b/dScripts/ai/GF/GfCampfire.cpp @@ -11,7 +11,7 @@ void GfCampfire::OnStartup(Entity* self) { self->SetProximityRadius(2.0f, "placeholder"); self->SetBoolean(u"isBurning", true); - auto* render = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto render = self->GetComponent(); if (render == nullptr) return; @@ -21,14 +21,14 @@ void GfCampfire::OnStartup(Entity* self) { void GfCampfire::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "physicsReady") { - auto* render = static_cast(self->GetComponent(eReplicaComponentType::RENDER)); + auto render = self->GetComponent(); render->PlayEffect(295, u"running", "Burn"); } } void GfCampfire::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - auto* skill = self->GetComponent(); + auto skill = self->GetComponent(); if (self->GetBoolean(u"isBurning")) { if (status == "ENTER") { @@ -43,7 +43,7 @@ void GfCampfire::OnProximityUpdate(Entity* self, Entity* entering, std::string n //self->SetVar("target", entering->GetObjectID()); - auto* missionComponet = entering->GetComponent(); + auto missionComponet = entering->GetComponent(); if (missionComponet != nullptr) { missionComponet->ForceProgress(440, 658, 1); @@ -65,7 +65,7 @@ void GfCampfire::OnProximityUpdate(Entity* self, Entity* entering, std::string n void GfCampfire::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) { if (message == "waterspray" && self->GetVar(u"isBurning")) { - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("Burn"); renderComponent->PlayEffect(295, u"idle", "Off"); @@ -91,7 +91,7 @@ void GfCampfire::OnTimerDone(Entity* self, std::string timerName) { } */ } else if (timerName == "FireRestart" && !self->GetVar(u"isBurning")) { - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent != nullptr) { renderComponent->StopEffect("Off"); renderComponent->PlayEffect(295, u"running", "Burn"); diff --git a/dScripts/ai/GF/GfJailkeepMission.cpp b/dScripts/ai/GF/GfJailkeepMission.cpp index b8d4cd30e..767d75037 100644 --- a/dScripts/ai/GF/GfJailkeepMission.cpp +++ b/dScripts/ai/GF/GfJailkeepMission.cpp @@ -4,7 +4,7 @@ #include "eMissionState.h" void GfJailkeepMission::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent == nullptr) return; @@ -25,7 +25,7 @@ void GfJailkeepMission::OnMissionDialogueOK(Entity* self, Entity* target, int mi } void GfJailkeepMission::OnUse(Entity* self, Entity* user) { - auto* missionComponent = user->GetComponent(); + auto missionComponent = user->GetComponent(); if (missionComponent == nullptr) return; diff --git a/dScripts/ai/GF/GfMaelstromGeyser.cpp b/dScripts/ai/GF/GfMaelstromGeyser.cpp index 825307a70..4761c4502 100644 --- a/dScripts/ai/GF/GfMaelstromGeyser.cpp +++ b/dScripts/ai/GF/GfMaelstromGeyser.cpp @@ -8,7 +8,7 @@ void GfMaelstromGeyser::OnStartup(Entity* self) { void GfMaelstromGeyser::OnTimerDone(Entity* self, std::string timerName) { if (timerName == m_StartSkillTimerName) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); skillComponent->CalculateBehavior(m_SkillID, m_BehaviorID, LWOOBJID_EMPTY, true); } if (timerName == m_KillSelfTimerName) { diff --git a/dScripts/ai/GF/GfParrotCrash.cpp b/dScripts/ai/GF/GfParrotCrash.cpp index 6b76a51d4..f8e53e684 100644 --- a/dScripts/ai/GF/GfParrotCrash.cpp +++ b/dScripts/ai/GF/GfParrotCrash.cpp @@ -4,7 +4,7 @@ #include "dLogger.h" void GfParrotCrash::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { - auto* skillComponent = self->GetComponent(); + auto skillComponent = self->GetComponent(); if (args == "Slow") { skillComponent->CalculateBehavior(m_SlowSkillID, m_SlowBehaviorID, sender->GetObjectID()); } else if (args == "Unslow") { diff --git a/dScripts/ai/GF/PetDigBuild.cpp b/dScripts/ai/GF/PetDigBuild.cpp index 504a11993..431bcde51 100644 --- a/dScripts/ai/GF/PetDigBuild.cpp +++ b/dScripts/ai/GF/PetDigBuild.cpp @@ -22,7 +22,7 @@ void PetDigBuild::OnRebuildComplete(Entity* self, Entity* target) { info.lot = 7410; // Normal GF treasure info.settings.push_back(new LDFData(u"groupID", u"Flag" + flagNumber)); } else { - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent != nullptr && missionComponent->GetMissionState(746) == eMissionState::ACTIVE) { info.lot = 9307; // Special Captain Jack treasure that drops a mission item } else { diff --git a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp index 9543504ac..a4786a78c 100644 --- a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp +++ b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp @@ -30,7 +30,7 @@ void SGCannon::OnStartup(Entity* self) { self->SetVar(InitialVelocityVariable, {}); self->SetVar(ImpactSkillVariale, constants.impactSkillID); - auto* shootingGalleryComponent = self->GetComponent(); + auto shootingGalleryComponent = self->GetComponent(); if (shootingGalleryComponent != nullptr) { shootingGalleryComponent->SetStaticParams({ Vector3 { -327.8609924316406, 256.8999938964844, 1.6482199430465698 }, @@ -57,7 +57,7 @@ void SGCannon::OnStartup(Entity* self) { self->SetVar(MatrixVariable, 1); self->SetVar(InitVariable, true); - auto* simplePhysicsComponent = self->GetComponent(); + auto simplePhysicsComponent = self->GetComponent(); if (simplePhysicsComponent != nullptr) { simplePhysicsComponent->SetPhysicsMotionState(5); @@ -88,7 +88,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int GameMessages::SendActivityEnter(self->GetObjectID(), player->GetSystemAddress()); - auto* shootingGalleryComponent = self->GetComponent(); + auto shootingGalleryComponent = self->GetComponent(); if (shootingGalleryComponent != nullptr) { shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID()); @@ -100,7 +100,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int Game::logger->Log("SGCannon", "Shooting gallery component is null"); } - auto* characterComponent = player->GetComponent(); + auto characterComponent = player->GetComponent(); if (characterComponent != nullptr) { characterComponent->SetIsRacing(true); @@ -287,9 +287,7 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) { auto* enemy = EntityManager::Instance()->CreateEntity(info, nullptr, self); EntityManager::Instance()->ConstructEntity(enemy); - auto* movementAI = new MovementAIComponent(enemy, {}); - - enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI); + auto movementAI = enemy->AddComponent({}); movementAI->SetSpeed(toSpawn.initialSpeed); movementAI->SetCurrentSpeed(toSpawn.initialSpeed); @@ -554,7 +552,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) { percentage = misses / fired; } - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar(TotalScoreVariable), self->GetObjectID(), "performact_score"); @@ -568,7 +566,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) { self->SetNetworkVar(AudioFinalWaveDoneVariable, true); // Give the player the model rewards they earned - auto* inventory = player->GetComponent(); + auto inventory = player->GetComponent(); if (inventory != nullptr) { for (const auto rewardLot : self->GetVar>(RewardsVariable)) { inventory->AddItem(rewardLot, 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS); @@ -720,7 +718,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { return; } - auto* inventoryComponent = player->GetComponent(); + auto inventoryComponent = player->GetComponent(); auto equippedItems = inventoryComponent->GetEquippedItems(); @@ -729,7 +727,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { auto skillID = constants.cannonSkill; auto cooldown = constants.cannonRefireRate; - auto* selfInventoryComponent = self->GetComponent(); + auto selfInventoryComponent = self->GetComponent(); if (inventoryComponent == nullptr) { Game::logger->Log("SGCannon", "Inventory component not found"); @@ -772,7 +770,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { const auto& constants = GetConstants(); - auto* shootingGalleryComponent = self->GetComponent(); + auto shootingGalleryComponent = self->GetComponent(); if (shootingGalleryComponent == nullptr) { return; diff --git a/dScripts/ai/NP/NpcNpSpacemanBob.cpp b/dScripts/ai/NP/NpcNpSpacemanBob.cpp index 2195f4b40..9fe71e335 100644 --- a/dScripts/ai/NP/NpcNpSpacemanBob.cpp +++ b/dScripts/ai/NP/NpcNpSpacemanBob.cpp @@ -6,9 +6,9 @@ void NpcNpSpacemanBob::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { if (missionState == eMissionState::READY_TO_COMPLETE && missionID == 173) { - DestroyableComponent* destroyable = static_cast(target->GetComponent(eReplicaComponentType::DESTROYABLE)); + auto destroyable = target->GetComponent(); destroyable->SetImagination(6); - MissionComponent* mission = static_cast(target->GetComponent(eReplicaComponentType::MISSION)); + auto mission = target->GetComponent(); mission->CompleteMission(664); } diff --git a/dScripts/ai/NS/NsConcertInstrument.cpp b/dScripts/ai/NS/NsConcertInstrument.cpp index ba99d4d1f..39a452054 100644 --- a/dScripts/ai/NS/NsConcertInstrument.cpp +++ b/dScripts/ai/NS/NsConcertInstrument.cpp @@ -72,7 +72,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) { if (activePlayer != nullptr && name == "checkPlayer" && self->GetVar(u"beingPlayed")) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"checkMovement", 0, 0, activePlayer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); - auto* stats = activePlayer->GetComponent(); + auto stats = activePlayer->GetComponent(); if (stats) { if (stats->GetImagination() > 0) { self->AddTimer("checkPlayer", updateFrequency); @@ -81,7 +81,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) { } } } else if (activePlayer != nullptr && name == "deductImagination" && self->GetVar(u"beingPlayed")) { - auto* stats = activePlayer->GetComponent(); + auto stats = activePlayer->GetComponent(); if (stats) stats->SetImagination(stats->GetImagination() - instrumentImaginationCost); @@ -93,20 +93,20 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) { activePlayer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); } - auto* rebuildComponent = self->GetComponent(); + auto rebuildComponent = self->GetComponent(); if (rebuildComponent != nullptr) rebuildComponent->ResetRebuild(false); self->Smash(self->GetObjectID(), eKillType::VIOLENT); self->SetVar(u"activePlayer", LWOOBJID_EMPTY); } else if (activePlayer != nullptr && name == "achievement") { - auto* missionComponent = activePlayer->GetComponent(); + auto missionComponent = activePlayer->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgress(302, 462, self->GetLOT()); } self->AddTimer("achievement2", 10.0f); } else if (activePlayer != nullptr && name == "achievement2") { - auto* missionComponent = activePlayer->GetComponent(); + auto missionComponent = activePlayer->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgress(602, achievementTaskID.at(GetInstrumentLot(self)), self->GetLOT()); } @@ -127,7 +127,7 @@ void NsConcertInstrument::StartPlayingInstrument(Entity* self, Entity* player) { }); for (auto* soundBox : EntityManager::Instance()->GetEntitiesInGroup("Audio-Concert")) { - auto* soundTrigger = soundBox->GetComponent(); + auto soundTrigger = soundBox->GetComponent(); if (soundTrigger != nullptr) { soundTrigger->ActivateMusicCue(music.at(instrumentLot)); } @@ -148,7 +148,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) { // Player might be null if they left if (player != nullptr) { - auto* missions = player->GetComponent(); + auto missions = player->GetComponent(); if (missions != nullptr && missions->GetMissionState(176) == eMissionState::ACTIVE) { missions->Progress(eMissionTaskType::SCRIPT, self->GetLOT()); } @@ -162,7 +162,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) { self->SetVar(u"beingPlayed", false); for (auto* soundBox : EntityManager::Instance()->GetEntitiesInGroup("Audio-Concert")) { - auto* soundTrigger = soundBox->GetComponent(); + auto soundTrigger = soundBox->GetComponent(); if (soundTrigger != nullptr) { soundTrigger->DeactivateMusicCue(music.at(instrumentLot)); } @@ -173,7 +173,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) { } void NsConcertInstrument::EquipInstruments(Entity* self, Entity* player) { - auto* inventory = player->GetComponent(); + auto inventory = player->GetComponent(); if (inventory != nullptr) { auto equippedItems = inventory->GetEquippedItems(); @@ -216,7 +216,7 @@ void NsConcertInstrument::EquipInstruments(Entity* self, Entity* player) { } void NsConcertInstrument::UnEquipInstruments(Entity* self, Entity* player) { - auto* inventory = player->GetComponent(); + auto inventory = player->GetComponent(); if (inventory != nullptr) { auto equippedItems = inventory->GetEquippedItems(); diff --git a/dScripts/ai/NS/NsConcertQuickBuild.cpp b/dScripts/ai/NS/NsConcertQuickBuild.cpp index 4589ee6a1..c27f1b9a3 100644 --- a/dScripts/ai/NS/NsConcertQuickBuild.cpp +++ b/dScripts/ai/NS/NsConcertQuickBuild.cpp @@ -103,7 +103,7 @@ void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) { // Move all the platforms so the user can collect the imagination brick const auto movingPlatforms = EntityManager::Instance()->GetEntitiesInGroup("ConcertPlatforms"); for (auto* movingPlatform : movingPlatforms) { - auto* component = movingPlatform->GetComponent(); + auto component = movingPlatform->GetComponent(); if (component) { component->WarpToWaypoint(component->GetLastWaypointIndex()); @@ -132,7 +132,7 @@ void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) { quickBuild->Smash(); }); - auto* destroyableComponent = quickBuild->GetComponent(); + auto destroyableComponent = quickBuild->GetComponent(); if (destroyableComponent) destroyableComponent->SetFaction(-1); } @@ -157,7 +157,7 @@ void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) { } void NsConcertQuickBuild::ProgressStageCraft(Entity* self, Entity* player) { - auto* missionComponent = player->GetComponent(); + auto missionComponent = player->GetComponent(); if (missionComponent) { // Has to be forced as to not accidentally trigger the licensed technician achievement diff --git a/dScripts/ai/NS/NsGetFactionMissionServer.cpp b/dScripts/ai/NS/NsGetFactionMissionServer.cpp index 185bd344d..1c42c1f7e 100644 --- a/dScripts/ai/NS/NsGetFactionMissionServer.cpp +++ b/dScripts/ai/NS/NsGetFactionMissionServer.cpp @@ -46,7 +46,7 @@ void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID, player->GetCharacter()->SetPlayerFlag(flagID, true); } - MissionComponent* mis = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); + auto mis = player->GetComponent(); for (int mission : factionMissions) { mis->AcceptMission(mission); diff --git a/dScripts/ai/NS/NsJohnnyMissionServer.cpp b/dScripts/ai/NS/NsJohnnyMissionServer.cpp index 107d3c442..9052482f0 100644 --- a/dScripts/ai/NS/NsJohnnyMissionServer.cpp +++ b/dScripts/ai/NS/NsJohnnyMissionServer.cpp @@ -4,7 +4,7 @@ void NsJohnnyMissionServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { if (missionID == 773 && missionState <= eMissionState::ACTIVE) { - auto* missionComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); if (missionComponent != nullptr) { missionComponent->AcceptMission(774); missionComponent->AcceptMission(775); diff --git a/dScripts/ai/NS/NsModularBuild.cpp b/dScripts/ai/NS/NsModularBuild.cpp index 1922eb17f..ed90fbb7e 100644 --- a/dScripts/ai/NS/NsModularBuild.cpp +++ b/dScripts/ai/NS/NsModularBuild.cpp @@ -5,7 +5,7 @@ void NsModularBuild::OnModularBuildExit(Entity* self, Entity* player, bool bCompleted, std::vector modules) { if (bCompleted) { - MissionComponent* mission = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); + auto mission = self->GetComponent(); if (mission->GetMissionState(m_MissionNum) == eMissionState::ACTIVE) { for (LOT mod : modules) { diff --git a/dScripts/ai/NS/WhFans.cpp b/dScripts/ai/NS/WhFans.cpp index 8500e8245..d5f8bb652 100644 --- a/dScripts/ai/NS/WhFans.cpp +++ b/dScripts/ai/NS/WhFans.cpp @@ -25,7 +25,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); - auto* renderComponent = self->GetComponent(); + auto renderComponent = self->GetComponent(); if (renderComponent == nullptr) return; diff --git a/dScripts/ai/PROPERTY/AG/AgPropGuard.cpp b/dScripts/ai/PROPERTY/AG/AgPropGuard.cpp index 853da92da..fd6d5113f 100644 --- a/dScripts/ai/PROPERTY/AG/AgPropGuard.cpp +++ b/dScripts/ai/PROPERTY/AG/AgPropGuard.cpp @@ -9,8 +9,8 @@ void AgPropGuard::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { auto* character = target->GetCharacter(); - auto* missionComponent = target->GetComponent(); - auto* inventoryComponent = target->GetComponent(); + auto missionComponent = target->GetComponent(); + auto inventoryComponent = target->GetComponent(); const auto state = missionComponent->GetMissionState(320); if (missionID == 768 && missionState == eMissionState::AVAILABLE) { diff --git a/dScripts/ai/PROPERTY/PropertyFXDamage.cpp b/dScripts/ai/PROPERTY/PropertyFXDamage.cpp index 560793841..6071da10f 100644 --- a/dScripts/ai/PROPERTY/PropertyFXDamage.cpp +++ b/dScripts/ai/PROPERTY/PropertyFXDamage.cpp @@ -6,8 +6,8 @@ void PropertyFXDamage::OnCollisionPhantom(Entity* self, Entity* target) { if (target == nullptr) return; - auto* skills = self->GetComponent(); - auto* targetStats = target->GetComponent(); + auto skills = self->GetComponent(); + auto targetStats = target->GetComponent(); if (skills != nullptr && targetStats != nullptr) { auto targetFactions = targetStats->GetFactionIDs(); diff --git a/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp b/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp index f69a3eb61..6e8c38e53 100644 --- a/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp +++ b/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp @@ -9,21 +9,21 @@ void FvRaceSmashEggImagineServer::OnDie(Entity* self, Entity* killer) { if (killer != nullptr) { - auto* destroyableComponent = killer->GetComponent(); + auto destroyableComponent = killer->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetImagination(destroyableComponent->GetImagination() + 10); EntityManager::Instance()->SerializeEntity(killer); } // get possessor to progress statistics and tasks. - auto* possessableComponent = killer->GetComponent(); + auto possessableComponent = killer->GetComponent(); if (possessableComponent != nullptr) { auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); if (possessor != nullptr) { - auto* missionComponent = possessor->GetComponent(); - auto* characterComponent = possessor->GetComponent(); + auto missionComponent = possessor->GetComponent(); + auto characterComponent = possessor->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(ImaginationPowerUpsCollected); characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed); diff --git a/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp b/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp index 6a29f9a8c..2b03b8e51 100644 --- a/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp +++ b/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp @@ -19,13 +19,13 @@ void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) { return; } - auto* skillComponent = killer->GetComponent(); + auto skillComponent = killer->GetComponent(); if (skillComponent == nullptr) { return; } - auto* destroyableComponent = killer->GetComponent(); + auto destroyableComponent = killer->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->SetImagination(60); @@ -34,14 +34,14 @@ void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) { } // Find possessor of race car to progress missions and update stats. - auto* possessableComponent = killer->GetComponent(); + auto possessableComponent = killer->GetComponent(); if (possessableComponent != nullptr) { auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); if (possessor != nullptr) { - auto* missionComponent = possessor->GetComponent(); - auto* characterComponent = possessor->GetComponent(); + auto missionComponent = possessor->GetComponent(); + auto characterComponent = possessor->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(RacingImaginationCratesSmashed); diff --git a/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp b/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp index 92a508733..fe0a15954 100644 --- a/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp +++ b/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp @@ -9,7 +9,7 @@ void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (sender->IsPlayer() && args == "powerup") { - auto* possessorComponent = sender->GetComponent(); + auto possessorComponent = sender->GetComponent(); if (possessorComponent == nullptr) { return; @@ -21,7 +21,7 @@ void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std return; } - auto* destroyableComponent = vehicle->GetComponent(); + auto destroyableComponent = vehicle->GetComponent(); if (destroyableComponent == nullptr) { return; @@ -29,7 +29,7 @@ void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std destroyableComponent->Imagine(10); - auto* missionComponent = sender->GetComponent(); + auto missionComponent = sender->GetComponent(); if (missionComponent == nullptr) return; missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::COLLECT_IMAGINATION); diff --git a/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp b/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp index 295f38ee6..298bc1ebe 100644 --- a/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp +++ b/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp @@ -8,14 +8,14 @@ void RaceSmashServer::OnDie(Entity* self, Entity* killer) { // Crate is smashed by the car - auto* possessableComponent = killer->GetComponent(); + auto possessableComponent = killer->GetComponent(); if (possessableComponent != nullptr) { auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor()); if (possessor != nullptr) { - auto* missionComponent = possessor->GetComponent(); - auto* characterComponent = possessor->GetComponent(); + auto missionComponent = possessor->GetComponent(); + auto characterComponent = possessor->GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed); diff --git a/dScripts/client/ai/PR/CrabServer.cpp b/dScripts/client/ai/PR/CrabServer.cpp index f30142ba0..6212f33cf 100644 --- a/dScripts/client/ai/PR/CrabServer.cpp +++ b/dScripts/client/ai/PR/CrabServer.cpp @@ -3,7 +3,7 @@ #include "ePetTamingNotifyType.h" void CrabServer::OnStartup(Entity* self) { - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; @@ -20,7 +20,7 @@ void CrabServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "killself") { // Don't accidentally kill a pet that is already owned - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; @@ -34,7 +34,7 @@ void CrabServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTami } else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) { self->Smash(self->GetObjectID(), eKillType::SILENT); } else if (type == ePetTamingNotifyType::SUCCESS) { - auto* petComponent = self->GetComponent(); + auto petComponent = self->GetComponent(); if (petComponent == nullptr) return; // TODO: Remove custom group? diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 186259609..0fa658ad8 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -685,7 +685,7 @@ void HandlePacket(Packet* packet) { } if (entity) { - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); if (skillComponent != nullptr) { skillComponent->Reset(); @@ -1020,13 +1020,13 @@ void HandlePacket(Packet* packet) { EntityManager::Instance()->ConstructAllEntities(packet->systemAddress); - auto* characterComponent = player->GetComponent(); + auto characterComponent = player->GetComponent(); if (characterComponent) { player->GetComponent()->RocketUnEquip(player); } // Do charxml fixes here - auto* levelComponent = player->GetComponent(); + auto levelComponent = player->GetComponent(); if (!levelComponent) return; auto version = levelComponent->GetCharacterVersion(); @@ -1052,7 +1052,7 @@ void HandlePacket(Packet* packet) { player->GetCharacter()->SetTargetScene(""); // Fix the destroyable component - auto* destroyableComponent = player->GetComponent(); + auto destroyableComponent = player->GetComponent(); if (destroyableComponent != nullptr) { destroyableComponent->FixStats(); @@ -1281,7 +1281,7 @@ void WorldShutdownProcess(uint32_t zoneId) { auto* entity = Player::GetPlayer(player); Game::logger->Log("WorldServer", "Saving data!"); if (entity != nullptr && entity->GetCharacter() != nullptr) { - auto* skillComponent = entity->GetComponent(); + auto skillComponent = entity->GetComponent(); if (skillComponent != nullptr) { skillComponent->Reset(); diff --git a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp index db9c033a2..558051d31 100644 --- a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp @@ -2,8 +2,8 @@ #include #include "BitStream.h" -#include "DestroyableComponent.h" #include "Entity.h" +#include "DestroyableComponent.h" #include "eReplicaComponentType.h" #include "eStateChangeType.h" @@ -17,7 +17,7 @@ class DestroyableTest : public GameDependenciesTest { SetUpDependencies(); baseEntity = new Entity(15, GameDependenciesTest::info); destroyableComponent = new DestroyableComponent(baseEntity); - baseEntity->AddComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent); + baseEntity->AddComponent(); // Initialize some values to be not default destroyableComponent->SetMaxHealth(12345.0f); destroyableComponent->SetHealth(23); @@ -319,7 +319,7 @@ TEST_F(DestroyableTest, DestroyableComponentFactionTest) { TEST_F(DestroyableTest, DestroyableComponentValiditiyTest) { auto* enemyEntity = new Entity(19, info); auto* enemyDestroyableComponent = new DestroyableComponent(enemyEntity); - enemyEntity->AddComponent(eReplicaComponentType::DESTROYABLE, enemyDestroyableComponent); + enemyEntity->AddComponent(); enemyDestroyableComponent->AddFactionNoLookup(16); destroyableComponent->AddEnemyFaction(16); EXPECT_TRUE(destroyableComponent->IsEnemy(enemyEntity)); From d11e2db8871e7ac3745f603a46f80dd3145fb1a8 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Thu, 8 Jun 2023 10:29:17 -0500 Subject: [PATCH 008/111] update component names, document heirarchy --- dCommon/dEnums/eReplicaComponentType.h | 39 +++-- dGame/Entity.cpp | 54 +++---- dGame/dComponents/CMakeLists.txt | 6 +- dGame/dComponents/CharacterComponent.cpp | 1 - dGame/dComponents/ComponentHeirachy.md | 148 ++++++++++++++++++ ...t.cpp => HavokVehiclePhysicsComponent.cpp} | 28 ++-- ...onent.h => HavokVehiclePhysicsComponent.h} | 8 +- dGame/dComponents/InventoryComponent.cpp | 10 +- ...mponent.cpp => ModelBehaviorComponent.cpp} | 6 +- ...elComponent.h => ModelBehaviorComponent.h} | 6 +- ...ent.cpp => MultiZoneEntranceComponent.cpp} | 10 +- ...mponent.h => MultiZoneEntranceComponent.h} | 8 +- dGame/dComponents/RacingControlComponent.cpp | 1 - .../RocketLaunchpadControlComponent.cpp | 6 +- .../RocketLaunchpadControlComponent.h | 2 +- dGame/dGameMessages/GameMessages.cpp | 9 +- dGame/dPropertyBehaviors/ControlBehaviors.cpp | 16 +- dGame/dPropertyBehaviors/ControlBehaviors.h | 14 +- dGame/dUtilities/SlashCommandHandler.cpp | 12 +- dNavigation/dTerrain/RawFile.h | 1 + dNet/ClientPackets.cpp | 22 +-- dZoneManager/LUTriggers.h | 1 + 22 files changed, 276 insertions(+), 132 deletions(-) create mode 100644 dGame/dComponents/ComponentHeirachy.md rename dGame/dComponents/{VehiclePhysicsComponent.cpp => HavokVehiclePhysicsComponent.cpp} (63%) rename dGame/dComponents/{VehiclePhysicsComponent.h => HavokVehiclePhysicsComponent.h} (92%) rename dGame/dComponents/{ModelComponent.cpp => ModelBehaviorComponent.cpp} (82%) rename dGame/dComponents/{ModelComponent.h => ModelBehaviorComponent.h} (92%) rename dGame/dComponents/{RocketLaunchLupComponent.cpp => MultiZoneEntranceComponent.cpp} (73%) rename dGame/dComponents/{RocketLaunchLupComponent.h => MultiZoneEntranceComponent.h} (85%) diff --git a/dCommon/dEnums/eReplicaComponentType.h b/dCommon/dEnums/eReplicaComponentType.h index 39f91efff..fb88bd142 100644 --- a/dCommon/dEnums/eReplicaComponentType.h +++ b/dCommon/dEnums/eReplicaComponentType.h @@ -11,14 +11,14 @@ enum class eReplicaComponentType : uint32_t { CHARACTER, SCRIPT, BOUNCER, - BUFF, // buff is really 98, this is DESTROYABLE + DESTROYABLE, GHOST, SKILL, - SPAWNER, + SPAWN, ITEM, - REBUILD, - REBUILD_START, - REBUILD_ACTIVATOR, + MODULAR_BUILD, + BUILD_CONTROLLER, + BUILD_ACTIVATOR, ICON_ONLY, VENDOR, INVENTORY, @@ -33,8 +33,8 @@ enum class eReplicaComponentType : uint32_t { PET, PLATFORM_BOUNDARY, MODULE, - ARCADE, - VEHICLE_PHYSICS, // Havok demo based + JETPACKPAD, + HAVOK_VEHICLE_PHYSICS, MOVEMENT_AI, EXHIBIT, OVERHEAD_ICON, @@ -46,23 +46,23 @@ enum class eReplicaComponentType : uint32_t { SCRIPTED_ACTIVITY, PHANTOM_PHYSICS, SPRINGPAD, - MODEL, + MODEL_BEHAVIOR, PROPERTY_ENTRANCE, FX, PROPERTY_MANAGEMENT, - VEHICLE_PHYSICS_NEW, // internal physics based on havok + VEHICLE_PHYSICS, PHYSICS_SYSTEM, QUICK_BUILD, SWITCH, - ZONE_CONTROL, // Minigame - CHANGLING, + MINIGAME_CONTROL, + CHANGLING_BUILD, CHOICE_BUILD, PACKAGE, SOUND_REPEATER, SOUND_AMBIENT_2D, SOUND_AMBIENT_3D, PRECONDITION, - PLAYER_FLAG, + FLAG, CUSTOM_BUILD_ASSEMBLY, BASE_COMBAT_AI, MODULE_ASSEMBLY, @@ -71,8 +71,8 @@ enum class eReplicaComponentType : uint32_t { GENERIC_ACTIVATOR, PROPERTY_VENDOR, HF_LIGHT_DIRECTION_GADGET, - ROCKET_LAUNCH, - ROCKET_LANDING, + ROCKET_LAUNCHPAD_CONTROL, + ROCKET_ANIMATION_CONTROL, TRIGGER, DROPPED_LOOT, RACING_CONTROL, @@ -84,7 +84,7 @@ enum class eReplicaComponentType : uint32_t { SOUND_TRIGGER, PROXIMITY_MONITOR, RACING_SOUND_TRIGGER, - CHAT, + CHAT_BUBBLE, FRIENDS_LIST, GUILD, LOCAL_SYSTEM, @@ -101,12 +101,12 @@ enum class eReplicaComponentType : uint32_t { TRADE, USER_CONTROL, IGNORE_LIST, - ROCKET_LAUNCH_LUP, - BUFF_REAL, // the real buff component, should just be name BUFF + MULTI_ZONE_ENTRANCE, + BUFF, INTERACTION_MANAGER, DONATION_VENDOR, COMBAT_MEDIATOR, - COMMENDATION_VENDOR, + ACHIEVEMENT_VENDOR, GATE_RUSH_CONTROL, RAIL_ACTIVATOR, ROLLER, @@ -121,8 +121,7 @@ enum class eReplicaComponentType : uint32_t { BUILD_BORDER, UNKNOWN_115, CULLING_PLANE, - NUMBER_OF_COMPONENTS, - DESTROYABLE = 1000 // Actually 7 + NUMBER_OF_COMPONENTS }; #endif //!__EREPLICACOMPONENTTYPE__H__ diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 4d4a5af93..bcb2a5b7b 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -30,7 +30,7 @@ #include "Component.h" #include "ControllablePhysicsComponent.h" #include "RenderComponent.h" -#include "RocketLaunchLupComponent.h" +#include "MultiZoneEntranceComponent.h" #include "CharacterComponent.h" #include "DestroyableComponent.h" #include "BuffComponent.h" @@ -58,10 +58,10 @@ #include "PropertyVendorComponent.h" #include "ProximityMonitorComponent.h" #include "PropertyEntranceComponent.h" -#include "ModelComponent.h" +#include "ModelBehaviorComponent.h" #include "ZCompression.h" #include "PetComponent.h" -#include "VehiclePhysicsComponent.h" +#include "HavokVehiclePhysicsComponent.h" #include "PossessableComponent.h" #include "PossessorComponent.h" #include "ModuleAssemblyComponent.h" @@ -148,21 +148,21 @@ void Entity::Initialize() { break; case eReplicaComponentType::BOUNCER: break; - case eReplicaComponentType::BUFF: + case eReplicaComponentType::DESTROYABLE: break; case eReplicaComponentType::GHOST: break; case eReplicaComponentType::SKILL: break; - case eReplicaComponentType::SPAWNER: + case eReplicaComponentType::SPAWN: break; case eReplicaComponentType::ITEM: break; - case eReplicaComponentType::REBUILD: + case eReplicaComponentType::MODULAR_BUILD: break; - case eReplicaComponentType::REBUILD_START: + case eReplicaComponentType::BUILD_CONTROLLER: break; - case eReplicaComponentType::REBUILD_ACTIVATOR: + case eReplicaComponentType::BUILD_ACTIVATOR: break; case eReplicaComponentType::ICON_ONLY: break; @@ -192,9 +192,9 @@ void Entity::Initialize() { break; case eReplicaComponentType::MODULE: break; - case eReplicaComponentType::ARCADE: + case eReplicaComponentType::JETPACKPAD: break; - case eReplicaComponentType::VEHICLE_PHYSICS: + case eReplicaComponentType::HAVOK_VEHICLE_PHYSICS: break; case eReplicaComponentType::MOVEMENT_AI: break; @@ -218,7 +218,7 @@ void Entity::Initialize() { break; case eReplicaComponentType::SPRINGPAD: break; - case eReplicaComponentType::MODEL: + case eReplicaComponentType::MODEL_BEHAVIOR: break; case eReplicaComponentType::PROPERTY_ENTRANCE: break; @@ -226,7 +226,7 @@ void Entity::Initialize() { break; case eReplicaComponentType::PROPERTY_MANAGEMENT: break; - case eReplicaComponentType::VEHICLE_PHYSICS_NEW: + case eReplicaComponentType::VEHICLE_PHYSICS: break; case eReplicaComponentType::PHYSICS_SYSTEM: break; @@ -234,9 +234,9 @@ void Entity::Initialize() { break; case eReplicaComponentType::SWITCH: break; - case eReplicaComponentType::ZONE_CONTROL: + case eReplicaComponentType::MINIGAME_CONTROL: break; - case eReplicaComponentType::CHANGLING: + case eReplicaComponentType::CHANGLING_BUILD: break; case eReplicaComponentType::CHOICE_BUILD: break; @@ -250,7 +250,7 @@ void Entity::Initialize() { break; case eReplicaComponentType::PRECONDITION: break; - case eReplicaComponentType::PLAYER_FLAG: + case eReplicaComponentType::FLAG: break; case eReplicaComponentType::CUSTOM_BUILD_ASSEMBLY: break; @@ -268,9 +268,9 @@ void Entity::Initialize() { break; case eReplicaComponentType::HF_LIGHT_DIRECTION_GADGET: break; - case eReplicaComponentType::ROCKET_LAUNCH: + case eReplicaComponentType::ROCKET_LAUNCHPAD_CONTROL: break; - case eReplicaComponentType::ROCKET_LANDING: + case eReplicaComponentType::ROCKET_ANIMATION_CONTROL: break; case eReplicaComponentType::TRIGGER: break; @@ -294,7 +294,7 @@ void Entity::Initialize() { break; case eReplicaComponentType::RACING_SOUND_TRIGGER: break; - case eReplicaComponentType::CHAT: + case eReplicaComponentType::CHAT_BUBBLE: break; case eReplicaComponentType::FRIENDS_LIST: break; @@ -328,9 +328,9 @@ void Entity::Initialize() { break; case eReplicaComponentType::IGNORE_LIST: break; - case eReplicaComponentType::ROCKET_LAUNCH_LUP: + case eReplicaComponentType::MULTI_ZONE_ENTRANCE: break; - case eReplicaComponentType::BUFF_REAL: + case eReplicaComponentType::BUFF: break; case eReplicaComponentType::INTERACTION_MANAGER: break; @@ -338,7 +338,7 @@ void Entity::Initialize() { break; case eReplicaComponentType::COMBAT_MEDIATOR: break; - case eReplicaComponentType::COMMENDATION_VENDOR: + case eReplicaComponentType::ACHIEVEMENT_VENDOR: break; case eReplicaComponentType::GATE_RUSH_CONTROL: break; @@ -370,8 +370,6 @@ void Entity::Initialize() { break; case eReplicaComponentType::NUMBER_OF_COMPONENTS: break; - case eReplicaComponentType::DESTROYABLE: - break; case eReplicaComponentType::INVALID: default: Game::logger->Log("Entity", "blah %i %i", componentId, m_TemplateID); @@ -483,7 +481,7 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke const auto& syncLDF = GetVar>(u"syncLDF"); // Only sync for models. - if (m_Settings.size() > 0 && (GetComponent() && !GetComponent())) { + if (m_Settings.size() > 0 && (GetComponent() && !GetComponent())) { outBitStream->Write1(); //ldf data RakNet::BitStream settingStream; @@ -1216,7 +1214,7 @@ const NiPoint3& Entity::GetPosition() const { return simple->GetPosition(); } - auto vehicle = GetComponent(); + auto vehicle = GetComponent(); if (vehicle != nullptr) { return vehicle->GetPosition(); @@ -1244,7 +1242,7 @@ const NiQuaternion& Entity::GetRotation() const { return simple->GetRotation(); } - auto vehicle = GetComponent(); + auto vehicle = GetComponent(); if (vehicle != nullptr) { return vehicle->GetRotation(); @@ -1272,7 +1270,7 @@ void Entity::SetPosition(NiPoint3 position) { simple->SetPosition(position); } - auto vehicle = GetComponent(); + auto vehicle = GetComponent(); if (vehicle != nullptr) { vehicle->SetPosition(position); @@ -1300,7 +1298,7 @@ void Entity::SetRotation(NiQuaternion rotation) { simple->SetRotation(rotation); } - auto vehicle = GetComponent(); + auto vehicle = GetComponent(); if (vehicle != nullptr) { vehicle->SetRotation(rotation); diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index b396829ab..ad1843733 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -11,7 +11,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "LUPExhibitComponent.cpp" "MissionComponent.cpp" "MissionOfferComponent.cpp" - "ModelComponent.cpp" + "ModelBehaviorComponent.cpp" "ModuleAssemblyComponent.cpp" "MovementAIComponent.cpp" "MovingPlatformComponent.cpp" @@ -30,7 +30,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "RebuildComponent.cpp" "RenderComponent.cpp" "RigidbodyPhantomPhysicsComponent.cpp" - "RocketLaunchLupComponent.cpp" + "MultiZoneEntranceComponent.cpp" "RocketLaunchpadControlComponent.cpp" "ScriptedActivityComponent.cpp" "ShootingGalleryComponent.cpp" @@ -39,5 +39,5 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "SoundTriggerComponent.cpp" "SwitchComponent.cpp" "TriggerComponent.cpp" - "VehiclePhysicsComponent.cpp" + "HavokVehiclePhysicsComponent.cpp" "VendorComponent.cpp" PARENT_SCOPE) diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 7d757c624..94006e834 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -10,7 +10,6 @@ #include "InventoryComponent.h" #include "ControllablePhysicsComponent.h" #include "EntityManager.h" -#include "VehiclePhysicsComponent.h" #include "GameMessages.h" #include "Item.h" #include "Amf3.h" diff --git a/dGame/dComponents/ComponentHeirachy.md b/dGame/dComponents/ComponentHeirachy.md new file mode 100644 index 000000000..af384946f --- /dev/null +++ b/dGame/dComponents/ComponentHeirachy.md @@ -0,0 +1,148 @@ +Legend +``` +├── Explicit inheritance +├~~ Loaded with Parent +├-> SubComponent +├-? idk lol, but related +``` + + +```tree + +LWOActivityComponent +├── LWOShootingGalleryComponent +├── LWOScriptedActivityComponent + └── LWOBaseRacingControlComponent + ├── LWORacingControlComponent + └── LWOGateRushControlComponent +├── LWOQuickBuildComponent +├── LWOMiniGameControlComponent +LWOBaseCombatAIComponent +├~~ LWOPathfindingControlComponent +├~~ LWOProximityMonitorComponent +LWOBasePhysComponent +├── LWORigidBodyPhantomComponent +├── LWOPhantomPhysComponent +├── LWOVehiclePhysicsComponent +├── LWOSimplePhysComponent +├── LWOPhysicsSystemComponent +├── LWOHavokVehiclePhysicsComponent +├── LWOControllablePhysComponent +LWOBaseRenderComponent +├── LWOSkinnedRenderComponent +LWOBaseVendorComponent +├── LWOVendorComponent + ├~~ LWOProximityMonitorComponent +├── LWODonationVendorComponent + ├~~ LWOProximityMonitorComponent +├── LWOAchievementVendorComponent + ├~~ LWOProximityMonitorComponent +LWOBBBComponent_Common +├── LWOBBBComponent_Client +LWOBlueprintComponent +LWOBouncerComponent +LWOBuildControllerComponentCommon +├── LWOBuildControllerComponent +LWOChangelingBuildComponent +LWOCharacterComponent +├── LWOMinifigComponent +├~~ LWOPossessionControlComponent +├~~ LWOMountControlComponent +├~~ LWOPetCreatorComponent +├~~ LWOLevelProgressionComponent +├~~ LWOPlayerForcedMovementComponent + ├~? LWOPathfindingControlComponent +LWOChestComponent +LWOChoiceBuildComponent +LWOCollectibleComponent +LWOCustomBuildAssemblyComponent +LWODestroyableComponent +├~~ LWOBuffComponent +├~~ LWOStatusEffectComponent +LWODropEffectComponent +LWODroppedLootComponent +LWOExhibitComponent +LWOFXComponent +LWOGenericActivatorComponent +LWOGhostComponent +LWOHFLightDirectionGadgetComponent +LWOInventoryComponent_Common +├── LWOInventoryComponent_Client + └── LWOInventoryComponent_EquippedItem +LWOItemComponent +LWOLUPExhibitComponent +LWOMissionOfferComponent +LWOModelBehaviorComponent +├~~ LWOSimplePhysComponent +├~~ LWOControllablePhysComponent +├~~ LWOPathfindingControlComponent +├~~ LWOMutableModelBehaviorComponent +LWOModelBuilderComponent +LWOModularBuildComponentCommon +├── LWOModularBuildComponent +LWOModuleAssemblyComponent +├── LWOModuleAssemblyComponentCommon +LWOModuleComponentCommon +├── LWOModuleComponent +LWOMovementAIComponent +LWOMultiZoneEntranceComponent +LWOOverheadIconComponent +LWOPetComponent +├~~ LWOPathfindingControlComponent +├~? LWOItemComponent +├~? LWOModelBehaviorComponent + ├~~ ... +LWOPlatformBoundaryComponent +LWOPlatformComponent +├-> LWOMoverPlatformSubComponent +├-> LWOSimpleMoverPlatformSubComponent +├-> LWORotaterPlatformSubComponent +LWOProjectilePhysComponent +LWOPropertyComponent +LWOPropertyEntranceComponent +LWOPropertyManagementComponent +LWOPropertyVendorComponent +LWOProximityMonitorComponent +LWOSoundTriggerComponent +├── LWORacingSoundTriggerComponent +LWORacingStatsComponentCommon +├── LWORacingStatsComponent +LWORocketAnimationControlComponentCommon +├── LWORocketAnimationControlComponent +LWORocketLaunchpadControlComponentCommon +├── LWORocketLaunchpadControlComponent +LWOScriptComponent +├~~ LWOPathfindingControlComponent +├~~ LWOProximityMonitorComponent +LWOShowcaseModelHandlerComponent +LWOSkillComponent +LWOSoundAmbient2DComponent +LWOSoundAmbient3DComponent +LWOSoundRepeaterComponent +LWOSpawnComponent +LWOSpringpadComponent +LWOSwitchComponent +LWOTriggerComponent +LocalPlayer (not a component) +├~~ LWOInteractionManagerComponent +├~~ LWOUserControlComponent +├~~ LWOFriendsListComponent +├~~ LWOIgnoreListComponent +├~~ LWOTextEffectComponent +├~~ LWOChatBubbleComponent +├~~ LWOGuildComponent +├~~ LWOPlayerPetTamingComponent +├~~ LWOLocalSystemsComponent +├~~ LWOSlashCommandComponent +├~~ LWOMissionComponent +├~~ LWOPropertyEditorComponent +├~~ LWOComponent115 +├~~ LWOTeamsComponent +├~~ LWOChatComponent +├~~ LWOPetControlComponent +├~~ LWOTradeComponent +├~~ LWOPreconditionComponent +├~~ LWOFlagComponent +├~~ LWOFactionTriggerComponent + +``` diff --git a/dGame/dComponents/VehiclePhysicsComponent.cpp b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp similarity index 63% rename from dGame/dComponents/VehiclePhysicsComponent.cpp rename to dGame/dComponents/HavokVehiclePhysicsComponent.cpp index c5818825b..9fe44d7a8 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.cpp +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp @@ -1,7 +1,7 @@ -#include "VehiclePhysicsComponent.h" +#include "HavokVehiclePhysicsComponent.h" #include "EntityManager.h" -VehiclePhysicsComponent::VehiclePhysicsComponent(Entity* parent) : Component(parent) { +HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent) : Component(parent) { m_Position = NiPoint3::ZERO; m_Rotation = NiQuaternion::IDENTITY; m_Velocity = NiPoint3::ZERO; @@ -14,52 +14,52 @@ VehiclePhysicsComponent::VehiclePhysicsComponent(Entity* parent) : Component(par m_EndBehavior = GeneralUtils::GenerateRandomNumber(0, 7); } -VehiclePhysicsComponent::~VehiclePhysicsComponent() { +HavokVehiclePhysicsComponent::~HavokVehiclePhysicsComponent() { } -void VehiclePhysicsComponent::SetPosition(const NiPoint3& pos) { +void HavokVehiclePhysicsComponent::SetPosition(const NiPoint3& pos) { m_Position = pos; } -void VehiclePhysicsComponent::SetRotation(const NiQuaternion& rot) { +void HavokVehiclePhysicsComponent::SetRotation(const NiQuaternion& rot) { m_DirtyPosition = true; m_Rotation = rot; } -void VehiclePhysicsComponent::SetVelocity(const NiPoint3& vel) { +void HavokVehiclePhysicsComponent::SetVelocity(const NiPoint3& vel) { m_DirtyPosition = true; m_Velocity = vel; } -void VehiclePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) { +void HavokVehiclePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) { m_DirtyPosition = true; m_AngularVelocity = vel; } -void VehiclePhysicsComponent::SetIsOnGround(bool val) { +void HavokVehiclePhysicsComponent::SetIsOnGround(bool val) { m_DirtyPosition = true; m_IsOnGround = val; } -void VehiclePhysicsComponent::SetIsOnRail(bool val) { +void HavokVehiclePhysicsComponent::SetIsOnRail(bool val) { m_DirtyPosition = true; m_IsOnRail = val; } -void VehiclePhysicsComponent::SetDirtyPosition(bool val) { +void HavokVehiclePhysicsComponent::SetDirtyPosition(bool val) { m_DirtyPosition = val; } -void VehiclePhysicsComponent::SetDirtyVelocity(bool val) { +void HavokVehiclePhysicsComponent::SetDirtyVelocity(bool val) { m_DirtyVelocity = val; } -void VehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) { +void HavokVehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) { m_DirtyAngularVelocity = val; } -void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); if (bIsInitialUpdate || m_DirtyPosition) { @@ -101,7 +101,7 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI outBitStream->Write0(); } -void VehiclePhysicsComponent::Update(float deltaTime) { +void HavokVehiclePhysicsComponent::Update(float deltaTime) { if (m_SoftUpdate > 5) { EntityManager::Instance()->SerializeEntity(m_OwningEntity); diff --git a/dGame/dComponents/VehiclePhysicsComponent.h b/dGame/dComponents/HavokVehiclePhysicsComponent.h similarity index 92% rename from dGame/dComponents/VehiclePhysicsComponent.h rename to dGame/dComponents/HavokVehiclePhysicsComponent.h index 64609edf1..4684689f1 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.h +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.h @@ -8,12 +8,12 @@ /** * Physics component for vehicles. */ -class VehiclePhysicsComponent : public Component { +class HavokVehiclePhysicsComponent : public Component { public: - static const eReplicaComponentType ComponentType = eReplicaComponentType::VEHICLE_PHYSICS; + static const eReplicaComponentType ComponentType = eReplicaComponentType::HAVOK_VEHICLE_PHYSICS; - VehiclePhysicsComponent(Entity* parentEntity); - ~VehiclePhysicsComponent() override; + HavokVehiclePhysicsComponent(Entity* parentEntity); + ~HavokVehiclePhysicsComponent() override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 1cbef0e0b..24fb50e6a 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -19,7 +19,7 @@ #include "PossessorComponent.h" #include "PossessableComponent.h" #include "ModuleAssemblyComponent.h" -#include "VehiclePhysicsComponent.h" +#include "HavokVehiclePhysicsComponent.h" #include "CharacterComponent.h" #include "dZoneManager.h" #include "PropertyManagementComponent.h" @@ -826,7 +826,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) { if (character != nullptr && !skipChecks) { // Hacky proximity rocket if (item->GetLot() == 6416) { - const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCH); + const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCHPAD_CONTROL); const auto position = m_OwningEntity->GetPosition(); @@ -986,8 +986,8 @@ void InventoryComponent::HandlePossession(Item* item) { auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity); // Check to see if the mount is a vehicle, if so, flip it - auto vehicleComponent = mount->GetComponent(); - if (vehicleComponent) { + auto havokVehiclePhysicsComponent = mount->GetComponent(); + if (havokVehiclePhysicsComponent) { auto angles = startRotation.GetEulerAngles(); // Make it right side up angles.x -= PI; @@ -1024,7 +1024,7 @@ void InventoryComponent::HandlePossession(Item* item) { EntityManager::Instance()->SerializeEntity(m_OwningEntity); // have to unlock the input so it vehicle can be driven - if (vehicleComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress()); + if (havokVehiclePhysicsComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress()); GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_OwningEntity->GetSystemAddress()); } diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelBehaviorComponent.cpp similarity index 82% rename from dGame/dComponents/ModelComponent.cpp rename to dGame/dComponents/ModelBehaviorComponent.cpp index 91924b5c5..73a730520 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelBehaviorComponent.cpp @@ -1,14 +1,14 @@ -#include "ModelComponent.h" +#include "ModelBehaviorComponent.h" #include "Entity.h" -ModelComponent::ModelComponent(Entity* parent) : Component(parent) { +ModelBehaviorComponent::ModelBehaviorComponent(Entity* parent) : Component(parent) { m_OriginalPosition = m_OwningEntity->GetDefaultPosition(); m_OriginalRotation = m_OwningEntity->GetDefaultRotation(); m_userModelID = m_OwningEntity->GetVarAs(u"userModelID"); } -void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void ModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { // ItemComponent Serialization. Pets do not get this serialization. if (!m_OwningEntity->HasComponent(eReplicaComponentType::PET)) { outBitStream->Write1(); diff --git a/dGame/dComponents/ModelComponent.h b/dGame/dComponents/ModelBehaviorComponent.h similarity index 92% rename from dGame/dComponents/ModelComponent.h rename to dGame/dComponents/ModelBehaviorComponent.h index b52248697..233c86bb2 100644 --- a/dGame/dComponents/ModelComponent.h +++ b/dGame/dComponents/ModelBehaviorComponent.h @@ -11,11 +11,11 @@ class Entity; /** * Component that represents entities that are a model, e.g. collectible models and BBB models. */ -class ModelComponent : public Component { +class ModelBehaviorComponent : public Component { public: - static const eReplicaComponentType ComponentType = eReplicaComponentType::MODEL; + static const eReplicaComponentType ComponentType = eReplicaComponentType::MODEL_BEHAVIOR; - ModelComponent(Entity* parent); + ModelBehaviorComponent(Entity* parent); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); diff --git a/dGame/dComponents/RocketLaunchLupComponent.cpp b/dGame/dComponents/MultiZoneEntranceComponent.cpp similarity index 73% rename from dGame/dComponents/RocketLaunchLupComponent.cpp rename to dGame/dComponents/MultiZoneEntranceComponent.cpp index 442ee09cd..012d5b3b7 100644 --- a/dGame/dComponents/RocketLaunchLupComponent.cpp +++ b/dGame/dComponents/MultiZoneEntranceComponent.cpp @@ -1,9 +1,9 @@ -#include "RocketLaunchLupComponent.h" +#include "MultiZoneEntranceComponent.h" #include "RocketLaunchpadControlComponent.h" #include "InventoryComponent.h" #include "CharacterComponent.h" -RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(parent) { +MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent) : Component(parent) { m_OwningEntity = parent; std::string zoneString = GeneralUtils::UTF16ToWTF8(m_OwningEntity->GetVar(u"MultiZoneIDs")); std::stringstream ss(zoneString); @@ -14,9 +14,9 @@ RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(p } } -RocketLaunchLupComponent::~RocketLaunchLupComponent() {} +MultiZoneEntranceComponent::~MultiZoneEntranceComponent() {} -void RocketLaunchLupComponent::OnUse(Entity* originator) { +void MultiZoneEntranceComponent::OnUse(Entity* originator) { auto rocket = originator->GetComponent()->RocketEquip(originator); if (!rocket) return; @@ -24,7 +24,7 @@ void RocketLaunchLupComponent::OnUse(Entity* originator) { GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress()); } -void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) { +void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) { auto rocketLaunchpadControlComponent = m_OwningEntity->GetComponent(); if (!rocketLaunchpadControlComponent) return; diff --git a/dGame/dComponents/RocketLaunchLupComponent.h b/dGame/dComponents/MultiZoneEntranceComponent.h similarity index 85% rename from dGame/dComponents/RocketLaunchLupComponent.h rename to dGame/dComponents/MultiZoneEntranceComponent.h index 226fa1b23..b230c1fe8 100644 --- a/dGame/dComponents/RocketLaunchLupComponent.h +++ b/dGame/dComponents/MultiZoneEntranceComponent.h @@ -9,16 +9,16 @@ * Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds. * */ -class RocketLaunchLupComponent : public Component { +class MultiZoneEntranceComponent : public Component { public: - static const eReplicaComponentType ComponentType = eReplicaComponentType::ROCKET_LAUNCH_LUP; + static const eReplicaComponentType ComponentType = eReplicaComponentType::MULTI_ZONE_ENTRANCE; /** * Constructor for this component, builds the m_LUPWorlds vector * @param parent parent that contains this component */ - RocketLaunchLupComponent(Entity* parent); - ~RocketLaunchLupComponent() override; + MultiZoneEntranceComponent(Entity* parent); + ~MultiZoneEntranceComponent() override; /** * Handles an OnUse event from some entity, preparing it for launch to some other world diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 6350107fc..1e945505c 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -17,7 +17,6 @@ #include "PossessorComponent.h" #include "eRacingTaskParam.h" #include "Spawner.h" -#include "VehiclePhysicsComponent.h" #include "dServer.h" #include "dZoneManager.h" #include "dConfig.h" diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.cpp b/dGame/dComponents/RocketLaunchpadControlComponent.cpp index 5376faa7a..718a8f11f 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.cpp +++ b/dGame/dComponents/RocketLaunchpadControlComponent.cpp @@ -13,7 +13,7 @@ #include "ChatPackets.h" #include "MissionComponent.h" #include "PropertyEntranceComponent.h" -#include "RocketLaunchLupComponent.h" +#include "MultiZoneEntranceComponent.h" #include "dServer.h" #include "PacketUtils.h" #include "eObjectWorldState.h" @@ -94,8 +94,8 @@ void RocketLaunchpadControlComponent::OnUse(Entity* originator) { return; } - auto rocketLaunchLUP = m_OwningEntity->GetComponent(); - if (rocketLaunchLUP) { + auto multiZoneEntranceComponent = m_OwningEntity->GetComponent(); + if (multiZoneEntranceComponent) { return; } diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.h b/dGame/dComponents/RocketLaunchpadControlComponent.h index 84cff22dc..0804ba8db 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.h +++ b/dGame/dComponents/RocketLaunchpadControlComponent.h @@ -18,7 +18,7 @@ class PreconditionExpression; */ class RocketLaunchpadControlComponent : public Component { public: - static const eReplicaComponentType ComponentType = eReplicaComponentType::ROCKET_LAUNCH; + static const eReplicaComponentType ComponentType = eReplicaComponentType::ROCKET_LAUNCHPAD_CONTROL; RocketLaunchpadControlComponent(Entity* parent, int rocketId); ~RocketLaunchpadControlComponent() override; diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 0d3b192d2..ce12011c6 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -24,7 +24,7 @@ #include "dConfig.h" #include "TeamManager.h" #include "ChatPackets.h" -#include "RocketLaunchLupComponent.h" +#include "MultiZoneEntranceComponent.h" #include "eUnequippableActiveType.h" #include "eMovementPlatformState.h" #include "LeaderboardManager.h" @@ -69,7 +69,6 @@ #include "MovingPlatformComponent.h" #include "PetComponent.h" #include "ModuleAssemblyComponent.h" -#include "VehiclePhysicsComponent.h" #include "RenderComponent.h" #include "PossessableComponent.h" #include "PossessorComponent.h" @@ -2809,9 +2808,9 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti return; } - auto rocketLaunchLupComponent = entity->GetComponent(); - if (rocketLaunchLupComponent != nullptr) { - rocketLaunchLupComponent->OnSelectWorld(player, index); + auto multiZoneEntranceComponent = entity->GetComponent(); + if (multiZoneEntranceComponent != nullptr) { + multiZoneEntranceComponent->OnSelectWorld(player, index); } } diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index 5e7b5c008..974dd9a2d 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -4,7 +4,7 @@ #include "Entity.h" #include "Game.h" #include "GameMessages.h" -#include "ModelComponent.h" +#include "ModelBehaviorComponent.h" #include "../../dWorldServer/ObjectIDManager.h" #include "dLogger.h" #include "BehaviorStates.h" @@ -30,7 +30,7 @@ #include "UpdateActionMessage.h" #include "UpdateStripUiMessage.h" -void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, std::shared_ptr modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) { +void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, std::shared_ptr modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) { // auto behavior = modelComponent->FindBehavior(behaviorID); // if (behavior->GetBehaviorID() == -1 || behavior->GetShouldSetNewID()) { // ObjectIDManager::Instance()->RequestPersistentID( @@ -57,7 +57,7 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, std::shared_ptrGetComponent(); + auto modelComponent = modelEntity->GetComponent(); if (!modelComponent) return; @@ -79,7 +79,7 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize); } -void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr ModelComponent) { +void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr ModelBehaviorComponent) { auto* modelTypeAmf = arguments->Get("ModelType"); if (!modelTypeAmf) return; @@ -137,7 +137,7 @@ void ControlBehaviors::Rename(Entity* modelEntity, const SystemAddress& sysAddr, } // TODO This is also supposed to serialize the state of the behaviors in progress but those aren't implemented yet -void ControlBehaviors::SendBehaviorBlocksToClient(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { +void ControlBehaviors::SendBehaviorBlocksToClient(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { // uint32_t behaviorID = ControlBehaviors::GetBehaviorIDFromArgument(arguments); // auto modelBehavior = modelComponent->FindBehavior(behaviorID); @@ -266,7 +266,7 @@ void ControlBehaviors::UpdateAction(AMFArrayValue* arguments) { } } -void ControlBehaviors::MoveToInventory(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { +void ControlBehaviors::MoveToInventory(std::shared_ptr modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) { // This closes the UI menu should it be open while the player is removing behaviors AMFArrayValue args; @@ -281,7 +281,7 @@ void ControlBehaviors::MoveToInventory(std::shared_ptr modelComp void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& sysAddr, AMFArrayValue* arguments, std::string command, Entity* modelOwner) { if (!isInitialized || !modelEntity || !modelOwner || !arguments) return; - auto modelComponent = modelEntity->GetComponent(); + auto modelComponent = modelEntity->GetComponent(); if (!modelComponent) return; @@ -342,7 +342,7 @@ ControlBehaviors::ControlBehaviors() { std::string buffer{}; bool commentBlockStart = false; while (std::getline(blocksBuffer, read)) { - // tinyxml2 should handle comment blocks but the client has one that fails the processing. + // tinyxml2 should handle comment blocks but the client has one that fails the processing. // This preprocessing just removes all comments from the read file out of an abundance of caution. if (read.find("