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 alpha has changed.

This commit is contained in:
Sandu Liviu Catalin
2016-08-19 18:05:29 +03:00
parent ba3f829750
commit cbe33f4f21
6 changed files with 36 additions and 4 deletions

View File

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

View File

@ -12,7 +12,8 @@ namespace SqMod {
*/
enum PickupCircularLocks
{
PICKUPCL_EMIT_PICKUP_WORLD = (1 << 0)
PICKUPCL_EMIT_PICKUP_WORLD = (1 << 0),
PICKUPCL_EMIT_PICKUP_ALPHA = (2 << 0)
};
/* ------------------------------------------------------------------------------------------------
@ -211,7 +212,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Mpdify the alpha of the managed pickup entity.
*/
void SetAlpha(Int32 alpha) const;
void SetAlpha(Int32 alpha);
/* --------------------------------------------------------------------------------------------
* See whether the managed pickup entity is automatic.