1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2026-07-09 01:57:09 +02:00

Implement a new event to receive notifications when an object world has changed.

This commit is contained in:
Sandu Liviu Catalin
2016-08-18 16:37:55 +03:00
parent 0afd4f3c2e
commit 3bbff3f258
6 changed files with 48 additions and 4 deletions
+18 -3
View File
@@ -39,7 +39,7 @@ Object & CObject::GetNull()
// ------------------------------------------------------------------------------------------------
CObject::CObject(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_OBJECT_POOL))
, m_Tag(ToStrF("%d", id)), m_Data()
, m_Tag(ToStrF("%d", id)), m_Data(), m_CircularLocks(0)
, mMoveToDuration(0)
, mMoveByDuration(0)
, mRotateToDuration(0)
@@ -184,12 +184,27 @@ Int32 CObject::GetWorld() const
}
// ------------------------------------------------------------------------------------------------
void CObject::SetWorld(Int32 world) const
void CObject::SetWorld(Int32 world)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
// Grab the current value for this property
const Int32 current = _Func->GetObjectWorld(m_ID);
// Don't even bother if it's the same value
if (current == world)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetObjectWorld(m_ID, world);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_WORLD))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_WORLD);
// Now forward the event call
Core::Get().EmitObjectWorld(m_ID, current, world);
}
}
// ------------------------------------------------------------------------------------------------