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 object shot or touched report status has changed.
This commit is contained in:
@ -421,12 +421,27 @@ bool CObject::GetShotReport() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CObject::SetShotReport(bool toggle) const
|
||||
void CObject::SetShotReport(bool toggle)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
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);
|
||||
// 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();
|
||||
// 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);
|
||||
// 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
|
||||
{
|
||||
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.
|
||||
*/
|
||||
void SetShotReport(bool toggle) const;
|
||||
void SetShotReport(bool toggle);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed object entity reports player bumps.
|
||||
@ -346,7 +347,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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.
|
||||
|
Reference in New Issue
Block a user