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.

124 lines
3.4 KiB

  1. //========= Copyright 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. void SetTransmit( bool bTransmit = true ) { m_bDrawForMoveParent = bTransmit; }
  47. #if defined( CLIENT_DLL )
  48. // Client only code
  49. virtual int DrawModel( int flags );
  50. virtual const Vector &GetRenderOrigin( void );
  51. virtual const QAngle &GetRenderAngles( void );
  52. // On data update
  53. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  54. virtual void OnDataChanged( DataUpdateType_t updateType );
  55. virtual void GetRenderBounds( Vector& mins, Vector& maxs );
  56. virtual void ClientThink();
  57. virtual bool ValidateEntityAttachedToPlayer( bool &bShouldRetry );
  58. #else
  59. // Server only code
  60. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  61. static CSpriteTrail *SpriteTrailCreate( const char *pSpriteName, const Vector &origin, bool animate );
  62. #endif
  63. private:
  64. #if defined( CLIENT_DLL )
  65. enum
  66. {
  67. // NOTE: # of points max must be a power of two!
  68. MAX_SPRITE_TRAIL_POINTS = 256,
  69. MAX_SPRITE_TRAIL_MASK = MAX_SPRITE_TRAIL_POINTS - 1,
  70. };
  71. TrailPoint_t *GetTrailPoint( int n );
  72. void UpdateTrail( void );
  73. void ComputeScreenPosition( Vector *pScreenPos );
  74. void ConvertSkybox();
  75. void UpdateBoundingBox( void );
  76. TrailPoint_t m_vecSteps[MAX_SPRITE_TRAIL_POINTS];
  77. int m_nFirstStep;
  78. int m_nStepCount;
  79. float m_flUpdateTime;
  80. Vector m_vecPrevSkyboxOrigin;
  81. float m_flPrevSkyboxScale;
  82. Vector m_vecRenderMins;
  83. Vector m_vecRenderMaxs;
  84. #endif
  85. CNetworkVar( float, m_flLifeTime ); // Amount of time before a new trail segment fades away
  86. CNetworkVar( float, m_flStartWidth ); // The starting scale
  87. CNetworkVar( float, m_flEndWidth ); // The ending scale
  88. CNetworkVar( float, m_flStartWidthVariance ); // The starting scale
  89. CNetworkVar( float, m_flTextureRes ); // Texture resolution along the trail
  90. CNetworkVar( float, m_flMinFadeLength ); // The end of the trail must fade out for this many units
  91. CNetworkVector( m_vecSkyboxOrigin ); // What's our skybox origin?
  92. CNetworkVar( float, m_flSkyboxScale ); // What's our skybox scale?
  93. string_t m_iszSpriteName;
  94. bool m_bAnimate;
  95. bool m_bDrawForMoveParent;
  96. #if defined( CLIENT_DLL )
  97. public:
  98. void SetUpdateTime(float setTo){ m_flUpdateTime = setTo; }
  99. #endif
  100. };
  101. #endif // SPRITETRAIL_H