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.

147 lines
5.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #if !defined( TEMPENT_H )
  9. #define TEMPENT_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "c_baseentity.h"
  14. #include "c_baseanimating.h"
  15. #include "c_sprite.h"
  16. // Temporary entity array
  17. #define TENTPRIORITY_LOW 0
  18. #define TENTPRIORITY_HIGH 1
  19. // TEMPENTITY flags
  20. #define FTENT_NONE 0x00000000
  21. #define FTENT_SINEWAVE 0x00000001
  22. #define FTENT_GRAVITY 0x00000002
  23. #define FTENT_ROTATE 0x00000004
  24. #define FTENT_SLOWGRAVITY 0x00000008
  25. #define FTENT_SMOKETRAIL 0x00000010
  26. #define FTENT_COLLIDEWORLD 0x00000020
  27. #define FTENT_FLICKER 0x00000040
  28. #define FTENT_FADEOUT 0x00000080
  29. #define FTENT_SPRANIMATE 0x00000100
  30. #define FTENT_HITSOUND 0x00000200
  31. #define FTENT_SPIRAL 0x00000400
  32. #define FTENT_SPRCYCLE 0x00000800
  33. #define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes
  34. #define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw
  35. #define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything
  36. #define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner)
  37. #define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed
  38. #define FTENT_SMOKEGROWANDFADE 0x00020000 // rapid grow and fade. Very specific for gunsmoke
  39. #define FTENT_ATTACHTOTARGET 0x00040000 // attach to whatever we hit, and stay there until die time is up
  40. #define FTENT_NOMODEL 0x00080000 // Doesn't have a model, never try to draw ( it just triggers other things )
  41. #define FTENT_CLIENTCUSTOM 0x00100000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things )
  42. #define FTENT_WINDBLOWN 0x00200000 // This is set when the temp entity is blown by the wind
  43. #define FTENT_NEVERDIE 0x00400000 // Don't die as long as die != 0
  44. #define FTENT_BEOCCLUDED 0x00800000 // Don't draw if my specified normal's facing away from the view
  45. #define FTENT_CHANGERENDERONCOLLIDE 0x01000000 //when we collide with something, change our rendergroup to RENDER_GROUP_OTHER
  46. #define FTENT_COLLISIONGROUP 0x02000000 // if set, use the C_BaseEntity::GetCollisionGroup when doing collide trace
  47. #define FTENT_ALIGNTOMOTION 0x04000000 // Change angles to always point in the direction of motion
  48. #define FTENT_CLIENTSIDEPARTICLES 0x08000000 // The object has a clientside particle system.
  49. #define FTENT_USEFASTCOLLISIONS 0x10000000 // Use fast collisions (cl_fasttempentcollision).
  50. #define FTENT_COLLIDEPROPS 0x20000000 // Collide with the world and props
  51. class C_LocalTempEntity;
  52. typedef int (*pfnDrawHelper)( C_LocalTempEntity *entity, int flags );
  53. //-----------------------------------------------------------------------------
  54. // Purpose: Should this derive from some other class
  55. //-----------------------------------------------------------------------------
  56. class C_LocalTempEntity : public C_BaseAnimating, public C_SpriteRenderer
  57. {
  58. public:
  59. DECLARE_CLASS( C_LocalTempEntity, C_BaseAnimating );
  60. C_LocalTempEntity();
  61. virtual void Prepare( const model_t *pmodel, float time );
  62. virtual bool IsActive( void );
  63. virtual bool Frame( float frametime, int framenumber );
  64. // C_BaseAnimating , etc. override
  65. virtual int DrawModel( int flags );
  66. // Sets the velocity
  67. void SetVelocity( const Vector &vecVelocity );
  68. const Vector &GetVelocity() const { return m_vecTempEntVelocity; }
  69. // Set the acceleration
  70. void SetAcceleration( const Vector &vecAccel );
  71. const Vector &GetAcceleration() const { return m_vecTempEntAcceleration; }
  72. void SetDrawHelper( pfnDrawHelper helper ) { m_pfnDrawHelper = helper; }
  73. void OnRemoveTempEntity();
  74. void SetImpactEffect( const char *pszImpactEffect ) { m_pszImpactEffect = pszImpactEffect; }
  75. CNewParticleEffect* AddParticleEffect( const char *pszParticleEffect );
  76. void SetParticleEffect( const char *pszParticleEffect ) { m_pszParticleEffect = pszParticleEffect; }
  77. protected:
  78. pfnDrawHelper m_pfnDrawHelper;
  79. public:
  80. int flags;
  81. float die;
  82. float m_flFrameMax;
  83. float x;
  84. float y;
  85. float fadeSpeed;
  86. float bounceFactor;
  87. int hitSound;
  88. int priority;
  89. // if attached, this is the index of the client to stick to
  90. // if COLLIDEALL, this is the index of the client to ignore
  91. // TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex!
  92. short clientIndex;
  93. // if attached, client origin + tentOffset = tent origin.
  94. Vector tentOffset;
  95. // Used by temp entities.
  96. QAngle m_vecTempEntAngVelocity;
  97. int tempent_renderamt;
  98. Vector m_vecNormal;
  99. float m_flSpriteScale;
  100. int m_nFlickerFrame;
  101. //
  102. float m_flFrameRate;
  103. float m_flFrame;
  104. RenderGroup_t m_RenderGroup;
  105. const char *m_pszImpactEffect;
  106. const char *m_pszParticleEffect;
  107. bool m_bParticleCollision;
  108. int m_iLastCollisionFrame;
  109. Vector m_vLastCollisionOrigin;
  110. private:
  111. C_LocalTempEntity( const C_LocalTempEntity & );
  112. Vector m_vecTempEntVelocity;
  113. Vector m_vecPrevLocalOrigin;
  114. Vector m_vecTempEntAcceleration;
  115. // Draw tempent as a studio model
  116. int DrawStudioModel( int flags );
  117. };
  118. #endif // TEMPENTITY_H