2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _ENTITY_BLIP_HPP_
|
|
|
|
#define _ENTITY_BLIP_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 Blip instances.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
class CBlip
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
friend class Core;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Cached identifiers for fast integer to string conversion.
|
|
|
|
*/
|
|
|
|
static SQChar s_StrID[SQMOD_BLIP_POOL][8];
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Identifier of the managed entity.
|
|
|
|
*/
|
|
|
|
Int32 m_ID;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* User tag and data associated with this instance.
|
|
|
|
*/
|
|
|
|
String m_Tag;
|
|
|
|
Object m_Data;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Base constructor.
|
|
|
|
*/
|
|
|
|
CBlip(Int32 id);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy constructor. (disabled)
|
|
|
|
*/
|
|
|
|
CBlip(const CBlip &);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy assignment operator. (disabled)
|
|
|
|
*/
|
|
|
|
CBlip & operator = (const CBlip &);
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
public:
|
2015-10-29 21:07:15 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static const Int32 Max;
|
|
|
|
|
2015-10-29 22:02:55 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Destructor.
|
2015-10-29 22:02:55 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
~CBlip();
|
2015-10-29 21:07:15 +01:00
|
|
|
|
2015-11-01 00:31:28 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* See whether this instance manages a valid entity.
|
2015-11-01 00:31:28 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Validate() const
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
return true;
|
|
|
|
SqThrow("Invalid blip reference [%s]", m_Tag.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-01 00:31:28 +01:00
|
|
|
|
2015-10-29 21:07:15 +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:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const CBlip & o) const;
|
2015-10-29 21:07:15 +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:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr ToString() const;
|
2015-10-29 21:07:15 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the identifier of the entity managed by this instance.
|
2015-10-29 21:07:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetID() const { return m_ID; }
|
2015-10-29 21:07:15 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the maximum possible identifier to an entity of this type.
|
2015-10-29 21:07:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetMaxID() const { return SQMOD_BLIP_POOL; }
|
2015-10-29 21:07:15 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Check whether this instance manages a valid entity.
|
2015-10-29 21:07:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool IsActive() const { return VALID_ENTITY(m_ID); }
|
2015-10-29 21:07:15 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user tag.
|
2015-10-29 21:07:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr GetTag() const;
|
2015-10-29 21:07:15 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user tag.
|
2015-10-29 21:07:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetTag(CSStr tag);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the associated user data.
|
|
|
|
*/
|
|
|
|
Object & GetData();
|
2015-10-29 21:07:15 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user data.
|
2015-10-29 21:07:15 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetData(Object & data);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed entity instance.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Int32 GetWorld() const;
|
|
|
|
Int32 GetScale() const;
|
|
|
|
const Vector3 & GetPosition() const;
|
|
|
|
const Color4 & GetColor() const;
|
|
|
|
Int32 GetSprID() const;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Float32 GetPosX() const;
|
|
|
|
Float32 GetPosY() const;
|
|
|
|
Float32 GetPosZ() const;
|
|
|
|
Int32 GetColorR() const;
|
|
|
|
Int32 GetColorG() const;
|
|
|
|
Int32 GetColorB() const;
|
|
|
|
Int32 GetColorA() const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
#endif // _ENTITY_BLIP_HPP_
|