encoree1996

Untitled

Dec 20th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 99.85 KB | None | 0 0
  1. //===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: A base class for the client-side representation of entities.
  4. //
  5. // This class encompasses both entities that are created on the server
  6. // and networked to the client AND entities that are created on the
  7. // client.
  8. //
  9. // $NoKeywords: $
  10. //===========================================================================//
  11.  
  12. #ifndef C_BASEENTITY_H
  13. #define C_BASEENTITY_H
  14. #ifdef _WIN32
  15. #pragma once
  16. #endif
  17.  
  18. #include "mathlib/vector.h"
  19. #include "IClientEntityInternal.h"
  20. #include "engine/IVModelRender.h"
  21. #include "client_class.h"
  22. #include "IClientShadowMgr.h"
  23. #include "ehandle.h"
  24. #include "iclientunknown.h"
  25. #include "client_thinklist.h"
  26. #if !defined( NO_ENTITY_PREDICTION )
  27. #include "predictableid.h"
  28. #endif
  29. #include "soundflags.h"
  30. #include "shareddefs.h"
  31. #include "networkvar.h"
  32. #include "sharedvar.h"
  33. #include "tier1/interpolatedvar.h"
  34. #include "collisionproperty.h"
  35. #include "particle_property.h"
  36. #include "toolframework/itoolentity.h"
  37. #include "tier0/threadtools.h"
  38. #include "vscript/ivscript.h"
  39. #include "vscript_shared.h"
  40. #include "../../public/PlayerState.h"
  41. #include "glow_outline_effect.h"
  42.  
  43. #ifndef LOG_BASEENTITY
  44. #define LOG_BASEENTITY
  45. #endif
  46.  
  47. #define SHOUTMEMBERENTITY(memberName, member) if (typeid(member) == typeid(float)) { LOG_BASEENTITY("0x%X | %s = %f (size 0x%X)", offsetof(class C_BaseEntity, member), memberName, member, sizeof(member)); printf("0x%X | %s = %f (size 0x%X)\n", offsetof(class C_BaseEntity, member), memberName, member, sizeof(member)); } else { LOG_BASEENTITY("0x%X | %s = %d (size 0x%X)", offsetof(class C_BaseEntity, member), memberName, member, sizeof(member)); printf("0x%X | %s = %d (size 0x%X)\n", offsetof(class C_BaseEntity, member), memberName, member, sizeof(member)); }
  48.  
  49. class C_Team;
  50. class IPhysicsObject;
  51. class IClientVehicle;
  52. class CPredictionCopy;
  53. class C_BasePlayer;
  54. struct studiohdr_t;
  55. class CStudioHdr;
  56. class CDamageModifier;
  57. class IRecipientFilter;
  58. class CUserCmd;
  59. struct solid_t;
  60. class ISave;
  61. class IRestore;
  62. class C_BaseAnimating;
  63. class C_BaseAnimatingOverlay;
  64. class C_AI_BaseNPC;
  65. struct EmitSound_t;
  66. class C_RecipientFilter;
  67. class CTakeDamageInfo;
  68. class C_BaseCombatCharacter;
  69. class CEntityMapData;
  70. class ConVar;
  71. class CClientAlphaProperty;
  72. struct CSoundParameters;
  73.  
  74. typedef unsigned int AimEntsListHandle_t;
  75.  
  76. #ifndef AI_CriteriaSet
  77. #define AI_CriteriaSet ResponseRules::CriteriaSet
  78. #endif
  79. namespace ResponseRules
  80. {
  81. class CriteriaSet;
  82. class IResponseSystem;
  83. };
  84. using ResponseRules::IResponseSystem;
  85.  
  86. #define INVALID_AIMENTS_LIST_HANDLE (AimEntsListHandle_t)~0
  87.  
  88. extern void RecvProxy_LocalVelocity( const CRecvProxyData *pData, void *pStruct, void *pOut );
  89.  
  90. enum CollideType_t
  91. {
  92. ENTITY_SHOULD_NOT_COLLIDE = 0,
  93. ENTITY_SHOULD_COLLIDE,
  94. ENTITY_SHOULD_RESPOND
  95. };
  96.  
  97. class VarMapEntry_t
  98. {
  99. public:
  100. unsigned short type;
  101. unsigned short m_bNeedsToInterpolate; // Set to false when this var doesn't
  102. // need Interpolate() called on it anymore.
  103. void *data;
  104. IInterpolatedVar *watcher;
  105. };
  106.  
  107. struct VarMapping_t
  108. {
  109. VarMapping_t( )
  110. {
  111. m_nInterpolatedEntries = 0;
  112. }
  113.  
  114. CUtlVector< VarMapEntry_t > m_Entries;
  115. int m_nInterpolatedEntries;
  116. float m_lastInterpolationTime;
  117. };
  118.  
  119.  
  120.  
  121. #define DECLARE_INTERPOLATION()
  122.  
  123.  
  124. // How many data slots to use when in multiplayer.
  125. #define MULTIPLAYER_BACKUP 150
  126.  
  127.  
  128. struct serialentity_t;
  129.  
  130. typedef CHandle<C_BaseEntity> EHANDLE; // The client's version of EHANDLE.
  131.  
  132. typedef void ( C_BaseEntity::*BASEPTR )( void );
  133. typedef void ( C_BaseEntity::*ENTITYFUNCPTR )( C_BaseEntity *pOther );
  134.  
  135. // For entity creation on the client
  136. typedef C_BaseEntity* ( *DISPATCHFUNCTION )( void );
  137.  
  138. #include "touchlink.h"
  139. #include "groundlink.h"
  140.  
  141. #if !defined( NO_ENTITY_PREDICTION ) && defined( USE_PREDICTABLEID )
  142. //-----------------------------------------------------------------------------
  143. // Purpose: For fully client side entities we use this information to determine
  144. // authoritatively if the server has acknowledged creating this entity, etc.
  145. //-----------------------------------------------------------------------------
  146. struct PredictionContext
  147. {
  148. PredictionContext( )
  149. {
  150. m_bActive = false;
  151. m_nCreationCommandNumber = -1;
  152. m_pszCreationModule = NULL;
  153. m_nCreationLineNumber = 0;
  154. m_hServerEntity = NULL;
  155. }
  156.  
  157. // The command_number of the usercmd which created this entity
  158. bool m_bActive;
  159. int m_nCreationCommandNumber;
  160. char const *m_pszCreationModule;
  161. int m_nCreationLineNumber;
  162. // The entity to whom we are attached
  163. CHandle< C_BaseEntity > m_hServerEntity;
  164. };
  165. #endif
  166.  
  167. //-----------------------------------------------------------------------------
  168. // Purpose: think contexts
  169. //-----------------------------------------------------------------------------
  170. struct thinkfunc_t
  171. {
  172. BASEPTR m_pfnThink;
  173. string_t m_iszContext;
  174. int m_nNextThinkTick;
  175. int m_nLastThinkTick;
  176. };
  177.  
  178. #define CREATE_PREDICTED_ENTITY( className ) C_BaseEntity::CreatePredictedEntityByName( className, __FILE__, __LINE__ );
  179.  
  180.  
  181. // Entity flags that only exist on the client.
  182. #define ENTCLIENTFLAG_GETTINGSHADOWRENDERBOUNDS 0x0001 // Tells us if we're getting the real ent render bounds or the shadow render bounds.
  183. #define ENTCLIENTFLAG_DONTUSEIK 0x0002 // Don't use IK on this entity even if its model has IK.
  184. #define ENTCLIENTFLAG_ALWAYS_INTERPOLATE 0x0004 // Used by view models.
  185.  
  186. enum entity_list_ids_t
  187. {
  188. ENTITY_LIST_INTERPOLATE = 0,
  189. ENTITY_LIST_TELEPORT,
  190. ENTITY_LIST_PRERENDER,
  191. ENTITY_LIST_SIMULATE,
  192. ENTITY_LIST_DELETE,
  193. NUM_ENTITY_LISTS
  194. };
  195.  
  196. //-----------------------------------------------------------------------------
  197. // Purpose: Base client side entity object
  198. //-----------------------------------------------------------------------------
  199. class C_BaseEntity : public IClientEntity
  200. {
  201. public:
  202. DECLARE_CLASS_NOBASE( C_BaseEntity );
  203. //friend class CPrediction;
  204. //friend void cc_cl_interp_all_changed(IConVar *pConVar, const char *pOldString, float flOldValue);
  205.  
  206. DECLARE_DATADESC( );
  207. //DECLARE_CLIENTCLASS();
  208. //DECLARE_PREDICTABLE();
  209. //DECLARE_ENT_SCRIPTDESC();
  210.  
  211. C_BaseEntity( );
  212.  
  213. protected:
  214. ~C_BaseEntity( );
  215.  
  216. public:
  217. //static C_BaseEntity *CreatePredictedEntityByName(const char *classname, const char *module, int line, bool persist = false);
  218. //static void UpdateVisibilityAllEntities();
  219. ////virtual void ModifyOrAppendCriteria(AI_CriteriaSet& set);
  220. //// FireBullets uses shared code for prediction.
  221. //virtual void FireBullets(const FireBulletsInfo_t &info);
  222. //virtual bool ShouldDrawUnderwaterBulletBubbles();
  223. //virtual bool ShouldDrawWaterImpacts(void) { return true; }
  224. //virtual bool HandleShotImpactingWater(const FireBulletsInfo_t &info, const Vector &vecEnd, ITraceFilter *pTraceFilter, Vector *pVecTracerDest);
  225. //virtual ITraceFilter* GetBeamTraceFilter(void);
  226. //virtual void DispatchTraceAttack(const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr);
  227. //virtual void TraceAttack(const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr);
  228. //virtual void DoImpactEffect(trace_t &tr, int nDamageType);
  229. //virtual void MakeTracer(const Vector &vecTracerSrc, const trace_t &tr, int iTracerType);
  230. //virtual int GetTracerAttachment(void);
  231. //void ComputeTracerStartPosition(const Vector &vecShotSrc, Vector *pVecTracerStart);
  232. //void TraceBleed(float flDamage, const Vector &vecDir, trace_t *ptr, int bitsDamageType);
  233. //virtual int BloodColor();
  234. //virtual const char* GetTracerType();
  235.  
  236. // called when entity is damaged by predicted attacks
  237. //virtual void TakeDamage(const CTakeDamageInfo &info) { }
  238. //virtual void Spawn(void);
  239. //virtual void SpawnClientEntity(void);
  240. //virtual void Precache(void);
  241. //virtual void Activate();
  242. //void ParseMapData(CEntityMapData *mapData);
  243. //virtual void OnParseMapDataFinished();
  244. //virtual bool KeyValue(const char *szKeyName, const char *szValue);
  245. //virtual bool KeyValue(const char *szKeyName, float flValue);
  246. //virtual bool KeyValue(const char *szKeyName, int nValue);
  247. //virtual bool KeyValue(const char *szKeyName, const Vector &vecValue);
  248. //virtual bool GetKeyValue(const char *szKeyName, char *szValue, int iMaxLen);
  249. //virtual void InitSharedVars();
  250. //virtual void Init(int, int);
  251.  
  252. // Entities block Line-Of-Sight for NPCs by default.
  253. // Set this to false if you want to change this behavior.
  254. //void SetBlocksLOS(bool bBlocksLOS);
  255. //bool BlocksLOS(void);
  256. //void SetAIWalkable(bool bBlocksLOS);
  257. //bool IsAIWalkable(void);
  258.  
  259. public:
  260. void SetRefEHandle( const CBaseHandle &handle ) { m_RefEHandle = handle; };
  261. const CBaseHandle& GetRefEHandle( ) const { return m_RefEHandle; };
  262. ICollideable* GetCollideable( ) { return &m_Collision; }
  263. IClientNetworkable* GetClientNetworkable( ) { return (IClientNetworkable*)( this + 0x8 ); }
  264. IClientRenderable* GetClientRenderable( ) { return (IClientRenderable*)( this + 0x4 ); }
  265. IClientEntity* GetIClientEntity( ) { return this; }
  266. C_BaseEntity* GetBaseEntity( ) { return this; }
  267. IClientThinkable* GetClientThinkable( ) { return (IClientThinkable*)( this + 0xC ); }
  268. IClientAlphaProperty* GetClientAlphaProperty( ) { return m_pClientAlphaProperty; }
  269.  
  270. protected:
  271. void Release( ) { }
  272.  
  273. public:
  274. //later usage
  275. //Vector GetEyeAngles( );
  276. bool IsUsingAntiAim( );
  277. const Vector& GetAbsOrigin( void ) const { return m_vecAbsOrigin; };
  278. const QAngle& GetAbsAngles( void ) const { return m_angRotation; };
  279.  
  280. class CMouthInfo* GetMouth( void ) { return NULL; };
  281. bool GetSoundSpatialization( SpatializationInfo_t& info ) { return false; }
  282. bool IsBlurred( void ) { return m_bIsBlurred; }
  283. //virtual void InitSharedVars(void) {};
  284. void Interp_SetupMappings( VarMapping_t *map );
  285.  
  286. // Returns 1 if there are no more changes (ie: we could call RemoveFromInterpolationList).
  287. int Interp_Interpolate( VarMapping_t *map, float currentTime );
  288. void Interp_RestoreToLastNetworked( VarMapping_t *map );
  289. void Interp_UpdateInterpolationAmounts( VarMapping_t *map );
  290. void Interp_HierarchyUpdateInterpolationAmounts( );
  291. // Called by the CLIENTCLASS macros.
  292. //virtual bool Init(int entnum, int iSerialNum);
  293.  
  294. // Called in the destructor to shutdown everything.
  295. void Term( );
  296.  
  297. // memory handling, uses calloc so members are zero'd out on instantiation
  298. void *operator new( size_t stAllocateBlock );
  299. void *operator new [ ]( size_t stAllocateBlock );
  300. void *operator new( size_t stAllocateBlock, int nBlockUse, const char *pFileName, int nLine );
  301. void *operator new [ ]( size_t stAllocateBlock, int nBlockUse, const char *pFileName, int nLine );
  302. void operator delete( void *pMem );
  303. void operator delete( void *pMem, int nBlockUse, const char *pFileName, int nLine ) { operator delete( pMem ); }
  304.  
  305.  
  306. // This just picks one of the routes to IClientUnknown.
  307. virtual IClientUnknown* GetIClientUnknown( ) { return this; }
  308. virtual C_BaseAnimating* GetBaseAnimating( ) { return ( C_BaseAnimating* )this; }
  309. virtual C_BaseAnimatingOverlay* GetBaseAnimatingOverlay( ) { return ( C_BaseAnimatingOverlay* )this; };
  310. virtual void SetClassname( const char *className );
  311. virtual Class_T Classify( ) { return CLASS_NONE; }
  312. HSCRIPT GetScriptInstance( );
  313.  
  314. // IClientUnknown overrides.
  315. public:
  316. void SetToolHandle( HTOOLHANDLE handle );
  317. HTOOLHANDLE GetToolHandle( ) const;
  318. void EnableInToolView( bool bEnable );
  319. bool IsEnabledInToolView( ) const;
  320. void SetToolRecording( bool recording );
  321. bool IsToolRecording( ) const;
  322. bool HasRecordedThisFrame( ) const;
  323. virtual void RecordToolMessage( );
  324. virtual void OnToolStartRecording( );
  325. // used to exclude entities from being recorded in the SFM tools
  326. void DontRecordInTools( );
  327. bool ShouldRecordInTools( ) const;
  328. virtual ResponseRules::IResponseSystem *GetResponseSystem( );
  329.  
  330. public:
  331. virtual IClientModelRenderable* GetClientModelRenderable( ) { return (IClientModelRenderable*)( ( DWORD )this + 0x4 ); }// (PVOID)(this + 0x4); }
  332.  
  333. // Methods of IClientRenderable
  334. virtual const Vector& GetRenderOrigin( void );
  335. virtual const QAngle& GetRenderAngles( void );
  336. virtual Vector GetObserverCamOrigin( void ) { return GetRenderOrigin( ); } // Return the origin for player observers tracking this target
  337. virtual const matrix3x4_t & RenderableToWorldTransform( );
  338. virtual bool IsTransparent( void );
  339. virtual int GetRenderFlags( void );
  340. virtual const model_t* GetModel( void ) const { return model; }
  341. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  342. virtual bool LODTest( ) { return true; } // NOTE: UNUSED
  343. virtual void GetRenderBounds( Vector& mins, Vector& maxs );
  344. virtual IPVSNotify* GetPVSNotifyInterface( );
  345. virtual void GetRenderBoundsWorldspace( Vector& absMins, Vector& absMaxs );
  346. virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
  347. virtual void GetColorModulation( float* color ); // Determine the color modulation amount
  348. virtual void OnThreadedDrawSetup( ) { }
  349.  
  350. public:
  351. virtual bool TestCollision( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
  352. virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
  353.  
  354. // To mimic server call convention
  355. C_BaseEntity* GetOwnerEntity( void ) const;
  356. void SetOwnerEntity( C_BaseEntity *pOwner );
  357. C_BaseEntity* GetEffectEntity( void ) const;
  358. void SetEffectEntity( C_BaseEntity *pEffectEnt );
  359. bool IsAbleToHaveFireEffect( void ) const;
  360. // This function returns a value that scales all damage done by this entity.
  361. // Use CDamageModifier to hook in damage modifiers on a guy.
  362. virtual float GetAttackDamageScale( void );
  363.  
  364. // IClientNetworkable implementation.
  365. public:
  366. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  367. // save out interpolated values
  368. virtual void PreDataUpdate( DataUpdateType_t updateType );
  369. virtual void PostDataUpdate( DataUpdateType_t updateType );
  370. virtual void OnDataUnchangedInPVS( void );
  371. virtual void ValidateModelIndex( void );
  372. // pvs info. NOTE: Do not override these!!
  373. virtual void SetDormant( bool bDormant );
  374. virtual bool IsDormant( void );
  375. virtual void OnSetDormant( bool bDormant ) { }
  376.  
  377. // Tells the entity that it's about to be destroyed due to the client receiving
  378. // an uncompressed update that's caused it to destroy all entities & recreate them.
  379. virtual void SetDestroyedOnRecreateEntities( void );
  380. virtual int GetEFlags( ) const;
  381. virtual void SetEFlags( int iEFlags );
  382. void AddEFlags( int nEFlagMask );
  383. void RemoveEFlags( int nEFlagMask );
  384. bool IsEFlagSet( int nEFlagMask ) const;
  385. // checks to see if the entity is marked for deletion
  386. bool IsMarkedForDeletion( void );
  387. virtual int entindex( void ) const;
  388. // This works for client-only entities and returns the GetEntryIndex() of the entity's handle,
  389. // so the sound system can get an IClientEntity from it.
  390. int GetSoundSourceIndex( ) const;
  391. // Server to client message received
  392. virtual void ReceiveMessage( int classID, bf_read &msg );
  393. virtual void* GetDataTableBasePtr( );
  394.  
  395. // IClientThinkable.
  396. public:
  397. virtual void ClientThink( );
  398. virtual ClientThinkHandle_t GetThinkHandle( );
  399. virtual void SetThinkHandle( ClientThinkHandle_t hThink );
  400.  
  401. public:
  402. void AddVar( void *data, IInterpolatedVar *watcher, int type, bool bSetup = false );
  403. void RemoveVar( void *data, bool bAssert = true );
  404. VarMapping_t* GetVarMapping( );
  405.  
  406. public:
  407. CCollisionProperty* CollisionProp( ); // An inline version the game code can use
  408. const CCollisionProperty* CollisionProp( ) const;
  409. CParticleProperty* ParticleProp( );
  410. const CParticleProperty* ParticleProp( ) const;
  411. CClientAlphaProperty* AlphaProp( );
  412. const CClientAlphaProperty* AlphaProp( ) const;
  413. // Simply here for game shared
  414. bool IsFloating( );
  415. virtual bool ShouldSavePhysics( );
  416. // save/restore stuff
  417. virtual void OnSave( );
  418. virtual void OnRestore( );
  419. // capabilities for save/restore
  420. virtual int ObjectCaps( void );
  421. // only overload these if you have special data to serialize
  422. virtual int Save( ISave &save );
  423. virtual int Restore( IRestore &restore );
  424.  
  425. private:
  426. int SaveDataDescBlock( ISave &save, datamap_t *dmap );
  427. int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
  428. // Called after spawn, and in the case of self-managing objects, after load
  429. virtual bool CreateVPhysics( );
  430. // Convenience routines to init the vphysics simulation for this object.
  431. // This creates a static object. Something that behaves like world geometry - solid, but never moves
  432. IPhysicsObject* VPhysicsInitStatic( void );
  433. // This creates a normal vphysics simulated object
  434. IPhysicsObject* VPhysicsInitNormal( SolidType_t solidType, int nSolidFlags, bool createAsleep, solid_t *pSolid = NULL );
  435. // This creates a vphysics object with a shadow controller that follows the AI
  436. // Move the object to where it should be and call UpdatePhysicsShadowToCurrentPosition()
  437. IPhysicsObject* VPhysicsInitShadow( bool allowPhysicsMovement, bool allowPhysicsRotation, solid_t *pSolid = NULL );
  438.  
  439. private:
  440. // called by all vphysics inits
  441. bool VPhysicsInitSetup( );
  442.  
  443. public:
  444. void VPhysicsSetObject( IPhysicsObject *pPhysics );
  445. // destroy and remove the physics object for this entity
  446. virtual void VPhysicsDestroyObject( void );
  447. // Purpose: My physics object has been updated, react or extract data
  448. virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
  449. virtual void VPhysicsShadowUpdate( IPhysicsObject *pPhysics );
  450. inline IPhysicsObject* VPhysicsGetObject( void ) const { return m_pPhysicsObject; }
  451. virtual int VPhysicsGetObjectList( IPhysicsObject **pList, int listMax );
  452. virtual bool VPhysicsIsFlesh( void );
  453. virtual void VPhysicsCompensateForPredictionErrors( uchar const* );
  454.  
  455. // IClientEntity implementation.
  456. public:
  457. virtual bool SetupBones( matrix3x4a_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime );
  458. virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
  459. virtual bool UsesFlexDelayedWeights( ) { return false; }
  460. virtual void DoAnimationEvents( void ); // see also GetVectors()
  461. inline Vector Forward( ) const; ///< get my forward (+x) vector
  462. inline Vector Left( ) const; ///< get my left (+y) vector
  463. inline Vector Up( ) const; ///< get my up (+z) vector
  464. const Vector& GetNetworkOrigin( ) const;
  465. const QAngle& GetNetworkAngles( ) const;
  466. void SetNetworkOrigin( const Vector& org );
  467. void SetNetworkAngles( const QAngle& ang );
  468. const Vector& GetLocalOrigin( void ) const;
  469. void SetLocalOrigin( const Vector& origin );
  470. vec_t GetLocalOriginDim( int iDim ) const; // You can use the X_INDEX, Y_INDEX, and Z_INDEX defines here.
  471. void SetLocalOriginDim( int iDim, vec_t flValue );
  472. const QAngle& GetLocalAngles( void ) const;
  473. void SetLocalAngles( const QAngle& angles );
  474. vec_t GetLocalAnglesDim( int iDim ) const; // You can use the X_INDEX, Y_INDEX, and Z_INDEX defines here.
  475. void SetLocalAnglesDim( int iDim, vec_t flValue );
  476. virtual const Vector& GetPrevLocalOrigin( ) const;
  477. virtual const QAngle& GetPrevLocalAngles( ) const;
  478. virtual void Teleport( const Vector*, const QAngle*, const Vector* );
  479. void SetLocalTransform( const matrix3x4_t &localTransform );
  480. void SetModelName( string_t name );
  481. string_t GetModelName( void ) const;
  482. int GetModelIndex( void ) const { return m_nModelIndex; };
  483. virtual void SetModelIndex( int index );
  484. // These methods return a *world-aligned* box relative to the absorigin of the entity.
  485. // This is used for collision purposes and is *not* guaranteed
  486. // to surround the entire entity's visual representation
  487. // NOTE: It is illegal to ask for the world-aligned bounds for
  488. // SOLID_BSP objects
  489. virtual const Vector& WorldAlignMins( ) const;
  490. virtual const Vector& WorldAlignMaxs( ) const;
  491. // This defines collision bounds *in whatever space is currently defined by the solid type*
  492. // SOLID_BBOX: World Align
  493. // SOLID_OBB: Entity space
  494. // SOLID_BSP: Entity space
  495. // SOLID_VPHYSICS Not used
  496. void SetCollisionBounds( const Vector& mins, const Vector &maxs );
  497. // NOTE: These use the collision OBB to compute a reasonable center point for the entity
  498. virtual const Vector& WorldSpaceCenter( ) const;
  499. // FIXME: Do we want this?
  500. const Vector& WorldAlignSize( ) const;
  501. bool IsPointSized( ) const;
  502. // Returns a radius of a sphere
  503. // *centered at the world space center* bounding the collision representation
  504. // of the entity. NOTE: The world space center *may* move when the entity rotates.
  505. float BoundingRadius( ) const;
  506. // Used when the collision prop is told to ask game code for the world-space surrounding box
  507. virtual void ComputeWorldSpaceSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs );
  508. // Returns the entity-to-world transform
  509. matrix3x4_t& EntityToWorldTransform( );
  510. const matrix3x4_t& EntityToWorldTransform( ) const;
  511. // Some helper methods that transform a point from entity space to world space + back
  512. void EntityToWorldSpace( const Vector &in, Vector *pOut ) const;
  513. void WorldToEntitySpace( const Vector &in, Vector *pOut ) const;
  514. // This function gets your parent's transform. If you're parented to an attachment,
  515. // this calculates the attachment's transform and gives you that.
  516. // You must pass in tempMatrix for scratch space - it may need to fill that in and return it instead of
  517. // pointing you right at a variable in your parent.
  518. matrix3x4_t& GetParentToWorldTransform( matrix3x4_t &tempMatrix );
  519. virtual void GetVectors( Vector* forward, Vector* right, Vector* up ) const;
  520. // Sets abs angles, but also sets local angles to be appropriate
  521. void SetAbsOrigin( const Vector& origin );
  522. void SetAbsAngles( const QAngle& angles );
  523. void AddFlag( int flags );
  524. void RemoveFlag( int flagsToRemove );
  525. int GetHealth( );
  526.  
  527. char GetLifeState( );
  528. int GetTeamNum( );
  529.  
  530. int GetFlags( );
  531. float GetFallVelocity( );
  532. Vector GetBaseVelocity( );
  533. Vector GetNetworkedOrigin( );
  534. Vector GetVecViewOffset( );
  535. Vector GetEyePosition( );
  536.  
  537. Vector GetPunchAngle( );
  538.  
  539. Vector GetVelocity( );
  540.  
  541. int GetTickBase( );
  542.  
  543. bool isValidPlayer( )
  544. {
  545. return ( GetLifeState( ) == LIFE_ALIVE && !IsDormant( ) );
  546. }
  547.  
  548. void ToggleFlag( int flagToToggle );
  549. int GetFlags( void ) const;
  550. void ClearFlags( );
  551. void SetDistanceFade( float flMinDist, float flMaxDist );
  552. void SetGlobalFadeScale( float flFadeScale );
  553. float GetMinFadeDist( ) const;
  554. float GetMaxFadeDist( ) const;
  555. float GetGlobalFadeScale( ) const;
  556. MoveType_t GetMoveType( void ) const;
  557. MoveCollide_t GetMoveCollide( void ) const;
  558. virtual SolidType_t GetSolid( void ) const;
  559. virtual int GetSolidFlags( void ) const;
  560. bool IsSolidFlagSet( int flagMask ) const;
  561. void SetSolidFlags( int nFlags );
  562. void AddSolidFlags( int nFlags );
  563. void RemoveSolidFlags( int nFlags );
  564. bool IsSolid( ) const;
  565. // Attachments
  566. virtual int LookupAttachment( const char *pAttachmentName ) { return -1; }
  567. virtual bool GetAttachment( int number, matrix3x4_t &matrix );
  568. virtual bool GetAttachment( int number, Vector &origin );
  569. virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
  570. virtual void ComputeLightingOrigin( int, Vector, const matrix3x4_t&, Vector& );
  571. virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
  572. virtual void InvalidateAttachments( ) { }
  573.  
  574. // Team handling
  575. virtual C_Team* GetTeam( void );
  576. virtual int GetTeamNumber( void ) const;
  577. virtual int GetPendingTeamNumber( void ) const;
  578. virtual void ChangeTeam( int iTeamNum ); // Assign this entity to a team.
  579. virtual int GetRenderTeamNumber( void );
  580. virtual bool InSameTeam( C_BaseEntity *pEntity ); // Returns true if the specified entity is on the same team as this one
  581. virtual bool InLocalTeam( void );
  582.  
  583. // ID Target handling
  584. virtual bool IsValidIDTarget( void );
  585. virtual char* GetIDString( void ) { return ""; };
  586. bool is_valid( );
  587. // See CSoundEmitterSystem
  588. void EmitSound( const char *soundname, float soundtime = 0.0f, float *duration = NULL ); // Override for doing the general case of CPASAttenuationFilter( this ), and EmitSound( filter, entindex(), etc. );
  589. void EmitSound( const char *soundname, HSOUNDSCRIPTHANDLE& handle, float soundtime = 0.0f, float *duration = NULL ); // Override for doing the general case of CPASAttenuationFilter( this ), and EmitSound( filter, entindex(), etc. );
  590. void StopSound( const char *soundname );
  591. void StopSound( const char *soundname, HSOUNDSCRIPTHANDLE& handle );
  592. void GenderExpandString( char const *in, char *out, int maxlen );
  593. // All statics
  594. static float GetSoundDuration( const char *soundname, char const *actormodel );
  595. static bool GetParametersForSound( const char *soundname, CSoundParameters &params, const char *actormodel );
  596. static bool GetParametersForSound( const char *soundname, HSOUNDSCRIPTHANDLE& handle, CSoundParameters &params, const char *actormodel );
  597. static void EmitSound( IRecipientFilter& filter, int iEntIndex, const char *soundname, const Vector *pOrigin = NULL, float soundtime = 0.0f, float *duration = NULL );
  598. static void EmitSound( IRecipientFilter& filter, int iEntIndex, const char *soundname, HSOUNDSCRIPTHANDLE& handle, const Vector *pOrigin = NULL, float soundtime = 0.0f, float *duration = NULL );
  599. static void StopSound( int iEntIndex, const char *soundname );
  600. static soundlevel_t LookupSoundLevel( const char *soundname );
  601. static soundlevel_t LookupSoundLevel( const char *soundname, HSOUNDSCRIPTHANDLE& handle );
  602. static void EmitSound( IRecipientFilter& filter, int iEntIndex, const EmitSound_t & params );
  603. static void EmitSound( IRecipientFilter& filter, int iEntIndex, const EmitSound_t & params, HSOUNDSCRIPTHANDLE& handle );
  604. static void StopSound( int iEntIndex, int iChannel, const char *pSample, bool bIsStoppingSpeakerSound = false );
  605. static void EmitAmbientSound( int entindex, const Vector& origin, const char *soundname, int flags = 0, float soundtime = 0.0f, float *duration = NULL );
  606. // These files need to be listed in scripts/game_sounds_manifest.txt
  607. static HSOUNDSCRIPTHANDLE PrecacheScriptSound( const char *soundname );
  608. static void PrefetchScriptSound( const char *soundname );
  609. // For each client who appears to be a valid recipient, checks the client has disabled CC and if so, removes them from
  610. // the recipient list.
  611. static void RemoveRecipientsIfNotCloseCaptioning( C_RecipientFilter& filter );
  612. static void EmitCloseCaption( IRecipientFilter& filter, int entindex, char const *token, CUtlVector< Vector >& soundorigins, float duration, bool warnifmissing = false );
  613. // Moves all aiments into their correct position for the frame
  614. static void MarkAimEntsDirty( );
  615. static void CalcAimEntPositions( );
  616. static bool IsPrecacheAllowed( );
  617. static void SetAllowPrecache( bool allow );
  618. static bool m_bAllowPrecache;
  619. static bool IsSimulatingOnAlternateTicks( );
  620. static bool sm_bAccurateTriggerBboxChecks; // SOLID_BBOX entities do a fully accurate trigger vs bbox check when this is set
  621.  
  622. // C_BaseEntity local functions
  623. public:
  624. virtual void UpdatePartitionListEntry( );
  625. // This can be used to setup the entity as a client-only entity.
  626. // Override this to perform per-entity clientside setup
  627. virtual bool InitializeAsClientEntity( const char *pszModelName, bool bRenderWithViewModels );
  628. // This function gets called on all client entities once per simulation phase. If the entity
  629. // is in the simulate list. It dispatches events like OnDataChanged()
  630. // return false if this entity no longer needs to simulate, true otherwise
  631. virtual bool Simulate( ) { return false; }
  632. // This event is triggered during the simulation phase if an entity's data has changed. It is
  633. // better to hook this instead of PostDataUpdate() because in PostDataUpdate(), server entity origins
  634. // are incorrect and attachment points can't be used.
  635. virtual void OnDataChanged( DataUpdateType_t type );
  636. // This is called once per frame before any data is read in from the server.
  637. virtual void OnPreDataChanged( DataUpdateType_t type );
  638. bool IsStandable( ) const;
  639. bool IsBSPModel( ) const;
  640. // If this is a vehicle, returns the vehicle interface
  641. virtual IClientVehicle* GetClientVehicle( ) { return NULL; }
  642. // Returns the aiment render origin + angles
  643. virtual void GetAimEntOrigin( IClientEntity *pAttachedTo, Vector *pAbsOrigin, QAngle *pAbsAngles );
  644. // get network origin from previous update
  645. virtual const Vector& GetOldOrigin( );
  646. // Methods relating to traversing hierarchy
  647. C_BaseEntity* GetMoveParent( void ) const;
  648. C_BaseEntity* GetRootMoveParent( );
  649. C_BaseEntity* FirstMoveChild( void ) const;
  650. C_BaseEntity* NextMovePeer( void ) const;
  651. inline ClientEntityHandle_t GetClientHandle( ) const { return ClientEntityHandle_t( m_RefEHandle ); }
  652. inline bool IsServerEntity( void );
  653. void RenderWithViewModels( bool bEnable );
  654. bool IsRenderingWithViewModels( ) const;
  655. void DisableCachedRenderBounds( bool bDisabled );
  656. bool IsCachedRenderBoundsDisabled( ) const;
  657. // NOTE: The goal of this function is different from IsTranslucent().
  658. // Here, we need to determine whether a renderable is inherently translucent
  659. // when run-time alpha modulation or any other game code is not taken into account
  660. virtual RenderableTranslucencyType_t ComputeTranslucencyType( );
  661. virtual uint8 OverrideAlphaModulation( uint8 nAlpha ) { return nAlpha; }
  662. virtual uint8 OverrideShadowAlphaModulation( uint8 nAlpha ) { return nAlpha; }
  663. // Client code should call this under any circumstances where translucency type may change
  664. void OnTranslucencyTypeChanged( );
  665. // Client code should call this under any circumstances where splitscreen rendering may change
  666. void OnSplitscreenRenderingChanged( );
  667. virtual void GetToolRecordingState( KeyValues *msg );
  668. virtual void CleanupToolRecordingState( KeyValues *msg );
  669. // The value returned by here determines whether or not (and how) the entity
  670. // is put into the spatial partition.
  671. virtual CollideType_t GetCollideType( void );
  672. virtual bool ShouldDraw( );
  673. virtual bool ShouldSuppressForSplitScreenPlayer( int index );
  674. inline bool IsVisible( ) const;
  675. inline bool IsVisibleToAnyPlayer( ) const;
  676. void UpdateVisibility( );
  677. // Returns true if the entity changes its position every frame on the server but it doesn't
  678. // set animtime. In that case, the client returns true here so it copies the server time to
  679. // animtime in OnDataChanged and the position history is correct for interpolation.
  680. virtual bool IsSelfAnimating( );
  681. // Set appropriate flags and store off data when these fields are about to change
  682. virtual void OnLatchInterpolatedVariables( int flags );
  683. // For predictable entities, stores last networked value
  684. void OnStoreLastNetworkedValue( );
  685. // Initialize things given a new model.
  686. virtual CStudioHdr* OnNewModel( );
  687. virtual void OnNewParticleEffect( const char *pszParticleName, CNewParticleEffect *pNewParticleEffect );
  688. virtual void OnParticleEffectDeleted( CNewParticleEffect *pParticleEffect );
  689. bool IsSimulatedEveryTick( ) const;
  690. bool IsAnimatedEveryTick( ) const;
  691. void SetSimulatedEveryTick( bool sim );
  692. void SetAnimatedEveryTick( bool anim );
  693. void Interp_Reset( VarMapping_t *map );
  694. virtual void ResetLatched( );
  695. //virtual float GetInterpolationAmount(int flags);
  696. float GetLastChangeTime( int flags );
  697. // Interpolate the position for rendering
  698. virtual bool Interpolate( float currentTime );
  699. // Did the object move so far that it shouldn't interpolate?
  700. bool Teleported( void );
  701. // Is this a submodel of the world ( *1 etc. in name ) ( brush models only )
  702. virtual bool IsSubModel( void );
  703. // Deal with EF_* flags
  704. virtual bool CreateLightEffects( void );
  705. void AddToAimEntsList( );
  706. void RemoveFromAimEntsList( );
  707. // Reset internal fields
  708. virtual void Clear( void );
  709. // Helper to draw raw brush models
  710. virtual int DrawBrushModel( bool bSort, bool bShadowDepth );
  711. // returns the material animation start time
  712. virtual float GetTextureAnimationStartTime( );
  713. // Indicates that a texture animation has wrapped
  714. virtual void TextureAnimationWrapped( );
  715. // Set the next think time. Pass in CLIENT_THINK_ALWAYS to have Think() called each frame.
  716. virtual void SetNextClientThink( float nextThinkTime );
  717. // anything that has health can override this...
  718. virtual void SetHealth( int iHealth ) { }
  719. virtual int GetHealth( ) const { return 0; }
  720. virtual int GetMaxHealth( ) const { return 1; }
  721.  
  722. // Returns the health fraction
  723. float HealthFraction( ) const;
  724. // Should this object cast shadows?
  725. virtual ShadowType_t ShadowCastType( );
  726. // Should this object receive shadows?
  727. virtual bool ShouldReceiveProjectedTextures( int flags );
  728. // Shadow-related methods
  729. virtual bool IsShadowDirty( );
  730. virtual void MarkShadowDirty( bool bDirty );
  731. virtual IClientRenderable* GetShadowParent( );
  732. virtual IClientRenderable* FirstShadowChild( );
  733. virtual IClientRenderable* NextShadowPeer( );
  734.  
  735. // Sets up a render handle so the leaf system will draw this entity.
  736. void AddToLeafSystem( );
  737. void AddToLeafSystem( bool bRenderWithViewModels );
  738. // remove entity form leaf system again
  739. void RemoveFromLeafSystem( );
  740.  
  741. // A method to apply a decal to an entity
  742. virtual void AddDecal( const Vector& rayStart, const Vector& rayEnd, const Vector& decalCenter, int hitbox, int decalIndex, bool doTrace, trace_t& tr, int maxLODToDecal = ADDDECAL_TO_ALL_LODS );
  743. // A method to remove all decals from an entity
  744. void RemoveAllDecals( void );
  745. // Is this a brush model?
  746. bool IsBrushModel( ) const;
  747. // A random value 0-1 used by proxies to make sure they're not all in sync
  748. float ProxyRandomValue( ) const { return m_flProxyRandomValue; }
  749. // The spawn time of this entity
  750. float SpawnTime( ) const { return m_flSpawnTime; }
  751. virtual bool IsClientCreated( void ) const;
  752. virtual void UpdateOnRemove( void );
  753. virtual void SUB_Remove( void );
  754.  
  755. // Prediction stuff
  756. void CheckInitPredictable( const char *context );
  757. virtual C_BasePlayer* GetPredictionOwner( void );
  758. void AllocateIntermediateData( void );
  759. void DestroyIntermediateData( void );
  760. void ShiftIntermediateDataForward( int slots_to_remove, int previous_last_slot );
  761. void* GetPredictedFrame( int framenumber );
  762. void* GetOriginalNetworkDataObject( void );
  763. bool IsIntermediateDataAllocated( void ) const;
  764. virtual void InitPredictable( C_BasePlayer *pOwner );
  765. void ShutdownPredictable( void );
  766. int GetSplitUserPlayerPredictionSlot( );
  767. virtual void SetPredictable( bool state );
  768. virtual void HandlePredictionError( bool state );
  769. virtual bool PredictionErrorShouldResetLatchedForAllPredictables( );
  770. virtual bool PredictionIsPhysicallySimulated( );
  771. bool GetPredictable( void ) const;
  772. void PreEntityPacketReceived( int commands_acknowledged );
  773. void PostEntityPacketReceived( void );
  774. bool PostNetworkDataReceived( int commands_acknowledged );
  775. bool GetPredictionEligible( void ) const;
  776. void SetPredictionEligible( bool canpredict );
  777. enum { SLOT_ORIGINALDATA = -1, };
  778. void SaveData( const char *context, int slot, int type );
  779. void RestoreData( const char *context, int slot, int type );
  780.  
  781. // Called after restoring data into prediction slots. This function is used in place of proxies
  782. // on the variables, so if some variable like m_nModelIndex needs to update other state (like
  783. // the model pointer), it is done here.
  784. void OnPostRestoreData( );
  785. virtual char const * DamageDecal( int bitsDamageType, int gameMaterial );
  786. virtual void DecalTrace( trace_t *pTrace, char const *decalName );
  787. virtual void ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName );
  788. virtual bool ShouldPredict( void ) { return false; };
  789. // interface function pointers
  790. void ( C_BaseEntity::*m_pfnThink )( void );
  791. virtual void Think( void ) { AssertMsg( m_pfnThink != &C_BaseEntity::Think, "Infinite recursion is infinitely bad." ); if ( m_pfnThink ) ( this->*m_pfnThink )( ); }
  792. void PhysicsDispatchThink( BASEPTR thinkFunc );
  793.  
  794. // Toggle the visualization of the entity's abs/bbox
  795. enum { VISUALIZE_COLLISION_BOUNDS = 0x1, VISUALIZE_SURROUNDING_BOUNDS = 0x2, VISUALIZE_RENDER_BOUNDS = 0x4, };
  796. void ClearBBoxVisualization( void );
  797. void ToggleBBoxVisualization( int fVisFlags );
  798. void DrawBBoxVisualizations( void );
  799. virtual bool PreRender( int nSplitScreenPlayerSlot );
  800. bool IsViewEntity( ) const;
  801.  
  802. // Methods implemented on both client and server
  803. public:
  804. void SetSize( const Vector &vecMin, const Vector &vecMax ); // UTIL_SetSize( pev, mins, maxs );
  805. virtual char const* GetClassname( void );
  806. char const* GetDebugName( void );
  807. virtual const char* GetPlayerName( ) const { return NULL; }
  808. static int PrecacheModel( const char *name );
  809. static bool PrecacheSound( const char *name );
  810. static void PrefetchSound( const char *name );
  811. void Remove( ); // UTIL_Remove( this );
  812.  
  813. public:
  814. // Returns the attachment point index on our parent that our transform is relative to.
  815. // 0 if we're relative to the parent's absorigin and absangles.
  816. unsigned char GetParentAttachment( ) const;
  817. // Externalized data objects ( see sharreddefs.h for DataObjectType_t )
  818. bool HasDataObjectType( int type ) const;
  819. void AddDataObjectType( int type );
  820. void RemoveDataObjectType( int type );
  821. void* GetDataObject( int type );
  822. void* CreateDataObject( int type );
  823. void DestroyDataObject( int type );
  824. void DestroyAllDataObjects( void );
  825. // Determine approximate velocity based on updates from server
  826. virtual void EstimateAbsVelocity( Vector& vel );
  827.  
  828. #if !defined( NO_ENTITY_PREDICTION ) // The player drives simulation of this entity
  829. void SetPlayerSimulated( C_BasePlayer *pOwner );
  830. bool IsPlayerSimulated( void ) const;
  831. CBasePlayer* GetSimulatingPlayer( void );
  832. void UnsetPlayerSimulated( void );
  833. #endif
  834.  
  835. // Sorry folks, here lies TF2-specific stuff that really has no other place to go
  836. virtual bool CanBePoweredUp( void ) { return false; }
  837. virtual bool AttemptToPowerup( int iPowerup, float flTime, float flAmount = 0, C_BaseEntity *pAttacker = NULL, CDamageModifier *pDamageModifier = NULL ) { return false; }
  838. void SetCheckUntouch( bool check );
  839. bool GetCheckUntouch( ) const;
  840. virtual bool IsCurrentlyTouching( void ) const;
  841. virtual void StartTouch( C_BaseEntity *pOther );
  842. virtual void Touch( C_BaseEntity *pOther );
  843. virtual void EndTouch( C_BaseEntity *pOther );
  844. void ( C_BaseEntity::*m_pfnTouch )( C_BaseEntity *pOther );
  845. void PhysicsStep( void );
  846.  
  847. protected: // Static
  848. static bool sm_bDisableTouchFuncs; // Disables PhysicsTouch and PhysicsStartTouch function calls
  849.  
  850. public:
  851. touchlink_t* PhysicsMarkEntityAsTouched( C_BaseEntity *other );
  852. void PhysicsTouch( C_BaseEntity *pentOther );
  853. void PhysicsStartTouch( C_BaseEntity *pentOther );
  854. // HACKHACK:Get the trace_t from the last physics touch call (replaces the even-hackier global trace vars)
  855. static const trace_t& GetTouchTrace( void );
  856. // FIXME: Should be priv ate, but I can't make em private just yet
  857. void PhysicsImpact( C_BaseEntity *other, trace_t &trace );
  858. void PhysicsMarkEntitiesAsTouching( C_BaseEntity *other, trace_t &trace );
  859. void PhysicsMarkEntitiesAsTouchingEventDriven( C_BaseEntity *other, trace_t &trace );
  860. void PhysicsTouchTriggers( const Vector *pPrevAbsOrigin = NULL );
  861. // Physics helper
  862. static void PhysicsRemoveTouchedList( C_BaseEntity *ent );
  863. static void PhysicsNotifyOtherOfUntouch( C_BaseEntity *ent, C_BaseEntity *other );
  864. static void PhysicsRemoveToucher( C_BaseEntity *other, touchlink_t *link );
  865. groundlink_t* AddEntityToGroundList( CBaseEntity *other );
  866. void PhysicsStartGroundContact( CBaseEntity *pentOther );
  867. static void PhysicsNotifyOtherOfGroundRemoval( CBaseEntity *ent, CBaseEntity *other );
  868. static void PhysicsRemoveGround( CBaseEntity *other, groundlink_t *link );
  869. static void PhysicsRemoveGroundList( CBaseEntity *ent );
  870. void StartGroundContact( CBaseEntity *ground );
  871. void EndGroundContact( CBaseEntity *ground );
  872. void SetGroundChangeTime( float flTime );
  873. float GetGroundChangeTime( void );
  874.  
  875. // Remove this as ground entity for all object resting on this object
  876. void WakeRestingObjects( );
  877. bool HasNPCsOnIt( );
  878. bool PhysicsCheckWater( void );
  879. void PhysicsCheckVelocity( void );
  880. void PhysicsAddHalfGravity( float timestep );
  881. void PhysicsAddGravityMove( Vector &move );
  882. virtual unsigned int PhysicsSolidMaskForEntity( void ) const;
  883. void SetGroundEntity( C_BaseEntity *ground );
  884. C_BaseEntity* GetGroundEntity( void );
  885. C_BaseEntity* GetGroundEntity( void ) const { return const_cast<C_BaseEntity *>( this )->GetGroundEntity( ); }
  886. void PhysicsPushEntity( const Vector& push, trace_t *pTrace );
  887. void PhysicsCheckWaterTransition( void );
  888. // Performs the collision resolution for fliers.
  889. void PerformFlyCollisionResolution( trace_t &trace, Vector &move );
  890. void ResolveFlyCollisionBounce( trace_t &trace, Vector &vecVelocity, float flMinTotalElasticity = 0.0f );
  891. void ResolveFlyCollisionSlide( trace_t &trace, Vector &vecVelocity );
  892. void ResolveFlyCollisionCustom( trace_t &trace, Vector &vecVelocity );
  893. void PhysicsCheckForEntityUntouch( void );
  894. // Creates the shadow (if it doesn't already exist) based on shadow cast type
  895. void CreateShadow( );
  896. // Destroys the shadow; causes its type to be recomputed if the entity doesn't go away immediately.
  897. void DestroyShadow( );
  898.  
  899. protected:
  900. enum thinkmethods_t { THINK_FIRE_ALL_FUNCTIONS, THINK_FIRE_BASE_ONLY, THINK_FIRE_ALL_BUT_BASE, }; // think function handling
  901.  
  902. public:
  903. // Unlinks from hierarchy
  904. // Set the movement parent. Your local origin and angles will become relative to this parent.
  905. // If iAttachment is a valid attachment on the parent, then your local origin and angles
  906. // are relative to the attachment on this entity.
  907. void SetParent( C_BaseEntity *pParentEntity, int iParentAttachment = 0 );
  908. bool PhysicsRunThink( thinkmethods_t thinkMethod = THINK_FIRE_ALL_FUNCTIONS );
  909. bool PhysicsRunSpecificThink( int nContextIndex, BASEPTR thinkFunc );
  910. virtual void PhysicsSimulate( void );
  911. virtual bool IsAlive( void );
  912. bool IsInWorld( void ) { return true; }
  913. bool IsWorld( ) const { return entindex( ) == 0; }
  914. /////////////////
  915. virtual bool ShouldRegenerateOriginFromCellBits( ) const;
  916. virtual bool IsPlayer( void ) const { return false; };
  917. virtual bool IsBaseCombatCharacter( void ) { return false; };
  918. virtual C_BaseCombatCharacter*MyCombatCharacterPointer( void ) { return ( CBaseCombatCharacter* )this; }
  919. virtual bool IsNPC( void ) { return false; }
  920. C_AI_BaseNPC* MyNPCPointer( void );
  921. virtual bool IsSprite( void ) const { return false; }
  922. virtual bool IsProp( void ) const { return false; }
  923. // TF2 specific
  924. virtual bool IsBaseObject( void ) const { return false; }
  925. virtual bool IsBaseCombatWeapon( void ) const { return false; }
  926. virtual class C_BaseCombatWeapon*MyCombatWeaponPointer( ) { return NULL; }
  927. // Entities like the player, weapon models, and view models have special logic per-view port related to visibility and the model to be used, etc.
  928. virtual bool ShouldDrawForSplitScreenUser( int nSlot );
  929. void SetBlurState( bool bShouldBlur );
  930. virtual bool IsBaseTrain( void ) const { return false; }
  931. // Returns the eye point + angles (used for viewing + shooting)
  932. virtual Vector EyePosition( void );
  933. virtual const QAngle& EyeAngles( void );
  934. virtual const QAngle& LocalEyeAngles( void ); // Direction of eyes in local space (pl.v_angle)
  935. // position of ears
  936. virtual Vector EarPosition( void );
  937. Vector EyePosition( void ) const; // position of eyes
  938. const QAngle& EyeAngles( void ) const; // Direction of eyes in world space
  939. const QAngle& LocalEyeAngles( void ) const; // Direction of eyes
  940. Vector EarPosition( void ) const; // position of ears
  941. // Called by physics to see if we should avoid a collision test....
  942. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
  943. // Sets physics parameters
  944. void SetFriction( float flFriction );
  945. void SetGravity( float flGravity );
  946. float GetGravity( void ) const;
  947. // Sets the model from a model index
  948. void SetModelByIndex( int nModelIndex );
  949. // Set model... (NOTE: Should only be used by client-only entities
  950. // Returns false if the model name is bogus
  951. bool SetModel( const char *pModelName );
  952. virtual void SetModelPointer( const model_t *pModel );
  953. // Access movetype and solid.
  954. void SetMoveType( MoveType_t val, MoveCollide_t moveCollide = MOVECOLLIDE_DEFAULT ); // Set to one of the MOVETYPE_ defines.
  955. void SetMoveCollide( MoveCollide_t val ); // Set to one of the MOVECOLLIDE_ defines.
  956. void SetSolid( SolidType_t val ); // Set to one of the SOLID_ defines.
  957. // NOTE: Setting the abs velocity in either space will cause a recomputation
  958. // in the other space, so setting the abs velocity will also set the local vel
  959. void SetLocalVelocity( const Vector &vecVelocity );
  960. void SetAbsVelocity( const Vector &vecVelocity );
  961. const Vector& GetLocalVelocity( ) const;
  962. const Vector& GetAbsVelocity( ) const;
  963. void ApplyLocalVelocityImpulse( const Vector &vecImpulse );
  964. void ApplyAbsVelocityImpulse( const Vector &vecImpulse );
  965. void ApplyLocalAngularVelocityImpulse( const AngularImpulse &angImpulse );
  966. // NOTE: Setting the abs velocity in either space will cause a recomputation
  967. // in the other space, so setting the abs velocity will also set the local vel
  968. void SetLocalAngularVelocity( const QAngle &vecAngVelocity );
  969. const QAngle& GetLocalAngularVelocity( ) const;
  970. //void SetAbsAngularVelocity( const QAngle &vecAngAbsVelocity );
  971. //const QAngle& GetAbsAngularVelocity( ) const;
  972. const Vector& GetBaseVelocity( ) const;
  973. void SetBaseVelocity( const Vector& v );
  974. virtual const Vector& GetViewOffset( ) const;
  975. virtual void SetViewOffset( const Vector& v );
  976. virtual void GetGroundVelocityToApply( Vector &vecGroundVel ) { vecGroundVel = vec3_origin; }
  977. //// TrackIR
  978. //const Vector& GetEyeOffset() const;
  979. //void SetEyeOffset(const Vector& v);
  980. //const QAngle & GetEyeAngleOffset() const;
  981. //void SetEyeAngleOffset(const QAngle & qa);
  982. //// TrackIR
  983. // Invalidates the abs state of all children
  984. void InvalidatePhysicsRecursive( int nChangeFlags );
  985. ClientRenderHandle_t GetRenderHandle( ) const;
  986. void SetRemovalFlag( bool bRemove );
  987. bool HasSpawnFlags( int nFlags ) const;
  988. // Effects...
  989. bool IsEffectActive( int nEffectMask ) const;
  990. void AddEffects( int nEffects );
  991. void RemoveEffects( int nEffects );
  992. int GetEffects( void ) const;
  993. void ClearEffects( void );
  994. void SetEffects( int nEffects );
  995. // Computes the abs position of a point specified in local space
  996. void ComputeAbsPosition( const Vector &vecLocalPosition, Vector *pAbsPosition );
  997. // Computes the abs position of a direction specified in local space
  998. void ComputeAbsDirection( const Vector &vecLocalDirection, Vector *pAbsDirection );
  999. // These methods encapsulate MOVETYPE_FOLLOW, which became obsolete
  1000. void FollowEntity( CBaseEntity *pBaseEntity, bool bBoneMerge = true );
  1001. void StopFollowingEntity( ); // will also change to MOVETYPE_NONE
  1002. bool IsFollowingEntity( );
  1003. CBaseEntity* GetFollowedEntity( );
  1004. // For shadows rendering the correct body + sequence...
  1005. virtual int GetBody( ) { return 0; }
  1006. virtual int GetSkin( ) { return 0; }
  1007. const Vector& ScriptGetForward( void ) { static Vector vecForward; GetVectors( &vecForward, NULL, NULL ); return vecForward; }
  1008. const Vector& ScriptGetLeft( void ) { static Vector vecLeft; GetVectors( NULL, &vecLeft, NULL ); return vecLeft; }
  1009. const Vector& ScriptGetUp( void ) { static Vector vecUp; GetVectors( NULL, NULL, &vecUp ); return vecUp; }
  1010. // Stubs on client
  1011. void NetworkStateManualMode( bool activate ) { }
  1012. void NetworkStateChanged( ) { }
  1013. void NetworkStateChanged( void *pVar ) { }
  1014. void NetworkStateSetUpdateInterval( float N ) { }
  1015. void NetworkStateForceUpdate( ) { }
  1016. // Think functions with contexts
  1017. int RegisterThinkContext( const char *szContext );
  1018. BASEPTR ThinkSet( BASEPTR func, float flNextThinkTime = 0, const char *szContext = NULL );
  1019. void SetNextThink( float nextThinkTime, const char *szContext = NULL );
  1020. float GetNextThink( const char *szContext = NULL );
  1021. float GetLastThink( const char *szContext = NULL );
  1022. int GetNextThinkTick( const char *szContext = NULL );
  1023. int GetLastThinkTick( const char *szContext = NULL );
  1024. // These set entity flags (EFL_*) to help optimize queries
  1025. void CheckHasThinkFunction( bool isThinkingHint = false );
  1026. void CheckHasGamePhysicsSimulation( );
  1027. bool WillThink( );
  1028. bool WillSimulateGamePhysics( );
  1029. int GetFirstThinkTick( ); // get first tick thinking on any context
  1030. float GetAnimTime( ) const;
  1031. void SetAnimTime( float at );
  1032. float GetSimulationTime( ) const;
  1033. void SetSimulationTime( float st );
  1034. float GetCreateTime( ) { return 0; }
  1035. void SetCreateTime( float flCreateTime ) { }
  1036. int GetCreationTick( ) const;
  1037. // Gets the model instance + shadow handle
  1038. virtual ModelInstanceHandle_t GetModelInstance( ) { return m_ModelInstance; }
  1039. void SetModelInstance( ModelInstanceHandle_t hInstance ) { m_ModelInstance = hInstance; }
  1040. bool SnatchModelInstance( C_BaseEntity * pToEntity );
  1041. virtual ClientShadowHandle_t GetShadowHandle( ) const { return m_ShadowHandle; }
  1042. virtual ClientRenderHandle_t&RenderHandle( );
  1043. virtual void CreateModelInstance( );
  1044. // Sets the origin + angles to match the last position received
  1045. void MoveToLastReceivedPosition( bool force = false );
  1046.  
  1047. protected:
  1048. // Only meant to be called from subclasses
  1049. void DestroyModelInstance( );
  1050. // Interpolate entity
  1051. static void ProcessTeleportList( );
  1052. static void ProcessInterpolatedList( );
  1053. static void CheckInterpolatedVarParanoidMeasurement( );
  1054. // overrideable rules if an entity should interpolate
  1055. virtual bool ShouldInterpolate( );
  1056. // Call this in OnDataChanged if you don't chain it down!
  1057. void MarkMessageReceived( );
  1058. // Gets the last message time
  1059. float GetLastMessageTime( ) const { return m_flLastMessageTime; }
  1060. // For non-players
  1061. int PhysicsClipVelocity( const Vector& in, const Vector& normal, Vector& out, float overbounce );
  1062.  
  1063. protected:
  1064. // Two part guts of Interpolate(). Shared with C_BaseAnimating.
  1065. enum { INTERPOLATE_STOP = 0, INTERPOLATE_CONTINUE };
  1066.  
  1067. // Returns INTERPOLATE_STOP or INTERPOLATE_CONTINUE.
  1068. // bNoMoreChanges is set to 1 if you can call RemoveFromInterpolationList on the entity.
  1069. int BaseInterpolatePart1( float &currentTime, Vector &oldOrigin, QAngle &oldAngles, int &bNoMoreChanges );
  1070. void BaseInterpolatePart2( Vector &oldOrigin, QAngle &oldAngles, int nChangeFlags );
  1071.  
  1072.  
  1073. public:
  1074. // Accessors for above
  1075. static int GetPredictionRandomSeed( void );
  1076. static void SetPredictionRandomSeed( const CUserCmd *cmd );
  1077. static C_BasePlayer* GetPredictionPlayer( void );
  1078. static void SetPredictionPlayer( C_BasePlayer *player );
  1079. static void CheckCLInterpChanged( );
  1080. // Collision group accessors
  1081. int GetCollisionGroup( ) const;
  1082. void SetCollisionGroup( int collisionGroup );
  1083. void CollisionRulesChanged( );
  1084. static C_BaseEntity* Instance( int iEnt );
  1085. // Doesn't do much, but helps with trace results
  1086. static C_BaseEntity* Instance( IClientEntity *ent );
  1087. static C_BaseEntity* Instance( CBaseHandle hEnt );
  1088. // For debugging shared code
  1089. static bool IsServer( void );
  1090. static bool IsClient( void );
  1091. static char const* GetDLLType( void );
  1092. static void SetAbsQueriesValid( bool bValid );
  1093. static bool IsAbsQueriesValid( void );
  1094. // Enable/disable abs recomputations on a stack.
  1095. static void PushEnableAbsRecomputations( bool bEnable );
  1096. static void PopEnableAbsRecomputations( );
  1097. // This requires the abs recomputation stack to be empty and just sets the global state.
  1098. // It should only be used at the scope of the frame loop.
  1099. static void EnableAbsRecomputations( bool bEnable );
  1100. static bool IsAbsRecomputationsEnabled( void );
  1101. static void PreRenderEntities( int nSplitScreenPlayerSlot );
  1102. static void PurgeRemovedEntities( );
  1103. static void SimulateEntities( );
  1104. // Bloat the culling bbox past the parent ent's bbox in local space if EF_BONEMERGE_FASTCULL is set.
  1105. virtual void BoneMergeFastCullBloat( Vector &localMins, Vector &localMaxs, const Vector &thisEntityMins, const Vector &thisEntityMaxs ) const;
  1106. // Accessors for color.
  1107. const color24 GetRenderColor( ) const;
  1108. byte GetRenderColorR( ) const;
  1109. byte GetRenderColorG( ) const;
  1110. byte GetRenderColorB( ) const;
  1111. byte GetRenderAlpha( ) const;
  1112. void SetRenderColor( byte r, byte g, byte b );
  1113. void SetRenderColorR( byte r );
  1114. void SetRenderColorG( byte g );
  1115. void SetRenderColorB( byte b );
  1116. void SetRenderAlpha( byte a );
  1117. void SetRenderMode( RenderMode_t nRenderMode, bool bForceUpdate = false );
  1118. RenderMode_t GetRenderMode( ) const;
  1119. void SetRenderFX( RenderFx_t nRenderFX, float flStartTime = FLT_MAX, float flDuration = 0.0f );
  1120. RenderFx_t GetRenderFX( ) const;
  1121. // Returns true if there was a change.
  1122. bool SetCellBits( int cellbits = CELL_BASEENTITY_ORIGIN_CELL_BITS );
  1123.  
  1124. static void RecvProxy_CellBits( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1125. static void RecvProxy_CellX( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1126. static void RecvProxy_CellY( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1127. static void RecvProxy_CellZ( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1128. static void RecvProxy_CellOrigin( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1129. static void RecvProxy_CellOriginXY( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1130. static void RecvProxy_CellOriginZ( const CRecvProxyData *pData, void *pStruct, void *pOut );
  1131.  
  1132. const char* GetEntityName( );
  1133. static bool IsInterpolationEnabled( ); // Should we be interpolating?
  1134.  
  1135. // Called after predicted entity has been acknowledged so that no longer needed entity can be deleted
  1136. // Return true to force deletion right now, regardless of isbeingremoved
  1137. virtual bool OnPredictedEntityRemove( bool isbeingremoved, C_BaseEntity *predicted );
  1138. bool IsDormantPredictable( void ) const;
  1139. bool BecameDormantThisPacket( void ) const;
  1140. void SetDormantPredictable( bool dormant );
  1141. int GetWaterLevel( ) const;
  1142. void SetWaterLevel( int nLevel );
  1143. int GetWaterType( ) const;
  1144. void SetWaterType( int nType );
  1145. float GetElasticity( void ) const;
  1146. int GetTextureFrameIndex( void );
  1147. void SetTextureFrameIndex( int iIndex );
  1148. virtual bool GetShadowCastDistance( float *pDist, ShadowType_t shadowType ) const;
  1149. virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
  1150. virtual C_BaseEntity *GetShadowUseOtherEntity( void ) const;
  1151. virtual void SetShadowUseOtherEntity( C_BaseEntity *pEntity );
  1152. CInterpolatedVar<QAngle>& GetRotationInterpolator( );
  1153. CInterpolatedVar<Vector>& GetOriginInterpolator( );
  1154. virtual bool AddRagdollToFadeQueue( void ) { return true; }
  1155. void MarkRenderHandleDirty( ); // Dirty bits
  1156. void HierarchyUpdateMoveParent( ); // used by SourceTV since move-parents may be missing when child spawns.
  1157. void SetCPULevels( int nMinCPULevel, int nMaxCPULevel );
  1158. void SetGPULevels( int nMinGPULevel, int nMaxGPULevel );
  1159. int GetMinCPULevel( ) const;
  1160. int GetMaxCPULevel( ) const;
  1161. int GetMinGPULevel( ) const;
  1162. int GetMaxGPULevel( ) const;
  1163. int GetIndexForThinkContext( const char *pszContext ); // Think contexts
  1164. virtual int GetStudioBody( void ) { return 0; } // Allow studio models to tell us what their m_nBody value is
  1165. bool IsParentChanging( ); // call this in postdataupdate to detect hierarchy changes
  1166. friend void OnRenderStart( );
  1167. bool InitializeAsClientEntityByIndex( int iIndex, bool bRenderWithViewModels );
  1168. static void InterpolateServerEntities( ); // Figure out the smoothly interpolated origin for all server entities.
  1169. static void AddVisibleEntities( ); // Check which entities want to be drawn and add them to the leaf system.
  1170. static void ToolRecordEntities( ); // For entities marked for recording, post bone messages to IToolSystems
  1171. void UpdateBaseVelocity( void );
  1172. void PhysicsPusher( void ); // Physics-related private methods
  1173. void PhysicsNone( void );
  1174. void PhysicsNoclip( void );
  1175. void PhysicsParent( void );
  1176. void PhysicsStepRunTimestep( float timestep );
  1177. void PhysicsToss( void );
  1178. void PhysicsCustom( void );
  1179. void PhysicsRigidChild( void ); // Simulation in local space of rigid children
  1180. void CalcAbsolutePosition( ) { } // Computes absolute position based on hierarchy
  1181. void CalcAbsoluteVelocity( )
  1182. {
  1183. if ( ( m_iEFlags & EFL_DIRTY_ABSVELOCITY ) == 0 )
  1184. return;
  1185.  
  1186. AUTO_LOCK( m_CalcAbsoluteVelocityMutex );
  1187.  
  1188. if ( ( m_iEFlags & EFL_DIRTY_ABSVELOCITY ) == 0 ) // need second check in event another thread grabbed mutex and did the calculation
  1189. {
  1190. return;
  1191. }
  1192.  
  1193. m_iEFlags &= ~EFL_DIRTY_ABSVELOCITY;
  1194.  
  1195. CBaseEntity *pMoveParent = GetMoveParent( );
  1196. if ( !pMoveParent )
  1197. {
  1198. m_vecAbsVelocity = m_vecVelocity;
  1199. return;
  1200. }
  1201.  
  1202. VectorRotate( m_vecVelocity, pMoveParent->EntityToWorldTransform( ), m_vecAbsVelocity );
  1203.  
  1204. // Add in the attachments velocity if it exists
  1205. if ( m_iParentAttachment != 0 )
  1206. {
  1207. Vector vOriginVel;
  1208. Quaternion vAngleVel;
  1209. if ( pMoveParent->GetAttachmentVelocity( m_iParentAttachment, vOriginVel, vAngleVel ) )
  1210. {
  1211. m_vecAbsVelocity += vOriginVel;
  1212. return;
  1213. }
  1214. }
  1215.  
  1216. // Now add in the parent abs velocity
  1217. m_vecAbsVelocity += pMoveParent->GetAbsVelocity( );
  1218. }
  1219. void SimulateAngles( float flFrameTime ); // Computes new angles based on the angular velocity
  1220. virtual void PerformCustomPhysics( Vector *pNewPosition, Vector *pNewVelocity, QAngle *pNewAngles, QAngle *pNewAngVelocity );
  1221. void AddStudioDecal( const Ray_t& ray, int hitbox, int decalIndex, bool doTrace, trace_t& tr, int maxLODToDecal = ADDDECAL_TO_ALL_LODS ); // methods related to decal adding
  1222. void AddBrushModelDecal( const Ray_t& ray, const Vector& decalCenter, int decalIndex, bool doTrace, trace_t& tr );
  1223. void ComputePackedOffsets( void );
  1224. int GetIntermediateDataSize( void );
  1225. void UnlinkChild( C_BaseEntity *pParent, C_BaseEntity *pChild );
  1226. void LinkChild( C_BaseEntity *pParent, C_BaseEntity *pChild );
  1227. void HierarchySetParent( C_BaseEntity *pNewParent );
  1228. void UnlinkFromHierarchy( );
  1229. void UpdateWaterState( ); // Computes the water level + type
  1230. void PhysicsCheckSweep( const Vector& vecAbsStart, const Vector &vecAbsDelta, trace_t *pTrace ); // Checks a sweep without actually performing the move
  1231. void MoveToAimEnt( ); // FIXME: REMOVE!!!
  1232. void SetNextThink( int nContextIndex, float thinkTime ); // Sets/Gets the next think based on context index
  1233. void SetLastThink( int nContextIndex, float thinkTime );
  1234. float GetNextThink( int nContextIndex ) const;
  1235. int GetNextThinkTick( int nContextIndex ) const;
  1236. void CleanUpAlphaProperty( );
  1237. virtual float* GetRenderClipPane( );
  1238. float * GetRenderClipPlane( void ); // Rendering clip plane, should be 4 floats, return value of NULL indicates a disabled render clip plane
  1239. void AddToEntityList( entity_list_ids_t listId );
  1240. void RemoveFromEntityList( entity_list_ids_t listId );
  1241.  
  1242. /* My accessors */
  1243. //QAngle GetPunchAngle( );
  1244. QAngle GetViewPunch( );
  1245. QAngle* GetAimPunchPtr( );
  1246. QAngle* GetViewPunchPtr( );
  1247. //Vector GetVelocity( );
  1248. Vector GetEyePos( );
  1249. QAngle GetEyeAngles( ) { return GetRenderAngles( ); }
  1250. int GetGlowIndex( );
  1251. void UpdateEntityGlow( Vector color, float alpha, float somefloat );
  1252. void GetEyeVectors( Vector *pForward, Vector *pRight, Vector *pUp );
  1253. Vector GetPredictedEyePos( );
  1254. Vector GetAbsOrigin( ) { return GetNetworkedOrigin( ); }
  1255. QAngle GetAbsAngles( );
  1256. //int TickBase( );
  1257. CPlayerState* GetPlayerState( );
  1258. C_BaseCombatWeapon* GetWeapon( );
  1259. int team( ) { return GetTeamNum( ); }
  1260. bool IsScoped( );
  1261. int health( );
  1262. int InCross( );
  1263. void dump( );
  1264.  
  1265. public:
  1266. string_t m_iClassname;
  1267. HSCRIPT m_hScriptInstance;
  1268. string_t m_iszScriptId;
  1269. VarMapping_t m_VarMap;
  1270. char pad_0x3C[ 0xC ];
  1271. int index; // Determine what entity this corresponds to
  1272. unsigned long m_EntClientFlags;
  1273. const model_t *model;
  1274. CNetworkColor32( m_clrRender );
  1275. int m_cellbits;
  1276. int m_cellwidth;
  1277. int m_cellX;
  1278. int m_cellY;
  1279. int m_cellZ;
  1280. Vector m_vecCellOrigin; // cached cell offset position
  1281. Vector m_vecAbsVelocity;
  1282. Vector m_vecAbsOrigin;
  1283. Vector m_vecOrigin;
  1284. QAngle m_vecAngVelocity;
  1285. QAngle m_angAbsRotation;
  1286. QAngle m_angRotation;
  1287. float m_flGravity;
  1288. float m_flProxyRandomValue;
  1289. unsigned long m_iEFlags;
  1290. unsigned char m_nWaterType;
  1291. bool m_bDormant;
  1292. int m_fEffects;
  1293. int m_iTeamNum;
  1294. int m_iPendingTeamNum;
  1295. int m_nNextThinkTick;
  1296. int m_iHealth;
  1297. int m_fFlags; // Behavior flags
  1298. Vector m_vecViewOffset; // Object eye position
  1299. Vector m_vecVelocity; // Object velocity
  1300. Vector m_vecBaseVelocity; // Base velocity
  1301. QAngle m_angNetworkAngles;
  1302. Vector m_vecNetworkOrigin; // Last values to come over the wire. Used for interpolation.
  1303. float m_flFriction;
  1304. EHANDLE m_hNetworkMoveParent; // The moveparent received from networking data
  1305. EHANDLE m_hOwnerEntity; // The owner!
  1306. EHANDLE m_hGroundEntity;
  1307. char m_iName[ MAX_PATH ];
  1308. short m_nModelIndex; // Object model index
  1309. unsigned char m_nRenderFX;
  1310. unsigned char m_nRenderMode;
  1311. unsigned char m_MoveType;
  1312. unsigned char m_MoveCollide;
  1313. unsigned char m_nWaterLevel;
  1314. unsigned char m_lifeState;
  1315. float m_flAnimTime; // Time animation sequence or frame was last changed
  1316. float m_flOldAnimTime;
  1317. float m_flSimulationTime;
  1318. float m_flOldSimulationTime;
  1319. char pad_0x26C[ 0x2 ];
  1320. ClientRenderHandle_t m_hRender; // link into spatial partition
  1321. unsigned char m_nOldRenderMode;
  1322. char pad_0x271[ 0x3 ];
  1323. CBitVec<1> m_VisibilityBits;
  1324. //char pad_0x275[0x1];
  1325. //bool m_bReadyToDraw; // Interpolation says don't draw yet
  1326. //bool m_bClientSideRagdoll;
  1327. int m_nLastThinkTick;
  1328. int m_takedamage;
  1329. float m_flSpeed; // was pev->speed
  1330. int touchStamp; // used so we know when things are no longer touching
  1331. CBaseHandle m_RefEHandle; // Reference ehandle. Used to generate ehandles off this entity.
  1332. int m_HandleIndex;
  1333. char pad_0x290[ 0x4 ];
  1334. HTOOLHANDLE m_ToolHandle; // 0x294
  1335. bool m_bEnabledInToolView;
  1336. bool m_bToolRecording;
  1337. //int m_nLastRecordedFrame;
  1338. bool m_bRecordInTools; // should this entity be recorded in the tools
  1339. bool m_bPredictionEligible;
  1340. IPhysicsObject *m_pPhysicsObject;
  1341. int m_iCurrentThinkContext;
  1342. int m_spawnflags;
  1343. int m_nSimulationTick;
  1344. CUtlVector<thinkfunc_t> m_aThinkFunctions;
  1345. //Vector m_vecEyeOffset; // TrackIR
  1346. //QAngle m_EyeAngleOffset; // TrackIR
  1347. char pad_0x2C0[ 0xB ];
  1348. bool m_bDormantPredictable;
  1349. int m_nIncomingPacketEntityBecameDormant; // So we can clean it up
  1350. float m_flLastMessageTime; // Timestamp of message arrival
  1351. float m_flSpawnTime; // The spawn time of the entity
  1352. ModelInstanceHandle_t m_ModelInstance; // Model instance data..
  1353. ClientShadowHandle_t m_ShadowHandle; // Shadow data
  1354. ClientThinkHandle_t m_hThink;
  1355. CBitVec<1> m_ShadowBits; // Per-splitscreen user shadow visibility bits
  1356. unsigned char m_iParentAttachment; // 0x2E4 // 0 if we're relative to the parent's absorigin and absangles.
  1357. unsigned char m_iOldParentAttachment; // 0x2E5
  1358. char pad_0x2E6[ 0x6 ];
  1359. float m_fadeMinDist; // 0x2EC // Fades
  1360. float m_fadeMaxDist; // 0x2F0
  1361. float m_flFadeScale; // 0x2F4
  1362. bool m_bPredictable; // Prediction system
  1363. bool m_bRenderWithViewModels;
  1364. bool m_bDisableCachedRenderBounds;
  1365. unsigned char m_nSplitUserPlayerPredictionSlot;
  1366. CHandle<C_BaseEntity> m_pMoveParent; // Hierarchy
  1367. CHandle<C_BaseEntity> m_pMoveChild;
  1368. CHandle<C_BaseEntity> m_pMovePeer;
  1369. CHandle<C_BaseEntity> m_pMovePrevPeer;
  1370. CHandle<C_BaseEntity> m_hOldMoveParent;
  1371. string_t m_ModelName;
  1372. CNetworkVarEmbedded( CCollisionProperty, m_Collision );
  1373. CNetworkVarEmbedded( CParticleProperty, m_Particles );
  1374. IClientAlphaProperty *m_pClientAlphaProperty;
  1375. float m_flElasticity; // Physics state
  1376. float m_flShadowCastDistance;
  1377. EHANDLE m_ShadowDirUseOtherEntity;
  1378. float m_flGroundChangeTime;
  1379. Vector m_vecOldOrigin;
  1380. QAngle m_vecOldAngRotation;
  1381. CInterpolatedVar<Vector> m_iv_vecOrigin;
  1382. char pad_0x3E8[ 0x14 ];
  1383. CInterpolatedVar<QAngle> m_iv_angRotation;
  1384. char pad_0x428[ 0x14 ];
  1385. matrix3x4_t m_rgflCoordinateFrame; // Specifies the entity-to-world transform
  1386. int m_CollisionGroup; // used to cull collision tests
  1387. unsigned char *m_pIntermediateData[ MULTIPLAYER_BACKUP ]; // 0x470 // For storing prediction results and pristine network state
  1388. unsigned char *m_pOldIntermediateData[ MULTIPLAYER_BACKUP ]; // 0x6C8
  1389. int unkint;
  1390. unsigned char *m_pOriginalData;
  1391. EHANDLE m_hUnknown;
  1392. int m_nIntermediateDataCount;
  1393. bool m_bIsSpectated;
  1394. bool m_bIsPlayerSimulated;
  1395. CNetworkVar( bool, m_bSimulatedEveryTick ); // 0x932
  1396. CNetworkVar( bool, m_bAnimatedEveryTick ); // 0x933
  1397. CNetworkVar( bool, m_bAlternateSorting ); // 0x934
  1398. CNetworkVar( bool, m_bSpotted ); // 0x935
  1399. CNetworkVar( bool, m_bSpottedBy ); // 0x936
  1400. char pad_0x937[ 0x41 ]; // 0x937
  1401. unsigned char m_bSpottedByMask; // 0x978
  1402. char pad_0x979[ 0x7 ]; // 0x979
  1403. unsigned char m_nMinCPULevel; // 0x980
  1404. unsigned char m_nMaxCPULevel; // 0x981
  1405. unsigned char m_nMinGPULevel; // 0x982
  1406. unsigned char m_nMaxGPULevel; // 0x983
  1407. int m_iTextureFrameIndex; // 0x984
  1408. //unsigned char m_fBBoxVisFlags; // Bbox visualization
  1409. //bool m_bIsValidIKAttachment;
  1410. //unsigned char m_DataChangeEventRef;
  1411. EHANDLE m_hEffectEntity; // 0x988
  1412. CHandle<CBasePlayer> m_hPlayerSimulationOwner; // 0x98C
  1413. EHANDLE m_hUnknown2; // 0x990
  1414. static int m_nPredictionRandomSeed;
  1415. static C_BasePlayer *m_pPredictionPlayer;
  1416. static bool s_bAbsQueriesValid;
  1417. static bool s_bAbsRecomputationEnabled;
  1418. static bool s_bInterpolate;
  1419. int m_fDataObjectTypes; // 0x994
  1420. AimEntsListHandle_t m_AimEntsListHandle; // 0x998
  1421. int m_nCreationTick; // 0x99C
  1422. float m_fRenderingClipPlane[ 4 ]; //world space clip plane when drawing
  1423. unsigned short m_bEnableRenderingClipPlane; //true to use the custom clip plane when drawing
  1424. unsigned short m_ListEntry[ NUM_ENTITY_LISTS ]; // Entry into each g_EntityList (or InvalidIndex() if not in the list).
  1425. CThreadFastMutex m_CalcAbsolutePositionMutex;
  1426. CThreadFastMutex m_CalcAbsoluteVelocityMutex;
  1427. bool m_bIsBlurred; // 0x9CB
  1428. char pad[ 0x4 ]; // 0x9CC
  1429. };
  1430.  
  1431. EXTERN_RECV_TABLE( DT_BaseEntity );
  1432.  
  1433. inline void C_BaseEntity::dump( )
  1434. {
  1435. printf( "C_BaseEntity -> Address = 0x%X\n", this );
  1436. LOG_BASEENTITY( "C_BaseEntity -> Address = 0x%X", ( DWORD )this );
  1437. SHOUTMEMBERENTITY( "m_iClassname", m_iClassname );
  1438. SHOUTMEMBERENTITY( "m_hScriptInstance", m_hScriptInstance );
  1439. SHOUTMEMBERENTITY( "m_iszScriptId", m_iszScriptId );
  1440. SHOUTMEMBERENTITY( "m_varMap", m_VarMap.m_Entries.m_Memory.m_pMemory );
  1441. SHOUTMEMBERENTITY( "index", index );
  1442. SHOUTMEMBERENTITY( "m_EntClientFlags", m_EntClientFlags );
  1443. SHOUTMEMBERENTITY( "model", model );
  1444. SHOUTMEMBERENTITY( "m_cellbits", m_cellbits );
  1445. SHOUTMEMBERENTITY( "m_cellwidth", m_cellwidth );
  1446. SHOUTMEMBERENTITY( "m_cellX", m_cellX );
  1447. SHOUTMEMBERENTITY( "m_cellY", m_cellY );
  1448. SHOUTMEMBERENTITY( "m_cellZ", m_cellZ );
  1449. SHOUTMEMBERENTITY( "m_vecCellOrigin", m_vecCellOrigin[ 0 ] );
  1450. SHOUTMEMBERENTITY( "m_vecAbsVelocity", m_vecAbsVelocity[ 0 ] );
  1451. SHOUTMEMBERENTITY( "m_vecAbsOrigin", m_vecAbsOrigin[ 0 ] );
  1452. SHOUTMEMBERENTITY( "m_vecOrigin", m_vecOrigin[ 0 ] );
  1453. SHOUTMEMBERENTITY( "m_vecAngVelocity", m_vecAngVelocity );
  1454. SHOUTMEMBERENTITY( "m_angAbsRotation", m_angAbsRotation );
  1455. SHOUTMEMBERENTITY( "m_angRotation", m_angRotation );
  1456. SHOUTMEMBERENTITY( "m_flGravity", m_flGravity );
  1457. SHOUTMEMBERENTITY( "m_flProxyRandomValue", m_flProxyRandomValue );
  1458. SHOUTMEMBERENTITY( "m_iEFlags", m_iEFlags );
  1459. SHOUTMEMBERENTITY( "m_nWaterType", m_nWaterType );
  1460. SHOUTMEMBERENTITY( "m_bDormant", m_bDormant );
  1461. SHOUTMEMBERENTITY( "m_fEffects", m_fEffects );
  1462. SHOUTMEMBERENTITY( "m_iTeamNum", m_iTeamNum );
  1463. SHOUTMEMBERENTITY( "m_iPendingTeamNum", m_iPendingTeamNum );
  1464. SHOUTMEMBERENTITY( "m_nNextThinkTick", m_nNextThinkTick );
  1465. SHOUTMEMBERENTITY( "m_iHealth", m_iHealth );
  1466. SHOUTMEMBERENTITY( "m_fFlags", m_fFlags );
  1467. SHOUTMEMBERENTITY( "m_vecViewOffset", m_vecViewOffset[ 0 ] );
  1468. SHOUTMEMBERENTITY( "m_vecVelocity", m_vecVelocity[ 0 ] );
  1469. SHOUTMEMBERENTITY( "m_vecBaseVelocity", m_vecBaseVelocity[ 0 ] );
  1470. SHOUTMEMBERENTITY( "m_angNetworkAngles", m_angNetworkAngles[ 0 ] );
  1471. SHOUTMEMBERENTITY( "m_vecNetworkOrigin", m_vecNetworkOrigin[ 0 ] );
  1472. SHOUTMEMBERENTITY( "m_flFriction", m_flFriction );
  1473. SHOUTMEMBERENTITY( "m_hNetworkMoveParent", m_hNetworkMoveParent );
  1474. SHOUTMEMBERENTITY( "m_hOwnerEntity", m_hOwnerEntity );
  1475. SHOUTMEMBERENTITY( "m_hGroundEntity", m_hGroundEntity );
  1476. SHOUTMEMBERENTITY( "m_iName", m_iName );
  1477. SHOUTMEMBERENTITY( "m_nModelIndex", m_nModelIndex );
  1478. SHOUTMEMBERENTITY( "m_nRenderFX", m_nRenderFX );
  1479. SHOUTMEMBERENTITY( "m_nRenderMode", m_nRenderMode );
  1480. SHOUTMEMBERENTITY( "m_MoveType", m_MoveType );
  1481. SHOUTMEMBERENTITY( "m_MoveCollide", m_MoveCollide );
  1482. SHOUTMEMBERENTITY( "m_nWaterLevel", m_nWaterLevel );
  1483. SHOUTMEMBERENTITY( "m_lifeState", m_lifeState );
  1484. SHOUTMEMBERENTITY( "m_flAnimTime", m_flAnimTime );
  1485. SHOUTMEMBERENTITY( "m_flOldAnimTime", m_flOldAnimTime );
  1486. SHOUTMEMBERENTITY( "m_flSimulationTime", m_flSimulationTime );
  1487. SHOUTMEMBERENTITY( "m_flOldSimulationTime", m_flOldSimulationTime );
  1488. SHOUTMEMBERENTITY( "m_hRender", m_hRender );
  1489. SHOUTMEMBERENTITY( "m_nOldRenderMode", m_nOldRenderMode );
  1490. SHOUTMEMBERENTITY( "m_VisibilityBits", m_VisibilityBits );
  1491. SHOUTMEMBERENTITY( "m_nLastThinkTick", m_nLastThinkTick );
  1492. SHOUTMEMBERENTITY( "m_takedamage", m_takedamage );
  1493. SHOUTMEMBERENTITY( "m_flSpeed", m_flSpeed );
  1494. SHOUTMEMBERENTITY( "touchStamp", touchStamp );
  1495. SHOUTMEMBERENTITY( "m_RefEHandle", m_RefEHandle );
  1496. SHOUTMEMBERENTITY( "m_HandleIndex", m_HandleIndex );
  1497. SHOUTMEMBERENTITY( "m_ToolHandle", m_ToolHandle );
  1498. SHOUTMEMBERENTITY( "m_bEnabledInToolView", m_bEnabledInToolView );
  1499. SHOUTMEMBERENTITY( "m_bToolRecording", m_bToolRecording );
  1500. SHOUTMEMBERENTITY( "m_bRecordInTools", m_bRecordInTools );
  1501. SHOUTMEMBERENTITY( "m_bPredictionEligible", m_bPredictionEligible );
  1502. SHOUTMEMBERENTITY( "m_pPhysicsObject", m_pPhysicsObject );
  1503. SHOUTMEMBERENTITY( "m_iCurrentThinkContext", m_iCurrentThinkContext );
  1504. SHOUTMEMBERENTITY( "m_spawnflags", m_spawnflags );
  1505. SHOUTMEMBERENTITY( "m_nSimulationTick", m_nSimulationTick );
  1506. SHOUTMEMBERENTITY( "m_aThinkFunctions", m_aThinkFunctions );
  1507. SHOUTMEMBERENTITY( "m_bDormantPredictable", m_bDormantPredictable );
  1508. SHOUTMEMBERENTITY( "m_nIncomingPacketEntityBecameDormant", m_nIncomingPacketEntityBecameDormant );
  1509. SHOUTMEMBERENTITY( "m_flLastMessageTime", m_flLastMessageTime );
  1510. SHOUTMEMBERENTITY( "m_flSpawnTime", m_flSpawnTime );
  1511. SHOUTMEMBERENTITY( "m_ModelInstance", m_ModelInstance );
  1512. SHOUTMEMBERENTITY( "m_ShadowHandle", m_ShadowHandle );
  1513. SHOUTMEMBERENTITY( "m_ShadowBits", m_ShadowBits );
  1514. SHOUTMEMBERENTITY( "m_hThink", m_hThink );
  1515. SHOUTMEMBERENTITY( "m_iParentAttachment", m_iParentAttachment );
  1516. SHOUTMEMBERENTITY( "m_iOldParentAttachment", m_iOldParentAttachment );
  1517. SHOUTMEMBERENTITY( "m_fadeMinDist", m_fadeMinDist );
  1518. SHOUTMEMBERENTITY( "m_fadeMaxDist", m_fadeMaxDist );
  1519. SHOUTMEMBERENTITY( "m_flFadeScale", m_flFadeScale );
  1520. SHOUTMEMBERENTITY( "m_bPredictable", m_bPredictable );
  1521. SHOUTMEMBERENTITY( "m_bRenderWithViewModels", m_bRenderWithViewModels );
  1522. SHOUTMEMBERENTITY( "m_bDisableCachedRenderBounds", m_bDisableCachedRenderBounds );
  1523. SHOUTMEMBERENTITY( "m_nSplitUserPlayerPredictionSlot", m_nSplitUserPlayerPredictionSlot );
  1524. SHOUTMEMBERENTITY( "m_pMoveParent", m_pMoveParent );
  1525. SHOUTMEMBERENTITY( "m_pMoveChild", m_pMoveChild );
  1526. SHOUTMEMBERENTITY( "m_pMovePeer", m_pMovePeer );
  1527. SHOUTMEMBERENTITY( "m_pMovePrevPeer", m_pMovePrevPeer );
  1528. SHOUTMEMBERENTITY( "m_hOldMoveParent", m_hOldMoveParent );
  1529. SHOUTMEMBERENTITY( "m_ModelName", m_ModelName );
  1530. SHOUTMEMBERENTITY( "m_Collision", m_Collision );
  1531. SHOUTMEMBERENTITY( "m_Particles", m_Particles );
  1532. SHOUTMEMBERENTITY( "m_pClientAlphaProperty", m_pClientAlphaProperty );
  1533. SHOUTMEMBERENTITY( "m_flElasticity", m_flElasticity );
  1534. SHOUTMEMBERENTITY( "m_flShadowCastDistance", m_flShadowCastDistance );
  1535. SHOUTMEMBERENTITY( "m_ShadowDirUseOtherEntity", m_ShadowDirUseOtherEntity );
  1536. SHOUTMEMBERENTITY( "m_flGroundChangeTime", m_flGroundChangeTime );
  1537. SHOUTMEMBERENTITY( "m_vecOldOrigin", m_vecOldOrigin[ 0 ] );
  1538. SHOUTMEMBERENTITY( "m_vecOldAngRotation", m_vecOldAngRotation[ 0 ] );
  1539. SHOUTMEMBERENTITY( "m_iv_vecOrigin", m_iv_vecOrigin.m_pValue );
  1540. SHOUTMEMBERENTITY( "m_iv_angRotation", m_iv_angRotation.m_pValue );
  1541. SHOUTMEMBERENTITY( "m_rgflCoordinateFrame", m_rgflCoordinateFrame[ 0 ][ 0 ] );
  1542. SHOUTMEMBERENTITY( "m_CollisionGroup", m_CollisionGroup );
  1543. SHOUTMEMBERENTITY( "m_pIntermediateData", m_pIntermediateData );
  1544. SHOUTMEMBERENTITY( "m_pOldIntermediateData", m_pOldIntermediateData );
  1545. SHOUTMEMBERENTITY( "unkint", unkint );
  1546. SHOUTMEMBERENTITY( "m_pOriginalData", m_pOriginalData );
  1547. SHOUTMEMBERENTITY( "m_hUnknown", m_hUnknown );
  1548. SHOUTMEMBERENTITY( "m_nIntermediateDataCount", m_nIntermediateDataCount );
  1549. SHOUTMEMBERENTITY( "m_bIsSpectated", m_bIsSpectated );
  1550. SHOUTMEMBERENTITY( "m_bIsPlayerSimulated", m_bIsPlayerSimulated );
  1551. SHOUTMEMBERENTITY( "m_bSimulatedEveryTick", m_bSimulatedEveryTick );
  1552. SHOUTMEMBERENTITY( "m_bAnimatedEveryTick", m_bAnimatedEveryTick );
  1553. SHOUTMEMBERENTITY( "m_bAlternateSorting", m_bAlternateSorting );
  1554. SHOUTMEMBERENTITY( "m_bSpotted", m_bSpotted );
  1555. SHOUTMEMBERENTITY( "m_bSpottedBy", m_bSpottedBy );
  1556. SHOUTMEMBERENTITY( "pad_0x937", pad_0x937 );
  1557. SHOUTMEMBERENTITY( "m_bSpottedByMask", m_bSpottedByMask );
  1558. SHOUTMEMBERENTITY( "pad_0x979", pad_0x979 );
  1559. SHOUTMEMBERENTITY( "m_nMinCPULevel", m_nMinCPULevel );
  1560. SHOUTMEMBERENTITY( "m_nMaxCPULevel", m_nMaxCPULevel );
  1561. SHOUTMEMBERENTITY( "m_nMinGPULevel", m_nMinGPULevel );
  1562. SHOUTMEMBERENTITY( "m_nMaxGPULevel", m_nMaxGPULevel );
  1563. SHOUTMEMBERENTITY( "m_iTextureFrameIndex", m_iTextureFrameIndex );
  1564. SHOUTMEMBERENTITY( "m_hEffectEntity", m_hEffectEntity );
  1565. SHOUTMEMBERENTITY( "m_hPlayerSimulationOwner", m_hPlayerSimulationOwner );
  1566. SHOUTMEMBERENTITY( "m_hUnknown2", m_hUnknown2 );
  1567. SHOUTMEMBERENTITY( "m_fDataObjectTypes", m_fDataObjectTypes );
  1568. SHOUTMEMBERENTITY( "m_AimEntsListHandle", m_AimEntsListHandle );
  1569. SHOUTMEMBERENTITY( "m_nCreationTick", m_nCreationTick );
  1570. SHOUTMEMBERENTITY( "m_fRenderingClipPlane", m_fRenderingClipPlane[ 0 ] );
  1571. SHOUTMEMBERENTITY( "m_bEnableRenderingClipPlane", m_bEnableRenderingClipPlane );
  1572. SHOUTMEMBERENTITY( "m_ListEntry", m_ListEntry[ 0 ] );
  1573. SHOUTMEMBERENTITY( "m_CalcAbsolutePositionMutex.m_ownerID", m_CalcAbsolutePositionMutex.m_ownerID );
  1574. SHOUTMEMBERENTITY( "m_CalcAbsoluteVelocityMutex.m_ownerID", m_CalcAbsoluteVelocityMutex.m_ownerID );
  1575. SHOUTMEMBERENTITY( "m_bIsBlurred", m_bIsBlurred );
  1576. printf( "\n" );
  1577. }
  1578.  
  1579. inline bool FClassnameIs( C_BaseEntity *pEntity, const char *szClassname )
  1580. {
  1581. Assert( pEntity );
  1582. if ( pEntity == NULL )
  1583. return false;
  1584. return !strcmp( pEntity->GetClassname( ), szClassname ) ? true : false;
  1585. }
  1586.  
  1587. #define SetThink( a ) ThinkSet( static_cast <void (CBaseEntity::*)(void)> (a), 0, NULL )
  1588. #define SetContextThink( a, b, context ) ThinkSet( static_cast <void (CBaseEntity::*)(void)> (a), (b), context )
  1589.  
  1590. #ifdef _DEBUG
  1591. #define SetTouch( a ) TouchSet( static_cast <void (C_BaseEntity::*)(C_BaseEntity *)> (a), #a )
  1592.  
  1593. #else
  1594. #define SetTouch( a ) m_pfnTouch = static_cast <void (C_BaseEntity::*)(C_BaseEntity *)> (a)
  1595.  
  1596. #endif
  1597.  
  1598.  
  1599. inline CCollisionProperty *C_BaseEntity::CollisionProp( )
  1600. {
  1601. return &m_Collision;
  1602. }
  1603.  
  1604. inline const CCollisionProperty *C_BaseEntity::CollisionProp( ) const
  1605. {
  1606. return &m_Collision;
  1607. }
  1608.  
  1609. inline CClientAlphaProperty *C_BaseEntity::AlphaProp( )
  1610. {
  1611. return (CClientAlphaProperty*)m_pClientAlphaProperty;
  1612. }
  1613.  
  1614. inline const CClientAlphaProperty *C_BaseEntity::AlphaProp( ) const
  1615. {
  1616. return (CClientAlphaProperty*)m_pClientAlphaProperty;
  1617. }
  1618.  
  1619. //-----------------------------------------------------------------------------
  1620. // An inline version the game code can use
  1621. //-----------------------------------------------------------------------------
  1622. inline CParticleProperty *C_BaseEntity::ParticleProp( )
  1623. {
  1624. return &m_Particles;
  1625. }
  1626.  
  1627. inline const CParticleProperty *C_BaseEntity::ParticleProp( ) const
  1628. {
  1629. return &m_Particles;
  1630. }
  1631.  
  1632. //-----------------------------------------------------------------------------
  1633. // Purpose: Returns whether this entity was created on the client.
  1634. //-----------------------------------------------------------------------------
  1635. inline bool C_BaseEntity::IsServerEntity( void )
  1636. {
  1637. return index != -1;
  1638. }
  1639.  
  1640. //-----------------------------------------------------------------------------
  1641. // Inline methods
  1642. //-----------------------------------------------------------------------------
  1643. inline matrix3x4_t &C_BaseEntity::EntityToWorldTransform( )
  1644. {
  1645. //Assert(s_bAbsQueriesValid);
  1646. //CalcAbsolutePosition();
  1647. return m_rgflCoordinateFrame;
  1648. }
  1649.  
  1650. inline const matrix3x4_t &C_BaseEntity::EntityToWorldTransform( ) const
  1651. {
  1652. //Assert(s_bAbsQueriesValid);
  1653. //const_cast<C_BaseEntity*>(this)->CalcAbsolutePosition();
  1654. return m_rgflCoordinateFrame;
  1655. }
  1656.  
  1657. //-----------------------------------------------------------------------------
  1658. // Some helper methods that transform a point from entity space to world space + back
  1659. //-----------------------------------------------------------------------------
  1660. inline void C_BaseEntity::EntityToWorldSpace( const Vector &in, Vector *pOut ) const
  1661. {
  1662. if ( m_angAbsRotation == vec3_angle )
  1663. VectorAdd( in, m_vecAbsOrigin, *pOut );
  1664. else
  1665. VectorTransform( in, EntityToWorldTransform( ), *pOut );
  1666. }
  1667.  
  1668. inline void C_BaseEntity::WorldToEntitySpace( const Vector &in, Vector *pOut ) const
  1669. {
  1670. if ( m_angAbsRotation == vec3_angle )
  1671. VectorSubtract( in, m_vecAbsOrigin, *pOut );
  1672. else
  1673. VectorITransform( in, EntityToWorldTransform( ), *pOut );
  1674. }
  1675.  
  1676. inline const Vector &C_BaseEntity::GetAbsVelocity( ) const
  1677. {
  1678. //Assert(s_bAbsQueriesValid);
  1679. //const_cast<C_BaseEntity*>(this)->CalcAbsoluteVelocity();
  1680. return m_vecAbsVelocity;
  1681. }
  1682.  
  1683. inline C_BaseEntity *C_BaseEntity::Instance( IClientEntity *ent )
  1684. {
  1685. return ent ? ent->GetBaseEntity( ) : NULL;
  1686. }
  1687.  
  1688. // For debugging shared code
  1689. inline bool C_BaseEntity::IsServer( void )
  1690. {
  1691. return false;
  1692. }
  1693.  
  1694. inline bool C_BaseEntity::IsClient( void )
  1695. {
  1696. return true;
  1697. }
  1698.  
  1699. inline const char *C_BaseEntity::GetDLLType( void )
  1700. {
  1701. return "client";
  1702. }
  1703.  
  1704.  
  1705. //-----------------------------------------------------------------------------
  1706. // Methods relating to solid type + flags
  1707. //-----------------------------------------------------------------------------
  1708. inline void C_BaseEntity::SetSolidFlags( int nFlags )
  1709. {
  1710. CollisionProp( )->SetSolidFlags( nFlags );
  1711. }
  1712.  
  1713. inline bool C_BaseEntity::IsSolidFlagSet( int flagMask ) const
  1714. {
  1715. return CollisionProp( )->IsSolidFlagSet( flagMask );
  1716. }
  1717.  
  1718. inline int C_BaseEntity::GetSolidFlags( void ) const
  1719. {
  1720. return CollisionProp( )->GetSolidFlags( );
  1721. }
  1722.  
  1723. inline void C_BaseEntity::AddSolidFlags( int nFlags )
  1724. {
  1725. CollisionProp( )->AddSolidFlags( nFlags );
  1726. }
  1727.  
  1728. inline void C_BaseEntity::RemoveSolidFlags( int nFlags )
  1729. {
  1730. CollisionProp( )->RemoveSolidFlags( nFlags );
  1731. }
  1732.  
  1733. inline bool C_BaseEntity::IsSolid( ) const
  1734. {
  1735. return CollisionProp( )->IsSolid( );
  1736. }
  1737.  
  1738. inline void C_BaseEntity::SetSolid( SolidType_t val )
  1739. {
  1740. CollisionProp( )->SetSolid( val );
  1741. }
  1742.  
  1743. inline SolidType_t C_BaseEntity::GetSolid( ) const
  1744. {
  1745. return CollisionProp( )->GetSolid( );
  1746. }
  1747.  
  1748. inline void C_BaseEntity::SetCollisionBounds( const Vector& mins, const Vector &maxs )
  1749. {
  1750. CollisionProp( )->SetCollisionBounds( mins, maxs );
  1751. }
  1752.  
  1753.  
  1754. //-----------------------------------------------------------------------------
  1755. // Methods relating to bounds
  1756. //-----------------------------------------------------------------------------
  1757. inline const Vector& C_BaseEntity::WorldAlignMins( ) const
  1758. {
  1759. Assert( !CollisionProp( )->IsBoundsDefinedInEntitySpace( ) );
  1760. Assert( CollisionProp( )->GetCollisionAngles( ) == vec3_angle );
  1761. return CollisionProp( )->OBBMins( );
  1762. }
  1763.  
  1764. inline const Vector& C_BaseEntity::WorldAlignMaxs( ) const
  1765. {
  1766. Assert( !CollisionProp( )->IsBoundsDefinedInEntitySpace( ) );
  1767. Assert( CollisionProp( )->GetCollisionAngles( ) == vec3_angle );
  1768. return CollisionProp( )->OBBMaxs( );
  1769. }
  1770.  
  1771. inline const Vector& C_BaseEntity::WorldAlignSize( ) const
  1772. {
  1773. Assert( !CollisionProp( )->IsBoundsDefinedInEntitySpace( ) );
  1774. Assert( CollisionProp( )->GetCollisionAngles( ) == vec3_angle );
  1775. return CollisionProp( )->OBBSize( );
  1776. }
  1777.  
  1778. inline float CBaseEntity::BoundingRadius( ) const
  1779. {
  1780. return CollisionProp( )->BoundingRadius( );
  1781. }
  1782.  
  1783. inline bool CBaseEntity::IsPointSized( ) const
  1784. {
  1785. return CollisionProp( )->BoundingRadius( ) == 0.0f;
  1786. }
  1787.  
  1788.  
  1789. //-----------------------------------------------------------------------------
  1790. // Methods relating to traversing hierarchy
  1791. //-----------------------------------------------------------------------------
  1792. inline C_BaseEntity *C_BaseEntity::GetMoveParent( void ) const
  1793. {
  1794. return m_pMoveParent;
  1795. }
  1796.  
  1797. inline C_BaseEntity *C_BaseEntity::FirstMoveChild( void ) const
  1798. {
  1799. return m_pMoveChild;
  1800. }
  1801.  
  1802. inline C_BaseEntity *C_BaseEntity::NextMovePeer( void ) const
  1803. {
  1804. return m_pMovePeer;
  1805. }
  1806.  
  1807. //-----------------------------------------------------------------------------
  1808. // Velocity
  1809. //-----------------------------------------------------------------------------
  1810. inline const Vector& C_BaseEntity::GetLocalVelocity( ) const
  1811. {
  1812. return m_vecVelocity;
  1813. }
  1814.  
  1815. inline const QAngle& C_BaseEntity::GetLocalAngularVelocity( ) const
  1816. {
  1817. return m_vecAngVelocity;
  1818. }
  1819.  
  1820. inline const Vector& C_BaseEntity::GetBaseVelocity( ) const
  1821. {
  1822. return m_vecBaseVelocity;
  1823. }
  1824.  
  1825. inline void C_BaseEntity::SetBaseVelocity( const Vector& v )
  1826. {
  1827. m_vecBaseVelocity = v;
  1828. }
  1829.  
  1830. inline void C_BaseEntity::SetFriction( float flFriction )
  1831. {
  1832. m_flFriction = flFriction;
  1833. }
  1834.  
  1835. inline void C_BaseEntity::SetGravity( float flGravity )
  1836. {
  1837. m_flGravity = flGravity;
  1838. }
  1839.  
  1840. inline float C_BaseEntity::GetGravity( void ) const
  1841. {
  1842. return m_flGravity;
  1843. }
  1844.  
  1845. inline int C_BaseEntity::GetWaterLevel( ) const
  1846. {
  1847. return m_nWaterLevel;
  1848. }
  1849.  
  1850. inline void C_BaseEntity::SetWaterLevel( int nLevel )
  1851. {
  1852. m_nWaterLevel = nLevel;
  1853. }
  1854.  
  1855. inline float C_BaseEntity::GetElasticity( void ) const
  1856. {
  1857. return m_flElasticity;
  1858. }
  1859.  
  1860. inline const color24 CBaseEntity::GetRenderColor( ) const
  1861. {
  1862. color24 c = { m_clrRender->r, m_clrRender->g, m_clrRender->b };
  1863. return c;
  1864. }
  1865.  
  1866. inline byte C_BaseEntity::GetRenderColorR( ) const
  1867. {
  1868. return m_clrRender->r;
  1869. }
  1870.  
  1871. inline byte C_BaseEntity::GetRenderColorG( ) const
  1872. {
  1873. return m_clrRender->g;
  1874. }
  1875.  
  1876. inline byte C_BaseEntity::GetRenderColorB( ) const
  1877. {
  1878. return m_clrRender->b;
  1879. }
  1880.  
  1881. inline void C_BaseEntity::SetRenderColor( byte r, byte g, byte b )
  1882. {
  1883. m_clrRender.SetR( r );
  1884. m_clrRender.SetG( g );
  1885. m_clrRender.SetB( b );
  1886. }
  1887.  
  1888. inline void C_BaseEntity::SetRenderColorR( byte r )
  1889. {
  1890. m_clrRender.SetR( r );
  1891. }
  1892.  
  1893. inline void C_BaseEntity::SetRenderColorG( byte g )
  1894. {
  1895. m_clrRender.SetG( g );
  1896. }
  1897.  
  1898. inline void C_BaseEntity::SetRenderColorB( byte b )
  1899. {
  1900. m_clrRender.SetB( b );
  1901. }
  1902.  
  1903. inline RenderMode_t C_BaseEntity::GetRenderMode( ) const
  1904. {
  1905. return (RenderMode_t)m_nRenderMode;
  1906. }
  1907.  
  1908. inline RenderFx_t C_BaseEntity::GetRenderFX( ) const
  1909. {
  1910. return (RenderFx_t)m_nRenderFX;
  1911. }
  1912.  
  1913. inline void C_BaseEntity::SetCPULevels( int nMinCPULevel, int nMaxCPULevel )
  1914. {
  1915. m_nMinCPULevel = nMinCPULevel;
  1916. m_nMaxCPULevel = nMaxCPULevel;
  1917. }
  1918.  
  1919. inline void C_BaseEntity::SetGPULevels( int nMinGPULevel, int nMaxGPULevel )
  1920. {
  1921. m_nMinGPULevel = nMinGPULevel;
  1922. m_nMaxGPULevel = nMaxGPULevel;
  1923. }
  1924.  
  1925. inline int C_BaseEntity::GetMinCPULevel( ) const
  1926. {
  1927. return m_nMinCPULevel;
  1928. }
  1929.  
  1930. inline int C_BaseEntity::GetMaxCPULevel( ) const
  1931. {
  1932. return m_nMaxCPULevel;
  1933. }
  1934.  
  1935. inline int C_BaseEntity::GetMinGPULevel( ) const
  1936. {
  1937. return m_nMinGPULevel;
  1938. }
  1939.  
  1940. inline int C_BaseEntity::GetMaxGPULevel( ) const
  1941. {
  1942. return m_nMaxGPULevel;
  1943. }
  1944.  
  1945.  
  1946. //-----------------------------------------------------------------------------
  1947. // checks to see if the entity is marked for deletion
  1948. //-----------------------------------------------------------------------------
  1949. //inline bool C_BaseEntity::IsMarkedForDeletion( void )
  1950. //{
  1951. // return ( m_iEFlags & EFL_KILLME );
  1952. //}
  1953. //
  1954. //inline void C_BaseEntity::AddEFlags( int nEFlagMask )
  1955. //{
  1956. // m_iEFlags |= nEFlagMask;
  1957. //}
  1958. //
  1959. //inline void C_BaseEntity::RemoveEFlags( int nEFlagMask )
  1960. //{
  1961. // m_iEFlags &= ~nEFlagMask;
  1962. //}
  1963. //
  1964. //inline bool CBaseEntity::IsEFlagSet( int nEFlagMask ) const
  1965. //{
  1966. // return ( m_iEFlags & nEFlagMask ) != 0;
  1967. //}
  1968. //
  1969. //inline unsigned char CBaseEntity::GetParentAttachment( ) const
  1970. //{
  1971. // return m_iParentAttachment;
  1972. //}
  1973.  
  1974. //inline ClientRenderHandle_t C_BaseEntity::GetRenderHandle( ) const
  1975. //{
  1976. // return m_hRender;
  1977. //}
  1978. //
  1979. //inline ClientRenderHandle_t& C_BaseEntity::RenderHandle( )
  1980. //{
  1981. // return m_hRender;
  1982. //}
  1983. //
  1984. //inline int C_BaseEntity::team( )
  1985. //{
  1986. // return m_iTeamNum;
  1987. //}
  1988. //
  1989. //inline bool C_BaseEntity::IsScoped( )
  1990. //{
  1991. // return *(bool*)( ( DWORD )this + offys.dwbIsScoped );
  1992. //}
  1993. //
  1994. //inline int C_BaseEntity::health( )
  1995. //{
  1996. // return m_iHealth;
  1997. //}
  1998. //
  1999. //inline int C_BaseEntity::InCross( )
  2000. //{
  2001. // return *(int*)( ( DWORD )this + 0x23DC );
  2002. //}
  2003.  
  2004. //inline Vector C_BaseEntity::GetAbsOrigin( )
  2005. //{
  2006. // return m_vecAbsOrigin;
  2007. //}
  2008. //
  2009. //inline QAngle C_BaseEntity::GetAbsAngles( )
  2010. //{
  2011. // return m_angAbsRotation;
  2012. //}
  2013. //
  2014. //
  2015. //inline QAngle C_BaseEntity::GetViewPunch( )
  2016. //{
  2017. // return *(QAngle*)( ( DWORD )this + offys.dwViewPunchAngles );
  2018. //}
  2019. //
  2020. //inline QAngle* C_BaseEntity::GetAimPunchPtr( )
  2021. //{
  2022. // return (QAngle*)( ( DWORD )this + offys.dwVecPunchAngles );
  2023. //}
  2024. //
  2025. //inline QAngle* C_BaseEntity::GetViewPunchPtr( )
  2026. //{
  2027. // return (QAngle*)( ( DWORD )this + offys.dwViewPunchAngles );
  2028. //}
  2029.  
  2030. //inline Vector C_BaseEntity::GetVelocity( )
  2031. //{
  2032. //return m_vecAbsVelocity;
  2033. //}
  2034.  
  2035. //inline Vector C_BaseEntity::GetEyePos( )
  2036. //{
  2037. // return m_vecAbsOrigin + m_vecViewOffset;
  2038. //}
  2039. //
  2040. //inline Vector C_BaseEntity::GetPredictedEyePos( )
  2041. //{
  2042. // return GetEyePos( ) + GetVelocity( ) * g_pGlobals->interval_per_tick * g_pGlobals->interpolation_amount;
  2043. //}
  2044. //
  2045. //inline CPlayerState* C_BaseEntity::GetPlayerState( )
  2046. //{
  2047. // return (CPlayerState*)( ( DWORD )this + offys.dwPlayerState );
  2048. //}
  2049. //
  2050. //inline QAngle C_BaseEntity::GetEyeAngles( )
  2051. //{
  2052. // return *(QAngle*)( ( DWORD )this + offys.dwEyeAngles );//GetPlayerState()->v_angle; for local player
  2053. //}
  2054. //
  2055. //inline int C_BaseEntity::GetGlowIndex( )
  2056. //{
  2057. // return *(int*)( ( DWORD )this + 0x1DB0 );
  2058. //}
  2059.  
  2060.  
  2061. inline void C_BaseEntity::UpdateEntityGlow( Vector color, float alpha, float bloomVal = 1.0f )
  2062. {
  2063. int index = g_pGlowObjectManager->GetIndex( this );
  2064. g_pGlowObjectManager->SetEntity( index, this );
  2065. g_pGlowObjectManager->SetColor( index, color );
  2066. g_pGlowObjectManager->SetAlpha( index, alpha );
  2067. g_pGlowObjectManager->SetBloom( index, bloomVal );
  2068. g_pGlowObjectManager->SetRenderFlags( index, true, false );
  2069. }
  2070.  
  2071. inline void C_BaseEntity::GetEyeVectors( Vector *pForward, Vector *pRight = NULL, Vector *pUp = NULL )
  2072. {
  2073. AngleVectors( GetEyeAngles( ), pForward, pRight, pUp );
  2074. }
  2075.  
  2076. //inline int C_BaseEntity::TickBase( )
  2077. //{
  2078. // return *(int*)( ( DWORD )this + offys.dwTickBase );
  2079. //}
  2080.  
  2081. //inline C_BaseCombatWeapon* C_BaseEntity::GetWeapon( )
  2082. //{
  2083. //DWORD weaponHandle = *(DWORD*)( ( DWORD )this + (DWORD)offys.dwhActiveWeapon );
  2084. //return (C_BaseCombatWeapon*)( entitylist->GetClientEntity( weaponHandle & 0xFFF ) );
  2085. //}
  2086.  
  2087.  
  2088. //-----------------------------------------------------------------------------
  2089. // Methods to cast away const
  2090. //-----------------------------------------------------------------------------
  2091. //inline Vector C_BaseEntity::EyePosition( void ) const
  2092. //{
  2093. // return const_cast<C_BaseEntity*>( this )->EyePosition( );
  2094. //}
  2095. //
  2096. //inline const QAngle &C_BaseEntity::EyeAngles( void ) const // Direction of eyes in world space
  2097. //{
  2098. // return const_cast<C_BaseEntity*>( this )->EyeAngles( );
  2099. //}
  2100. //
  2101. //inline const QAngle &C_BaseEntity::LocalEyeAngles( void ) const // Direction of eyes
  2102. //{
  2103. // return const_cast<C_BaseEntity*>( this )->LocalEyeAngles( );
  2104. //}
  2105. //
  2106. //inline Vector C_BaseEntity::EarPosition( void ) const // position of ears
  2107. //{
  2108. // return const_cast<C_BaseEntity*>( this )->EarPosition( );
  2109. //}
  2110. //
  2111. //inline VarMapping_t* C_BaseEntity::GetVarMapping( )
  2112. //{
  2113. // return &m_VarMap;
  2114. //}
  2115.  
  2116.  
  2117. //-----------------------------------------------------------------------------
  2118. // Should we be interpolating?
  2119. //-----------------------------------------------------------------------------
  2120. inline bool C_BaseEntity::IsInterpolationEnabled( )
  2121. {
  2122. return s_bInterpolate;
  2123. }
  2124.  
  2125. //-----------------------------------------------------------------------------
  2126. // Purpose:
  2127. // Input : handle -
  2128. // Output : inline void
  2129. //-----------------------------------------------------------------------------
  2130. inline void C_BaseEntity::SetToolHandle( HTOOLHANDLE handle )
  2131. {
  2132. #ifndef NO_TOOLFRAMEWORK
  2133. m_ToolHandle = handle;
  2134. #endif
  2135. }
  2136.  
  2137. //-----------------------------------------------------------------------------
  2138. // Purpose:
  2139. // Input : -
  2140. // Output : inline HTOOLHANDLE
  2141. //-----------------------------------------------------------------------------
  2142. inline HTOOLHANDLE C_BaseEntity::GetToolHandle( ) const
  2143. {
  2144. #ifndef NO_TOOLFRAMEWORK
  2145. return m_ToolHandle;
  2146. #else
  2147. return (HTOOLHANDLE)0;
  2148. #endif
  2149. }
  2150.  
  2151. //-----------------------------------------------------------------------------
  2152. //
  2153. //-----------------------------------------------------------------------------
  2154. inline bool C_BaseEntity::IsEnabledInToolView( ) const
  2155. {
  2156.  
  2157. return false;
  2158. //#ifndef NO_TOOLFRAMEWORK
  2159. // return m_bEnabledInToolView;
  2160. //#else
  2161. // return false;
  2162. //#endif
  2163. }
  2164.  
  2165.  
  2166. //-----------------------------------------------------------------------------
  2167. // Client version of UTIL_Remove
  2168. //-----------------------------------------------------------------------------
  2169. inline void UTIL_Remove( C_BaseEntity *pEntity )
  2170. {
  2171. pEntity->Remove( );
  2172. }
  2173.  
  2174.  
  2175. inline bool C_BaseEntity::ShouldRecordInTools( ) const
  2176. {
  2177. #ifndef NO_TOOLFRAMEWORK
  2178. return m_bRecordInTools;
  2179. #else
  2180. return true;
  2181. #endif
  2182. }
  2183.  
  2184. inline bool C_BaseEntity::IsVisible( ) const
  2185. {
  2186. ASSERT_LOCAL_PLAYER_RESOLVABLE( );
  2187. if ( INVALID_CLIENT_RENDER_HANDLE == m_hRender )
  2188. return false;
  2189. return m_VisibilityBits.IsBitSet( GET_ACTIVE_SPLITSCREEN_SLOT( ) );
  2190. }
  2191.  
  2192. inline bool C_BaseEntity::IsVisibleToAnyPlayer( ) const
  2193. {
  2194. return !m_VisibilityBits.IsAllClear( );
  2195. }
  2196.  
  2197. inline bool C_BaseEntity::HasSpawnFlags( int nFlags ) const
  2198. {
  2199. return ( m_spawnflags & nFlags ) != 0;
  2200. }
  2201.  
  2202. //-----------------------------------------------------------------------------
  2203. // Inline methods
  2204. //-----------------------------------------------------------------------------
  2205. inline const char *C_BaseEntity::GetEntityName( )
  2206. {
  2207. return m_iName;
  2208. }
  2209.  
  2210. class CAbsQueryScopeGuard
  2211. {
  2212. public:
  2213. CAbsQueryScopeGuard( bool state )
  2214. {
  2215. m_bSavedState = C_BaseEntity::IsAbsQueriesValid( );
  2216. C_BaseEntity::SetAbsQueriesValid( state );
  2217. }
  2218. ~CAbsQueryScopeGuard( )
  2219. {
  2220. C_BaseEntity::SetAbsQueriesValid( m_bSavedState );
  2221. }
  2222. private:
  2223. bool m_bSavedState;
  2224. };
  2225.  
  2226. #define ABS_QUERY_GUARD( state ) CAbsQueryScopeGuard s_AbsQueryGuard( state );
  2227.  
  2228. C_BaseEntity *CreateEntityByName( const char *className );
  2229.  
  2230. #if !defined( NO_ENTITY_PREDICTION )
  2231. class CEntIndexLessFunc
  2232. {
  2233. public:
  2234. bool Less( C_BaseEntity * const & lhs, C_BaseEntity * const & rhs, void *pContext )
  2235. {
  2236. int e1 = lhs->entindex( );
  2237. int e2 = rhs->entindex( );
  2238.  
  2239. // if an entity has an invalid entity index, then put it at the end of the list
  2240. e1 = ( e1 == -1 ) ? MAX_EDICTS : e1;
  2241. e2 = ( e2 == -1 ) ? MAX_EDICTS : e2;
  2242.  
  2243. return e1 < e2;
  2244. }
  2245. };
  2246.  
  2247. //-----------------------------------------------------------------------------
  2248. // Purpose: Maintains a list of predicted or client created entities
  2249. //-----------------------------------------------------------------------------
  2250. class CPredictableList
  2251. {
  2252. public:
  2253. C_BaseEntity *GetPredictable( int slot );
  2254. int GetPredictableCount( void ) const;
  2255.  
  2256. protected:
  2257. void AddToPredictableList( C_BaseEntity *add );
  2258. void RemoveFromPredictablesList( C_BaseEntity *remove );
  2259.  
  2260. private:
  2261. CUtlSortVector< C_BaseEntity *, CEntIndexLessFunc > m_Predictables;
  2262.  
  2263. friend class C_BaseEntity;
  2264. };
  2265.  
  2266. FORCEINLINE C_BaseEntity *CPredictableList::GetPredictable( int slot )
  2267. {
  2268. return m_Predictables[ slot ];
  2269. }
  2270.  
  2271. FORCEINLINE int CPredictableList::GetPredictableCount( void ) const
  2272. {
  2273. return m_Predictables.Count( );
  2274. }
  2275.  
  2276. FORCEINLINE int C_BaseEntity::GetSplitUserPlayerPredictionSlot( )
  2277. {
  2278. #if defined( USE_PREDICTABLEID )
  2279. Assert( m_bPredictable || m_pPredictionContext );
  2280. #else
  2281. Assert( m_bPredictable );
  2282. #endif
  2283. return m_nSplitUserPlayerPredictionSlot;
  2284. }
  2285.  
  2286. extern CPredictableList *GetPredictables( int nSlot );
  2287.  
  2288. // To temporarily muck with g_pGlobals->curtime
  2289. class CCurTimeScopeGuard
  2290. {
  2291. public:
  2292. CCurTimeScopeGuard( float flNewCurTime, bool bOptionalCondition = true );
  2293. ~CCurTimeScopeGuard( );
  2294. private:
  2295.  
  2296. float m_flSavedTime;
  2297. bool m_bActive;
  2298. };
  2299. #endif
  2300.  
  2301.  
  2302. #endif // C_BASEENTITY_H
Add Comment
Please, Sign In to add comment