mirror of
https://github.com/mangosfour/server.git
synced 2025-12-23 16:37:03 +00:00
[10073] Make object active at applying view on it
also isActiveObject check moved to WorldObject - all worldobjects are inactive by default, excluding players this is a final part of cameras implementation (based on commit efc9623) Signed-off-by: VladimirMangos <vladimir@getmangos.com> Also remove template-way code selection for object for Map::AddToActive/Map::RemoveFromActive. This simplify function use from not Map code.
This commit is contained in:
parent
33d73f2efc
commit
6ca609629c
15 changed files with 69 additions and 75 deletions
|
|
@ -39,6 +39,9 @@ void Camera::SetView(WorldObject *obj)
|
|||
{
|
||||
ASSERT(obj);
|
||||
|
||||
if (m_source == obj)
|
||||
return;
|
||||
|
||||
if (!m_owner.IsInMap(obj))
|
||||
{
|
||||
sLog.outError("Camera::SetView, viewpoint is not in map with camera's owner");
|
||||
|
|
@ -51,8 +54,16 @@ void Camera::SetView(WorldObject *obj)
|
|||
return;
|
||||
}
|
||||
|
||||
// detach and deregister from active objects if there are no more reasons to be active
|
||||
m_source->GetViewPoint().Detach(this);
|
||||
if (!m_source->isActiveObject())
|
||||
m_source->GetMap()->RemoveFromActive(m_source);
|
||||
|
||||
m_source = obj;
|
||||
|
||||
if (!m_source->isActiveObject())
|
||||
m_source->GetMap()->AddToActive(m_source);
|
||||
|
||||
m_source->GetViewPoint().Attach(this);
|
||||
|
||||
UpdateForCurrentViewPoint();
|
||||
|
|
@ -66,11 +77,7 @@ void Camera::Event_ViewPointVisibilityChanged()
|
|||
|
||||
void Camera::ResetView()
|
||||
{
|
||||
m_source->GetViewPoint().Detach(this);
|
||||
m_source = &m_owner;
|
||||
m_source->GetViewPoint().Attach(this);
|
||||
|
||||
UpdateForCurrentViewPoint();
|
||||
SetView(&m_owner);
|
||||
}
|
||||
|
||||
void Camera::Event_AddedToWorld()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue