mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/Gameobject: fix collision for gameobjects
This commit is contained in:
@@ -133,13 +133,13 @@ void GameObject::AddToWorld()
|
||||
m_zoneScript->OnGameObjectCreate(this);
|
||||
|
||||
sObjectAccessor->AddObject(this);
|
||||
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
|
||||
|
||||
// The state can be changed after GameObject::Create but before GameObject::AddToWorld
|
||||
bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState () == GO_READY : GetGoState() != GO_STATE_READY;
|
||||
bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState () == GO_READY : GetGoState() == GO_STATE_READY;
|
||||
if (m_model)
|
||||
GetMap()->InsertGameObjectModel(*m_model);
|
||||
|
||||
EnableCollision(startOpen ^ toggledState);
|
||||
EnableCollision(toggledState);
|
||||
WorldObject::AddToWorld();
|
||||
}
|
||||
}
|
||||
@@ -1926,14 +1926,12 @@ void GameObject::SetLootState(LootState state, Unit* unit)
|
||||
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
|
||||
if (m_model)
|
||||
{
|
||||
// startOpen determines whether we are going to add or remove the LoS on activation
|
||||
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
|
||||
|
||||
bool collision = false;
|
||||
// Use the current go state
|
||||
if ((GetGoState() != GO_STATE_READY && (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)) || state == GO_READY)
|
||||
startOpen = !startOpen;
|
||||
collision = !collision;
|
||||
|
||||
EnableCollision(startOpen);
|
||||
EnableCollision(collision);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1947,12 +1945,11 @@ void GameObject::SetGoState(GOState state)
|
||||
return;
|
||||
|
||||
// startOpen determines whether we are going to add or remove the LoS on activation
|
||||
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
|
||||
bool collision = false;
|
||||
if (state == GO_STATE_READY)
|
||||
collision = !collision;
|
||||
|
||||
if (state != GO_STATE_READY)
|
||||
startOpen = !startOpen;
|
||||
|
||||
EnableCollision(startOpen);
|
||||
EnableCollision(collision);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user