82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
//================= Copyright kotofyt, All rights reserved ==================//
|
|
//
|
|
// Purpose:
|
|
//
|
|
//===========================================================================//
|
|
|
|
#ifndef BASEENTITY_H
|
|
#define BASEENTITY_H
|
|
|
|
#include "entitysystem.h"
|
|
#include "datamap.h"
|
|
#include "cglm/cglm.h"
|
|
#include "trig.h"
|
|
|
|
#define DECLARE_CLASS_NOBASE( className ) \
|
|
typedef className ThisClass;
|
|
#define DECLARE_CLASS( className, baseName ) \
|
|
typedef baseName BaseClass; \
|
|
typedef className ThisClass;
|
|
|
|
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
|
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName );
|
|
|
|
class C_BaseEntity;
|
|
|
|
class IEntityFactory
|
|
{
|
|
public:
|
|
virtual C_BaseEntity *Create() = 0;
|
|
};
|
|
|
|
|
|
template<class T>
|
|
class CEntityFactory : public IEntityFactory
|
|
{
|
|
public:
|
|
CEntityFactory( const char *szClassName )
|
|
{
|
|
EntitySystem()->RegisterEntityClass(this, szClassName);
|
|
};
|
|
virtual C_BaseEntity *Create() {
|
|
return new T;
|
|
}
|
|
};
|
|
|
|
|
|
class C_BaseEntity;
|
|
typedef void(C_BaseEntity::*fnThink)( float fTime );
|
|
class C_BaseEntity
|
|
{
|
|
public:
|
|
DECLARE_CLASS_NOBASE(C_BaseEntity);
|
|
DECLARE_DATADESC_NOBASE()
|
|
|
|
typedescription_t *FindDataByName( const char *szName );
|
|
typedescription_t *FindDataByMapName( const char *szName );
|
|
|
|
virtual ~C_BaseEntity();
|
|
virtual void Precache();
|
|
virtual void Spawn();
|
|
|
|
virtual void SetAbsAngles( float fPitch, float fYaw, float fRoll );
|
|
virtual void SetAbsOrigin( Vector origin );
|
|
virtual void SetScale( float fScale );
|
|
|
|
virtual QAngle GetAbsAngles( void );
|
|
virtual Vector GetAbsOrigin( void );
|
|
virtual float GetScale( void );
|
|
|
|
#define SetThink(fn) SetThinkImpl((fnThink)&ThisClass::fn)
|
|
virtual void SetThinkImpl( fnThink pfnThink );
|
|
virtual void SetNextThink( float fThink );
|
|
|
|
fnThink m_pfnThink = NULL;
|
|
private:
|
|
Vector m_vPosition;
|
|
Quat m_vRotation;
|
|
Vector m_vScale;
|
|
};
|
|
|
|
#endif
|