Core/Gameobject: fix collision handling.

This commit is contained in:
Kandera
2012-08-23 11:58:57 -04:00
parent 85ed0e32a9
commit 53db3d9700

View File

@@ -135,7 +135,7 @@ void GameObject::AddToWorld()
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 = GetGOData() ? GetGOData()->go_state == GO_STATE_READY : false;
bool toggledState = GetGOData() ? GetGOData()->go_state != GO_STATE_READY : false;
if (m_model)
GetMap()->InsertGameObjectModel(*m_model);
@@ -1929,7 +1929,7 @@ void GameObject::SetLootState(LootState state, Unit* unit)
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
// Use the current go state
if (GetGoState() != GO_STATE_ACTIVE)
if (GetGoState() != GO_STATE_READY)
startOpen = !startOpen;
if (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)
@@ -1951,13 +1951,10 @@ void GameObject::SetGoState(GOState state)
// 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);
if (GetGOData() && GetGOData()->go_state == GO_STATE_READY)
startOpen = !startOpen;
if (state != GO_STATE_READY)
startOpen = !startOpen
if (state == GO_STATE_ACTIVE || state == GO_STATE_ACTIVE_ALTERNATIVE)
EnableCollision(startOpen);
else if (state == GO_STATE_READY)
EnableCollision(!startOpen);
EnableCollision(startOpen);
}
}