mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-03-12 07:07:13 +01:00
Implement a new event to receive notifications when an pickup world has changed.
This commit is contained in:
parent
d08e57f69a
commit
102c77aa77
@ -303,6 +303,7 @@ protected:
|
|||||||
Function mOnRespawn;
|
Function mOnRespawn;
|
||||||
Function mOnClaimed;
|
Function mOnClaimed;
|
||||||
Function mOnCollected;
|
Function mOnCollected;
|
||||||
|
Function mOnWorld;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -1011,6 +1012,7 @@ public:
|
|||||||
void EmitCheckpointRadius(Int32 checkpoint_id, Float32 old_radius, Float32 new_radius);
|
void EmitCheckpointRadius(Int32 checkpoint_id, Float32 old_radius, Float32 new_radius);
|
||||||
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 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);
|
||||||
@ -1162,6 +1164,7 @@ private:
|
|||||||
Function mOnPickupClaimed;
|
Function mOnPickupClaimed;
|
||||||
Function mOnPickupCollected;
|
Function mOnPickupCollected;
|
||||||
Function mOnPickupRespawn;
|
Function mOnPickupRespawn;
|
||||||
|
Function mOnPickupWorld;
|
||||||
Function mOnCheckpointEntered;
|
Function mOnCheckpointEntered;
|
||||||
Function mOnCheckpointExited;
|
Function mOnCheckpointExited;
|
||||||
Function mOnCheckpointWorld;
|
Function mOnCheckpointWorld;
|
||||||
|
@ -708,6 +708,14 @@ void Core::EmitObjectAlpha(Int32 object_id, Int32 old_alpha, Int32 new_alpha, In
|
|||||||
Emit(mOnObjectAlpha, _object.mObj, old_alpha, new_alpha, time);
|
Emit(mOnObjectAlpha, _object.mObj, old_alpha, new_alpha, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Core::EmitPickupWorld(Int32 pickup_id, Int32 old_world, Int32 new_world)
|
||||||
|
{
|
||||||
|
PickupInst & _pickup = m_Pickups.at(pickup_id);
|
||||||
|
Emit(_pickup.mOnRespawn, old_world, new_world);
|
||||||
|
Emit(mOnPickupRespawn, _pickup.mObj, old_world, new_world);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -165,6 +165,7 @@ void Core::ResetFunc(PickupInst & inst)
|
|||||||
inst.mOnRespawn.ReleaseGently();
|
inst.mOnRespawn.ReleaseGently();
|
||||||
inst.mOnClaimed.ReleaseGently();
|
inst.mOnClaimed.ReleaseGently();
|
||||||
inst.mOnCollected.ReleaseGently();
|
inst.mOnCollected.ReleaseGently();
|
||||||
|
inst.mOnWorld.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -222,6 +223,7 @@ void Core::ResetFunc(PlayerInst & inst)
|
|||||||
inst.mOnObjectTouched.ReleaseGently();
|
inst.mOnObjectTouched.ReleaseGently();
|
||||||
inst.mOnPickupClaimed.ReleaseGently();
|
inst.mOnPickupClaimed.ReleaseGently();
|
||||||
inst.mOnPickupCollected.ReleaseGently();
|
inst.mOnPickupCollected.ReleaseGently();
|
||||||
|
inst.mOnPickupCollected.ReleaseGently();
|
||||||
inst.mOnCheckpointEntered.ReleaseGently();
|
inst.mOnCheckpointEntered.ReleaseGently();
|
||||||
inst.mOnCheckpointExited.ReleaseGently();
|
inst.mOnCheckpointExited.ReleaseGently();
|
||||||
inst.mOnClientScriptData.ReleaseGently();
|
inst.mOnClientScriptData.ReleaseGently();
|
||||||
@ -352,6 +354,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnObjectReport.ReleaseGently();
|
Core::Get().mOnObjectReport.ReleaseGently();
|
||||||
Core::Get().mOnPickupClaimed.ReleaseGently();
|
Core::Get().mOnPickupClaimed.ReleaseGently();
|
||||||
Core::Get().mOnPickupCollected.ReleaseGently();
|
Core::Get().mOnPickupCollected.ReleaseGently();
|
||||||
|
Core::Get().mOnPickupWorld.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();
|
||||||
@ -479,6 +482,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_OBJECTREPORT: return mOnObjectReport;
|
case EVT_OBJECTREPORT: return mOnObjectReport;
|
||||||
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_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;
|
||||||
@ -598,6 +602,7 @@ Function & Core::GetPickupEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_PICKUPRESPAWN: return inst.mOnRespawn;
|
case EVT_PICKUPRESPAWN: return inst.mOnRespawn;
|
||||||
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;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ Object & CPickup::GetNull()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
CPickup::CPickup(Int32 id)
|
CPickup::CPickup(Int32 id)
|
||||||
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PICKUP_POOL))
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PICKUP_POOL))
|
||||||
, m_Tag(ToStrF("%d", id))
|
, m_Tag(ToStrF("%d", id)), m_Data(), m_CircularLocks(0)
|
||||||
{
|
{
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
@ -167,12 +167,27 @@ Int32 CPickup::GetWorld() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CPickup::SetWorld(Int32 world) const
|
void CPickup::SetWorld(Int32 world)
|
||||||
{
|
{
|
||||||
// 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->GetPickupWorld(m_ID);
|
||||||
|
// Don't even bother if it's the same value
|
||||||
|
if (current == world)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
_Func->SetPickupWorld(m_ID, world);
|
_Func->SetPickupWorld(m_ID, world);
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_WORLD))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_WORLD);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitPickupWorld(m_ID, current, world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -7,6 +7,14 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Circular locks employed by the pickup manager.
|
||||||
|
*/
|
||||||
|
enum PickupCircularLocks
|
||||||
|
{
|
||||||
|
PICKUPCL_EMIT_PICKUP_WORLD = (1 << 0)
|
||||||
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Manages a single pickup entity.
|
* Manages a single pickup entity.
|
||||||
*/
|
*/
|
||||||
@ -35,6 +43,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
Object m_Data;
|
Object m_Data;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Prevent events from triggering themselves.
|
||||||
|
*/
|
||||||
|
Uint32 m_CircularLocks;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Base constructor.
|
* Base constructor.
|
||||||
*/
|
*/
|
||||||
@ -188,7 +201,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Mpdify the world in which the managed pickup entity exists.
|
* Mpdify the world in which the managed pickup entity exists.
|
||||||
*/
|
*/
|
||||||
void SetWorld(Int32 world) const;
|
void SetWorld(Int32 world);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the alpha of the managed pickup entity.
|
* Retrieve the alpha of the managed pickup entity.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user