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.

103 lines
3.2 KiB

  1. // ClientInferno.cpp
  2. // Render client-side Inferno effects
  3. // Author: Michael Booth, February 2005
  4. // Copyright (c) 2005 Turtle Rock Studios, Inc. - All Rights Reserved
  5. #include "cbase.h"
  6. #include "tier0/memdbgon.h"
  7. //-----------------------------------------------------------------------------------------------
  8. /**
  9. * The client-side Inferno effect
  10. */
  11. class C_Inferno : public C_BaseEntity
  12. {
  13. public:
  14. DECLARE_CLASS( C_Inferno, C_BaseEntity );
  15. DECLARE_CLIENTCLASS();
  16. C_Inferno();
  17. virtual ~C_Inferno();
  18. virtual void Spawn( void );
  19. virtual void ClientThink();
  20. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  21. virtual bool ShouldDraw() { return true; }
  22. virtual RenderableTranslucencyType_t ComputeTranslucencyType() { return RENDERABLE_IS_TRANSLUCENT; }
  23. virtual void GetRenderBounds( Vector& mins, Vector& maxs );
  24. // returns the bounds as an AABB in worldspace
  25. virtual void GetRenderBoundsWorldspace( Vector& mins, Vector& maxs );
  26. virtual void OnNewParticleEffect( const char *pszParticleName, CNewParticleEffect *pNewParticleEffect );
  27. virtual void OnParticleEffectDeleted( CNewParticleEffect *pParticleEffect );
  28. virtual const char* GetParticleEffectName();
  29. private:
  30. void UpdateParticles( void );
  31. CUtlReference<CNewParticleEffect> m_burnParticleEffect;
  32. enum { MAX_INFERNO_FIRES = 100 };
  33. int m_fireXDelta[ MAX_INFERNO_FIRES ];
  34. int m_fireYDelta[ MAX_INFERNO_FIRES ];
  35. int m_fireZDelta[ MAX_INFERNO_FIRES ];
  36. bool m_bFireIsBurning[ MAX_INFERNO_FIRES ];
  37. Vector m_BurnNormal[ MAX_INFERNO_FIRES ];
  38. int m_fireUniqueID[ MAX_INFERNO_FIRES ];
  39. int m_fireCount;
  40. int m_nInfernoType;
  41. int m_lastFireCount; ///< used to detect changes
  42. // these are the actual visible fires
  43. enum FireState { STARTING, BURNING, GOING_OUT, FIRE_OUT, UNKNOWN };
  44. struct Drawable
  45. {
  46. Vector m_pos; ///< position of flame
  47. Vector m_normal; ///< normal of flame surface
  48. int m_frame; ///< current animation frame
  49. float m_framerate; ///< rate of animation
  50. bool m_mirror; ///< if true, flame is mirrored about vertical axis
  51. int m_dlightIndex;
  52. FireState m_state; ///< the state of this fire
  53. float m_stateTimestamp; ///< when the fire entered its current state
  54. void SetState( FireState state )
  55. {
  56. m_state = state;
  57. m_stateTimestamp = gpGlobals->realtime;
  58. }
  59. float m_size; ///< current flame size
  60. float m_maxSize; ///< maximum size of full-grown flame
  61. void Draw( void ); ///< render this flame
  62. };
  63. Drawable m_drawable[ MAX_INFERNO_FIRES ];
  64. int m_drawableCount;
  65. void SynchronizeDrawables( void ); ///< compare m_fireX etc to m_drawable and update states
  66. Drawable *GetDrawable( const Vector &pos ); ///< given a position, return the fire there
  67. float m_maxFireHalfWidth;
  68. float m_maxFireHeight;
  69. Vector m_minBounds, m_maxBounds;
  70. void DrawFire( C_Inferno::Drawable *fire, IMesh *mesh ); ///< render an individual flame
  71. void RecomputeBounds( void );
  72. };
  73. //---------------------------------------------------------
  74. //---------------------------------------------------------
  75. class C_FireCrackerBlast: public C_Inferno
  76. {
  77. public:
  78. DECLARE_CLASS( C_FireCrackerBlast, C_Inferno );
  79. DECLARE_CLIENTCLASS();
  80. virtual const char* GetParticleEffectName();
  81. };