Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.8 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef C_BASETEMPENTITY_H
  8. #define C_BASETEMPENTITY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "client_class.h"
  13. #include "iclientnetworkable.h"
  14. #include "c_recipientfilter.h"
  15. //-----------------------------------------------------------------------------
  16. // Purpose: Base class for TEs. All TEs should derive from this and at
  17. // least implement OnDataChanged to be notified when the TE has been received
  18. // from the server
  19. //-----------------------------------------------------------------------------
  20. class C_BaseTempEntity : public IClientUnknown, public IClientNetworkable
  21. {
  22. public:
  23. DECLARE_CLASS_NOBASE( C_BaseTempEntity );
  24. DECLARE_CLIENTCLASS();
  25. C_BaseTempEntity( void );
  26. virtual ~C_BaseTempEntity( void );
  27. // IClientUnknown implementation.
  28. public:
  29. virtual void SetRefEHandle( const CBaseHandle &handle ) { Assert( false ); }
  30. virtual const CBaseHandle& GetRefEHandle() const { Assert( false ); return *( ( CBaseHandle* )0 ); }
  31. virtual IClientUnknown* GetIClientUnknown() { return this; }
  32. virtual ICollideable* GetCollideable() { return 0; }
  33. virtual IClientNetworkable* GetClientNetworkable() { return this; }
  34. virtual IClientRenderable* GetClientRenderable() { return 0; }
  35. virtual IClientEntity* GetIClientEntity() { return 0; }
  36. virtual C_BaseEntity* GetBaseEntity() { return 0; }
  37. virtual IClientThinkable* GetClientThinkable() { return 0; }
  38. virtual IClientModelRenderable* GetClientModelRenderable() { return 0; }
  39. virtual IClientAlphaProperty* GetClientAlphaProperty() { return 0; }
  40. // IClientNetworkable overrides.
  41. public:
  42. virtual void Release();
  43. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  44. virtual void PreDataUpdate( DataUpdateType_t updateType );
  45. virtual void PostDataUpdate( DataUpdateType_t updateType );
  46. virtual void OnDataUnchangedInPVS( void ) { }
  47. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  48. virtual void OnDataChanged( DataUpdateType_t updateType );
  49. virtual void SetDormant( bool bDormant );
  50. virtual bool IsDormant( void ) const;
  51. virtual int entindex( void ) const;
  52. virtual void ReceiveMessage( int classID, bf_read &msg );
  53. virtual void* GetDataTableBasePtr();
  54. virtual void SetDestroyedOnRecreateEntities( void );
  55. public:
  56. // Dummy for CNetworkVars.
  57. void NetworkStateChanged() {}
  58. void NetworkStateChanged( void *pVar ) {}
  59. virtual bool Init(int entnum, int iSerialNum);
  60. virtual void Precache( void );
  61. // For dynamic entities, return true to allow destruction
  62. virtual bool ShouldDestroy( void ) { return false; };
  63. C_BaseTempEntity *GetNext( void );
  64. // Get list of tempentities
  65. static C_BaseTempEntity *GetList( void );
  66. C_BaseTempEntity *GetNextDynamic( void );
  67. // Determine the color modulation amount
  68. void GetColorModulation( float* color )
  69. {
  70. assert(color);
  71. color[0] = color[1] = color[2] = 1.0f;
  72. }
  73. // Should this object be able to have shadows cast onto it?
  74. virtual bool ShouldReceiveProjectedTextures( int flags ) { return false; }
  75. // Static members
  76. public:
  77. // List of dynamically allocated temp entis
  78. static C_BaseTempEntity *GetDynamicList();
  79. // Called at startup to allow temp entities to precache any models/sounds that they need
  80. static void PrecacheTempEnts( void );
  81. static void ClearDynamicTempEnts( void );
  82. static void CheckDynamicTempEnts( void );
  83. private:
  84. // Next in chain
  85. C_BaseTempEntity *m_pNext;
  86. C_BaseTempEntity *m_pNextDynamic;
  87. // TEs add themselves to this list for the executable.
  88. static C_BaseTempEntity *s_pTempEntities;
  89. static C_BaseTempEntity *s_pDynamicEntities;
  90. };
  91. #endif // C_BASETEMPENTITY_H