From e4de42659eb0859e87b0eec1244740eac45b8cff Mon Sep 17 00:00:00 2001 From: Jett <55758076+Jettford@users.noreply.github.com> Date: Thu, 9 Dec 2021 13:56:07 +0000 Subject: [PATCH 1/3] Update Entity.cpp --- dGame/Entity.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index c98323a9..4b8aadb8 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -775,6 +775,15 @@ void Entity::Initialize() TriggerEvent("OnCreate"); + // so basically unless you leave and reenter the moonbase bubble (not something you can do), the physics effect will not trigger on the client + // one solution of this was change the OnEnter event to a OnCreate event + // but this required changing client files so instead that solution we can bodge + if (m_Trigger && Game::server->GetZoneID() == 1603) { + if (m_Trigger->id == 11) { + TriggerEvent("OnEnter"); + } + } + if (m_Character) { auto* controllablePhysicsComponent = GetComponent(); auto* characterComponent = GetComponent(); From a9dc0e0daccebb6fba283df0fb8f0f25803f85eb Mon Sep 17 00:00:00 2001 From: Jett <55758076+Jettford@users.noreply.github.com> Date: Thu, 9 Dec 2021 21:06:01 +0000 Subject: [PATCH 2/3] to improve (broken) --- dGame/Entity.cpp | 9 --------- dGame/dComponents/ControllablePhysicsComponent.cpp | 12 ++++++++++++ dGame/dComponents/ControllablePhysicsComponent.h | 9 +++++++++ dGame/dComponents/PhantomPhysicsComponent.h | 7 +++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 4b8aadb8..c98323a9 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -775,15 +775,6 @@ void Entity::Initialize() TriggerEvent("OnCreate"); - // so basically unless you leave and reenter the moonbase bubble (not something you can do), the physics effect will not trigger on the client - // one solution of this was change the OnEnter event to a OnCreate event - // but this required changing client files so instead that solution we can bodge - if (m_Trigger && Game::server->GetZoneID() == 1603) { - if (m_Trigger->id == 11) { - TriggerEvent("OnEnter"); - } - } - if (m_Character) { auto* controllablePhysicsComponent = GetComponent(); auto* characterComponent = GetComponent(); diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index 922ae55d..7fe19acc 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -40,6 +40,18 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com m_dpEntity = new dpEntity(m_Parent->GetObjectID(), radius, false); m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY); dpWorld::Instance().AddEntity(m_dpEntity); + + auto triggers = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_PHANTOM_PHYSICS); + + for (auto* trigger : triggers) { + for (const auto* event : trigger->GetTrigger()->events) { + if (event->eventID == "OnEnter") { + if (dpCollisionChecks::AreColliding(trigger->GetComponent()->GetdpEntity(), this->m_dpEntity)) { + trigger->TriggerEvent("OnEnter", this->m_Parent); + } + } + } + } } } diff --git a/dGame/dComponents/ControllablePhysicsComponent.h b/dGame/dComponents/ControllablePhysicsComponent.h index 50ec4f26..1c1a4f44 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.h +++ b/dGame/dComponents/ControllablePhysicsComponent.h @@ -7,6 +7,8 @@ #include "NiQuaternion.h" #include "tinyxml2.h" #include "Component.h" +#include "dpCollisionChecks.h" +#include "PhantomPhysicsComponent.h" class Entity; class dpEntity; @@ -218,6 +220,13 @@ public: */ bool GetStatic() const { return m_Static; } + /** + * Returns the Physics entity for the component + * @return Physics entity for the component + */ + + dpEntity* GetdpEntity() const { return m_dpEntity; } + private: /** * The entity that owns this component diff --git a/dGame/dComponents/PhantomPhysicsComponent.h b/dGame/dComponents/PhantomPhysicsComponent.h index fe1ee242..faf6362f 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.h +++ b/dGame/dComponents/PhantomPhysicsComponent.h @@ -110,6 +110,13 @@ public: */ void SetEffectType(uint32_t type); + /** + * Returns the Physics entity for the component + * @return Physics entity for the component + */ + + dpEntity* GetdpEntity() const { return m_dpEntity; } + /** * Spawns an object at each of the vertices for debugging purposes */ From c8991666d2f01ecee5bdaa4ce53c80e6f9fd6f91 Mon Sep 17 00:00:00 2001 From: Jett <55758076+Jettford@users.noreply.github.com> Date: Sat, 11 Dec 2021 10:46:45 +0000 Subject: [PATCH 3/3] Potential solution --- dGame/Entity.cpp | 5 +++++ dGame/dComponents/ControllablePhysicsComponent.cpp | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index c98323a9..a0c19aa0 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1768,6 +1768,7 @@ void Entity::HandleTriggerCommand(std::string id, std::string target, std::strin else if (argArray[0] == "repulse") effectType = 2; else if (argArray[0] == "gravity") effectType = 3; else if (argArray[0] == "friction") effectType = 4; + phanPhys->SetEffectType(effectType); phanPhys->SetDirectionalMultiplier(std::stof(argArray[1])); if (argArray.size() > 4) { @@ -1781,6 +1782,10 @@ void Entity::HandleTriggerCommand(std::string id, std::string target, std::strin phanPhys->SetMin(std::stoi(argArray[6])); phanPhys->SetMax(std::stoi(argArray[7])); } + + if (target == "self") { + EntityManager::Instance()->ConstructEntity(this); + } } else if (id == "updateMission") { CDMissionTasksTable* missionTasksTable = CDClientManager::Instance()->GetTable("MissionTasks"); diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index 7fe19acc..922ae55d 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -40,18 +40,6 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com m_dpEntity = new dpEntity(m_Parent->GetObjectID(), radius, false); m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY); dpWorld::Instance().AddEntity(m_dpEntity); - - auto triggers = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_PHANTOM_PHYSICS); - - for (auto* trigger : triggers) { - for (const auto* event : trigger->GetTrigger()->events) { - if (event->eventID == "OnEnter") { - if (dpCollisionChecks::AreColliding(trigger->GetComponent()->GetdpEntity(), this->m_dpEntity)) { - trigger->TriggerEvent("OnEnter", this->m_Parent); - } - } - } - } } }