From 55ed12f8d1eb6887d348be03aee5573d44177ffb Mon Sep 17 00:00:00 2001 From: Michael Sartain Date: Thu, 2 Oct 2014 08:25:55 -0700 Subject: Updated the SDK with the latest code from the TF and HL2 branches. --- mp/src/game/server/baseentity.h | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'mp/src/game/server/baseentity.h') diff --git a/mp/src/game/server/baseentity.h b/mp/src/game/server/baseentity.h index c5843015..7261e0a8 100644 --- a/mp/src/game/server/baseentity.h +++ b/mp/src/game/server/baseentity.h @@ -83,7 +83,7 @@ class CUserCmd; class CSkyCamera; class CEntityMapData; class INextBot; - +class IHasAttributes; typedef CUtlVector< CBaseEntity* > EntityList_t; @@ -1087,49 +1087,57 @@ public: int GetHealth() const { return m_iHealth; } void SetHealth( int amt ) { m_iHealth = amt; } + float HealthFraction() const; + // Ugly code to lookup all functions to make sure they are in the table when set. #ifdef _DEBUG - void FunctionCheck( void *pFunction, const char *name ); - ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name ) - { #ifdef GNUC - COMPILE_TIME_ASSERT( sizeof(func) == 8 ); +#define ENTITYFUNCPTR_SIZE 8 #else - COMPILE_TIME_ASSERT( sizeof(func) == 4 ); +#define ENTITYFUNCPTR_SIZE 4 #endif + + void FunctionCheck( void *pFunction, const char *name ); + ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name ) + { + COMPILE_TIME_ASSERT( sizeof(func) == ENTITYFUNCPTR_SIZE ); m_pfnTouch = func; FunctionCheck( *(reinterpret_cast(&m_pfnTouch)), name ); return func; } USEPTR UseSet( USEPTR func, char *name ) { -#ifdef GNUC - COMPILE_TIME_ASSERT( sizeof(func) == 8 ); -#else - COMPILE_TIME_ASSERT( sizeof(func) == 4 ); -#endif + COMPILE_TIME_ASSERT( sizeof(func) == ENTITYFUNCPTR_SIZE ); m_pfnUse = func; FunctionCheck( *(reinterpret_cast(&m_pfnUse)), name ); return func; } ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name ) { -#ifdef GNUC - COMPILE_TIME_ASSERT( sizeof(func) == 8 ); -#else - COMPILE_TIME_ASSERT( sizeof(func) == 4 ); -#endif + COMPILE_TIME_ASSERT( sizeof(func) == ENTITYFUNCPTR_SIZE ); m_pfnBlocked = func; FunctionCheck( *(reinterpret_cast(&m_pfnBlocked)), name ); return func; } -#endif +#endif // _DEBUG + virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set ); void AppendContextToCriteria( AI_CriteriaSet& set, const char *prefix = "" ); void DumpResponseCriteria( void ); - + + // Return the IHasAttributes interface for this base entity. Removes the need for: + // dynamic_cast< IHasAttributes * >( pEntity ); + // Which is remarkably slow. + // GetAttribInterface( CBaseEntity *pEntity ) in attribute_manager.h uses + // this function, tests for NULL, and Asserts m_pAttributes == dynamic_cast. + inline IHasAttributes *GetHasAttributesInterfacePtr() const { return m_pAttributes; } + +protected: + // NOTE: m_pAttributes needs to be set in the leaf class constructor. + IHasAttributes *m_pAttributes; + private: friend class CAI_Senses; CBaseEntity *m_pLink;// used for temporary link-list operations. -- cgit v1.2.3