class CBaseEntity : public IServerEntity
{
public:
DECLARE_CLASS_NOBASE( CBaseEntity );
//----------------------------------------
// Class vars and functions
//----------------------------------------
static inline void Debug_Pause(bool bPause);
static inline bool Debug_IsPaused(void);
static inline void Debug_SetSteps(int nSteps);
static inline bool Debug_ShouldStep(void);
static inline bool Debug_Step(void);
static bool m_bInDebugSelect;
static int m_nDebugPlayer;
protected:
static bool m_bDebugPause; // Whether entity i/o is paused for debugging.
static int m_nDebugSteps; // Number of entity outputs to fire before pausing again.
static bool sm_bDisableTouchFuncs; // Disables PhysicsTouch and PhysicsStartTouch function calls
public:
static bool sm_bAccurateTriggerBboxChecks; // SOLID_BBOX entities do a fully accurate trigger vs bbox check when this is set
public:
// If bServerOnly is true, then the ent never goes to the client. This is used
// by logical entities.
CBaseEntity( bool bServerOnly=false );
virtual ~CBaseEntity();
// prediction system
DECLARE_PREDICTABLE();
// network data
DECLARE_SERVERCLASS();
// data description
DECLARE_DATADESC();
// memory handling
void *operator new( size_t stAllocateBlock );
void *operator new( size_t stAllocateBlock, int nBlockUse, const char *pFileName, int nLine );
void operator delete( void *pMem );
void operator delete( void *pMem, int nBlockUse, const char *pFileName, int nLine ) { operator delete(pMem); }
// Class factory
static CBaseEntity *CreatePredictedEntityByName( const char *classname, const char *module, int line, bool persist = false );
// IHandleEntity overrides.
public:
virtual void SetRefEHandle( const CBaseHandle &handle );
virtual const CBaseHandle& GetRefEHandle() const;
// IServerUnknown overrides
virtual ICollideable *GetCollideable();
virtual IServerNetworkable *GetNetworkable();
virtual CBaseEntity *GetBaseEntity();
// IServerEntity overrides.
public:
virtual void SetModelIndex( int index );
virtual int GetModelIndex( void ) const;
virtual string_t GetModelName( void ) const;
public:
// virtual methods for derived classes to override
virtual bool TestCollision( const Ray_t& ray, unsigned int mask, trace_t& trace );
virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
virtual void ComputeWorldSpaceSurroundingBox( Vector *pWorldMins, Vector *pWorldMaxs );
// non-virtual methods. Don't override these!
public:
// An inline version the game code can use
CCollisionProperty *CollisionProp();
const CCollisionProperty*CollisionProp() const;
CServerNetworkProperty *NetworkProp();
const CServerNetworkProperty *NetworkProp() const;
bool IsCurrentlyTouching( void ) const;
const Vector& GetAbsOrigin( void ) const;
const QAngle& GetAbsAngles( void ) const;
SolidType_t GetSolid() const;
int GetSolidFlags( void ) const;
int GetEFlags() const;
void SetEFlags( int iEFlags );
void AddEFlags( int nEFlagMask );
void RemoveEFlags( int nEFlagMask );
bool IsEFlagSet( int nEFlagMask ) const;
// Quick way to ask if we have a player entity as a child anywhere in our hierarchy.
void RecalcHasPlayerChildBit();
bool DoesHavePlayerChild();
bool IsTransparent() const;
void SetNavIgnore( float duration = FLT_MAX );
void ClearNavIgnore();
bool IsNavIgnored() const;
// Is the entity floating?
bool IsFloating();
// Called by physics to see if we should avoid a collision test....
virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
// Move type / move collide
MoveType_t GetMoveType() const;
MoveCollide_t GetMoveCollide() const;
void SetMoveType( MoveType_t val, MoveCollide_t moveCollide = MOVECOLLIDE_DEFAULT );
void SetMoveCollide( MoveCollide_t val );
// Returns the entity-to-world transform
matrix3x4_t &EntityToWorldTransform();
const matrix3x4_t &EntityToWorldTransform() const;
// Some helper methods that transform a point from entity space to world space + back
void EntityToWorldSpace( const Vector &in, Vector *pOut ) const;
void WorldToEntitySpace( const Vector &in, Vector *pOut ) const;
// This function gets your parent's transform. If you're parented to an attachment,
// this calculates the attachment's transform and gives you that.
//
// You must pass in tempMatrix for scratch space - it may need to fill that in and return it instead of
// pointing you right at a variable in your parent.
matrix3x4_t& GetParentToWorldTransform( matrix3x4_t &tempMatrix );
// Externalized data objects ( see sharreddefs.h for DataObjectType_t )
bool HasDataObjectType( int type ) const;
void AddDataObjectType( int type );
void RemoveDataObjectType( int type );
void *GetDataObject( int type );
void *CreateDataObject( int type );
void DestroyDataObject( int type );
void DestroyAllDataObjects( void );
// virtual methods; you can override these
public:
// Owner entity.
// FIXME: These are virtual only because of CNodeEnt
CBaseEntity *GetOwnerEntity() const;
virtual void SetOwnerEntity( CBaseEntity* pOwner );
void SetEffectEntity( CBaseEntity *pEffectEnt );
CBaseEntity *GetEffectEntity() const;
// Only CBaseEntity implements these. CheckTransmit calls the virtual ShouldTransmit to see if the
// entity wants to be sent. If so, it calls SetTransmit, which will mark any dependents for transmission too.
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
// update the global transmit state if a transmission rule changed
int SetTransmitState( int nFlag);
int GetTransmitState( void );
int DispatchUpdateTransmitState();
// Do NOT call this directly. Use DispatchUpdateTransmitState.
virtual int UpdateTransmitState();
// Entities (like ropes) use this to own the transmit state of another entity
// by forcing it to not call UpdateTransmitState.
void IncrementTransmitStateOwnedCounter();
void DecrementTransmitStateOwnedCounter();
// This marks the entity for transmission and passes the SetTransmit call to any dependents.
virtual void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
// This function finds out if the entity is in the 3D skybox. If so, it sets the EFL_IN_SKYBOX
// flag so the entity gets transmitted to all the clients.
// Entities usually call this during their Activate().
// Returns true if the entity is in the skybox (and EFL_IN_SKYBOX was set).
bool DetectInSkybox();
// Returns which skybox the entity is in
CSkyCamera *GetEntitySkybox();
bool IsSimulatedEveryTick() const;
bool IsAnimatedEveryTick() const;
void SetSimulatedEveryTick( bool sim );
void SetAnimatedEveryTick( bool anim );
public:
virtual const char *GetTracerType( void );
// returns a pointer to the entities edict, if it has one. should be removed!
inline edict_t *edict( void ) { return NetworkProp()->edict(); }
inline const edict_t *edict( void ) const { return NetworkProp()->edict(); }
inline int entindex( ) const { return m_Network.entindex(); };
inline int GetSoundSourceIndex() const { return entindex(); }
// These methods encapsulate MOVETYPE_FOLLOW, which became obsolete
void FollowEntity( CBaseEntity *pBaseEntity, bool bBoneMerge = true );
void StopFollowingEntity( ); // will also change to MOVETYPE_NONE
bool IsFollowingEntity();
CBaseEntity *GetFollowedEntity();
// initialization
virtual void Spawn( void );