Team Fortress 2 Source Code as on 22/4/2020
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.

122 lines
3.6 KiB

  1. //========= Copyright 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 { 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. // IClientNetworkable overrides.
  39. public:
  40. virtual void Release();
  41. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  42. virtual void PreDataUpdate( DataUpdateType_t updateType );
  43. virtual void PostDataUpdate( DataUpdateType_t updateType );
  44. virtual void OnDataUnchangedInPVS( void ) { }
  45. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  46. virtual void OnDataChanged( DataUpdateType_t updateType );
  47. virtual void SetDormant( bool bDormant );
  48. virtual bool IsDormant( void );
  49. virtual int entindex( void ) const;
  50. virtual void ReceiveMessage( int classID, bf_read &msg );
  51. virtual void* GetDataTableBasePtr();
  52. virtual void SetDestroyedOnRecreateEntities( void );
  53. public:
  54. // Dummy for CNetworkVars.
  55. void NetworkStateChanged() {}
  56. void NetworkStateChanged( void *pVar ) {}
  57. virtual bool Init(int entnum, int iSerialNum);
  58. virtual void Precache( void );
  59. // For dynamic entities, return true to allow destruction
  60. virtual bool ShouldDestroy( void ) { return false; };
  61. C_BaseTempEntity *GetNext( void );
  62. // Get list of tempentities
  63. static C_BaseTempEntity *GetList( void );
  64. C_BaseTempEntity *GetNextDynamic( void );
  65. // Determine the color modulation amount
  66. void GetColorModulation( float* color )
  67. {
  68. assert(color);
  69. color[0] = color[1] = color[2] = 1.0f;
  70. }
  71. // Should this object be able to have shadows cast onto it?
  72. virtual bool ShouldReceiveProjectedTextures( int flags ) { return false; }
  73. // Static members
  74. public:
  75. // List of dynamically allocated temp entis
  76. static C_BaseTempEntity *GetDynamicList();
  77. // Called at startup to allow temp entities to precache any models/sounds that they need
  78. static void PrecacheTempEnts( void );
  79. static void ClearDynamicTempEnts( void );
  80. static void CheckDynamicTempEnts( void );
  81. private:
  82. // Next in chain
  83. C_BaseTempEntity *m_pNext;
  84. C_BaseTempEntity *m_pNextDynamic;
  85. // TEs add themselves to this list for the executable.
  86. static C_BaseTempEntity *s_pTempEntities;
  87. static C_BaseTempEntity *s_pDynamicEntities;
  88. };
  89. #endif // C_BASETEMPENTITY_H