2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _ENTITY_CHECKPOINT_HPP_
|
|
|
|
#define _ENTITY_CHECKPOINT_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Shared.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Manages Checkpoint instances.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
class CCheckpoint
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
friend class Core;
|
|
|
|
|
|
|
|
private:
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
static Color4 s_Color4;
|
|
|
|
static Vector3 s_Vector3;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static Uint32 s_ColorR, s_ColorG, s_ColorB, s_ColorA;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Cached identifiers for fast integer to string conversion.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
static SQChar s_StrID[SQMOD_CHECKPOINT_POOL][8];
|
2015-10-29 21:07:31 +01:00
|
|
|
|
2015-11-01 00:31:38 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Identifier of the managed entity.
|
2015-11-01 00:31:38 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 m_ID;
|
2015-11-01 00:31:38 +01:00
|
|
|
|
2015-10-29 21:07:31 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* User tag and data associated with this instance.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
String m_Tag;
|
|
|
|
Object m_Data;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Base constructor.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CCheckpoint(Int32 id);
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Copy constructor. (disabled)
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CCheckpoint(const CCheckpoint &);
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Copy assignment operator. (disabled)
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CCheckpoint & operator = (const CCheckpoint &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static const Int32 Max;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Destructor.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
~CCheckpoint();
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* See whether this instance manages a valid entity.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Validate() const
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
return true;
|
|
|
|
SqThrow("Invalid checkpoint reference [%s]", m_Tag.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Used by the script engine to compare two instances of this type.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const CCheckpoint & o) const;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr ToString() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the identifier of the entity managed by this instance.
|
|
|
|
*/
|
|
|
|
Int32 GetID() const { return m_ID; }
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the maximum possible identifier to an entity of this type.
|
|
|
|
*/
|
|
|
|
Int32 GetMaxID() const { return SQMOD_CHECKPOINT_POOL; }
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Check whether this instance manages a valid entity.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool IsActive() const { return VALID_ENTITY(m_ID); }
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user tag.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr GetTag() const;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user tag.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetTag(CSStr tag);
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user data.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & GetData();
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user data.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetData(Object & data);
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
bool Destroy(Int32 header, Object & payload);
|
|
|
|
bool Destroy() { return Destroy(0, NullObject()); }
|
|
|
|
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
bool BindEvent(Int32 evid, Object & env, Function & func) const;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
bool IsStreamedFor(CPlayer & player) const;
|
|
|
|
Int32 GetWorld() const;
|
|
|
|
void SetWorld(Int32 world) const;
|
|
|
|
const Color4 & GetColor() const;
|
|
|
|
void SetColor(const Color4 & col) const;
|
|
|
|
void SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
|
|
|
|
const Vector3 & GetPosition() const;
|
|
|
|
void SetPosition(const Vector3 & pos) const;
|
|
|
|
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
|
|
|
|
Float32 GetRadius() const;
|
|
|
|
void SetRadius(Float32 radius) const;
|
|
|
|
Object & GetOwner() const;
|
|
|
|
Int32 GetOwnerID() const;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Float32 GetPosX() const;
|
|
|
|
Float32 GetPosY() const;
|
|
|
|
Float32 GetPosZ() const;
|
|
|
|
void SetPosX(Float32 x) const;
|
|
|
|
void SetPosY(Float32 y) const;
|
|
|
|
void SetPosZ(Float32 z) const;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Uint32 GetColR() const;
|
|
|
|
Uint32 GetColG() const;
|
|
|
|
Uint32 GetColB() const;
|
|
|
|
Uint32 GetColA() const;
|
|
|
|
void SetColR(Uint32 r) const;
|
|
|
|
void SetColG(Uint32 g) const;
|
|
|
|
void SetColB(Uint32 b) const;
|
|
|
|
void SetColA(Uint32 a) const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _ENTITY_CHECKPOINT_HPP_
|