2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _ENTITY_SPRITE_HPP_
|
|
|
|
#define _ENTITY_SPRITE_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Shared.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Manages a single sprite entity.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
class CSprite
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
friend class Core;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
private:
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Identifier of the managed entity.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 m_ID;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* User tag associated with this instance.
|
2015-10-29 21:41:20 +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:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Base constructor.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSprite(Int32 id);
|
2015-10-29 21:41:20 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
public:
|
|
|
|
|
2015-10-29 21:41:20 +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:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
static const Int32 Max;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor. (disabled)
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
CSprite(const CSprite &) = delete;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move constructor. (disabled)
|
|
|
|
*/
|
|
|
|
CSprite(CSprite &&) = delete;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Destructor.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
~CSprite();
|
2015-10-29 21:41:20 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy assignment operator. (disabled)
|
|
|
|
*/
|
|
|
|
CSprite & operator = (const CSprite &) = delete;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator. (disabled)
|
|
|
|
*/
|
|
|
|
CSprite & operator = (CSprite &&) = delete;
|
|
|
|
|
2015-10-29 21:41:20 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* See whether this instance manages a valid entity.
|
2015-10-29 21:41:20 +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 sprite 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:41:20 +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:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const CSprite & o) const;
|
2015-10-29 21:41:20 +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:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & ToString() const;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to retrieve the name from instances of this type.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
static SQInteger Typename(HSQUIRRELVM vm);
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Retrieve the identifier of the entity managed by this instance.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
Int32 GetID() const
|
|
|
|
{
|
|
|
|
return m_ID;
|
|
|
|
}
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Check whether this instance manages a valid entity.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
bool IsActive() const
|
|
|
|
{
|
|
|
|
return VALID_ENTITY(m_ID);
|
|
|
|
}
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user tag.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & GetTag() const;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user tag.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetTag(CSStr tag);
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user data.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & GetData();
|
2015-10-29 21:41:20 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user data.
|
2015-10-29 21:41:20 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetData(Object & data);
|
2015-10-29 21:41:20 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed sprite entity.
|
|
|
|
*/
|
|
|
|
bool Destroy()
|
|
|
|
{
|
|
|
|
return Destroy(0, NullObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed sprite entity.
|
|
|
|
*/
|
|
|
|
bool Destroy(Int32 header)
|
|
|
|
{
|
|
|
|
return Destroy(header, NullObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed sprite entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Destroy(Int32 header, Object & payload);
|
2015-10-29 21:41:20 +01:00
|
|
|
|
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;
|
2015-10-29 21:41:20 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Show the managed sprite entity to all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void ShowAll() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Show the managed sprite entity to the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void ShowFor(CPlayer & player) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Show the managed sprite entity to all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void ShowRange(Int32 first, Int32 last) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Hide the managed sprite entity from all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void HideAll() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Hide the managed sprite entity from the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void HideFor(CPlayer & player) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Hide the managed sprite entity from all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void HideRange(Int32 first, Int32 last) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed sprite entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionAll(const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed sprite entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionAllEx(Int32 x, Int32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed sprite entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionFor(CPlayer & player, const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed sprite entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed sprite entity for all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the center of the managed sprite entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetCenterAll(const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the center of the managed sprite entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetCenterAllEx(Int32 x, Int32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the center of the managed sprite entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetCenterFor(CPlayer & player, const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the center of the managed sprite entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the center of the managed sprite entity for all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the rotation of the managed sprite entity for all players on the server.
|
|
|
|
*/
|
|
|
|
void SetRotationAll(Float32 rot) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the rotation of the managed sprite entity for the specified player entity.
|
|
|
|
*/
|
|
|
|
void SetRotationFor(CPlayer & player, Float32 rot) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the rotation of the managed sprite entity for all players in the specified range.
|
|
|
|
*/
|
|
|
|
void SetRotationRange(Int32 first, Int32 last, Float32 rot) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the alpha of the managed sprite entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetAlphaAll(Uint8 alpha) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the alpha of the managed sprite entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetAlphaFor(CPlayer & player, Uint8 alpha) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the alpha of the managed sprite entity for all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the file path of the texture used by the managed sprite entity.
|
|
|
|
*/
|
|
|
|
const String & GetFilePath() const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _ENTITY_SPRITE_HPP_
|