Rename source to module.

This commit is contained in:
Sandu Liviu Catalin committed 2020-03-21 23:02:27 +02:00
1 parent a5c87bae5e
commit c0fd374404
237 files changed
-272718

No files matched your search

+353
View File
@@ -0,0 +1,353 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Blip.hpp"
#include "Core.hpp"
#include "Misc/Tasks.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqBlip"))
// ------------------------------------------------------------------------------------------------
const Int32 CBlip::Max = SQMOD_BLIP_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CBlip::SqGetNull(HSQUIRRELVM vm)
{
sq_pushobject(vm, Core::Get().GetNullBlip().GetObject());
return 1;
}
// ------------------------------------------------------------------------------------------------
LightObj & CBlip::GetNull()
{
return Core::Get().GetNullBlip();
}
// ------------------------------------------------------------------------------------------------
CBlip::CBlip(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_BLIP_POOL))
, m_Tag(ToStrF("%d", id))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CBlip::~CBlip()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CBlip::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CBlip::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CBlip::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
}
// ------------------------------------------------------------------------------------------------
CBlip & CBlip::ApplyTag(StackStrF & tag)
{
SetTag(tag);
return *this;
}
// ------------------------------------------------------------------------------------------------
LightObj & CBlip::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CBlip::SetData(LightObj & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CBlip::Destroy(Int32 header, LightObj & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return Core::Get().DelBlip(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
LightObj & CBlip::GetEvents() const
{
// Validate the managed identifier
Validate();
// Return the associated event table
return Core::Get().GetBlip(m_ID).mEvents;
}
// ------------------------------------------------------------------------------------------------
void CBlip::CustomEvent(Int32 header, LightObj & payload) const
{
// Validate the managed identifier
Validate();
// Perfrom the requested action
Core::Get().EmitBlipCustom(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetWorld() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mWorld;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetScale() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mScale;
}
// ------------------------------------------------------------------------------------------------
const Vector3 & CBlip::GetPosition() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mPosition;
}
// ------------------------------------------------------------------------------------------------
const Color4 & CBlip::GetColor() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mColor;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetSprID() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mSprID;
}
// ------------------------------------------------------------------------------------------------
Float32 CBlip::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mPosition.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CBlip::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mPosition.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CBlip::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mPosition.z;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetColorR() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mColor.r;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetColorG() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mColor.g;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetColorB() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mColor.b;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetColorA() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetBlip(m_ID).mColor.a;
}
// ------------------------------------------------------------------------------------------------
static LightObj & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
{
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, LightObj & payload)
{
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 scale, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
{
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, LightObj & payload)
{
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
Int32 sprid)
{
return Core::Get().NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
Int32 sprid, Int32 header, LightObj & payload)
{
return Core::Get().NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32 scale,
const Color4 & color, Int32 sprid)
{
return Core::Get().NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32 scale,
const Color4 & color, Int32 sprid, Int32 header, LightObj & payload)
{
return Core::Get().NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
// ================================================================================================
void Register_CBlip(HSQUIRRELVM vm)
{
RootTable(vm).Bind(Typename::Str,
Class< CBlip, NoConstructor< CBlip > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &CBlip::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CBlip::Max)
// Core Properties
.Prop(_SC("On"), &CBlip::GetEvents)
.Prop(_SC("ID"), &CBlip::GetID)
.Prop(_SC("Tag"), &CBlip::GetTag, &CBlip::SetTag)
.Prop(_SC("Data"), &CBlip::GetData, &CBlip::SetData)
.Prop(_SC("Active"), &CBlip::IsActive)
// Core Methods
.FmtFunc(_SC("SetTag"), &CBlip::ApplyTag)
.Func(_SC("CustomEvent"), &CBlip::CustomEvent)
// Core Overloads
.Overload< bool (CBlip::*)(void) >(_SC("Destroy"), &CBlip::Destroy)
.Overload< bool (CBlip::*)(Int32) >(_SC("Destroy"), &CBlip::Destroy)
.Overload< bool (CBlip::*)(Int32, LightObj &) >(_SC("Destroy"), &CBlip::Destroy)
// Properties
.Prop(_SC("World"), &CBlip::GetWorld)
.Prop(_SC("Scale"), &CBlip::GetScale)
.Prop(_SC("Pos"), &CBlip::GetPosition)
.Prop(_SC("Position"), &CBlip::GetPosition)
.Prop(_SC("Color"), &CBlip::GetColor)
.Prop(_SC("Colour"), &CBlip::GetColor)
.Prop(_SC("SprID"), &CBlip::GetSprID)
.Prop(_SC("PosX"), &CBlip::GetPositionX)
.Prop(_SC("PosY"), &CBlip::GetPositionY)
.Prop(_SC("PosZ"), &CBlip::GetPositionZ)
.Prop(_SC("Red"), &CBlip::GetColorR)
.Prop(_SC("Green"), &CBlip::GetColorG)
.Prop(_SC("Blue"), &CBlip::GetColorB)
.Prop(_SC("Alpha"), &CBlip::GetColorA)
// Static Overloads
.StaticOverload< LightObj & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
(_SC("CreateEx"), &Blip_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32, Int32, LightObj &) >
(_SC("CreateEx"), &Blip_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
(_SC("CreateEx"), &Blip_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32, Int32, LightObj &) >
(_SC("CreateEx"), &Blip_CreateEx)
.StaticOverload< LightObj & (*)(Int32, const Vector3 &, Int32, const Color4 &, Int32) >
(_SC("Create"), &Blip_Create)
.StaticOverload< LightObj & (*)(Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, LightObj &) >
(_SC("Create"), &Blip_Create)
.StaticOverload< LightObj & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32) >
(_SC("Create"), &Blip_Create)
.StaticOverload< LightObj & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, LightObj &) >
(_SC("Create"), &Blip_Create)
// Raw Squirrel Methods
.SquirrelFunc(_SC("NullInst"), &CBlip::SqGetNull)
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CBlip, ENT_BLIP >)
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CBlip, ENT_BLIP >)
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CBlip, ENT_BLIP >)
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CBlip, ENT_BLIP >)
);
}
} // Namespace:: SqMod
+233
View File
@@ -0,0 +1,233 @@
#ifndef _ENTITY_BLIP_HPP_
#define _ENTITY_BLIP_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a single blip entity.
*/
class CBlip
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CBlip(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CBlip(const CBlip &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CBlip(CBlip &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CBlip();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CBlip & operator = (const CBlip &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CBlip & operator = (CBlip &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid blip reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CBlip & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed blip entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed blip entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed blip entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced blip entity exists.
*/
Int32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the scale of the managed blip entity.
*/
Int32 GetScale() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed blip entity.
*/
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the managed blip entity.
*/
const Color4 & GetColor() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the sprite used by the managed blip entity.
*/
Int32 GetSprID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed blip entity.
*/
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed blip entity.
*/
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed blip entity.
*/
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed blip entity.
*/
Int32 GetColorR() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the green color of the managed blip entity.
*/
Int32 GetColorG() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the blue color of the managed blip entity.
*/
Int32 GetColorB() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha transparency of the managed blip entity.
*/
Int32 GetColorA() const;
};
} // Namespace:: SqMod
#endif // _ENTITY_BLIP_HPP_
+577
View File
@@ -0,0 +1,577 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Checkpoint.hpp"
#include "Entity/Player.hpp"
#include "Base/Color4.hpp"
#include "Base/Vector3.hpp"
#include "Core.hpp"
#include "Misc/Tasks.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqCheckpoint"))
// ------------------------------------------------------------------------------------------------
const Int32 CCheckpoint::Max = SQMOD_CHECKPOINT_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CCheckpoint::SqGetNull(HSQUIRRELVM vm)
{
sq_pushobject(vm, Core::Get().GetNullCheckpoint().GetObject());
return 1;
}
// ------------------------------------------------------------------------------------------------
LightObj & CCheckpoint::GetNull()
{
return Core::Get().GetNullCheckpoint();
}
// ------------------------------------------------------------------------------------------------
CCheckpoint::CCheckpoint(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_CHECKPOINT_POOL))
, m_Tag(ToStrF("%d", id)), m_Data(), m_CircularLocks(0)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CCheckpoint::~CCheckpoint()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CCheckpoint::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CCheckpoint::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
}
// ------------------------------------------------------------------------------------------------
CCheckpoint & CCheckpoint::ApplyTag(StackStrF & tag)
{
SetTag(tag);
return *this;
}
// ------------------------------------------------------------------------------------------------
LightObj & CCheckpoint::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetData(LightObj & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::Destroy(Int32 header, LightObj & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return Core::Get().DelCheckpoint(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
LightObj & CCheckpoint::GetEvents() const
{
// Validate the managed identifier
Validate();
// Return the associated event table
return Core::Get().GetCheckpoint(m_ID).mEvents;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::CustomEvent(Int32 header, LightObj & payload) const
{
// Validate the managed identifier
Validate();
// Perfrom the requested action
Core::Get().EmitCheckpointCustom(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
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);
}
// ------------------------------------------------------------------------------------------------
Int32 CCheckpoint::GetWorld() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetCheckPointWorld(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetWorld(Int32 world)
{
// Validate the managed identifier
Validate();
// 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
_Func->SetCheckPointWorld(m_ID, world);
// 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);
}
}
// ------------------------------------------------------------------------------------------------
Color4 CCheckpoint::GetColor() const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the color information
Int32 r, g, b, a;
// Query the server for the color values
_Func->GetCheckPointColour(m_ID, &r, &g, &b, &a);
// Return the requested information
return Color4(ConvTo< Color4::Value >::From(r), ConvTo< Color4::Value >::From(g),
ConvTo< Color4::Value >::From(b), ConvTo< Color4::Value >::From(a));
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColor(const Color4 & col) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_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);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckPointColour(m_ID, r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
Vector3 CCheckpoint::GetPosition() const
{
// Validate the managed identifier
Validate();
// Create a default vector instance
Vector3 vec;
// Query the server for the position values
_Func->GetCheckPointPosition(m_ID, &vec.x, &vec.y, &vec.z);
// Return the requested information
return vec;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPosition(const Vector3 & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckPointPosition(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckPointPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetRadius() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetCheckPointRadius(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetRadius(Float32 radius)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Float32 current = _Func->GetCheckPointRadius(m_ID);
// Avoid property unwind from a recursive call
_Func->SetCheckPointRadius(m_ID, radius);
// 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);
}
}
// ------------------------------------------------------------------------------------------------
LightObj & CCheckpoint::GetOwner() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetPlayer(_Func->GetCheckPointOwner(m_ID)).mObj;
}
// ------------------------------------------------------------------------------------------------
Int32 CCheckpoint::GetOwnerID() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetCheckPointOwner(m_ID);
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetCheckPointPosition(m_ID, &x, &dummy, &dummy);
// Return the requested information
return x;
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetCheckPointPosition(m_ID, &dummy, &y, &dummy);
// Return the requested information
return y;
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetCheckPointPosition(m_ID, &dummy, &dummy, &z);
// Return the requested information
return z;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPositionX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointPosition(m_ID, &dummy, &y, &z);
// Perform the requested operation
_Func->SetCheckPointPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPositionY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointPosition(m_ID, &x, &dummy, &z);
// Perform the requested operation
_Func->SetCheckPointPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPositionZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointPosition(m_ID, &x, &y, &dummy);
// Perform the requested operation
_Func->SetCheckPointPosition(m_ID, z, y, z);
}
// ------------------------------------------------------------------------------------------------
Int32 CCheckpoint::GetColorR() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
Int32 r = 0, dummy;
// Query the server for the requested component value
_Func->GetCheckPointColour(m_ID, &r, &dummy, &dummy, &dummy);
// Return the requested information
return r;
}
// ------------------------------------------------------------------------------------------------
Int32 CCheckpoint::GetColorG() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
Int32 g = 0, dummy;
// Query the server for the requested component value
_Func->GetCheckPointColour(m_ID, &dummy, &g, &dummy, &dummy);
// Return the requested information
return g;
}
// ------------------------------------------------------------------------------------------------
Int32 CCheckpoint::GetColorB() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
Int32 b = 0, dummy;
// Query the server for the requested component value
_Func->GetCheckPointColour(m_ID, &dummy, &dummy, &b, &dummy);
// Return the requested information
return b;
}
// ------------------------------------------------------------------------------------------------
Int32 CCheckpoint::GetColorA() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
Int32 a = 0, dummy;
// Query the server for the requested component value
_Func->GetCheckPointColour(m_ID, &dummy, &dummy, &dummy, &a);
// Return the requested information
return a;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorR(Int32 r) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary integers to retrieve the missing components
Int32 g, b, a, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointColour(m_ID, &dummy, &g, &b, &a);
// Perform the requested operation
_Func->SetCheckPointColour(m_ID, r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorG(Int32 g) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary integers to retrieve the missing components
Int32 r, b, a, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointColour(m_ID, &r, &dummy, &b, &a);
// Perform the requested operation
_Func->SetCheckPointColour(m_ID, r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorB(Int32 b) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary integers to retrieve the missing components
Int32 r, g, a, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointColour(m_ID, &r, &g, &dummy, &a);
// Perform the requested operation
_Func->SetCheckPointColour(m_ID, r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorA(Int32 a) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary integers to retrieve the missing components
Int32 r, g, b, dummy;
// Retrieve the current values for unchanged components
_Func->GetCheckPointColour(m_ID, &r, &g, &b, &dummy);
// Perform the requested operation
_Func->SetCheckPointColour(m_ID, r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Checkpoint_CreateEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius)
{
return Core::Get().NewCheckpoint(-1, world, sphere, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Checkpoint_CreateEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius,
Int32 header, LightObj & payload)
{
return Core::Get().NewCheckpoint(-1, world, sphere, x, y, z, r, g, b, a,
radius, header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos,
const Color4 & color, Float32 radius)
{
return Core::Get().NewCheckpoint(-1, world, sphere, pos.x, pos.y, pos.z,
color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos,
const Color4 & color, Float32 radius, Int32 header, LightObj & payload)
{
return Core::Get().NewCheckpoint(-1, world, sphere, pos.x, pos.y, pos.z,
color.r, color.g, color.b, color.a, radius, header, payload);
}
// ================================================================================================
void Register_CCheckpoint(HSQUIRRELVM vm)
{
RootTable(vm).Bind(Typename::Str,
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &CCheckpoint::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CCheckpoint::Max)
// Core Properties
.Prop(_SC("On"), &CCheckpoint::GetEvents)
.Prop(_SC("ID"), &CCheckpoint::GetID)
.Prop(_SC("Tag"), &CCheckpoint::GetTag, &CCheckpoint::SetTag)
.Prop(_SC("Data"), &CCheckpoint::GetData, &CCheckpoint::SetData)
.Prop(_SC("Active"), &CCheckpoint::IsActive)
// Core Methods
.FmtFunc(_SC("SetTag"), &CCheckpoint::ApplyTag)
.Func(_SC("CustomEvent"), &CCheckpoint::CustomEvent)
// Core Overloads
.Overload< bool (CCheckpoint::*)(void) >(_SC("Destroy"), &CCheckpoint::Destroy)
.Overload< bool (CCheckpoint::*)(Int32) >(_SC("Destroy"), &CCheckpoint::Destroy)
.Overload< bool (CCheckpoint::*)(Int32, LightObj &) >(_SC("Destroy"), &CCheckpoint::Destroy)
// Properties
.Prop(_SC("Sphere"), &CCheckpoint::IsSphere)
.Prop(_SC("World"), &CCheckpoint::GetWorld, &CCheckpoint::SetWorld)
.Prop(_SC("Color"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
.Prop(_SC("Colour"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
.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)
.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)
// Member Methods
.Func(_SC("StreamedFor"), &CCheckpoint::IsStreamedFor)
.Func(_SC("SetPos"), &CCheckpoint::SetPositionEx)
.Func(_SC("SetPosition"), &CCheckpoint::SetPositionEx)
// 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)
// Static Overloads
.StaticOverload< LightObj & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateEx"), &Checkpoint_CreateEx)
.StaticOverload< LightObj & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, LightObj &) >
(_SC("CreateEx"), &Checkpoint_CreateEx)
.StaticOverload< LightObj & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32) >
(_SC("Create"), &Checkpoint_Create)
.StaticOverload< LightObj & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, LightObj &) >
(_SC("Create"), &Checkpoint_Create)
// Raw Squirrel Methods
.SquirrelFunc(_SC("NullInst"), &CCheckpoint::SqGetNull)
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CCheckpoint, ENT_CHECKPOINT >)
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CCheckpoint, ENT_CHECKPOINT >)
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CCheckpoint, ENT_CHECKPOINT >)
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CCheckpoint, ENT_CHECKPOINT >)
);
}
} // Namespace:: SqMod
+332
View File
@@ -0,0 +1,332 @@
#ifndef _ENTITY_CHECKPOINT_HPP_
#define _ENTITY_CHECKPOINT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Circular locks employed by the checkpoint manager.
*/
enum CheckpointCircularLocks
{
CHECKPOINTCL_EMIT_CHECKPOINT_WORLD = (1 << 0),
CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS = (1 << 1)
};
/* ------------------------------------------------------------------------------------------------
* Manages a single checkpoint entity.
*/
class CCheckpoint
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Prevent events from triggering themselves.
*/
Uint32 m_CircularLocks;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CCheckpoint(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CCheckpoint(const CCheckpoint &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CCheckpoint(CCheckpoint &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CCheckpoint();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CCheckpoint & operator = (const CCheckpoint &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CCheckpoint & operator = (CCheckpoint &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid checkpoint reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CCheckpoint & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed checkpoint entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed checkpoint entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed checkpoint entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* See if the managed checkpoint entity is streamed for the specified player.
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* See if the managed checkpoint entity of sphere type.
*/
bool IsSphere() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed checkpoint entity exists.
*/
Int32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Modify the world in which the managed checkpoint entity exists.
*/
void SetWorld(Int32 world);
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the managed checkpoint entity.
*/
Color4 GetColor() const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed checkpoint entity.
*/
void SetColor(const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed checkpoint entity.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed checkpoint entity.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed checkpoint entity.
*/
Vector3 GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed checkpoint entity.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed checkpoint entity.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radius of the managed checkpoint entity.
*/
Float32 GetRadius() const;
/* --------------------------------------------------------------------------------------------
* Modify the radius of the managed checkpoint entity.
*/
void SetRadius(Float32 radius);
/* --------------------------------------------------------------------------------------------
* Retrieve the owner of the managed checkpoint entity.
*/
LightObj & GetOwner() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner identifier of the managed checkpoint entity.
*/
Int32 GetOwnerID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed checkpoint entity.
*/
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed checkpoint entity.
*/
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed checkpoint entity.
*/
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed checkpoint entity.
*/
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed checkpoint entity.
*/
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed checkpoint entity.
*/
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed checkpoint entity.
*/
Int32 GetColorR() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the green color of the managed checkpoint entity.
*/
Int32 GetColorG() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the blue color of the managed checkpoint entity.
*/
Int32 GetColorB() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha transparency of the managed checkpoint entity.
*/
Int32 GetColorA() const;
/* --------------------------------------------------------------------------------------------
* Modify the red color of the managed checkpoint entity.
*/
void SetColorR(Int32 r) const;
/* --------------------------------------------------------------------------------------------
* Modify the green color of the managed checkpoint entity.
*/
void SetColorG(Int32 g) const;
/* --------------------------------------------------------------------------------------------
* Modify the blue color of the managed checkpoint entity.
*/
void SetColorB(Int32 b) const;
/* --------------------------------------------------------------------------------------------
* Modify the alpha transparency of the managed checkpoint entity.
*/
void SetColorA(Int32 a) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_CHECKPOINT_HPP_
+236
View File
@@ -0,0 +1,236 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Keybind.hpp"
#include "Core.hpp"
#include "Misc/Tasks.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqKeybind"))
// ------------------------------------------------------------------------------------------------
const Int32 CKeybind::Max = SQMOD_KEYBIND_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CKeybind::SqGetNull(HSQUIRRELVM vm)
{
sq_pushobject(vm, Core::Get().GetNullKeybind().GetObject());
return 1;
}
// ------------------------------------------------------------------------------------------------
LightObj & CKeybind::GetNull()
{
return Core::Get().GetNullKeybind();
}
// ------------------------------------------------------------------------------------------------
CKeybind::CKeybind(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_KEYBIND_POOL))
, m_Tag(ToStrF("%d", id))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CKeybind::~CKeybind()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CKeybind::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CKeybind::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CKeybind::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
}
// ------------------------------------------------------------------------------------------------
CKeybind & CKeybind::ApplyTag(StackStrF & tag)
{
SetTag(tag);
return *this;
}
// ------------------------------------------------------------------------------------------------
LightObj & CKeybind::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CKeybind::SetData(LightObj & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CKeybind::Destroy(Int32 header, LightObj & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return Core::Get().DelKeybind(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
LightObj & CKeybind::GetEvents() const
{
// Validate the managed identifier
Validate();
// Return the associated event table
return Core::Get().GetKeybind(m_ID).mEvents;
}
// ------------------------------------------------------------------------------------------------
void CKeybind::CustomEvent(Int32 header, LightObj & payload) const
{
// Validate the managed identifier
Validate();
// Perfrom the requested action
Core::Get().EmitKeybindCustom(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
Int32 CKeybind::GetFirst() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetKeybind(m_ID).mFirst;
}
// ------------------------------------------------------------------------------------------------
Int32 CKeybind::GetSecond() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetKeybind(m_ID).mSecond;
}
// ------------------------------------------------------------------------------------------------
Int32 CKeybind::GetThird() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetKeybind(m_ID).mThird;
}
// ------------------------------------------------------------------------------------------------
bool CKeybind::IsRelease() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetKeybind(m_ID).mRelease;
}
// ------------------------------------------------------------------------------------------------
static LightObj & Keybind_CreateEx(Int32 slot, bool release, Int32 primary, Int32 secondary,
Int32 alternative)
{
return Core::Get().NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Keybind_CreateEx(Int32 slot, bool release, Int32 primary, Int32 secondary,
Int32 alternative, Int32 header, LightObj & payload)
{
return Core::Get().NewKeybind(slot, release, primary, secondary, alternative, header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Keybind_Create(bool release, Int32 primary, Int32 secondary, Int32 alternative)
{
return Core::Get().NewKeybind(-1, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Keybind_Create(bool release, Int32 primary, Int32 secondary, Int32 alternative,
Int32 header, LightObj & payload)
{
return Core::Get().NewKeybind(-1, release, primary, secondary, alternative, header, payload);
}
// ------------------------------------------------------------------------------------------------
static SQInteger Keybind_UnusedSlot()
{
return _Func->GetKeyBindUnusedSlot();
}
// ================================================================================================
void Register_CKeybind(HSQUIRRELVM vm)
{
RootTable(vm).Bind(Typename::Str,
Class< CKeybind, NoConstructor< CKeybind > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &CKeybind::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CKeybind::Max)
// Core Properties
.Prop(_SC("On"), &CKeybind::GetEvents)
.Prop(_SC("ID"), &CKeybind::GetID)
.Prop(_SC("Tag"), &CKeybind::GetTag, &CKeybind::SetTag)
.Prop(_SC("Data"), &CKeybind::GetData, &CKeybind::SetData)
.Prop(_SC("Active"), &CKeybind::IsActive)
// Core Methods
.FmtFunc(_SC("SetTag"), &CKeybind::ApplyTag)
.Func(_SC("CustomEvent"), &CKeybind::CustomEvent)
// Core Overloads
.Overload< bool (CKeybind::*)(void) >(_SC("Destroy"), &CKeybind::Destroy)
.Overload< bool (CKeybind::*)(Int32) >(_SC("Destroy"), &CKeybind::Destroy)
.Overload< bool (CKeybind::*)(Int32, LightObj &) >(_SC("Destroy"), &CKeybind::Destroy)
// Properties
.Prop(_SC("First"), &CKeybind::GetFirst)
.Prop(_SC("Second"), &CKeybind::GetSecond)
.Prop(_SC("Third"), &CKeybind::GetThird)
.Prop(_SC("Release"), &CKeybind::IsRelease)
// Static Functions
.StaticFunc(_SC("UnusedSlot"), &Keybind_UnusedSlot)
// Static Overloads
.StaticOverload< LightObj & (*)(Int32, bool, Int32, Int32, Int32) >
(_SC("CreateEx"), &Keybind_CreateEx)
.StaticOverload< LightObj & (*)(Int32, bool, Int32, Int32, Int32, Int32, LightObj &) >
(_SC("CreateEx"), &Keybind_CreateEx)
.StaticOverload< LightObj & (*)(bool, Int32, Int32, Int32) >
(_SC("Create"), &Keybind_Create)
.StaticOverload< LightObj & (*)(bool, Int32, Int32, Int32, Int32, LightObj &) >
(_SC("Create"), &Keybind_Create)
// Raw Squirrel Methods
.SquirrelFunc(_SC("NullInst"), &CKeybind::SqGetNull)
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CKeybind, ENT_KEYBIND >)
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CKeybind, ENT_KEYBIND >)
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CKeybind, ENT_KEYBIND >)
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CKeybind, ENT_KEYBIND >)
);
}
} // Namespace:: SqMod
+193
View File
@@ -0,0 +1,193 @@
#ifndef _ENTITY_KEYBIND_HPP_
#define _ENTITY_KEYBIND_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a single keybind entity.
*/
class CKeybind
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CKeybind(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CKeybind(const CKeybind &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CKeybind(CKeybind &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CKeybind();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CKeybind & operator = (const CKeybind &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CKeybind & operator = (CKeybind &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity instance otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid keybind reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CKeybind & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed destroy entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed destroy entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed destroy entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the first key code of the managed keybind entity.
*/
Int32 GetFirst() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the second key code of the managed keybind entity.
*/
Int32 GetSecond() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the third key code of the managed keybind entity.
*/
Int32 GetThird() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed keybind entity reacts to key release events.
*/
bool IsRelease() const;
};
} // Namespace:: SqMod
#endif // _ENTITY_KEYBIND_HPP_
+989
View File
@@ -0,0 +1,989 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Object.hpp"
#include "Entity/Player.hpp"
#include "Base/Quaternion.hpp"
#include "Base/Vector3.hpp"
#include "Core.hpp"
#include "Misc/Tasks.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqObject"))
// ------------------------------------------------------------------------------------------------
const Int32 CObject::Max = SQMOD_OBJECT_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CObject::SqGetNull(HSQUIRRELVM vm)
{
sq_pushobject(vm, Core::Get().GetNullObject().GetObject());
return 1;
}
// ------------------------------------------------------------------------------------------------
LightObj & CObject::GetNull()
{
return Core::Get().GetNullObject();
}
// ------------------------------------------------------------------------------------------------
CObject::CObject(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_OBJECT_POOL))
, m_Tag(ToStrF("%d", id)), m_Data(), m_CircularLocks(0)
, mMoveToDuration(0)
, mMoveByDuration(0)
, mRotateToDuration(0)
, mRotateByDuration(0)
, mRotateToEulerDuration(0)
, mRotateByEulerDuration(0)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CObject::~CObject()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CObject::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CObject::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CObject::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
}
// ------------------------------------------------------------------------------------------------
CObject & CObject::ApplyTag(StackStrF & tag)
{
SetTag(tag);
return *this;
}
// ------------------------------------------------------------------------------------------------
LightObj & CObject::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CObject::SetData(LightObj & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CObject::Destroy(Int32 header, LightObj & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return Core::Get().DelObject(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
LightObj & CObject::GetEvents() const
{
// Validate the managed identifier
Validate();
// Return the associated event table
return Core::Get().GetObject(m_ID).mEvents;
}
// ------------------------------------------------------------------------------------------------
void CObject::CustomEvent(Int32 header, LightObj & payload) const
{
// Validate the managed identifier
Validate();
// Perfrom the requested action
Core::Get().EmitObjectCustom(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CObject::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsObjectStreamedForPlayer(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
Int32 CObject::GetModel() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetObjectModel(m_ID);
}
// ------------------------------------------------------------------------------------------------
Int32 CObject::GetWorld() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetObjectWorld(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetWorld(Int32 world)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Int32 current = _Func->GetObjectWorld(m_ID);
// Don't even bother if it's the same value
if (current == world)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetObjectWorld(m_ID, world);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_WORLD))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_WORLD);
// Now forward the event call
Core::Get().EmitObjectWorld(m_ID, current, world);
}
}
// ------------------------------------------------------------------------------------------------
Int32 CObject::GetAlpha() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetObjectAlpha(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetAlpha(Int32 alpha)
{
SetAlphaEx(alpha, 0);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetAlphaEx(Int32 alpha, Uint32 time)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Int32 current = _Func->GetObjectAlpha(m_ID);
// Don't even bother if it's the same value
if (current == alpha)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetObjectAlpha(m_ID, alpha, time);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_ALPHA))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_ALPHA);
// Now forward the event call
Core::Get().EmitObjectAlpha(m_ID, current, alpha, time);
}
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveTo(const Vector3 & pos, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectTo(m_ID, pos.x, pos.y, pos.z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectTo(m_ID, x, y, z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveBy(const Vector3 & pos, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, pos.x, pos.y, pos.z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, x, y, z, time);
}
// ------------------------------------------------------------------------------------------------
Vector3 CObject::GetPosition()
{
// Validate the managed identifier
Validate();
// Create a default vector instance
Vector3 vec;
// Query the server for the values
_Func->GetObjectPosition(m_ID, &vec.x, &vec.y, &vec.z);
// Return the requested information
return vec;
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPosition(const Vector3 & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectPosition(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateTo(const Quaternion & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectTo(m_ID, rot.x, rot.y, rot.z, rot.w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectTo(m_ID, x, y, z, w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEuler(const Vector3 & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, rot.x, rot.y, rot.z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, x, y, z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateBy(const Quaternion & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, rot.x, rot.y, rot.z, rot.w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, x, y, z, w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEuler(const Vector3 & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, rot.x, rot.y, rot.z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, x, y, z, time);
}
// ------------------------------------------------------------------------------------------------
Quaternion CObject::GetRotation()
{
// Validate the managed identifier
Validate();
// Create a default quaternion instance
Quaternion quat;
// Query the server for the values
_Func->GetObjectRotation(m_ID, &quat.x, &quat.y, &quat.z, &quat.w);
// Return the requested information
return quat;
}
// ------------------------------------------------------------------------------------------------
Vector3 CObject::GetRotationEuler()
{
// Validate the managed identifier
Validate();
// Create a default vector instance
Vector3 vec;
// Query the server for the values
_Func->GetObjectRotationEuler(m_ID, &vec.x, &vec.y, &vec.z);
// Return the requested information
return vec;
}
// ------------------------------------------------------------------------------------------------
bool CObject::GetShotReport() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsObjectShotReportEnabled(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetShotReport(bool toggle)
{
// Validate the managed identifier
Validate();
// 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);
}
}
// ------------------------------------------------------------------------------------------------
bool CObject::GetTouchedReport() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsObjectTouchedReportEnabled(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetTouchedReport(bool toggle)
{
// Validate the managed identifier
Validate();
// 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);
}
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectPosition(m_ID, &x, &dummy, &dummy);
// Return the requested information
return x;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectPosition(m_ID, &dummy, &y, &dummy);
// Return the requested information
return y;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectPosition(m_ID, &dummy, &dummy, &z);
// Return the requested information
return z;
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPositionX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &dummy, &y, &z);
// Perform the requested operation
_Func->SetObjectPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPositionY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &x, &dummy, &z);
// Perform the requested operation
_Func->SetObjectPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPositionZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &x, &y, &dummy);
// Perform the requested operation
_Func->SetObjectPosition(m_ID, z, y, z);
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotationX() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotation(m_ID, &x, &dummy, &dummy, &dummy);
// Return the requested information
return x;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotationY() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotation(m_ID, &dummy, &y, &dummy, &dummy);
// Return the requested information
return y;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotationZ() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotation(m_ID, &dummy, &dummy, &z, &dummy);
// Return the requested information
return z;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotationW() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 w = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotation(m_ID, &dummy, &dummy, &dummy, &w);
// Return the requested information
return w;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetEulerRotationX() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotationEuler(m_ID, &x, &dummy, &dummy);
// Return the requested information
return x;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetEulerRotationY() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotationEuler(m_ID, &dummy, &y, &dummy);
// Return the requested information
return y;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetEulerRotationZ() const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetObjectRotationEuler(m_ID, &dummy, &dummy, &z);
// Return the requested information
return z;
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &dummy, &y, &z);
// Perform the requested operation
_Func->MoveObjectTo(m_ID, x, y, z, mMoveToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &x, &dummy, &z);
// Perform the requested operation
_Func->MoveObjectTo(m_ID, x, y, z, mMoveToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &x, &y, &dummy);
// Perform the requested operation
_Func->MoveObjectTo(m_ID, z, y, z, mMoveToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, x, 0.0f, 0.0f, mMoveByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, 0.0f, y, 0.0f, mMoveByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, 0.0f, 0.0f, z, mMoveByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, w, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &dummy, &y, &z, &w);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, x, y, z, w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, w, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &x, &dummy, &z, &w);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, x, y, z, w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, w, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &x, &y, &dummy, &w);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, x, y, z, w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToW(Float32 w) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &x, &y, &z, &dummy);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, x, y, z, w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, x, 0.0f, 0.0f, 0.0f, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, 0.0f, y, 0.0f, 0.0f, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, 0.0f, 0.0f, z, 0.0f, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByW(Float32 w) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, 0.0f, 0.0f, 0.0f, w, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotationEuler(m_ID, &dummy, &y, &z);
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, x, y, z, mRotateToEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotationEuler(m_ID, &x, &dummy, &z);
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, x, y, z, mRotateToEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetObjectRotationEuler(m_ID, &x, &y, &dummy);
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, z, y, z, mRotateToEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, x, 0.0f, 0.0f, mRotateByEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, 0.0f, y, 0.0f, mRotateByEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, 0.0f, 0.0f, z, mRotateByEulerDuration);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Object_CreateEx(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 alpha)
{
return Core::Get().NewObject(model, world, x, y, z, alpha, SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Object_CreateEx(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 alpha, Int32 header, LightObj & payload)
{
return Core::Get().NewObject(model, world, x, y, z, alpha, header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Object_Create(Int32 model, Int32 world, const Vector3 & pos, Int32 alpha)
{
return Core::Get().NewObject(model, world, pos.x, pos.y, pos.z, alpha,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Object_Create(Int32 model, Int32 world, const Vector3 & pos, Int32 alpha,
Int32 header, LightObj & payload)
{
return Core::Get().NewObject(model, world, pos.x, pos.y, pos.z, alpha, header, payload);
}
// ================================================================================================
void Register_CObject(HSQUIRRELVM vm)
{
RootTable(vm).Bind(Typename::Str,
Class< CObject, NoConstructor< CObject > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &CObject::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CObject::Max)
// Member Variables
.Var(_SC("MoveToDuration"), &CObject::mMoveToDuration)
.Var(_SC("MoveByDuration"), &CObject::mMoveByDuration)
.Var(_SC("RotateToDuration"), &CObject::mRotateToDuration)
.Var(_SC("RotateByDuration"), &CObject::mRotateByDuration)
.Var(_SC("RotateToEulerDuration"), &CObject::mRotateToEulerDuration)
.Var(_SC("RotateByEulerDuration"), &CObject::mRotateByEulerDuration)
// Core Properties
.Prop(_SC("On"), &CObject::GetEvents)
.Prop(_SC("ID"), &CObject::GetID)
.Prop(_SC("Tag"), &CObject::GetTag, &CObject::SetTag)
.Prop(_SC("Data"), &CObject::GetData, &CObject::SetData)
.Prop(_SC("Active"), &CObject::IsActive)
// Core Methods
.FmtFunc(_SC("SetTag"), &CObject::ApplyTag)
.Func(_SC("CustomEvent"), &CObject::CustomEvent)
// Core Overloads
.Overload< bool (CObject::*)(void) >(_SC("Destroy"), &CObject::Destroy)
.Overload< bool (CObject::*)(Int32) >(_SC("Destroy"), &CObject::Destroy)
.Overload< bool (CObject::*)(Int32, LightObj &) >(_SC("Destroy"), &CObject::Destroy)
// Properties
.Prop(_SC("Model"), &CObject::GetModel)
.Prop(_SC("World"), &CObject::GetWorld, &CObject::SetWorld)
.Prop(_SC("Alpha"), &CObject::GetAlpha, &CObject::SetAlpha)
.Prop(_SC("Pos"), &CObject::GetPosition, &CObject::SetPosition)
.Prop(_SC("Position"), &CObject::GetPosition, &CObject::SetPosition)
.Prop(_SC("Rot"), &CObject::GetRotation)
.Prop(_SC("Rotation"), &CObject::GetRotation)
.Prop(_SC("EulerRot"), &CObject::GetRotationEuler)
.Prop(_SC("EulerRotation"), &CObject::GetRotationEuler)
.Prop(_SC("ShotReport"), &CObject::GetShotReport, &CObject::SetShotReport)
.Prop(_SC("BumpReport"), &CObject::GetTouchedReport, &CObject::SetTouchedReport)
.Prop(_SC("TouchedReport"), &CObject::GetTouchedReport, &CObject::SetTouchedReport)
.Prop(_SC("PosX"), &CObject::GetPositionX, &CObject::SetPositionX)
.Prop(_SC("PosY"), &CObject::GetPositionY, &CObject::SetPositionY)
.Prop(_SC("PosZ"), &CObject::GetPositionZ, &CObject::SetPositionZ)
.Prop(_SC("RotX"), &CObject::GetRotationX)
.Prop(_SC("RotY"), &CObject::GetRotationY)
.Prop(_SC("RotZ"), &CObject::GetRotationZ)
.Prop(_SC("RotW"), &CObject::GetRotationW)
.Prop(_SC("EulerRotX"), &CObject::GetEulerRotationX)
.Prop(_SC("EulerRotY"), &CObject::GetEulerRotationY)
.Prop(_SC("EulerRotZ"), &CObject::GetEulerRotationZ)
.Prop(_SC("MoveToX"), &CObject::GetPositionX, &CObject::MoveToX)
.Prop(_SC("MoveToY"), &CObject::GetPositionY, &CObject::MoveToY)
.Prop(_SC("MoveToZ"), &CObject::GetPositionZ, &CObject::MoveToZ)
.Prop(_SC("MoveByX"), &CObject::GetPositionX, &CObject::MoveByX)
.Prop(_SC("MoveByY"), &CObject::GetPositionY, &CObject::MoveByY)
.Prop(_SC("MoveByZ"), &CObject::GetPositionZ, &CObject::MoveByZ)
.Prop(_SC("RotateToX"), &CObject::GetRotationX, &CObject::RotateToX)
.Prop(_SC("RotateToY"), &CObject::GetRotationY, &CObject::RotateToY)
.Prop(_SC("RotateToZ"), &CObject::GetRotationZ, &CObject::RotateToZ)
.Prop(_SC("RotateToW"), &CObject::GetRotationW, &CObject::RotateToW)
.Prop(_SC("RotateByX"), &CObject::GetRotationX, &CObject::RotateByX)
.Prop(_SC("RotateByY"), &CObject::GetRotationY, &CObject::RotateByY)
.Prop(_SC("RotateByZ"), &CObject::GetRotationZ, &CObject::RotateByZ)
.Prop(_SC("RotateByW"), &CObject::GetRotationW, &CObject::RotateByW)
.Prop(_SC("RotateToEulerX"), &CObject::GetEulerRotationX, &CObject::RotateToEulerX)
.Prop(_SC("RotateToEulerY"), &CObject::GetEulerRotationY, &CObject::RotateToEulerY)
.Prop(_SC("RotateToEulerZ"), &CObject::GetEulerRotationZ, &CObject::RotateToEulerZ)
.Prop(_SC("RotateByEulerX"), &CObject::GetEulerRotationX, &CObject::RotateByEulerX)
.Prop(_SC("RotateByEulerY"), &CObject::GetEulerRotationY, &CObject::RotateByEulerY)
.Prop(_SC("RotateByEulerZ"), &CObject::GetEulerRotationZ, &CObject::RotateByEulerZ)
// Member Methods
.Func(_SC("StreamedFor"), &CObject::IsStreamedFor)
.Func(_SC("SetAlpha"), &CObject::SetAlphaEx)
.Func(_SC("SetPosition"), &CObject::SetPositionEx)
// Member Overloads
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("MoveTo"), &CObject::MoveTo)
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("MoveTo"), &CObject::MoveToEx)
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("MoveBy"), &CObject::MoveBy)
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("MoveBy"), &CObject::MoveByEx)
.Overload< void (CObject::*)(const Quaternion &, Uint32) const >
(_SC("RotateTo"), &CObject::RotateTo)
.Overload< void (CObject::*)(Float32, Float32, Float32, Float32, Uint32) const >
(_SC("RotateTo"), &CObject::RotateToEx)
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("RotateToEuler"), &CObject::RotateToEuler)
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("RotateToEuler"), &CObject::RotateToEulerEx)
.Overload< void (CObject::*)(const Quaternion &, Uint32) const >
(_SC("RotateBy"), &CObject::RotateBy)
.Overload< void (CObject::*)(Float32, Float32, Float32, Float32, Uint32) const >
(_SC("RotateBy"), &CObject::RotateByEx)
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("RotateByEuler"), &CObject::RotateByEuler)
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("RotateByEuler"), &CObject::RotateByEulerEx)
// Static Overloads
.StaticOverload< LightObj & (*)(Int32, Int32, Float32, Float32, Float32, Int32) >
(_SC("CreateEx"), &Object_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Int32, LightObj &) >
(_SC("CreateEx"), &Object_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Int32, const Vector3 &, Int32) >
(_SC("Create"), &Object_Create)
.StaticOverload< LightObj & (*)(Int32, Int32, const Vector3 &, Int32, Int32, LightObj &) >
(_SC("Create"), &Object_Create)
// Raw Squirrel Methods
.SquirrelFunc(_SC("NullInst"), &CObject::SqGetNull)
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CObject, ENT_OBJECT >)
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CObject, ENT_OBJECT >)
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CObject, ENT_OBJECT >)
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CObject, ENT_OBJECT >)
);
}
} // Namespace:: SqMod
+511
View File
@@ -0,0 +1,511 @@
#ifndef _ENTITY_OBJECT_HPP_
#define _ENTITY_OBJECT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Circular locks employed by the object manager.
*/
enum ObjectCircularLocks
{
OBJECTCL_EMIT_OBJECT_WORLD = (1 << 0),
OBJECTCL_EMIT_OBJECT_ALPHA = (2 << 0),
OBJECTCL_EMIT_OBJECT_REPORT = (3 << 0)
};
/* ------------------------------------------------------------------------------------------------
* Manages a single object entity.
*/
class CObject
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Prevent events from triggering themselves.
*/
Uint32 m_CircularLocks;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CObject(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* The default duration to use when moving the object.
*/
Uint32 mMoveToDuration;
Uint32 mMoveByDuration;
/* --------------------------------------------------------------------------------------------
* The default duration to use when rotating the object to Quaternion.
*/
Uint32 mRotateToDuration;
Uint32 mRotateByDuration;
/* --------------------------------------------------------------------------------------------
* The default duration to use when rotating the object to Euler.
*/
Uint32 mRotateToEulerDuration;
Uint32 mRotateByEulerDuration;
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CObject(const CObject &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CObject(CObject &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CObject();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CObject & operator = (const CObject &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CObject & operator = (CObject &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity instance otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid object reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CObject & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed object entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed object entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed object entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* See if the managed object entity is streamed for the specified player.
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the model of the managed object entity.
*/
Int32 GetModel() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed object entity exists.
*/
Int32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Modify the world in which the managed object entity exists.
*/
void SetWorld(Int32 world);
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha of the managed object entity.
*/
Int32 GetAlpha() const;
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed object entity.
*/
void SetAlpha(Int32 alpha);
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed object entity over the specified time.
*/
void SetAlphaEx(Int32 alpha, Uint32 time);
/* --------------------------------------------------------------------------------------------
* Move the managed object entity to the specified position over the specified time.
*/
void MoveTo(const Vector3 & pos, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity to the specified position over the specified time.
*/
void MoveToEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity by the specified position over the specified time.
*/
void MoveBy(const Vector3 & pos, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity by the specified position over the specified time.
*/
void MoveByEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed object entity.
*/
Vector3 GetPosition();
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed object entity.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed object entity.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified rotation over the specified time.
*/
void RotateTo(const Quaternion & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified rotation over the specified time.
*/
void RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified Euler rotation over the specified time.
*/
void RotateToEuler(const Vector3 & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified Euler rotation over the specified time.
*/
void RotateToEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified rotation over the specified time.
*/
void RotateBy(const Quaternion & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified rotation over the specified time.
*/
void RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified Euler rotation over the specified time.
*/
void RotateByEuler(const Vector3 & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified Euler rotation over the specified time.
*/
void RotateByEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation of the managed object entity.
*/
Quaternion GetRotation();
/* --------------------------------------------------------------------------------------------
* Retrieve the Euler rotation of the managed object entity.
*/
Vector3 GetRotationEuler();
/* --------------------------------------------------------------------------------------------
* See whether the managed object entity reports gunshots.
*/
bool GetShotReport() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed object entity reports gunshots.
*/
void SetShotReport(bool toggle);
/* --------------------------------------------------------------------------------------------
* See whether the managed object entity reports player bumps.
*/
bool GetTouchedReport() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed object entity reports player bumps.
*/
void SetTouchedReport(bool toggle);
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed object entity.
*/
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed object entity.
*/
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed object entity.
*/
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed object entity.
*/
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed object entity.
*/
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed object entity.
*/
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the x axis of the managed object entity.
*/
Float32 GetRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the y axis of the managed object entity.
*/
Float32 GetRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the z axis of the managed object entity.
*/
Float32 GetRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation amount of the managed object entity.
*/
Float32 GetRotationW() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the Euler rotation on the x axis of the managed object entity.
*/
Float32 GetEulerRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the Euler rotation on the y axis of the managed object entity.
*/
Float32 GetEulerRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the Euler rotation on the z axis of the managed object entity.
*/
Float32 GetEulerRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed object entity.
*/
void MoveToX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed object entity.
*/
void MoveToY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed object entity.
*/
void MoveToZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed object entity.
*/
void MoveByX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed object entity.
*/
void MoveByY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed object entity.
*/
void MoveByZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateToX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateToY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateToZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the w axis of the managed object entity.
*/
void RotateToW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateByX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateByY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateByZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the w axis of the managed object entity.
*/
void RotateByW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateToEulerX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateToEulerY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateToEulerZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateByEulerX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateByEulerY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateByEulerZ(Float32 z) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_OBJECT_HPP_
+550
View File
@@ -0,0 +1,550 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Pickup.hpp"
#include "Entity/Player.hpp"
#include "Base/Vector3.hpp"
#include "Core.hpp"
#include "Misc/Tasks.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqPickup"))
// ------------------------------------------------------------------------------------------------
const Int32 CPickup::Max = SQMOD_PICKUP_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CPickup::SqGetNull(HSQUIRRELVM vm)
{
sq_pushobject(vm, Core::Get().GetNullPickup().GetObject());
return 1;
}
// ------------------------------------------------------------------------------------------------
LightObj & CPickup::GetNull()
{
return Core::Get().GetNullPickup();
}
// ------------------------------------------------------------------------------------------------
CPickup::CPickup(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PICKUP_POOL))
, m_Tag(ToStrF("%d", id)), m_Data(), m_CircularLocks(0)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CPickup::~CPickup()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CPickup::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CPickup::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
}
// ------------------------------------------------------------------------------------------------
CPickup & CPickup::ApplyTag(StackStrF & tag)
{
SetTag(tag);
return *this;
}
// ------------------------------------------------------------------------------------------------
LightObj & CPickup::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetData(LightObj & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CPickup::Destroy(Int32 header, LightObj & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return Core::Get().DelPickup(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
LightObj & CPickup::GetEvents() const
{
// Validate the managed identifier
Validate();
// Return the associated event table
return Core::Get().GetPickup(m_ID).mEvents;
}
// ------------------------------------------------------------------------------------------------
void CPickup::CustomEvent(Int32 header, LightObj & payload) const
{
// Validate the managed identifier
Validate();
// Perfrom the requested action
Core::Get().EmitPickupCustom(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CPickup::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsPickupStreamedForPlayer(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
bool CPickup::GetOption(Int32 option_id) const
{
// Attempt to obtain the current value of the specified option
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
// Check for errors
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
// Return the requested value
return value;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetOption(Int32 option_id, bool toggle)
{
// Attempt to obtain the current value of the specified option
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
// Attempt to modify the current value of the specified option
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
// Now forward the event call
Core::Get().EmitPickupOption(m_ID, option_id, value, 0, NullLightObj());
}
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj & payload)
{
// Attempt to obtain the current value of the specified option
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
// Attempt to modify the current value of the specified option
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
// Now forward the event call
Core::Get().EmitPickupOption(m_ID, option_id, value, header, payload);
}
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetWorld() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPickupWorld(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetWorld(Int32 world)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Int32 current = _Func->GetPickupWorld(m_ID);
// Don't even bother if it's the same value
if (current == world)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupWorld(m_ID, world);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_WORLD))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_WORLD);
// Now forward the event call
Core::Get().EmitPickupWorld(m_ID, current, world);
}
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetAlpha() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPickupAlpha(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAlpha(Int32 alpha)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Int32 current = _Func->GetPickupAlpha(m_ID);
// Don't even bother if it's the same value
if (current == alpha)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupAlpha(m_ID, alpha);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_ALPHA))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_ALPHA);
// Now forward the event call
Core::Get().EmitPickupAlpha(m_ID, current, alpha);
}
}
// ------------------------------------------------------------------------------------------------
bool CPickup::GetAutomatic() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsPickupAutomatic(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAutomatic(bool toggle)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const bool current = _Func->IsPickupAutomatic(m_ID);
// Don't even bother if it's the same value
if (current == toggle)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupIsAutomatic(m_ID, toggle);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOMATIC))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOMATIC);
// Now forward the event call
Core::Get().EmitPickupAutomatic(m_ID, current, toggle);
}
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetAutoTimer() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPickupAutoTimer(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAutoTimer(Int32 timer)
{
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Int32 current = _Func->GetPickupAutoTimer(m_ID);
// Don't even bother if it's the same value
if (current == timer)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupAutoTimer(m_ID, timer);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOTIMER))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOTIMER);
// Now forward the event call
Core::Get().EmitPickupAutoTimer(m_ID, current, timer);
}
}
// ------------------------------------------------------------------------------------------------
void CPickup::Refresh() const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RefreshPickup(m_ID);
}
// ------------------------------------------------------------------------------------------------
Vector3 CPickup::GetPosition()
{
// Validate the managed identifier
Validate();
// Create a default vector instance
Vector3 vec;
// Query the server for the position values
_Func->GetPickupPosition(m_ID, &vec.x, &vec.y, &vec.z);
// Return the requested information
return vec;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPosition(const Vector3 & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetPickupPosition(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetPickupPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetModel() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPickupModel(m_ID);
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetQuantity() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPickupQuantity(m_ID);
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetPickupPosition(m_ID, &x, &dummy, &dummy);
// Return the requested information
return x;
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetPickupPosition(m_ID, &dummy, &y, &dummy);
// Return the requested information
return y;
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetPickupPosition(m_ID, &dummy, &dummy, &z);
// Return the requested information
return z;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPositionX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetPickupPosition(m_ID, &dummy, &y, &z);
// Perform the requested operation
_Func->SetPickupPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPositionY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetPickupPosition(m_ID, &x, &dummy, &z);
// Perform the requested operation
_Func->SetPickupPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPositionZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetPickupPosition(m_ID, &x, &y, &dummy);
// Perform the requested operation
_Func->SetPickupPosition(m_ID, z, y, z);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Pickup_CreateEx(Int32 model, Int32 world, Int32 quantity,
Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic)
{
return Core::Get().NewPickup(model, world, quantity, x, y, z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Pickup_CreateEx(Int32 model, Int32 world, Int32 quantity,
Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic,
Int32 header, LightObj & payload)
{
return Core::Get().NewPickup(model, world, quantity, x, y, z, alpha, automatic, header, payload);
}
// ------------------------------------------------------------------------------------------------
static LightObj & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const Vector3 & pos,
Int32 alpha, bool automatic)
{
return Core::Get().NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullLightObj());
}
static LightObj & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const Vector3 & pos,
Int32 alpha, bool automatic, Int32 header, LightObj & payload)
{
return Core::Get().NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
header, payload);
}
// ================================================================================================
void Register_CPickup(HSQUIRRELVM vm)
{
RootTable(vm).Bind(Typename::Str,
Class< CPickup, NoConstructor< CPickup > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &CPickup::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CPickup::Max)
// Core Properties
.Prop(_SC("On"), &CPickup::GetEvents)
.Prop(_SC("ID"), &CPickup::GetID)
.Prop(_SC("Tag"), &CPickup::GetTag, &CPickup::SetTag)
.Prop(_SC("Data"), &CPickup::GetData, &CPickup::SetData)
.Prop(_SC("Active"), &CPickup::IsActive)
// Core Methods
.FmtFunc(_SC("SetTag"), &CPickup::ApplyTag)
.Func(_SC("CustomEvent"), &CPickup::CustomEvent)
// Core Overloads
.Overload< bool (CPickup::*)(void) >(_SC("Destroy"), &CPickup::Destroy)
.Overload< bool (CPickup::*)(Int32) >(_SC("Destroy"), &CPickup::Destroy)
.Overload< bool (CPickup::*)(Int32, LightObj &) >(_SC("Destroy"), &CPickup::Destroy)
// Properties
.Prop(_SC("Model"), &CPickup::GetModel)
.Prop(_SC("World"), &CPickup::GetWorld, &CPickup::SetWorld)
.Prop(_SC("Alpha"), &CPickup::GetAlpha, &CPickup::SetAlpha)
.Prop(_SC("Auto"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
.Prop(_SC("Automatic"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
.Prop(_SC("Timer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
.Prop(_SC("Autotimer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
.Prop(_SC("Pos"), &CPickup::GetPosition, &CPickup::SetPosition)
.Prop(_SC("Position"), &CPickup::GetPosition, &CPickup::SetPosition)
.Prop(_SC("Quantity"), &CPickup::GetQuantity)
.Prop(_SC("PosX"), &CPickup::GetPositionX, &CPickup::SetPositionX)
.Prop(_SC("PosY"), &CPickup::GetPositionY, &CPickup::SetPositionY)
.Prop(_SC("PosZ"), &CPickup::GetPositionZ, &CPickup::SetPositionZ)
// Member Methods
.Func(_SC("StreamedFor"), &CPickup::IsStreamedFor)
.Func(_SC("GetOption"), &CPickup::GetOption)
.Func(_SC("SetOption"), &CPickup::SetOption)
.Func(_SC("SetOptionEx"), &CPickup::SetOptionEx)
.Func(_SC("Refresh"), &CPickup::Refresh)
.Func(_SC("SetPos"), &CPickup::SetPositionEx)
.Func(_SC("SetPosition"), &CPickup::SetPositionEx)
// Static Overloads
.StaticOverload< LightObj & (*)(Int32, Int32, Int32, Float32, Float32, Float32, Int32, bool) >
(_SC("CreateEx"), &Pickup_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Int32, Int32, Float32, Float32, Float32, Int32, bool, Int32, LightObj &) >
(_SC("CreateEx"), &Pickup_CreateEx)
.StaticOverload< LightObj & (*)(Int32, Int32, Int32, const Vector3 &, Int32, bool) >
(_SC("Create"), &Pickup_Create)
.StaticOverload< LightObj & (*)(Int32, Int32, Int32, const Vector3 &, Int32, bool, Int32, LightObj &) >
(_SC("Create"), &Pickup_Create)
// Raw Squirrel Methods
.SquirrelFunc(_SC("NullInst"), &CPickup::SqGetNull)
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CPickup, ENT_PICKUP >)
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CPickup, ENT_PICKUP >)
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CPickup, ENT_PICKUP >)
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CPickup, ENT_PICKUP >)
);
}
} // Namespace:: SqMod
+310
View File
@@ -0,0 +1,310 @@
#ifndef _ENTITY_PICKUP_HPP_
#define _ENTITY_PICKUP_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Circular locks employed by the pickup manager.
*/
enum PickupCircularLocks
{
PICKUPCL_EMIT_PICKUP_OPTION = (1 << 0),
PICKUPCL_EMIT_PICKUP_WORLD = (1 << 1),
PICKUPCL_EMIT_PICKUP_ALPHA = (1 << 2),
PICKUPCL_EMIT_PICKUP_AUTOMATIC = (1 << 3),
PICKUPCL_EMIT_PICKUP_AUTOTIMER = (1 << 4)
};
/* ------------------------------------------------------------------------------------------------
* Manages a single pickup entity.
*/
class CPickup
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Prevent events from triggering themselves.
*/
Uint32 m_CircularLocks;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CPickup(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CPickup(const CPickup &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CPickup(CPickup &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CPickup();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CPickup & operator = (const CPickup &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CPickup & operator = (CPickup &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity instance otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid pickup reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CPickup & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed pickup entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed pickup entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed pickup entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* See if the managed pickup entity is streamed for the specified player.
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current option value of the managed pickup entity.
*/
bool GetOption(Int32 option_id) const;
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed pickup entity.
*/
void SetOption(Int32 option_id, bool toggle);
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed pickup entity.
*/
void SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed pickup entity exists.
*/
Int32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Mpdify the world in which the managed pickup entity exists.
*/
void SetWorld(Int32 world);
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha of the managed pickup entity.
*/
Int32 GetAlpha() const;
/* --------------------------------------------------------------------------------------------
* Mpdify the alpha of the managed pickup entity.
*/
void SetAlpha(Int32 alpha);
/* --------------------------------------------------------------------------------------------
* See whether the managed pickup entity is automatic.
*/
bool GetAutomatic() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed pickup entity is automatic.
*/
void SetAutomatic(bool toggle);
/* --------------------------------------------------------------------------------------------
* Retrieve the automatic timer of the managed pickup entity.
*/
Int32 GetAutoTimer() const;
/* --------------------------------------------------------------------------------------------
* Mpdify the automatic timer of the managed pickup entity.
*/
void SetAutoTimer(Int32 timer);
/* --------------------------------------------------------------------------------------------
* Refresh the managed pickup entity.
*/
void Refresh() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed pickup entity.
*/
Vector3 GetPosition();
/* --------------------------------------------------------------------------------------------
* Mpdify the position of the managed pickup entity.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Mpdify the position of the managed pickup entity.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the model of the managed pickup entity.
*/
Int32 GetModel() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the quantity of the managed pickup entity.
*/
Int32 GetQuantity() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed pickup entity.
*/
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed pickup entity.
*/
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed pickup entity.
*/
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed pickup entity.
*/
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed pickup entity.
*/
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed pickup entity.
*/
void SetPositionZ(Float32 z) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_PICKUP_HPP_
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+928
View File
@@ -0,0 +1,928 @@
#ifndef _ENTITY_VEHICLE_HPP_
#define _ENTITY_VEHICLE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Circular locks employed by the vehicle manager.
*/
enum VehicleCircularLocks
{
VEHICLECL_EMIT_VEHICLE_OPTION = (1 << 0),
VEHICLECL_EMIT_VEHICLE_WORLD = (1 << 1),
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (1 << 2),
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (1 << 3),
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (1 << 4),
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (1 << 5),
VEHICLECL_EMIT_VEHICLE_RADIO = (1 << 6),
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (1 << 7)
};
/* ------------------------------------------------------------------------------------------------
* Manages a single vehicle entity.
*/
class CVehicle
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Prevent events from triggering themselves.
*/
Uint32 m_CircularLocks;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CVehicle(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CVehicle(const CVehicle &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CVehicle(CVehicle &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CVehicle();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CVehicle & operator = (const CVehicle &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CVehicle & operator = (CVehicle &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid vehicle reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CVehicle & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed vehicle entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed vehicle entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed vehicle entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* See if the managed vehicle entity is streamed for the specified player.
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current option value of the managed vehicle entity.
*/
bool GetOption(Int32 option_id) const;
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed vehicle entity.
*/
void SetOption(Int32 option_id, bool toggle);
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed vehicle entity.
*/
void SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the synchronization source of the managed vehicle entity.
*/
Int32 GetSyncSource() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the synchronization type of the managed vehicle entity.
*/
Int32 GetSyncType() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed vehicle entity exists.
*/
Int32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Modify the world in which the managed vehicle entity exists.
*/
void SetWorld(Int32 world);
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle model of the managed vehicle entity.
*/
Int32 GetModel() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the slot occupant from the managed vehicle entity.
*/
LightObj & GetOccupant(Int32 slot) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the slot occupant identifier from the managed vehicle entity.
*/
Int32 GetOccupantID(Int32 slot) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity has an occupant in a certain slot.
*/
bool HasOccupant(Int32 slot) const;
/* --------------------------------------------------------------------------------------------
* Respawn the managed vehicle entity.
*/
void Respawn() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the immunity flags of the managed vehicle entity.
*/
Int32 GetImmunity() const;
/* --------------------------------------------------------------------------------------------
* Modify the immunity flags of the managed vehicle entity.
*/
void SetImmunity(Int32 flags);
/* --------------------------------------------------------------------------------------------
* Explode the managed vehicle entity.
*/
void Explode() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity is wrecked.
*/
bool IsWrecked() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed vehicle entity.
*/
Vector3 GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed vehicle entity.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed vehicle entity.
*/
void SetPositionEx(const Vector3 & pos, bool empty) const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed vehicle entity.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed vehicle entity.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z, bool empty) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation of the managed vehicle entity.
*/
Quaternion GetRotation() const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation of the managed vehicle entity.
*/
void SetRotation(const Quaternion & rot) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation of the managed vehicle entity.
*/
void SetRotationEx(Float32 x, Float32 y, Float32 z, Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation of the managed vehicle entity.
*/
Vector3 GetRotationEuler() const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation of the managed vehicle entity.
*/
void SetRotationEuler(const Vector3 & rot) const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation of the managed vehicle entity.
*/
void SetRotationEulerEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the speed of the managed vehicle entity.
*/
Vector3 GetSpeed() const;
/* --------------------------------------------------------------------------------------------
* Modify the speed of the managed vehicle entity.
*/
void SetSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the speed of the managed vehicle entity.
*/
void SetSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the speed of the managed vehicle entity.
*/
void AddSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the speed of the managed vehicle entity.
*/
void AddSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative speed of the managed vehicle entity.
*/
Vector3 GetRelativeSpeed() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void SetRelativeSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void SetRelativeSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void AddRelativeSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void AddRelativeSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn speed of the managed vehicle entity.
*/
Vector3 GetTurnSpeed() const;
/* --------------------------------------------------------------------------------------------
* Modify the turn speed of the managed vehicle entity.
*/
void SetTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn speed of the managed vehicle entity.
*/
void SetTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn speed of the managed vehicle entity.
*/
void AddTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn speed of the managed vehicle entity.
*/
void AddTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn speed of the managed vehicle entity.
*/
Vector3 GetRelativeTurnSpeed() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void SetRelativeTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void SetRelativeTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void AddRelativeTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void AddRelativeTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the spawn position of the managed vehicle entity.
*/
Vector3 GetSpawnPosition() const;
/* --------------------------------------------------------------------------------------------
* Modify the spawn position of the managed vehicle entity.
*/
void SetSpawnPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Modify the spawn position of the managed vehicle entity.
*/
void SetSpawnPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the spawn rotation of the managed vehicle entity.
*/
Quaternion GetSpawnRotation() const;
/* --------------------------------------------------------------------------------------------
* Modify the spawn rotation of the managed vehicle entity.
*/
void SetSpawnRotation(const Quaternion & rot) const;
/* --------------------------------------------------------------------------------------------
* Modify the spawn rotation of the managed vehicle entity.
*/
void SetSpawnRotationEx(Float32 x, Float32 y, Float32 z, Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler spawn rotation of the managed vehicle entity.
*/
Vector3 GetSpawnRotationEuler() const;
/* --------------------------------------------------------------------------------------------
* Modify the euler spawn rotation of the managed vehicle entity.
*/
void SetSpawnRotationEuler(const Vector3 & rot) const;
/* --------------------------------------------------------------------------------------------
* Modify the euler spawn rotation of the managed vehicle entity.
*/
void SetSpawnRotationEulerEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the respawn timer of the managed vehicle entity.
*/
Uint32 GetIdleRespawnTimer() const;
/* --------------------------------------------------------------------------------------------
* Modify the respawn timer of the managed vehicle entity.
*/
void SetIdleRespawnTimer(Uint32 millis) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the health of the managed vehicle entity.
*/
Float32 GetHealth() const;
/* --------------------------------------------------------------------------------------------
* Modify the health of the managed vehicle entity.
*/
void SetHealth(Float32 amount) const;
/* --------------------------------------------------------------------------------------------
* Fix the damage and restore health for the managed vehicle entity.
*/
void Fix() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the primary color of the managed vehicle entity.
*/
Int32 GetPrimaryColor() const;
/* --------------------------------------------------------------------------------------------
* Modify the primary color of the managed vehicle entity.
*/
void SetPrimaryColor(Int32 col) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the secondary color of the managed vehicle entity.
*/
Int32 GetSecondaryColor() const;
/* --------------------------------------------------------------------------------------------
* Modify the secondary color of the managed vehicle entity.
*/
void SetSecondaryColor(Int32 col) const;
/* --------------------------------------------------------------------------------------------
* Modify the primary and secondary colors of the managed vehicle entity.
*/
void SetColors(Int32 primary, Int32 secondary) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the part status of the managed vehicle entity.
*/
Int32 GetPartStatus(Int32 part) const;
/* --------------------------------------------------------------------------------------------
* Modify the part status of the managed vehicle entity.
*/
void SetPartStatus(Int32 part, Int32 status);
/* --------------------------------------------------------------------------------------------
* Retrieve the tyre status of the managed vehicle entity.
*/
Int32 GetTyreStatus(Int32 tyre) const;
/* --------------------------------------------------------------------------------------------
* Modify the tyre status of the managed vehicle entity.
*/
void SetTyreStatus(Int32 tyre, Int32 status);
/* --------------------------------------------------------------------------------------------
* Retrieve the damage data of the managed vehicle entity.
*/
Uint32 GetDamageData() const;
/* --------------------------------------------------------------------------------------------
* Modify the damage data of the managed vehicle entity.
*/
void SetDamageData(Uint32 data);
/* --------------------------------------------------------------------------------------------
* Retrieve the radio of the managed vehicle entity.
*/
Int32 GetRadio() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radio of the managed vehicle entity.
*/
void SetRadio(Int32 radio);
/* --------------------------------------------------------------------------------------------
* Retrieve the turret rotation of the managed vehicle entity.
*/
Vector2 GetTurretRotation() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the horizontal turret rotation of the managed vehicle entity.
*/
Float32 GetHorizontalTurretRotation() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vertical turret rotation of the managed vehicle entity.
*/
Float32 GetVerticalTurretRotation() const;
/* --------------------------------------------------------------------------------------------
* See whether the specified handling ruleexists in the managed vehicle entity.
*/
bool ExistsHandlingRule(Int32 rule) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the handling data of the managed vehicle entity.
*/
Float32 GetHandlingRule(Int32 rule) const;
/* --------------------------------------------------------------------------------------------
* Modify the handling data of the managed vehicle entity.
*/
void SetHandlingRule(Int32 rule, Float32 data);
/* --------------------------------------------------------------------------------------------
* Reset the specified handling rule for the managed vehicle entity.
*/
void ResetHandlingRule(Int32 rule);
/* --------------------------------------------------------------------------------------------
* Reset all the handling rules for the managed vehicle entity.
*/
void ResetHandlings() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the lights data for the managed vehicle entity.
*/
Int32 GetLightsData() const;
/* --------------------------------------------------------------------------------------------
* Modify the lights data for the managed vehicle entity.
*/
void SetLightsData(Int32 data) const;
/* --------------------------------------------------------------------------------------------
* Embark the specified player entity into the managed vehicle entity.
*/
bool Embark(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Embark the specified player entity into the managed vehicle entity.
*/
bool Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) const;
#if SQMOD_SDK_LEAST(2, 1)
/* --------------------------------------------------------------------------------------------
* Set whether the target player will see an objective arrow over a vehicle.
*/
void SetPlayer3DArrow(CPlayer & target, bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the target player sees an objective arrow over a vehicle.
*/
bool GetPlayer3DArrow(CPlayer & target) const;
/* --------------------------------------------------------------------------------------------
* Set whether the target player will see an objective arrow over a vehicle.
*/
void SetPlayer3DArrowID(SQInteger id, bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the target player sees an objective arrow over a vehicle.
*/
bool GetPlayer3DArrowID(SQInteger id) const;
#endif
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity collides with user defined areas.
*/
bool GetCollideAreas() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity can collide with user defined areas.
*/
void SetCollideAreas(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity can collide with user defined areas (with last test).
*/
void SetAreasCollide(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the amount of tracked position changes for the managed vehicle entity.
*/
SQInteger GetTrackPosition() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the amount of tracked position changes for the managed vehicle entity.
*/
void SetTrackPosition(SQInteger num) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the amount of tracked rotation changes for the managed vehicle entity.
*/
SQInteger GetTrackRotation() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the amount of tracked rotation changes for the managed vehicle entity.
*/
void SetTrackRotation(SQInteger num) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known primary color for the managed vehicle entity.
*/
Int32 GetLastPrimaryColor() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known secondary color for the managed vehicle entity.
*/
Int32 GetLastSecondaryColor() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known health for the managed vehicle entity.
*/
Float32 GetLastHealth() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known position for the managed player entity.
*/
const Vector3 & GetLastPosition() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known rotation for the managed player entity.
*/
const Quaternion & GetLastRotation() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed vehicle entity.
*/
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed vehicle entity.
*/
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed vehicle entity.
*/
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed vehicle entity.
*/
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed vehicle entity.
*/
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed vehicle entity.
*/
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the x axis of the managed vehicle entity.
*/
Float32 GetRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the y axis of the managed vehicle entity.
*/
Float32 GetRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the z axis of the managed vehicle entity.
*/
Float32 GetRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation amount of the managed vehicle entity.
*/
Float32 GetRotationW() const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed vehicle entity.
*/
void SetRotationX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed vehicle entity.
*/
void SetRotationY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed vehicle entity.
*/
void SetRotationZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation amount of the managed vehicle entity.
*/
void SetRotationW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the x axis of the managed vehicle entity.
*/
Float32 GetEulerRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the y axis of the managed vehicle entity.
*/
Float32 GetEulerRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the z axis of the managed vehicle entity.
*/
Float32 GetEulerRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation on the x axis of the managed vehicle entity.
*/
void SetEulerRotationX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation on the y axis of the managed vehicle entity.
*/
void SetEulerRotationY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation on the z axis of the managed vehicle entity.
*/
void SetEulerRotationZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the velocity on the x axis of the managed vehicle entity.
*/
Float32 GetSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the velocity on the y axis of the managed vehicle entity.
*/
Float32 GetSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the velocity on the z axis of the managed vehicle entity.
*/
Float32 GetSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the velocity on the x axis of the managed vehicle entity.
*/
void SetSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the velocity on the y axis of the managed vehicle entity.
*/
void SetSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the velocity on the z axis of the managed vehicle entity.
*/
void SetSpeedZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative velocity on the x axis of the managed vehicle entity.
*/
Float32 GetRelativeSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative velocity on the y axis of the managed vehicle entity.
*/
Float32 GetRelativeSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative velocity on the z axis of the managed vehicle entity.
*/
Float32 GetRelativeSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative velocity on the x axis of the managed vehicle entity.
*/
void SetRelativeSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative velocity on the y axis of the managed vehicle entity.
*/
void SetRelativeSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative velocity on the z axis of the managed vehicle entity.
*/
void SetRelativeSpeedZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn velocity on the x axis of the managed vehicle entity.
*/
Float32 GetTurnSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn velocity on the y axis of the managed vehicle entity.
*/
Float32 GetTurnSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn velocity on the z axis of the managed vehicle entity.
*/
Float32 GetTurnSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the turn velocity on the x axis of the managed vehicle entity.
*/
void SetTurnSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn velocity on the y axis of the managed vehicle entity.
*/
void SetTurnSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn velocity on the z axis of the managed vehicle entity.
*/
void SetTurnSpeedZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn velocity on the x axis of the managed vehicle entity.
*/
Float32 GetRelativeTurnSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn velocity on the y axis of the managed vehicle entity.
*/
Float32 GetRelativeTurnSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn velocity on the z axis of the managed vehicle entity.
*/
Float32 GetRelativeTurnSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn velocity on the x axis of the managed vehicle entity.
*/
void SetRelativeTurnSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn velocity on the y axis of the managed vehicle entity.
*/
void SetRelativeTurnSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn velocity on the z axis of the managed vehicle entity.
*/
void SetRelativeTurnSpeedZ(Float32 z) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_VEHICLE_HPP_