mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-09-16 09:17:17 +02:00
Implement simple distance tracking for player and vehicle entities.
Doesn't differentiate from in-air and on-ground. Just sums up the distance from last position on each position update.
This commit is contained in:
@@ -1780,6 +1780,49 @@ const Vector3 & CPlayer::GetLastPosition() const
|
||||
return Core::Get().GetPlayer(m_ID).mLastPosition;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat CPlayer::GetDistance() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Return the requested information
|
||||
return static_cast< SQFloat >(Core::Get().GetPlayer(m_ID).mDistance);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetDistance(SQFloat distance) const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Assign the requested information
|
||||
Core::Get().GetPlayer(m_ID).mDistance = static_cast< Float64 >(distance);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CPlayer::GetTrackDistance() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Return the requested information
|
||||
return static_cast< bool >(Core::Get().GetPlayer(m_ID).mFlags & ENF_DIST_TRACK);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetTrackDistance(bool toggle) const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Assign the requested information
|
||||
if (toggle)
|
||||
{
|
||||
Core::Get().GetPlayer(m_ID).mFlags |= ENF_DIST_TRACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Core::Get().GetPlayer(m_ID).mFlags ^= ENF_DIST_TRACK;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::StartStream()
|
||||
{
|
||||
@@ -2796,6 +2839,8 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
||||
.Prop(_SC("LastArmour"), &CPlayer::GetLastArmour)
|
||||
.Prop(_SC("LastHeading"), &CPlayer::GetLastHeading)
|
||||
.Prop(_SC("LastPosition"), &CPlayer::GetLastPosition)
|
||||
.Prop(_SC("Distance"), &CPlayer::GetDistance, &CPlayer::SetDistance)
|
||||
.Prop(_SC("TrackDistance"), &CPlayer::GetTrackDistance, &CPlayer::SetTrackDistance)
|
||||
.Prop(_SC("BufferCursor"), &CPlayer::GetBufferCursor, &CPlayer::SetBufferCursor)
|
||||
.Prop(_SC("BufferCapacity"), &CPlayer::GetBufferCapacity)
|
||||
.Prop(_SC("PosX"), &CPlayer::GetPositionX, &CPlayer::SetPositionX)
|
||||
|
@@ -925,6 +925,26 @@ public:
|
||||
*/
|
||||
const Vector3 & GetLastPosition() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the distance traveled by the managed player entity while tracking was enabled.
|
||||
*/
|
||||
SQFloat GetDistance() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the distance traveled by the managed player entity.
|
||||
*/
|
||||
void SetDistance(SQFloat distance) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether distance tracking is enabled for the managed player entity.
|
||||
*/
|
||||
bool GetTrackDistance() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether distance tracking is enabled for the managed player entity.
|
||||
*/
|
||||
void SetTrackDistance(bool toggle) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Start a new stream with the default size.
|
||||
*/
|
||||
|
@@ -1349,6 +1349,49 @@ const Quaternion & CVehicle::GetLastRotation() const
|
||||
return Core::Get().GetVehicle(m_ID).mLastRotation;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat CVehicle::GetDistance() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Return the requested information
|
||||
return static_cast< SQFloat >(Core::Get().GetVehicle(m_ID).mDistance);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::SetDistance(SQFloat distance) const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Assign the requested information
|
||||
Core::Get().GetVehicle(m_ID).mDistance = static_cast< Float64 >(distance);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CVehicle::GetTrackDistance() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Return the requested information
|
||||
return static_cast< bool >(Core::Get().GetVehicle(m_ID).mFlags & ENF_DIST_TRACK);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CVehicle::SetTrackDistance(bool toggle) const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Assign the requested information
|
||||
if (toggle)
|
||||
{
|
||||
Core::Get().GetVehicle(m_ID).mFlags |= ENF_DIST_TRACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Core::Get().GetVehicle(m_ID).mFlags ^= ENF_DIST_TRACK;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Float32 CVehicle::GetPositionX() const
|
||||
{
|
||||
@@ -2027,6 +2070,8 @@ void Register_CVehicle(HSQUIRRELVM vm)
|
||||
.Prop(_SC("LastHealth"), &CVehicle::GetLastHealth)
|
||||
.Prop(_SC("LastPosition"), &CVehicle::GetLastPosition)
|
||||
.Prop(_SC("LastRotation"), &CVehicle::GetLastRotation)
|
||||
.Prop(_SC("Distance"), &CVehicle::GetDistance, &CVehicle::SetDistance)
|
||||
.Prop(_SC("TrackDistance"), &CVehicle::GetTrackDistance, &CVehicle::SetTrackDistance)
|
||||
.Prop(_SC("PosX"), &CVehicle::GetPositionX, &CVehicle::SetPositionX)
|
||||
.Prop(_SC("PosY"), &CVehicle::GetPositionY, &CVehicle::SetPositionY)
|
||||
.Prop(_SC("PosZ"), &CVehicle::GetPositionZ, &CVehicle::SetPositionZ)
|
||||
|
@@ -687,15 +687,35 @@ public:
|
||||
Float32 GetLastHealth() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the last known position for the managed player entity.
|
||||
* Retrieve the last known position for the managed vehicle entity.
|
||||
*/
|
||||
const Vector3 & GetLastPosition() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the last known rotation for the managed player entity.
|
||||
* Retrieve the last known rotation for the managed vehicle entity.
|
||||
*/
|
||||
const Quaternion & GetLastRotation() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the distance traveled by the managed vehicle entity while tracking was enabled.
|
||||
*/
|
||||
SQFloat GetDistance() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the distance traveled by the managed vehicle entity.
|
||||
*/
|
||||
void SetDistance(SQFloat distance) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether distance tracking is enabled for the managed vehicle entity.
|
||||
*/
|
||||
bool GetTrackDistance() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether distance tracking is enabled for the managed vehicle entity.
|
||||
*/
|
||||
void SetTrackDistance(bool toggle) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the position on the x axis of the managed vehicle entity.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user