1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 07:07:13 +02:00

Implement a new event to receive notifications when an pickup auto timer has changed.

This commit is contained in:
Sandu Liviu Catalin
2016-08-19 18:26:52 +03:00
parent a47f7541d0
commit e179452a61
6 changed files with 36 additions and 4 deletions

View File

@ -266,12 +266,27 @@ Int32 CPickup::GetAutoTimer() const
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAutoTimer(Int32 timer) const
void CPickup::SetAutoTimer(Int32 timer)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
// Grab the current value for this property
const Int32 current = _Func->GetPickupAutoTimer(m_ID);
// Don't even bother if it's the same value
if (current == timer)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupAutoTimer(m_ID, timer);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOTIMER))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOTIMER);
// Now forward the event call
Core::Get().EmitPickupAutoTimer(m_ID, current, timer);
}
}
// ------------------------------------------------------------------------------------------------

View File

@ -14,7 +14,8 @@ enum PickupCircularLocks
{
PICKUPCL_EMIT_PICKUP_WORLD = (1 << 0),
PICKUPCL_EMIT_PICKUP_ALPHA = (2 << 0),
PICKUPCL_EMIT_PICKUP_AUTOMATIC = (3 << 0)
PICKUPCL_EMIT_PICKUP_AUTOMATIC = (3 << 0),
PICKUPCL_EMIT_PICKUP_AUTOTIMER = (4 << 0)
};
/* ------------------------------------------------------------------------------------------------
@ -233,7 +234,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Mpdify the automatic timer of the managed pickup entity.
*/
void SetAutoTimer(Int32 timer) const;
void SetAutoTimer(Int32 timer);
/* --------------------------------------------------------------------------------------------
* Refresh the managed pickup entity.