2015-11-11 07:57:10 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Checkpoint.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Entity/Player.hpp"
|
|
|
|
#include "Base/Color4.hpp"
|
|
|
|
#include "Base/Vector3.hpp"
|
2015-11-01 00:31:38 +01:00
|
|
|
#include "Core.hpp"
|
2018-07-29 11:25:44 +02:00
|
|
|
#include "Misc/Tasks.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2016-11-15 20:16:24 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqCheckpoint"))
|
|
|
|
|
2015-11-01 00:31:38 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const Int32 CCheckpoint::Max = SQMOD_CHECKPOINT_POOL;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-08-07 00:54:33 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CCheckpoint::SqGetNull(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-04-17 16:42:09 +02:00
|
|
|
sq_pushobject(vm, Core::Get().GetNullCheckpoint().GetObj());
|
2016-08-07 00:54:33 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CCheckpoint::GetNull()
|
2016-08-07 00:54:33 +02:00
|
|
|
{
|
|
|
|
return Core::Get().GetNullCheckpoint();
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CCheckpoint::CCheckpoint(Int32 id)
|
|
|
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_CHECKPOINT_POOL))
|
2016-08-18 14:54:26 +02:00
|
|
|
, m_Tag(ToStrF("%d", id)), m_Data(), m_CircularLocks(0)
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CCheckpoint::ToString() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & CCheckpoint::GetTag() const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CCheckpoint::SetTag(StackStrF & tag)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-11-16 13:48:19 +01:00
|
|
|
if (tag.mLen > 0)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
|
2016-11-16 13:48:19 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Tag.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
CCheckpoint & CCheckpoint::ApplyTag(StackStrF & tag)
|
2016-11-16 13:48:19 +01:00
|
|
|
{
|
|
|
|
SetTag(tag);
|
|
|
|
return *this;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:07:31 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CCheckpoint::GetData()
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return m_Data;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CCheckpoint::SetData(LightObj & data)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Apply the specified value
|
|
|
|
m_Data = data;
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
bool CCheckpoint::Destroy(Int32 header, LightObj & payload)
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().DelCheckpoint(m_ID, header, payload);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CCheckpoint::GetEvents() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-02-21 20:24:59 +01:00
|
|
|
// Return the associated event table
|
|
|
|
return Core::Get().GetCheckpoint(m_ID).mEvents;
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-07-26 23:13:50 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CCheckpoint::CustomEvent(Int32 header, LightObj & payload) const
|
2016-07-26 23:13:50 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perfrom the requested action
|
|
|
|
Core::Get().EmitCheckpointCustom(m_ID, header, payload);
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:07:31 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CCheckpoint::IsStreamedFor(CPlayer & player) const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->IsCheckPointStreamedForPlayer(m_ID, player.GetID());
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CCheckpoint::IsSphere() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsCheckPointSphere(m_ID);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CCheckpoint::GetWorld() const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetCheckPointWorld(m_ID);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-18 14:54:26 +02:00
|
|
|
void CCheckpoint::SetWorld(Int32 world)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-18 14:54:26 +02:00
|
|
|
// Grab the current value for this property
|
|
|
|
const Int32 current = _Func->GetCheckPointWorld(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == world)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointWorld(m_ID, world);
|
2016-08-18 14:54:26 +02:00
|
|
|
// Avoid infinite recursive event loops
|
|
|
|
if (!(m_CircularLocks & CHECKPOINTCL_EMIT_CHECKPOINT_WORLD))
|
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, CHECKPOINTCL_EMIT_CHECKPOINT_WORLD);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitCheckpointWorld(m_ID, current, world);
|
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Color4 CCheckpoint::GetColor() const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the color information
|
|
|
|
Int32 r, g, b, a;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the color values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, &r, &g, &b, &a);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2020-03-22 09:00:31 +01:00
|
|
|
return {ConvTo< Color4::Value >::From(r), ConvTo< Color4::Value >::From(g),
|
|
|
|
ConvTo< Color4::Value >::From(b), ConvTo< Color4::Value >::From(a)};
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CCheckpoint::SetColor(const Color4 & col) const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, col.r, col.g, col.b, col.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CCheckpoint::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetCheckPointColour(m_ID, r, g, b, 0xFF);
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CCheckpoint::SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, r, g, b, a);
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Vector3 CCheckpoint::GetPosition() const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create a default vector instance
|
|
|
|
Vector3 vec;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the position values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &vec.x, &vec.y, &vec.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return vec;
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CCheckpoint::SetPosition(const Vector3 & pos) const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, pos.x, pos.y, pos.z);
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CCheckpoint::SetPositionEx(Float32 x, Float32 y, Float32 z) const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, x, y, z);
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Float32 CCheckpoint::GetRadius() const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetCheckPointRadius(m_ID);
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-18 15:15:53 +02:00
|
|
|
void CCheckpoint::SetRadius(Float32 radius)
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-18 15:10:18 +02:00
|
|
|
// Grab the current value for this property
|
|
|
|
const Float32 current = _Func->GetCheckPointRadius(m_ID);
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointRadius(m_ID, radius);
|
2016-08-18 15:10:18 +02:00
|
|
|
// Avoid infinite recursive event loops
|
|
|
|
if (!(m_CircularLocks & CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS))
|
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitCheckpointRadius(m_ID, current, radius);
|
|
|
|
}
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CCheckpoint::GetOwner() const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(_Func->GetCheckPointOwner(m_ID)).mObj;
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CCheckpoint::GetOwnerID() const
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetCheckPointOwner(m_ID);
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2015-11-01 00:31:38 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 CCheckpoint::GetPositionX() const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous position information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 x = 0.0f, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &x, &dummy, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return x;
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 CCheckpoint::GetPositionY() const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous position information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 y = 0.0f, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &dummy, &y, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return y;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 CCheckpoint::GetPositionZ() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous position information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 z = 0.0f, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &dummy, &dummy, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return z;
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetPositionX(Float32 x) const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 y, z, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &dummy, &y, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, x, y, z);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetPositionY(Float32 y) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 x, z, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &x, &dummy, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, x, y, z);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetPositionZ(Float32 z) const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 x, y, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &x, &y, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, z, y, z);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CCheckpoint::GetColorR() const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous color information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 r = 0, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &r, &dummy, &dummy, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return r;
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CCheckpoint::GetColorG() const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous color information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 g = 0, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &dummy, &g, &dummy, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return g;
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CCheckpoint::GetColorB() const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous color information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 b = 0, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &dummy, &dummy, &b, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return b;
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CCheckpoint::GetColorA() const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous color information, if any
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 a = 0, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &dummy, &dummy, &dummy, &a);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return a;
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetColorR(Int32 r) const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary integers to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 g, b, a, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &dummy, &g, &b, &a);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, r, g, b, a);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetColorG(Int32 g) const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary integers to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 r, b, a, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &r, &dummy, &b, &a);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, r, g, b, a);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetColorB(Int32 b) const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary integers to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 r, g, a, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &r, &g, &dummy, &a);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, r, g, b, a);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CCheckpoint::SetColorA(Int32 a) const
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary integers to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Int32 r, g, b, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetCheckPointColour(m_ID, &r, &g, &b, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, r, g, b, a);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
static LightObj & Checkpoint_CreateEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius)
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(-1, world, sphere, x, y, z, r, g, b, a, radius,
|
2017-02-21 20:24:59 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj());
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2017-02-21 20:24:59 +01:00
|
|
|
static LightObj & Checkpoint_CreateEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius,
|
2017-02-21 20:24:59 +01:00
|
|
|
Int32 header, LightObj & payload)
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(-1, world, sphere, x, y, z, r, g, b, a,
|
2016-05-22 05:20:38 +02:00
|
|
|
radius, header, payload);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
static LightObj & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos,
|
2016-02-20 23:25:00 +01:00
|
|
|
const Color4 & color, Float32 radius)
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(-1, world, sphere, pos.x, pos.y, pos.z,
|
2016-02-20 23:25:00 +01:00
|
|
|
color.r, color.g, color.b, color.a, radius,
|
2017-02-21 20:24:59 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj());
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2017-02-21 20:24:59 +01:00
|
|
|
static LightObj & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos,
|
|
|
|
const Color4 & color, Float32 radius, Int32 header, LightObj & payload)
|
2015-11-01 00:31:38 +01:00
|
|
|
{
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(-1, world, sphere, pos.x, pos.y, pos.z,
|
2016-02-20 23:25:00 +01:00
|
|
|
color.r, color.g, color.b, color.a, radius, header, payload);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2015-10-29 21:07:31 +01:00
|
|
|
// ================================================================================================
|
2020-03-22 09:00:31 +01:00
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CCheckpoint(HSQUIRRELVM vm)
|
2020-03-22 09:00:31 +01:00
|
|
|
#pragma clang diagnostic pop
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-11-15 20:16:24 +01:00
|
|
|
RootTable(vm).Bind(Typename::Str,
|
|
|
|
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, Typename::Str)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-11-15 20:16:24 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_tostring"), &CCheckpoint::ToString)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Values
|
2016-03-10 04:57:13 +01:00
|
|
|
.SetStaticValue(_SC("MaxID"), CCheckpoint::Max)
|
|
|
|
// Core Properties
|
2017-02-21 20:24:59 +01:00
|
|
|
.Prop(_SC("On"), &CCheckpoint::GetEvents)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("ID"), &CCheckpoint::GetID)
|
|
|
|
.Prop(_SC("Tag"), &CCheckpoint::GetTag, &CCheckpoint::SetTag)
|
|
|
|
.Prop(_SC("Data"), &CCheckpoint::GetData, &CCheckpoint::SetData)
|
|
|
|
.Prop(_SC("Active"), &CCheckpoint::IsActive)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Core Methods
|
2016-11-16 13:48:19 +01:00
|
|
|
.FmtFunc(_SC("SetTag"), &CCheckpoint::ApplyTag)
|
2016-07-26 23:13:50 +02:00
|
|
|
.Func(_SC("CustomEvent"), &CCheckpoint::CustomEvent)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Core Overloads
|
2016-02-20 23:25:00 +01:00
|
|
|
.Overload< bool (CCheckpoint::*)(void) >(_SC("Destroy"), &CCheckpoint::Destroy)
|
|
|
|
.Overload< bool (CCheckpoint::*)(Int32) >(_SC("Destroy"), &CCheckpoint::Destroy)
|
2017-02-21 20:24:59 +01:00
|
|
|
.Overload< bool (CCheckpoint::*)(Int32, LightObj &) >(_SC("Destroy"), &CCheckpoint::Destroy)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Properties
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Sphere"), &CCheckpoint::IsSphere)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("World"), &CCheckpoint::GetWorld, &CCheckpoint::SetWorld)
|
|
|
|
.Prop(_SC("Color"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
|
2016-06-13 00:33:52 +02:00
|
|
|
.Prop(_SC("Colour"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Pos"), &CCheckpoint::GetPosition, &CCheckpoint::SetPosition)
|
|
|
|
.Prop(_SC("Position"), &CCheckpoint::GetPosition, &CCheckpoint::SetPosition)
|
|
|
|
.Prop(_SC("Radius"), &CCheckpoint::GetRadius, &CCheckpoint::SetRadius)
|
|
|
|
.Prop(_SC("Owner"), &CCheckpoint::GetOwner)
|
|
|
|
.Prop(_SC("OwnerID"), &CCheckpoint::GetOwnerID)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("PosX"), &CCheckpoint::GetPositionX, &CCheckpoint::SetPositionX)
|
|
|
|
.Prop(_SC("PosY"), &CCheckpoint::GetPositionY, &CCheckpoint::SetPositionY)
|
|
|
|
.Prop(_SC("PosZ"), &CCheckpoint::GetPositionZ, &CCheckpoint::SetPositionZ)
|
|
|
|
.Prop(_SC("Red"), &CCheckpoint::GetColorR, &CCheckpoint::SetColorR)
|
|
|
|
.Prop(_SC("Green"), &CCheckpoint::GetColorG, &CCheckpoint::SetColorG)
|
|
|
|
.Prop(_SC("Blue"), &CCheckpoint::GetColorB, &CCheckpoint::SetColorB)
|
|
|
|
.Prop(_SC("Alpha"), &CCheckpoint::GetColorA, &CCheckpoint::SetColorA)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Member Methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("StreamedFor"), &CCheckpoint::IsStreamedFor)
|
|
|
|
.Func(_SC("SetPos"), &CCheckpoint::SetPositionEx)
|
|
|
|
.Func(_SC("SetPosition"), &CCheckpoint::SetPositionEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Member Overloads
|
|
|
|
.Overload< void (CCheckpoint::*)(Uint8, Uint8, Uint8) const >
|
|
|
|
(_SC("SetColor"), &CCheckpoint::SetColorEx)
|
|
|
|
.Overload< void (CCheckpoint::*)(Uint8, Uint8, Uint8, Uint8) const >
|
|
|
|
(_SC("SetColor"), &CCheckpoint::SetColorEx)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Static Overloads
|
2017-02-21 20:24:59 +01:00
|
|
|
.StaticOverload< LightObj & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("CreateEx"), &Checkpoint_CreateEx)
|
2017-02-21 20:24:59 +01:00
|
|
|
.StaticOverload< LightObj & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, LightObj &) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("CreateEx"), &Checkpoint_CreateEx)
|
2017-02-21 20:24:59 +01:00
|
|
|
.StaticOverload< LightObj & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("Create"), &Checkpoint_Create)
|
2017-02-21 20:24:59 +01:00
|
|
|
.StaticOverload< LightObj & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, LightObj &) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("Create"), &Checkpoint_Create)
|
2016-08-07 00:54:33 +02:00
|
|
|
// Raw Squirrel Methods
|
|
|
|
.SquirrelFunc(_SC("NullInst"), &CCheckpoint::SqGetNull)
|
2016-11-16 23:23:59 +01:00
|
|
|
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CCheckpoint, ENT_CHECKPOINT >)
|
|
|
|
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CCheckpoint, ENT_CHECKPOINT >)
|
|
|
|
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CCheckpoint, ENT_CHECKPOINT >)
|
2016-11-17 16:04:21 +01:00
|
|
|
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CCheckpoint, ENT_CHECKPOINT >)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
} // Namespace:: SqMod
|