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.

111 lines
3.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef SPRITETRAIL_H
  7. #define SPRITETRAIL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "Sprite.h"
  12. #if defined( CLIENT_DLL )
  13. #define CSpriteTrail C_SpriteTrail
  14. #endif
  15. //-----------------------------------------------------------------------------
  16. // Sprite trail
  17. //-----------------------------------------------------------------------------
  18. struct TrailPoint_t
  19. {
  20. DECLARE_SIMPLE_DATADESC();
  21. Vector m_vecScreenPos;
  22. float m_flDieTime;
  23. float m_flTexCoord;
  24. float m_flWidthVariance;
  25. };
  26. class CSpriteTrail : public CSprite
  27. {
  28. DECLARE_CLASS( CSpriteTrail, CSprite );
  29. DECLARE_DATADESC();
  30. DECLARE_NETWORKCLASS();
  31. DECLARE_PREDICTABLE();
  32. public:
  33. CSpriteTrail( void );
  34. // Sets parameters of the sprite trail
  35. void SetLifeTime( float time );
  36. void SetStartWidth( float flStartWidth );
  37. void SetEndWidth( float flEndWidth );
  38. void SetStartWidthVariance( float flStartWidthVariance );
  39. void SetTextureResolution( float flTexelsPerInch );
  40. void SetMinFadeLength( float flMinFadeLength );
  41. void SetSkybox( const Vector &vecSkyboxOrigin, float flSkyboxScale );
  42. // Is the trail in the skybox?
  43. bool IsInSkybox() const;
  44. void Spawn( void );
  45. void Precache( void );
  46. #if defined( CLIENT_DLL )
  47. // Client only code
  48. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  49. virtual const Vector &GetRenderOrigin( void );
  50. virtual const QAngle &GetRenderAngles( void );
  51. // On data update
  52. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  53. virtual void OnDataChanged( DataUpdateType_t updateType );
  54. virtual void GetRenderBounds( Vector& mins, Vector& maxs );
  55. virtual void ClientThink();
  56. #else
  57. // Server only code
  58. static CSpriteTrail *SpriteTrailCreate( const char *pSpriteName, const Vector &origin, bool animate );
  59. #endif
  60. private:
  61. #if defined( CLIENT_DLL )
  62. enum
  63. {
  64. // NOTE: # of points max must be a power of two!
  65. MAX_SPRITE_TRAIL_POINTS = 64,
  66. MAX_SPRITE_TRAIL_MASK = 0x3F,
  67. };
  68. TrailPoint_t *GetTrailPoint( int n );
  69. void UpdateTrail( void );
  70. void ComputeScreenPosition( Vector *pScreenPos );
  71. void ConvertSkybox();
  72. void UpdateBoundingBox( void );
  73. TrailPoint_t m_vecSteps[MAX_SPRITE_TRAIL_POINTS];
  74. int m_nFirstStep;
  75. int m_nStepCount;
  76. float m_flUpdateTime;
  77. Vector m_vecPrevSkyboxOrigin;
  78. float m_flPrevSkyboxScale;
  79. Vector m_vecRenderMins;
  80. Vector m_vecRenderMaxs;
  81. #endif
  82. CNetworkVar( float, m_flLifeTime ); // Amount of time before a new trail segment fades away
  83. CNetworkVar( float, m_flStartWidth ); // The starting scale
  84. CNetworkVar( float, m_flEndWidth ); // The ending scale
  85. CNetworkVar( float, m_flStartWidthVariance ); // The starting scale
  86. CNetworkVar( float, m_flTextureRes ); // Texture resolution along the trail
  87. CNetworkVar( float, m_flMinFadeLength ); // The end of the trail must fade out for this many units
  88. CNetworkVector( m_vecSkyboxOrigin ); // What's our skybox origin?
  89. CNetworkVar( float, m_flSkyboxScale ); // What's our skybox scale?
  90. string_t m_iszSpriteName;
  91. bool m_bAnimate;
  92. };
  93. #endif // SPRITETRAIL_H