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.

236 lines
10 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ITOOLENTITY_H
  7. #define ITOOLENTITY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/interface.h"
  12. #include "tier1/utlvector.h"
  13. #include "color.h"
  14. #include "basehandle.h"
  15. #include "iclientrenderable.h"
  16. #include "engine/ishadowmgr.h"
  17. #include "engine/ivmodelinfo.h"
  18. #include "engine/IClientLeafSystem.h"
  19. //-----------------------------------------------------------------------------
  20. // Forward declarations
  21. //-----------------------------------------------------------------------------
  22. class IServerEntity;
  23. class IClientEntity;
  24. class IToolSystem;
  25. class IClientRenderable;
  26. class Vector;
  27. class QAngle;
  28. //-----------------------------------------------------------------------------
  29. // Safe accessor to an entity
  30. //-----------------------------------------------------------------------------
  31. typedef unsigned int HTOOLHANDLE;
  32. enum
  33. {
  34. HTOOLHANDLE_INVALID = 0
  35. };
  36. //-----------------------------------------------------------------------------
  37. // If you change this, change the flags in IClientShadowMgr.h also
  38. //-----------------------------------------------------------------------------
  39. enum ClientShadowFlags_t
  40. {
  41. SHADOW_FLAGS_USE_RENDER_TO_TEXTURE = (SHADOW_FLAGS_LAST_FLAG<<1),
  42. SHADOW_FLAGS_ANIMATING_SOURCE = (SHADOW_FLAGS_LAST_FLAG<<2),
  43. SHADOW_FLAGS_USE_DEPTH_TEXTURE = (SHADOW_FLAGS_LAST_FLAG<<3),
  44. SHADOW_FLAGS_CUSTOM_DRAW = (SHADOW_FLAGS_LAST_FLAG<<4),
  45. // Update this if you add flags
  46. CLIENT_SHADOW_FLAGS_LAST_FLAG = SHADOW_FLAGS_CUSTOM_DRAW
  47. };
  48. //-----------------------------------------------------------------------------
  49. // Opaque pointer returned from Find* methods, don't store this, you need to
  50. // Attach it to a tool entity or discard after searching
  51. //-----------------------------------------------------------------------------
  52. typedef void *EntitySearchResult;
  53. typedef void *ParticleSystemSearchResult;
  54. //-----------------------------------------------------------------------------
  55. // Purpose: Client side tool interace (right now just handles IClientRenderables).
  56. // In theory could support hooking into client side entities directly
  57. //-----------------------------------------------------------------------------
  58. class IClientTools : public IBaseInterface
  59. {
  60. public:
  61. // Allocates or returns the handle to an entity previously found using the Find* APIs below
  62. virtual HTOOLHANDLE AttachToEntity( EntitySearchResult entityToAttach ) = 0;
  63. virtual void DetachFromEntity( EntitySearchResult entityToDetach ) = 0;
  64. virtual EntitySearchResult GetEntity( HTOOLHANDLE handle ) = 0;
  65. // Checks whether a handle is still valid.
  66. virtual bool IsValidHandle( HTOOLHANDLE handle ) = 0;
  67. // Iterates the list of entities which have been associated with tools
  68. virtual int GetNumRecordables() = 0;
  69. virtual HTOOLHANDLE GetRecordable( int index ) = 0;
  70. // Iterates through ALL entities (separate list for client vs. server)
  71. virtual EntitySearchResult NextEntity( EntitySearchResult currentEnt ) = 0;
  72. EntitySearchResult FirstEntity() { return NextEntity( NULL ); }
  73. // Use this to turn on/off the presence of an underlying game entity
  74. virtual void SetEnabled( HTOOLHANDLE handle, bool enabled ) = 0;
  75. // Use this to tell an entity to post "state" to all listening tools
  76. virtual void SetRecording( HTOOLHANDLE handle, bool recording ) = 0;
  77. // Some entities are marked with ShouldRecordInTools false, such as ui entities, etc.
  78. virtual bool ShouldRecord( HTOOLHANDLE handle ) = 0;
  79. virtual HTOOLHANDLE GetToolHandleForEntityByIndex( int entindex ) = 0;
  80. virtual int GetModelIndex( HTOOLHANDLE handle ) = 0;
  81. virtual const char* GetModelName ( HTOOLHANDLE handle ) = 0;
  82. virtual const char* GetClassname ( HTOOLHANDLE handle ) = 0;
  83. virtual void AddClientRenderable( IClientRenderable *pRenderable, bool bDrawWithViewModels, RenderableTranslucencyType_t nType, RenderableModelType_t nModelType = RENDERABLE_MODEL_UNKNOWN_TYPE ) = 0;
  84. virtual void RemoveClientRenderable( IClientRenderable *pRenderable ) = 0;
  85. virtual void SetTranslucencyType( IClientRenderable *pRenderable, RenderableTranslucencyType_t nType ) = 0;
  86. virtual void MarkClientRenderableDirty( IClientRenderable *pRenderable ) = 0;
  87. virtual void UpdateProjectedTexture( ClientShadowHandle_t h, bool bForce ) = 0;
  88. virtual bool DrawSprite( IClientRenderable *pRenderable, float scale, float frame, int rendermode, int renderfx, const Color &color, float flProxyRadius, int *pVisHandle ) = 0;
  89. virtual void DrawSprite( const Vector &vecOrigin, float flWidth, float flHeight, color32 color ) = 0;
  90. virtual EntitySearchResult GetLocalPlayer() = 0;
  91. virtual bool GetLocalPlayerEyePosition( Vector& org, QAngle& ang, float &fov ) = 0;
  92. // See ClientShadowFlags_t above
  93. virtual ClientShadowHandle_t CreateShadow( CBaseHandle handle, int nFlags ) = 0;
  94. virtual void DestroyShadow( ClientShadowHandle_t h ) = 0;
  95. virtual ClientShadowHandle_t CreateFlashlight( const FlashlightState_t &lightState ) = 0;
  96. virtual void DestroyFlashlight( ClientShadowHandle_t h ) = 0;
  97. virtual void UpdateFlashlightState( ClientShadowHandle_t h, const FlashlightState_t &lightState ) = 0;
  98. virtual void AddToDirtyShadowList( ClientShadowHandle_t h, bool force = false ) = 0;
  99. virtual void MarkRenderToTextureShadowDirty( ClientShadowHandle_t h ) = 0;
  100. // Global toggle for recording
  101. virtual void EnableRecordingMode( bool bEnable ) = 0;
  102. virtual bool IsInRecordingMode() const = 0;
  103. // Trigger a temp entity
  104. virtual void TriggerTempEntity( KeyValues *pKeyValues ) = 0;
  105. // get owning weapon (for viewmodels)
  106. virtual int GetOwningWeaponEntIndex( int entindex ) = 0;
  107. virtual int GetEntIndex( EntitySearchResult entityToAttach ) = 0;
  108. virtual int FindGlobalFlexcontroller( char const *name ) = 0;
  109. virtual char const *GetGlobalFlexControllerName( int idx ) = 0;
  110. // helper for traversing ownership hierarchy
  111. virtual EntitySearchResult GetOwnerEntity( EntitySearchResult currentEnt ) = 0;
  112. // common and useful types to query for hierarchically
  113. virtual bool IsPlayer ( EntitySearchResult currentEnt ) = 0;
  114. virtual bool IsCombatCharacter ( EntitySearchResult currentEnt ) = 0;
  115. virtual bool IsNPC ( EntitySearchResult currentEnt ) = 0;
  116. virtual bool IsRagdoll ( EntitySearchResult currentEnt ) = 0;
  117. virtual bool IsViewModel ( EntitySearchResult currentEnt ) = 0;
  118. virtual bool IsViewModelOrAttachment( EntitySearchResult currentEnt ) = 0;
  119. virtual bool IsWeapon ( EntitySearchResult currentEnt ) = 0;
  120. virtual bool IsSprite ( EntitySearchResult currentEnt ) = 0;
  121. virtual bool IsProp ( EntitySearchResult currentEnt ) = 0;
  122. virtual bool IsBrush ( EntitySearchResult currentEnt ) = 0;
  123. virtual Vector GetAbsOrigin( HTOOLHANDLE handle ) = 0;
  124. virtual QAngle GetAbsAngles( HTOOLHANDLE handle ) = 0;
  125. // This reloads a portion or all of a particle definition file.
  126. // It's up to the client to decide if it cares about this file
  127. // Use a UtlBuffer to crack the data
  128. virtual void ReloadParticleDefintions( const char *pFileName, const void *pBufData, int nLen ) = 0;
  129. // ParticleSystem iteration, query, modification
  130. virtual ParticleSystemSearchResult FirstParticleSystem() { return NextParticleSystem( NULL ); }
  131. virtual ParticleSystemSearchResult NextParticleSystem( ParticleSystemSearchResult sr ) = 0;
  132. virtual void SetRecording( ParticleSystemSearchResult sr, bool bRecord ) = 0;
  133. // Sends a mesage from the tool to the client
  134. virtual void PostToolMessage( KeyValues *pKeyValues ) = 0;
  135. // Indicates whether the client should render particle systems
  136. virtual void EnableParticleSystems( bool bEnable ) = 0;
  137. // Is the game rendering in 3rd person mode?
  138. virtual bool IsRenderingThirdPerson() const = 0;
  139. };
  140. #define VCLIENTTOOLS_INTERFACE_VERSION "VCLIENTTOOLS001"
  141. class CEntityRespawnInfo
  142. {
  143. public:
  144. int m_nHammerID;
  145. const char *m_pEntText;
  146. };
  147. //-----------------------------------------------------------------------------
  148. // Purpose: Interface from engine to tools for manipulating entities
  149. //-----------------------------------------------------------------------------
  150. class IServerTools : public IBaseInterface
  151. {
  152. public:
  153. virtual IServerEntity *GetIServerEntity( IClientEntity *pClientEntity ) = 0;
  154. virtual bool SnapPlayerToPosition( const Vector &org, const QAngle &ang, IClientEntity *pClientPlayer = NULL ) = 0;
  155. virtual bool GetPlayerPosition( Vector &org, QAngle &ang, IClientEntity *pClientPlayer = NULL ) = 0;
  156. virtual bool SetPlayerFOV( int fov, IClientEntity *pClientPlayer = NULL ) = 0;
  157. virtual int GetPlayerFOV( IClientEntity *pClientPlayer = NULL ) = 0;
  158. virtual bool IsInNoClipMode( IClientEntity *pClientPlayer = NULL ) = 0;
  159. // entity searching
  160. virtual void *FirstEntity( void ) = 0;
  161. virtual void *NextEntity( void *pEntity ) = 0;
  162. virtual void *FindEntityByHammerID( int iHammerID ) = 0;
  163. // entity query
  164. virtual bool GetKeyValue( void *pEntity, const char *szField, char *szValue, int iMaxLen ) = 0;
  165. virtual bool SetKeyValue( void *pEntity, const char *szField, const char *szValue ) = 0;
  166. virtual bool SetKeyValue( void *pEntity, const char *szField, float flValue ) = 0;
  167. virtual bool SetKeyValue( void *pEntity, const char *szField, const Vector &vecValue ) = 0;
  168. // entity spawning
  169. virtual void *CreateEntityByName( const char *szClassName ) = 0;
  170. virtual void DispatchSpawn( void *pEntity ) = 0;
  171. virtual bool DestroyEntityByHammerId( int iHammerID ) = 0;
  172. // This function respawns the entity into the same entindex slot AND tricks the EHANDLE system into thinking it's the same
  173. // entity version so anyone holding an EHANDLE to the entity points at the newly-respawned entity.
  174. virtual bool RespawnEntitiesWithEdits( CEntityRespawnInfo *pInfos, int nInfos ) = 0;
  175. // This reloads a portion or all of a particle definition file.
  176. // It's up to the server to decide if it cares about this file
  177. // Use a UtlBuffer to crack the data
  178. virtual void ReloadParticleDefintions( const char *pFileName, const void *pBufData, int nLen ) = 0;
  179. virtual void AddOriginToPVS( const Vector &org ) = 0;
  180. virtual void MoveEngineViewTo( const Vector &vPos, const QAngle &vAngles ) = 0;
  181. // Call UTIL_Remove on the entity.
  182. virtual void RemoveEntity( int nHammerID ) = 0;
  183. };
  184. #define VSERVERTOOLS_INTERFACE_VERSION "VSERVERTOOLS001"
  185. #endif // ITOOLENTITY_H