2012-02-13 16:47:03 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
#pragma once
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Vector3d.h"
|
|
|
|
#include "Vector3f.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
#define CLASS_PROT_ISA() virtual bool IsA( const char* a_EntityType );
|
|
|
|
#define CLASS_PROT_GETCLASS() virtual const char* GetClass();
|
|
|
|
|
|
|
|
/* Can't use this (yet) because of tolua */
|
|
|
|
#define CLASS_PROTOTYPE() \
|
|
|
|
CLASS_PROT_ISA(); \
|
|
|
|
CLASS_PROT_GETCLASS();
|
|
|
|
|
|
|
|
#define CLASS_DEF_ISA( classname, superclass ) \
|
|
|
|
bool classname::IsA( const char* a_EntityType ) \
|
|
|
|
{ \
|
|
|
|
if( strcmp( a_EntityType, #classname ) == 0 ) return true; \
|
|
|
|
return superclass::IsA( a_EntityType ); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CLASS_DEF_GETCLASS( classname ) \
|
|
|
|
const char* classname::GetClass() \
|
|
|
|
{ \
|
|
|
|
return #classname; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CLASS_DEFINITION( classname, superclass ) \
|
|
|
|
CLASS_DEF_ISA( classname, superclass ) \
|
|
|
|
CLASS_DEF_GETCLASS( classname )
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-30 20:52:20 -04:00
|
|
|
class cWorld;
|
2011-10-03 14:41:19 -04:00
|
|
|
class cReferenceManager;
|
|
|
|
class cClientHandle;
|
2012-02-13 16:47:03 -05:00
|
|
|
class cPacket;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
class cEntity //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
public: //tolua_export
|
|
|
|
cEntity(const double & a_X, const double & a_Y, const double & a_Z); //tolua_export
|
|
|
|
virtual ~cEntity(); //tolua_export
|
|
|
|
|
2011-10-30 20:52:20 -04:00
|
|
|
virtual void Initialize( cWorld* a_World ); //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
enum ENUM_ENTITY_TYPE //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
E_ENTITY, //tolua_export
|
|
|
|
E_PLAYER, //tolua_export
|
|
|
|
E_PICKUP //tolua_export
|
|
|
|
}; //tolua_export
|
|
|
|
|
|
|
|
virtual unsigned int GetEntityType() { return m_EntityType; } //tolua_export
|
|
|
|
virtual bool IsA( const char* a_EntityType ); //tolua_export
|
|
|
|
virtual const char* GetClass(); //tolua_export
|
|
|
|
|
2012-02-15 17:50:00 -05:00
|
|
|
cWorld * GetWorld(void) const { return m_World; } //tolua_export
|
|
|
|
|
|
|
|
const Vector3d & GetPosition(void) const {return m_Pos; } //tolua_export
|
|
|
|
const double & GetPosX (void) const {return m_Pos.x; } //tolua_export
|
|
|
|
const double & GetPosY (void) const {return m_Pos.y; } //tolua_export
|
|
|
|
const double & GetPosZ (void) const {return m_Pos.z; } //tolua_export
|
|
|
|
const Vector3f & GetRot (void) const {return m_Rot; } //tolua_export
|
|
|
|
float GetRotation(void) const {return m_Rot.x; } //tolua_export
|
|
|
|
float GetPitch (void) const {return m_Rot.y; } //tolua_export
|
|
|
|
float GetRoll (void) const {return m_Rot.z; } //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
Vector3f GetLookVector(); //tolua_export
|
2012-02-20 11:39:00 -05:00
|
|
|
|
|
|
|
int GetChunkX(void) const {return m_ChunkX; }
|
|
|
|
int GetChunkY(void) const {return m_ChunkY; }
|
|
|
|
int GetChunkZ(void) const {return m_ChunkZ; }
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
void SetPosX( const double & a_PosX ); //tolua_export
|
|
|
|
void SetPosY( const double & a_PosY ); //tolua_export
|
|
|
|
void SetPosZ( const double & a_PosZ ); //tolua_export
|
2012-03-07 08:36:30 -05:00
|
|
|
void SetPosition( const double & a_PosX, const double & a_PosY, const double & a_PosZ );//tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
void SetPosition( const Vector3d & a_Pos ); //tolua_export
|
|
|
|
void SetRot( const Vector3f & a_Rot ); //tolua_export
|
|
|
|
void SetRotation( float a_Rotation ); //tolua_export
|
|
|
|
void SetPitch( float a_Pitch ); //tolua_export
|
|
|
|
void SetRoll( float a_Roll ); //tolua_export
|
|
|
|
|
2012-03-07 08:36:30 -05:00
|
|
|
inline int GetUniqueID(void) const { return m_UniqueID; } //tolua_export
|
|
|
|
inline bool IsDestroyed(void) const { return m_bDestroyed; } //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
|
2011-11-02 16:19:57 -04:00
|
|
|
void Destroy(); //tolua_export
|
2012-02-13 16:47:03 -05:00
|
|
|
void RemoveFromChunk(void); // for internal use in cChunk
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
virtual void Tick(float a_Dt) = 0; //tolua_export
|
|
|
|
|
2012-02-19 18:00:00 -05:00
|
|
|
virtual cPacket * GetSpawnPacket(void) const {ASSERT(!"GetSpawnedPacket unimplemented!"); return NULL; }; // _X: Needs to be implemented due to Lua bindings
|
2012-02-13 16:47:03 -05:00
|
|
|
void SpawnOn (cClientHandle * a_Client); // tolua_export
|
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
void WrapRotation();
|
|
|
|
|
|
|
|
protected:
|
2012-03-07 08:36:30 -05:00
|
|
|
virtual void Destroyed() {} // Called after the entity has been destroyed
|
2012-02-13 16:47:03 -05:00
|
|
|
|
2011-12-26 16:54:08 -05:00
|
|
|
void SetWorld( cWorld* a_World ) { m_World = a_World; }
|
2011-12-25 21:13:40 -05:00
|
|
|
void MoveToCorrectChunk(bool a_bIgnoreOldChunk = false);
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
friend class cReferenceManager;
|
|
|
|
void AddReference( cEntity*& a_EntityPtr );
|
|
|
|
void ReferencedBy( cEntity*& a_EntityPtr );
|
|
|
|
void Dereference( cEntity*& a_EntityPtr );
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
static cCriticalSection m_CSCount;
|
2011-10-03 14:41:19 -04:00
|
|
|
static int m_EntityCount;
|
2012-02-13 16:47:03 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
int m_UniqueID;
|
|
|
|
|
|
|
|
cReferenceManager* m_Referencers;
|
|
|
|
cReferenceManager* m_References;
|
|
|
|
|
|
|
|
int m_ChunkX, m_ChunkY, m_ChunkZ;
|
2012-02-15 17:50:00 -05:00
|
|
|
Vector3d m_Pos;
|
2011-10-03 14:41:19 -04:00
|
|
|
bool m_bDirtyPosition;
|
|
|
|
|
2012-02-15 17:50:00 -05:00
|
|
|
Vector3f m_Rot;
|
2011-10-03 14:41:19 -04:00
|
|
|
bool m_bDirtyOrientation;
|
|
|
|
|
|
|
|
bool m_bDestroyed;
|
2011-11-02 16:19:57 -04:00
|
|
|
bool m_bRemovedFromChunk;
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
ENUM_ENTITY_TYPE m_EntityType;
|
2012-02-13 16:47:03 -05:00
|
|
|
|
2011-10-30 20:52:20 -04:00
|
|
|
cWorld* m_World;
|
2011-10-03 14:41:19 -04:00
|
|
|
}; //tolua_export
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
typedef std::list<cEntity *> cEntityList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|