mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 12:17:12 +01:00
Implement a new event to receive notifications when an pickup alpha has changed.
This commit is contained in:
parent
ba3f829750
commit
cbe33f4f21
@ -304,6 +304,7 @@ protected:
|
|||||||
Function mOnClaimed;
|
Function mOnClaimed;
|
||||||
Function mOnCollected;
|
Function mOnCollected;
|
||||||
Function mOnWorld;
|
Function mOnWorld;
|
||||||
|
Function mOnAlpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -1013,6 +1014,7 @@ public:
|
|||||||
void EmitObjectWorld(Int32 object_id, Int32 old_world, Int32 new_world);
|
void EmitObjectWorld(Int32 object_id, Int32 old_world, Int32 new_world);
|
||||||
void EmitObjectAlpha(Int32 object_id, Int32 old_alpha, Int32 new_alpha, Int32 time);
|
void EmitObjectAlpha(Int32 object_id, Int32 old_alpha, Int32 new_alpha, Int32 time);
|
||||||
void EmitPickupWorld(Int32 pickup_id, Int32 old_world, Int32 new_world);
|
void EmitPickupWorld(Int32 pickup_id, Int32 old_world, Int32 new_world);
|
||||||
|
void EmitPickupAlpha(Int32 pickup_id, Int32 old_alpha, Int32 new_alpha);
|
||||||
void EmitObjectReport(Int32 object_id, bool old_status, bool new_status, bool touched);
|
void EmitObjectReport(Int32 object_id, bool old_status, bool new_status, bool touched);
|
||||||
void EmitPlayerHealth(Int32 player_id, Float32 old_health, Float32 new_health);
|
void EmitPlayerHealth(Int32 player_id, Float32 old_health, Float32 new_health);
|
||||||
void EmitPlayerArmour(Int32 player_id, Float32 old_armour, Float32 new_armour);
|
void EmitPlayerArmour(Int32 player_id, Float32 old_armour, Float32 new_armour);
|
||||||
@ -1165,6 +1167,7 @@ private:
|
|||||||
Function mOnPickupCollected;
|
Function mOnPickupCollected;
|
||||||
Function mOnPickupRespawn;
|
Function mOnPickupRespawn;
|
||||||
Function mOnPickupWorld;
|
Function mOnPickupWorld;
|
||||||
|
Function mOnPickupAlpha;
|
||||||
Function mOnCheckpointEntered;
|
Function mOnCheckpointEntered;
|
||||||
Function mOnCheckpointExited;
|
Function mOnCheckpointExited;
|
||||||
Function mOnCheckpointWorld;
|
Function mOnCheckpointWorld;
|
||||||
|
@ -716,6 +716,14 @@ void Core::EmitPickupWorld(Int32 pickup_id, Int32 old_world, Int32 new_world)
|
|||||||
Emit(mOnPickupWorld, _pickup.mObj, old_world, new_world);
|
Emit(mOnPickupWorld, _pickup.mObj, old_world, new_world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EmitPickupAlpha(Int32 pickup_id, Int32 old_alpha, Int32 new_alpha)
|
||||||
|
{
|
||||||
|
PickupInst & _pickup = m_Pickups.at(pickup_id);
|
||||||
|
Emit(_pickup.mOnAlpha, old_alpha, new_alpha);
|
||||||
|
Emit(mOnPickupAlpha, _pickup.mObj, old_alpha, new_alpha);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Core::EmitObjectReport(Int32 object_id, bool old_status, bool new_status, bool touched)
|
void Core::EmitObjectReport(Int32 object_id, bool old_status, bool new_status, bool touched)
|
||||||
{
|
{
|
||||||
|
@ -166,6 +166,7 @@ void Core::ResetFunc(PickupInst & inst)
|
|||||||
inst.mOnClaimed.ReleaseGently();
|
inst.mOnClaimed.ReleaseGently();
|
||||||
inst.mOnCollected.ReleaseGently();
|
inst.mOnCollected.ReleaseGently();
|
||||||
inst.mOnWorld.ReleaseGently();
|
inst.mOnWorld.ReleaseGently();
|
||||||
|
inst.mOnAlpha.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -354,6 +355,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnPickupClaimed.ReleaseGently();
|
Core::Get().mOnPickupClaimed.ReleaseGently();
|
||||||
Core::Get().mOnPickupCollected.ReleaseGently();
|
Core::Get().mOnPickupCollected.ReleaseGently();
|
||||||
Core::Get().mOnPickupWorld.ReleaseGently();
|
Core::Get().mOnPickupWorld.ReleaseGently();
|
||||||
|
Core::Get().mOnPickupAlpha.ReleaseGently();
|
||||||
Core::Get().mOnPickupRespawn.ReleaseGently();
|
Core::Get().mOnPickupRespawn.ReleaseGently();
|
||||||
Core::Get().mOnCheckpointEntered.ReleaseGently();
|
Core::Get().mOnCheckpointEntered.ReleaseGently();
|
||||||
Core::Get().mOnCheckpointExited.ReleaseGently();
|
Core::Get().mOnCheckpointExited.ReleaseGently();
|
||||||
@ -482,6 +484,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_PICKUPCLAIMED: return mOnPickupClaimed;
|
case EVT_PICKUPCLAIMED: return mOnPickupClaimed;
|
||||||
case EVT_PICKUPCOLLECTED: return mOnPickupCollected;
|
case EVT_PICKUPCOLLECTED: return mOnPickupCollected;
|
||||||
case EVT_PICKUPWORLD: return mOnPickupWorld;
|
case EVT_PICKUPWORLD: return mOnPickupWorld;
|
||||||
|
case EVT_PICKUPALPHA: return mOnPickupAlpha;
|
||||||
case EVT_PICKUPRESPAWN: return mOnPickupRespawn;
|
case EVT_PICKUPRESPAWN: return mOnPickupRespawn;
|
||||||
case EVT_CHECKPOINTENTERED: return mOnCheckpointEntered;
|
case EVT_CHECKPOINTENTERED: return mOnCheckpointEntered;
|
||||||
case EVT_CHECKPOINTEXITED: return mOnCheckpointExited;
|
case EVT_CHECKPOINTEXITED: return mOnCheckpointExited;
|
||||||
@ -602,6 +605,7 @@ Function & Core::GetPickupEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_PICKUPCLAIMED: return inst.mOnClaimed;
|
case EVT_PICKUPCLAIMED: return inst.mOnClaimed;
|
||||||
case EVT_PICKUPCOLLECTED: return inst.mOnCollected;
|
case EVT_PICKUPCOLLECTED: return inst.mOnCollected;
|
||||||
case EVT_PICKUPWORLD: return inst.mOnWorld;
|
case EVT_PICKUPWORLD: return inst.mOnWorld;
|
||||||
|
case EVT_PICKUPWORLD: return inst.mOnAlpha;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,12 +200,27 @@ Int32 CPickup::GetAlpha() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CPickup::SetAlpha(Int32 alpha) const
|
void CPickup::SetAlpha(Int32 alpha)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
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);
|
_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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -12,7 +12,8 @@ namespace SqMod {
|
|||||||
*/
|
*/
|
||||||
enum PickupCircularLocks
|
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.
|
* 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.
|
* See whether the managed pickup entity is automatic.
|
||||||
|
@ -368,6 +368,7 @@ enum EventType
|
|||||||
EVT_PICKUPCOLLECTED,
|
EVT_PICKUPCOLLECTED,
|
||||||
EVT_PICKUPRESPAWN,
|
EVT_PICKUPRESPAWN,
|
||||||
EVT_PICKUPWORLD,
|
EVT_PICKUPWORLD,
|
||||||
|
EVT_PICKUPALPHA,
|
||||||
EVT_CHECKPOINTENTERED,
|
EVT_CHECKPOINTENTERED,
|
||||||
EVT_CHECKPOINTEXITED,
|
EVT_CHECKPOINTEXITED,
|
||||||
EVT_CHECKPOINTWORLD,
|
EVT_CHECKPOINTWORLD,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user