diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/SpriteTrail.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/shared/SpriteTrail.h')
| -rw-r--r-- | game/shared/SpriteTrail.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/game/shared/SpriteTrail.h b/game/shared/SpriteTrail.h new file mode 100644 index 0000000..2248dc9 --- /dev/null +++ b/game/shared/SpriteTrail.h @@ -0,0 +1,124 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef SPRITETRAIL_H +#define SPRITETRAIL_H +#ifdef _WIN32 +#pragma once +#endif + +#include "Sprite.h" + +#if defined( CLIENT_DLL ) +#define CSpriteTrail C_SpriteTrail +#endif + + +//----------------------------------------------------------------------------- +// Sprite trail +//----------------------------------------------------------------------------- +struct TrailPoint_t +{ + DECLARE_SIMPLE_DATADESC(); + + Vector m_vecScreenPos; + float m_flDieTime; + float m_flTexCoord; + float m_flWidthVariance; +}; + +class CSpriteTrail : public CSprite +{ + DECLARE_CLASS( CSpriteTrail, CSprite ); + DECLARE_DATADESC(); + DECLARE_NETWORKCLASS(); + DECLARE_PREDICTABLE(); + +public: + CSpriteTrail( void ); + + // Sets parameters of the sprite trail + void SetLifeTime( float time ); + void SetStartWidth( float flStartWidth ); + void SetEndWidth( float flEndWidth ); + void SetStartWidthVariance( float flStartWidthVariance ); + void SetTextureResolution( float flTexelsPerInch ); + void SetMinFadeLength( float flMinFadeLength ); + void SetSkybox( const Vector &vecSkyboxOrigin, float flSkyboxScale ); + + // Is the trail in the skybox? + bool IsInSkybox() const; + void Spawn( void ); + void Precache( void ); + void SetTransmit( bool bTransmit = true ) { m_bDrawForMoveParent = bTransmit; } + +#if defined( CLIENT_DLL ) + // Client only code + virtual int DrawModel( int flags ); + virtual const Vector &GetRenderOrigin( void ); + virtual const QAngle &GetRenderAngles( void ); + + // On data update + virtual void OnPreDataChanged( DataUpdateType_t updateType ); + virtual void OnDataChanged( DataUpdateType_t updateType ); + virtual void GetRenderBounds( Vector& mins, Vector& maxs ); + virtual void ClientThink(); + + virtual bool ValidateEntityAttachedToPlayer( bool &bShouldRetry ); + +#else + // Server only code + + virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo ); + static CSpriteTrail *SpriteTrailCreate( const char *pSpriteName, const Vector &origin, bool animate ); + +#endif + +private: +#if defined( CLIENT_DLL ) + enum + { + // NOTE: # of points max must be a power of two! + MAX_SPRITE_TRAIL_POINTS = 256, + MAX_SPRITE_TRAIL_MASK = MAX_SPRITE_TRAIL_POINTS - 1, + }; + + TrailPoint_t *GetTrailPoint( int n ); + void UpdateTrail( void ); + void ComputeScreenPosition( Vector *pScreenPos ); + void ConvertSkybox(); + void UpdateBoundingBox( void ); + + TrailPoint_t m_vecSteps[MAX_SPRITE_TRAIL_POINTS]; + int m_nFirstStep; + int m_nStepCount; + float m_flUpdateTime; + Vector m_vecPrevSkyboxOrigin; + float m_flPrevSkyboxScale; + Vector m_vecRenderMins; + Vector m_vecRenderMaxs; +#endif + + CNetworkVar( float, m_flLifeTime ); // Amount of time before a new trail segment fades away + CNetworkVar( float, m_flStartWidth ); // The starting scale + CNetworkVar( float, m_flEndWidth ); // The ending scale + CNetworkVar( float, m_flStartWidthVariance ); // The starting scale + CNetworkVar( float, m_flTextureRes ); // Texture resolution along the trail + CNetworkVar( float, m_flMinFadeLength ); // The end of the trail must fade out for this many units + CNetworkVector( m_vecSkyboxOrigin ); // What's our skybox origin? + CNetworkVar( float, m_flSkyboxScale ); // What's our skybox scale? + + string_t m_iszSpriteName; + bool m_bAnimate; + bool m_bDrawForMoveParent; + +#if defined( CLIENT_DLL ) +public: + void SetUpdateTime(float setTo){ m_flUpdateTime = setTo; } +#endif +}; + +#endif // SPRITETRAIL_H |