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-08-18 14:54:26 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Circular locks employed by the checkpoint manager.
|
|
|
|
*/
|
|
|
|
enum CheckpointCircularLocks
|
|
|
|
{
|
|
|
|
CHECKPOINTCL_EMIT_CHECKPOINT_WORLD = (1 << 0)
|
|
|
|
};
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Manages a single checkpoint entity.
|
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
|
|
|
// --------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
static Int32 s_ColorR, s_ColorG, s_ColorB, s_ColorA;
|
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-03-10 04:57:13 +01:00
|
|
|
* User tag associated with this instance.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
String m_Tag;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* User data associated with this instance.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object m_Data;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
2016-08-18 14:54:26 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Prevent events from triggering themselves.
|
|
|
|
*/
|
|
|
|
Uint32 m_CircularLocks;
|
|
|
|
|
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-03-10 04:57:13 +01:00
|
|
|
public:
|
|
|
|
|
2015-10-29 21:07:31 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Maximum possible number that could represent an identifier for this entity type.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
static const Int32 Max;
|
2015-10-29 21:07:31 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor. (disabled)
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
CCheckpoint(const CCheckpoint &) = delete;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move constructor. (disabled)
|
|
|
|
*/
|
|
|
|
CCheckpoint(CCheckpoint &&) = delete;
|
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-03-10 04:57:13 +01:00
|
|
|
* 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.
|
2015-10-29 21:07:31 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
void Validate() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
if (INVALID_ENTITY(m_ID))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid checkpoint reference [%s]", m_Tag.c_str());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
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-03-10 04:57:13 +01:00
|
|
|
const String & ToString() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to retrieve the name from instances of this type.
|
2016-02-20 23:25:00 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
static SQInteger Typename(HSQUIRRELVM vm);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-08-07 00:54:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the associated null entity instance.
|
|
|
|
*/
|
|
|
|
static SQInteger SqGetNull(HSQUIRRELVM vm);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the associated null entity instance.
|
|
|
|
*/
|
|
|
|
static Object & GetNull();
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Retrieve the identifier of the entity managed by this instance.
|
2016-02-20 23:25:00 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
Int32 GetID() const
|
|
|
|
{
|
|
|
|
return m_ID;
|
|
|
|
}
|
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-03-10 04:57:13 +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-03-10 04:57:13 +01:00
|
|
|
const String & 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);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed checkpoint entity.
|
|
|
|
*/
|
|
|
|
bool Destroy()
|
|
|
|
{
|
|
|
|
return Destroy(0, NullObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed checkpoint entity.
|
|
|
|
*/
|
|
|
|
bool Destroy(Int32 header)
|
|
|
|
{
|
|
|
|
return Destroy(header, NullObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Destroy(Int32 header, Object & payload);
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Bind to an event supported by this entity type.
|
|
|
|
*/
|
|
|
|
void BindEvent(Int32 evid, Object & env, Function & func) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-07-26 23:13:50 +02:00
|
|
|
* Emit a custom event for the managed entity
|
|
|
|
*/
|
|
|
|
void CustomEvent(Int32 header, Object & payload) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* See if the managed checkpoint entity is streamed for the specified player.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool IsStreamedFor(CPlayer & player) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* See if the managed checkpoint entity of sphere type.
|
|
|
|
*/
|
|
|
|
bool IsSphere() const;
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the world in which the managed checkpoint entity exists.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetWorld() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the world in which the managed checkpoint entity exists.
|
|
|
|
*/
|
2016-08-18 14:54:26 +02:00
|
|
|
void SetWorld(Int32 world);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
const Color4 & GetColor() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColor(const Color4 & col) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the color of the managed checkpoint entity.
|
|
|
|
*/
|
|
|
|
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the position of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
const Vector3 & GetPosition() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the position of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPosition(const Vector3 & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the position of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the radius of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Float32 GetRadius() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the radius of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetRadius(Float32 radius) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the owner of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & GetOwner() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the owner identifier of the managed checkpoint entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetOwnerID() const;
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the position on the x axis of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 GetPositionX() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the position on the y axis of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 GetPositionY() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the position on the z axis of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 GetPositionZ() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the position on the x axis of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetPositionX(Float32 x) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the position on the y axis of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetPositionY(Float32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the position on the z axis of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetPositionZ(Float32 z) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the red color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 GetColorR() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the green color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 GetColorG() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the blue color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 GetColorB() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the alpha transparency of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 GetColorA() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the red color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetColorR(Int32 r) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the green color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetColorG(Int32 g) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the blue color of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetColorB(Int32 b) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Modify the alpha transparency of the managed checkpoint entity.
|
|
|
|
*/
|
2016-05-22 05:20:38 +02:00
|
|
|
void SetColorA(Int32 a) const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _ENTITY_CHECKPOINT_HPP_
|