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 */