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"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Color4 CCheckpoint::s_Color4;
|
|
|
|
Vector3 CCheckpoint::s_Vector3;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CCheckpoint::s_ColorR;
|
|
|
|
Int32 CCheckpoint::s_ColorG;
|
|
|
|
Int32 CCheckpoint::s_ColorB;
|
|
|
|
Int32 CCheckpoint::s_ColorA;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
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-03-10 04:57:13 +01:00
|
|
|
SQInteger CCheckpoint::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
static const SQChar name[] = _SC("SqCheckpoint");
|
2016-03-10 04:57:13 +01:00
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-08-07 00:54:33 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CCheckpoint::SqGetNull(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
sq_pushobject(vm, Core::Get().GetNullCheckpoint().GetObject());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Object & CCheckpoint::GetNull()
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:07:31 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CCheckpoint::~CCheckpoint()
|
2015-10-29 21:07:31 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Int32 CCheckpoint::Cmp(const CCheckpoint & o) const
|
|
|
|
{
|
|
|
|
if (m_ID == o.m_ID)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 0;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else if (m_ID > o.m_ID)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:07:31 +01:00
|
|
|
else
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return -1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:07:31 +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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CCheckpoint::SetTag(CSStr tag)
|
|
|
|
{
|
|
|
|
m_Tag.assign(tag);
|
|
|
|
}
|
2015-10-29 21:07:31 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & CCheckpoint::GetData()
|
|
|
|
{
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CCheckpoint::SetData(Object & data)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CCheckpoint::Destroy(Int32 header, Object & 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
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
void CCheckpoint::BindEvent(Int32 evid, Object & env, Function & func) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Obtain the function instance called for this event
|
2016-05-22 05:20:38 +02:00
|
|
|
Function & event = Core::Get().GetCheckpointEvent(m_ID, evid);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified callback function null?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (func.IsNull())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 20:36:49 +02:00
|
|
|
event.ReleaseGently(); // Then release the current callback
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-05-24 06:29:14 +02:00
|
|
|
// Does this function need a custom environment?
|
|
|
|
else if (env.IsNull())
|
|
|
|
{
|
|
|
|
event = func;
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Assign the specified environment and function
|
2015-10-29 21:07:31 +01:00
|
|
|
else
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
event = Function(env.GetVM(), env, func.GetFunc());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2015-10-29 21:07:31 +01:00
|
|
|
}
|
|
|
|
|
2016-07-26 23:13:50 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CCheckpoint::CustomEvent(Int32 header, Object & payload) const
|
|
|
|
{
|
|
|
|
// 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
const 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();
|
|
|
|
// Clear previous color information, if any
|
2016-05-22 05:20:38 +02:00
|
|
|
s_ColorR = s_ColorG = s_ColorB = s_ColorA = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the color values
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, &s_ColorR, &s_ColorG, &s_ColorB, &s_ColorA);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Convert and assign the retrieved values
|
2016-07-24 22:18:12 +02:00
|
|
|
s_Color4.SetColor4Ex(s_ColorR, s_ColorG, s_ColorB, s_ColorA);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2015-10-29 21:07:31 +01:00
|
|
|
return s_Color4;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
const 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();
|
|
|
|
// Clear previous position information, if any
|
2015-10-29 21:07:31 +01:00
|
|
|
s_Vector3.Clear();
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the position values
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2015-10-29 21:07:31 +01:00
|
|
|
return s_Vector3;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & 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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_Vector3.x = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, nullptr, nullptr);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_Vector3.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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_Vector3.y = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, nullptr, &s_Vector3.y, nullptr);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_Vector3.y;
|
|
|
|
}
|
|
|
|
|
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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_Vector3.z = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, nullptr, nullptr, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_Vector3.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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, nullptr, &s_Vector3.y, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, x, s_Vector3.y, s_Vector3.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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, nullptr, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, s_Vector3.x, y, s_Vector3.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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, &s_Vector3.y, nullptr);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointPosition(m_ID, s_Vector3.z, s_Vector3.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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_ColorR = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, &s_ColorR, NULL, NULL, NULL);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_ColorR;
|
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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_ColorG = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, NULL, &s_ColorG, NULL, NULL);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_ColorG;
|
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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_ColorB = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, NULL, NULL, &s_ColorB, NULL);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_ColorB;
|
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
|
2016-02-20 23:25:00 +01:00
|
|
|
s_ColorA = 0;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, NULL, NULL, NULL, &s_ColorA);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-02-20 23:25:00 +01:00
|
|
|
return s_ColorA;
|
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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, NULL, &s_ColorG, &s_ColorB, &s_ColorA);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, r, s_ColorG, s_ColorB, s_ColorA);
|
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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, &s_ColorR, NULL, &s_ColorB, &s_ColorA);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, s_ColorR, g, s_ColorB, s_ColorA);
|
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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, &s_ColorB, &s_ColorG, NULL, &s_ColorA);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, s_ColorB, s_ColorG, b, s_ColorA);
|
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();
|
|
|
|
// Retrieve the current values for unchanged components
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetCheckPointColour(m_ID, &s_ColorA, &s_ColorG, &s_ColorB, NULL);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCheckPointColour(m_ID, s_ColorA, s_ColorG, s_ColorB, a);
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-24 22:37:58 +02:00
|
|
|
static Object & 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,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-06-24 22:37:58 +02:00
|
|
|
static Object & 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,
|
|
|
|
Int32 header, Object & 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
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-24 22:37:58 +02:00
|
|
|
static Object & 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,
|
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2016-06-24 22:37:58 +02:00
|
|
|
static Object & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos,
|
2016-02-20 23:25:00 +01:00
|
|
|
const Color4 & color, Float32 radius, Int32 header, Object & 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
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CCheckpoint(HSQUIRRELVM vm)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
RootTable(vm).Bind(_SC("SqCheckpoint"),
|
|
|
|
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, _SC("SqCheckpoint"))
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_cmp"), &CCheckpoint::Cmp)
|
2016-03-10 04:57:13 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &CCheckpoint::Typename)
|
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
|
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-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Bind"), &CCheckpoint::BindEvent)
|
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)
|
|
|
|
.Overload< bool (CCheckpoint::*)(Int32, Object &) >(_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
|
2016-06-24 22:37:58 +02:00
|
|
|
.StaticOverload< Object & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("CreateEx"), &Checkpoint_CreateEx)
|
2016-06-24 22:37:58 +02:00
|
|
|
.StaticOverload< Object & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("CreateEx"), &Checkpoint_CreateEx)
|
2016-06-24 22:37:58 +02:00
|
|
|
.StaticOverload< Object & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32) >
|
2016-03-10 04:57:13 +01:00
|
|
|
(_SC("Create"), &Checkpoint_Create)
|
2016-06-24 22:37:58 +02:00
|
|
|
.StaticOverload< Object & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, Object &) >
|
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)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
} // Namespace:: SqMod
|