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.

150 lines
5.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: provides an interface for plugins to query information about entities from the game dll
  4. //
  5. //===============================================================================================//
  6. #ifndef IENTITYINFO_H
  7. #define IENTITYINFO_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "mathlib/vector.h"
  12. #include "pluginvariant.h"
  13. abstract_class IEntityInfo
  14. {
  15. public:
  16. // returns true if entity is a player
  17. virtual const int EntityIndex() = 0;
  18. virtual const char *GetEntityName() = 0;
  19. virtual const char *GetClassname() = 0;
  20. virtual const char *GetModelName() = 0;
  21. //TODO
  22. virtual const char *GetTargetName() = 0;
  23. virtual void SetModel(const char *modelName) = 0;
  24. virtual bool IsPlayer() = 0;
  25. virtual bool IsNPC() = 0;
  26. virtual bool IsDead() = 0;
  27. virtual bool IsAlive() = 0;
  28. virtual bool IsInWorld() = 0;
  29. virtual bool IsTemplate() = 0;
  30. virtual int GetEFlags() = 0;
  31. virtual void SetEFlags( int iEFlags ) = 0;
  32. virtual void AddEFlags( int nEFlagMask ) = 0;
  33. virtual bool IsEFlagSet( int EFlagMask ) = 0;
  34. virtual const int GetEffects( void ) = 0;
  35. virtual void AddEffects( int nEffects ) = 0;
  36. virtual void RemoveEffects( int nEffects ) = 0;
  37. virtual void ClearEffects( void ) = 0;
  38. virtual void SetEffects( int nEffects ) = 0;
  39. virtual bool IsEffectActive( int nEffects ) = 0;
  40. virtual int GetRenderMode() = 0;
  41. virtual void SetRenderMode( int nRenderMode ) = 0;
  42. virtual void SetBlocksLOS( bool bBlocksLOS ) = 0;
  43. virtual bool BlocksLOS( void ) = 0;
  44. virtual const int GetHealth() = 0;
  45. virtual const int GetMaxHealth() = 0;
  46. virtual void SetHealth( int iHealth ) = 0;
  47. virtual void SetMaxHealth( int iMaxHealth ) = 0;
  48. // returns the team the entity is on
  49. virtual int GetTeamIndex() = 0;
  50. // changes the entity to a new team (if the game dll logic allows it)
  51. virtual void ChangeTeam( int iTeamNum ) = 0;
  52. // positioning and sizes
  53. virtual const Vector GetAbsOrigin() = 0;
  54. virtual void SetAbsOrigin( Vector & vec ) = 0;
  55. virtual const QAngle GetAbsAngles() = 0;
  56. virtual void SetAbsAngles( QAngle & ang ) = 0;
  57. virtual const Vector GetLocalOrigin() = 0;
  58. virtual void SetLocalOrigin( const Vector& origin ) = 0;
  59. virtual const QAngle GetLocalAngles() = 0;
  60. virtual void SetLocalAngles( const QAngle& angles ) = 0;
  61. virtual const Vector GetAbsVelocity() = 0;
  62. virtual const Vector GetLocalVelocity() = 0;
  63. virtual const QAngle GetLocalAngularVelocity() = 0;
  64. virtual void EntityToWorldSpace( const Vector &in, Vector *pOut ) = 0;
  65. virtual void WorldToEntitySpace( const Vector &in, Vector *pOut ) = 0;
  66. virtual Vector EyePosition() = 0;
  67. virtual QAngle EyeAngles() = 0;
  68. virtual QAngle LocalEyeAngles() = 0;
  69. virtual Vector EarPosition() = 0;
  70. // returns world aligned mins/maxs of this entity
  71. virtual const Vector GetWorldMins() = 0;
  72. virtual const Vector GetWorldMaxs() = 0;
  73. virtual const Vector WorldSpaceCenter() = 0;
  74. virtual int GetWaterLevel() = 0;
  75. // if this entity has an owner, it returns their edict_t.
  76. virtual edict_t *GetOwner() = 0;
  77. virtual edict_t *GetParent() = 0;
  78. virtual edict_t *GetMoveParent() = 0;
  79. virtual edict_t *GetRootMoveParent() = 0;
  80. // if this entity is following another, returns that entities edict_t.
  81. virtual edict_t *GetFollowedEntity() = 0;
  82. virtual edict_t *GetGroundEntity() = 0; //returns the entity that this one is standing on - if set.
  83. // accessor to hook mod specific information about the entity.
  84. virtual bool GetCustomInfo(int valueType, pluginvariant &outValue, pluginvariant options) = 0;
  85. // entity debugging stuff.
  86. virtual const char *GetDebugName() = 0;
  87. virtual void EntityText( int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255 ) = 0;
  88. //Keyvalues
  89. virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) = 0;
  90. };
  91. #define INTERFACEVERSION_ENTITYINFOMANAGER "EntityInfoManager001"
  92. abstract_class IEntityInfoManager
  93. {
  94. public:
  95. virtual IEntityInfo *GetEntityInfo( edict_t *pEdict ) = 0;
  96. virtual IEntityInfo *GetEntityInfo( int index ) = 0; //Retrieves the info
  97. //Experiment..
  98. virtual IServerUnknown *GetServerEntity( edict_t *pEdict ) = 0;
  99. //-----------------------------------------------------------------------------
  100. // Purpose: Iterates the entities with a given classname.
  101. // Input : pStartEntity - Last entity found, NULL to start a new iteration.
  102. // szName - Classname to search for.
  103. //-----------------------------------------------------------------------------
  104. virtual edict_t *FindEntityByClassname( edict_t *pStartEntity, const char *szName ) = 0;
  105. //-----------------------------------------------------------------------------
  106. // Purpose: Iterates the entities with a given name.
  107. // Input : pStartEntity - Last entity found, NULL to start a new iteration.
  108. // szName - Name to search for.
  109. //-----------------------------------------------------------------------------
  110. virtual edict_t *FindEntityByName( edict_t *pStartEntity, const char *szName ) = 0;
  111. //-----------------------------------------------------------------------------
  112. // Purpose: Iterates the entities with a given model name.
  113. // Input : pStartEntity - Last entity found, NULL to start a new iteration.
  114. // szModelName - Model Name to search for.
  115. //-----------------------------------------------------------------------------
  116. virtual edict_t *FindEntityByModel( edict_t *pStartEntity, const char *szModelName ) = 0;
  117. //-----------------------------------------------------------------------------
  118. // Purpose: Used to iterate all the entities within a sphere.
  119. // Input : pStartEntity -
  120. // vecCenter -
  121. // flRadius -
  122. //-----------------------------------------------------------------------------
  123. virtual edict_t *FindEntityInSphere( edict_t *pStartEntity, const Vector &vecCenter, float flRadius ) = 0;
  124. virtual void GetWorldBounds( Vector &mins, Vector &maxs ) = 0;
  125. };
  126. #endif // IENTITYINFO_H