mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 12:07:13 +01:00
Implement a new event to receive notifications when an object shot or touched report status has changed.
This commit is contained in:
parent
9ce8a8a4f8
commit
ed5f1a86de
@ -257,6 +257,7 @@ protected:
|
|||||||
Function mOnTouched;
|
Function mOnTouched;
|
||||||
Function mOnWorld;
|
Function mOnWorld;
|
||||||
Function mOnAlpha;
|
Function mOnAlpha;
|
||||||
|
Function mOnReport;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -1010,6 +1011,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 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);
|
||||||
void EmitPlayerWeapon(Int32 player_id, Int32 old_weapon, Int32 new_weapon);
|
void EmitPlayerWeapon(Int32 player_id, Int32 old_weapon, Int32 new_weapon);
|
||||||
@ -1156,6 +1158,7 @@ private:
|
|||||||
Function mOnObjectTouched;
|
Function mOnObjectTouched;
|
||||||
Function mOnObjectWorld;
|
Function mOnObjectWorld;
|
||||||
Function mOnObjectAlpha;
|
Function mOnObjectAlpha;
|
||||||
|
Function mOnObjectReport;
|
||||||
Function mOnPickupClaimed;
|
Function mOnPickupClaimed;
|
||||||
Function mOnPickupCollected;
|
Function mOnPickupCollected;
|
||||||
Function mOnPickupRespawn;
|
Function mOnPickupRespawn;
|
||||||
|
@ -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::EmitObjectReport(Int32 object_id, bool old_status, bool new_status, bool touched)
|
||||||
|
{
|
||||||
|
ObjectInst & _object = m_Objects.at(object_id);
|
||||||
|
Emit(_object.mOnReport, old_status, new_status, touched);
|
||||||
|
Emit(mOnObjectReport, _object.mObj, old_status, new_status, touched);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Core::EmitPlayerHealth(Int32 player_id, Float32 old_health, Float32 new_health)
|
void Core::EmitPlayerHealth(Int32 player_id, Float32 old_health, Float32 new_health)
|
||||||
{
|
{
|
||||||
|
@ -154,6 +154,7 @@ void Core::ResetFunc(ObjectInst & inst)
|
|||||||
inst.mOnTouched.ReleaseGently();
|
inst.mOnTouched.ReleaseGently();
|
||||||
inst.mOnWorld.ReleaseGently();
|
inst.mOnWorld.ReleaseGently();
|
||||||
inst.mOnAlpha.ReleaseGently();
|
inst.mOnAlpha.ReleaseGently();
|
||||||
|
inst.mOnReport.ReleaseGently();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -348,6 +349,7 @@ void Core::ResetFunc()
|
|||||||
Core::Get().mOnObjectTouched.ReleaseGently();
|
Core::Get().mOnObjectTouched.ReleaseGently();
|
||||||
Core::Get().mOnObjectWorld.ReleaseGently();
|
Core::Get().mOnObjectWorld.ReleaseGently();
|
||||||
Core::Get().mOnObjectAlpha.ReleaseGently();
|
Core::Get().mOnObjectAlpha.ReleaseGently();
|
||||||
|
Core::Get().mOnObjectReport.ReleaseGently();
|
||||||
Core::Get().mOnPickupClaimed.ReleaseGently();
|
Core::Get().mOnPickupClaimed.ReleaseGently();
|
||||||
Core::Get().mOnPickupCollected.ReleaseGently();
|
Core::Get().mOnPickupCollected.ReleaseGently();
|
||||||
Core::Get().mOnPickupRespawn.ReleaseGently();
|
Core::Get().mOnPickupRespawn.ReleaseGently();
|
||||||
@ -474,6 +476,7 @@ Function & Core::GetEvent(Int32 evid)
|
|||||||
case EVT_OBJECTTOUCHED: return mOnObjectTouched;
|
case EVT_OBJECTTOUCHED: return mOnObjectTouched;
|
||||||
case EVT_OBJECTWORLD: return mOnObjectWorld;
|
case EVT_OBJECTWORLD: return mOnObjectWorld;
|
||||||
case EVT_OBJECTALPHA: return mOnObjectAlpha;
|
case EVT_OBJECTALPHA: return mOnObjectAlpha;
|
||||||
|
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_PICKUPRESPAWN: return mOnPickupRespawn;
|
case EVT_PICKUPRESPAWN: return mOnPickupRespawn;
|
||||||
@ -578,6 +581,7 @@ Function & Core::GetObjectEvent(Int32 id, Int32 evid)
|
|||||||
case EVT_OBJECTTOUCHED: return inst.mOnTouched;
|
case EVT_OBJECTTOUCHED: return inst.mOnTouched;
|
||||||
case EVT_OBJECTWORLD: return inst.mOnWorld;
|
case EVT_OBJECTWORLD: return inst.mOnWorld;
|
||||||
case EVT_OBJECTALPHA: return inst.mOnAlpha;
|
case EVT_OBJECTALPHA: return inst.mOnAlpha;
|
||||||
|
case EVT_OBJECTREPORT: return inst.mOnReport;
|
||||||
default: return NullFunction();
|
default: return NullFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,12 +421,27 @@ bool CObject::GetShotReport() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CObject::SetShotReport(bool toggle) const
|
void CObject::SetShotReport(bool toggle)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Perform the requested operation
|
// Grab the current value for this property
|
||||||
|
const bool current = _Func->IsObjectShotReportEnabled(m_ID);
|
||||||
|
// Don't even bother if it's the same value
|
||||||
|
if (current == toggle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
_Func->SetObjectShotReportEnabled(m_ID, toggle);
|
_Func->SetObjectShotReportEnabled(m_ID, toggle);
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_REPORT);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitObjectReport(m_ID, current, toggle, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -439,12 +454,27 @@ bool CObject::GetTouchedReport() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CObject::SetTouchedReport(bool toggle) const
|
void CObject::SetTouchedReport(bool toggle)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Perform the requested operation
|
// Grab the current value for this property
|
||||||
|
const bool current = _Func->IsObjectTouchedReportEnabled(m_ID);
|
||||||
|
// Don't even bother if it's the same value
|
||||||
|
if (current == toggle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
_Func->SetObjectTouchedReportEnabled(m_ID, toggle);
|
_Func->SetObjectTouchedReportEnabled(m_ID, toggle);
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_REPORT);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitObjectReport(m_ID, current, toggle, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -13,7 +13,8 @@ namespace SqMod {
|
|||||||
enum ObjectCircularLocks
|
enum ObjectCircularLocks
|
||||||
{
|
{
|
||||||
OBJECTCL_EMIT_OBJECT_WORLD = (1 << 0),
|
OBJECTCL_EMIT_OBJECT_WORLD = (1 << 0),
|
||||||
OBJECTCL_EMIT_OBJECT_ALPHA = (2 << 0)
|
OBJECTCL_EMIT_OBJECT_ALPHA = (2 << 0),
|
||||||
|
OBJECTCL_EMIT_OBJECT_REPORT = (3 << 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -336,7 +337,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether the managed object entity reports gunshots.
|
* Set whether the managed object entity reports gunshots.
|
||||||
*/
|
*/
|
||||||
void SetShotReport(bool toggle) const;
|
void SetShotReport(bool toggle);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether the managed object entity reports player bumps.
|
* See whether the managed object entity reports player bumps.
|
||||||
@ -346,7 +347,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether the managed object entity reports player bumps.
|
* Set whether the managed object entity reports player bumps.
|
||||||
*/
|
*/
|
||||||
void SetTouchedReport(bool toggle) const;
|
void SetTouchedReport(bool toggle);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the position on the x axis of the managed object entity.
|
* Retrieve the position on the x axis of the managed object entity.
|
||||||
|
@ -363,6 +363,7 @@ enum EventType
|
|||||||
EVT_OBJECTTOUCHED,
|
EVT_OBJECTTOUCHED,
|
||||||
EVT_OBJECTWORLD,
|
EVT_OBJECTWORLD,
|
||||||
EVT_OBJECTALPHA,
|
EVT_OBJECTALPHA,
|
||||||
|
EVT_OBJECTREPORT,
|
||||||
EVT_PICKUPCLAIMED,
|
EVT_PICKUPCLAIMED,
|
||||||
EVT_PICKUPCOLLECTED,
|
EVT_PICKUPCOLLECTED,
|
||||||
EVT_PICKUPRESPAWN,
|
EVT_PICKUPRESPAWN,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user