mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-20 09:07:14 +02:00
Implement a new event to receive notifications when a vehicle handling rule has changed.
This commit is contained in:
@ -1045,21 +1045,41 @@ Float32 CVehicle::GetHandlingRule(Int32 rule) const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::SetHandlingRule(Int32 rule, Float32 data) const
|
||||
void CVehicle::SetHandlingRule(Int32 rule, Float32 data)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Float32 current = _Func->GetInstHandlingRule(m_ID, rule);
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetInstHandlingRule(m_ID, rule, data);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_HANDLINGRULE);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitVehicleHandlingRule(m_ID, current, data);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::ResetHandlingRule(Int32 rule) const
|
||||
void CVehicle::ResetHandlingRule(Int32 rule)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Float32 current = _Func->GetInstHandlingRule(m_ID, rule);
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->ResetInstHandlingRule(m_ID, rule);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_HANDLINGRULE);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitVehicleHandlingRule(m_ID, current, _Func->GetInstHandlingRule(m_ID, rule));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -18,7 +18,8 @@ enum VehicleCircularLocks
|
||||
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (4 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (5 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (6 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_RADIO = (7 << 0)
|
||||
VEHICLECL_EMIT_VEHICLE_RADIO = (7 << 0),
|
||||
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (8 << 0)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -594,12 +595,12 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the handling data of the managed vehicle entity.
|
||||
*/
|
||||
void SetHandlingRule(Int32 rule, Float32 data) const;
|
||||
void SetHandlingRule(Int32 rule, Float32 data);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Reset the specified handling rule for the managed vehicle entity.
|
||||
*/
|
||||
void ResetHandlingRule(Int32 rule) const;
|
||||
void ResetHandlingRule(Int32 rule);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Reset all the handling rules for the managed vehicle entity.
|
||||
|
Reference in New Issue
Block a user