92 lines
1.9 KiB
C++
92 lines
1.9 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"
|
|
#include "netmap.h"
|
|
|
|
|
|
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
|
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
|
|
|
|
|
class CBaseEntity;
|
|
|
|
class IEntityFactory
|
|
{
|
|
public:
|
|
virtual CBaseEntity *Create() = 0;
|
|
};
|
|
|
|
|
|
template<class T>
|
|
class CEntityFactory : public IEntityFactory
|
|
{
|
|
public:
|
|
CEntityFactory( const char *szClassName )
|
|
{
|
|
EntitySystem()->RegisterEntityClass(this, szClassName);
|
|
};
|
|
virtual CBaseEntity *Create() {
|
|
return new T;
|
|
}
|
|
};
|
|
|
|
|
|
class CBaseEntity;
|
|
typedef void(CBaseEntity::*fnThink)( float fTime );
|
|
class CBaseEntity
|
|
{
|
|
public:
|
|
|
|
public:
|
|
DECLARE_CLASS_NOBASE(CBaseEntity);
|
|
DECLARE_DATADESC_NOBASE()
|
|
DECLARE_SERVERCLASS_NOBASE()
|
|
|
|
|
|
typedescription_t *FindDataByName( const char *szName );
|
|
typedescription_t *FindDataByMapName( const char *szName );
|
|
|
|
const char *GetClassName();
|
|
void SetNetworkOwner( uint64_t ullPlayer );
|
|
|
|
virtual ~CBaseEntity();
|
|
virtual void Precache();
|
|
virtual void Spawn();
|
|
|
|
virtual void SetAbsAngles( Quat vQuat );
|
|
virtual void SetAbsQAngles( float fPitch, float fYaw, float fRoll );
|
|
virtual void SetAbsOrigin( Vector origin );
|
|
virtual void SetScale( float fScale );
|
|
|
|
virtual QAngle GetAbsQAngles( void );
|
|
virtual Quat 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;
|
|
const char *m_szClassName = NULL;
|
|
uint64_t m_ullOwner = 0;
|
|
private:
|
|
Vector m_vPosition = {};
|
|
Quat m_vRotation = {};
|
|
Vector m_vScale = {1,1,1};
|
|
|
|
|
|
};
|
|
|
|
#endif
|