Core/Gameobject: fix collision for gameobjects

This commit is contained in:
Kandera
2012-09-04 14:04:47 -04:00
parent a4c115a494
commit 8afecc6572

View File

@@ -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);
}
}