From 48ec2df81fa8f88cd32d7a79b587603aedbd89e0 Mon Sep 17 00:00:00 2001 From: Subv Date: Sun, 1 Jun 2014 22:27:29 -0500 Subject: Core/Phases: Preliminary work with correctly implementing the phase system in 4.3.4 Put here for peer review. --- src/server/game/Entities/GameObject/GameObject.cpp | 17 +++++++++++++++++ src/server/game/Entities/GameObject/GameObject.h | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/server/game/Entities/GameObject') diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index d6a029d29bf..736c39461cd 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -813,6 +813,16 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) if (!Create(guid, entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit)) return false; + if (data->phaseid) + SetInPhase(data->phaseid, false, true); + + if (data->phaseGroup) + { + // Set the gameobject in all the phases of the phasegroup + for (auto ph : GetPhasesForGroup(data->phaseGroup)) + SetInPhase(ph, false, true); + } + if (data->spawntimesecs >= 0) { m_spawnedByDefault = true; @@ -2053,6 +2063,13 @@ void GameObject::SetDisplayId(uint32 displayid) UpdateModel(); } +void GameObject::SetInPhase(uint32 id, bool update, bool apply) +{ + WorldObject::SetInPhase(id, update, apply); + if (m_model && m_model->isEnabled()) + EnableCollision(true); +} + void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update) { WorldObject::SetPhaseMask(newPhaseMask, update); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 640d5718186..2b24f29fe69 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -592,7 +592,7 @@ struct GameObjectData { explicit GameObjectData() : id(0), mapid(0), phaseMask(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), rotation0(0.0f), rotation1(0.0f), rotation2(0.0f), rotation3(0.0f), spawntimesecs(0), - animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), dbData(true) { } + animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), phaseid(0), phaseGroup(0), dbData(true) { } uint32 id; // entry in gamobject_template uint16 mapid; uint32 phaseMask; @@ -609,6 +609,8 @@ struct GameObjectData GOState go_state; uint8 spawnMask; uint8 artKit; + uint32 phaseid; + uint32 phaseGroup; bool dbData; }; @@ -725,6 +727,7 @@ class GameObject : public WorldObject, public GridObject, public Map static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0); void SetPhaseMask(uint32 newPhaseMask, bool update); + void SetInPhase(uint32 id, bool update, bool apply); void EnableCollision(bool enable); void Use(Unit* user); @@ -876,6 +879,7 @@ class GameObject : public WorldObject, public GridObject, public Map //! Following check does check 3d distance return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare); } + GameObjectAI* m_AI; }; #endif -- cgit v1.2.3