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.

102 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "rotorwash.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. // ==============================================
  11. // Rotorwash entity
  12. // ==============================================
  13. class CRotorWashEmitter : public CBaseEntity
  14. {
  15. public:
  16. DECLARE_CLASS( CRotorWashEmitter, CBaseEntity );
  17. DECLARE_SERVERCLASS();
  18. DECLARE_DATADESC();
  19. void SetAltitude( float flAltitude ) { m_flAltitude = flAltitude; }
  20. void SetEmit( bool state ) { m_bEmit = state; }
  21. void Spawn ( void );
  22. void Precache( void );
  23. int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  24. int UpdateTransmitState( void );
  25. protected:
  26. CNetworkVar( bool, m_bEmit );
  27. CNetworkVar( float, m_flAltitude );
  28. };
  29. IMPLEMENT_SERVERCLASS_ST( CRotorWashEmitter, DT_RotorWashEmitter )
  30. SendPropFloat(SENDINFO(m_flAltitude), -1, SPROP_NOSCALE ),
  31. END_SEND_TABLE()
  32. LINK_ENTITY_TO_CLASS( env_rotorwash_emitter, CRotorWashEmitter );
  33. BEGIN_DATADESC( CRotorWashEmitter )
  34. DEFINE_FIELD( m_bEmit, FIELD_BOOLEAN ),
  35. DEFINE_KEYFIELD( m_flAltitude, FIELD_FLOAT, "altitude" ),
  36. END_DATADESC()
  37. void CRotorWashEmitter::Spawn( void )
  38. {
  39. Precache();
  40. BaseClass::Spawn();
  41. SetEmit( false );
  42. }
  43. void CRotorWashEmitter::Precache( void )
  44. {
  45. PrecacheMaterial( "effects/splashwake3" );
  46. }
  47. int CRotorWashEmitter::ShouldTransmit( const CCheckTransmitInfo *pInfo )
  48. {
  49. if ( GetParent() )
  50. {
  51. return GetParent()->ShouldTransmit( pInfo );
  52. }
  53. return FL_EDICT_PVSCHECK;
  54. }
  55. int CRotorWashEmitter::UpdateTransmitState( void )
  56. {
  57. if ( GetParent() )
  58. {
  59. return SetTransmitState( FL_EDICT_FULLCHECK );
  60. }
  61. return SetTransmitState( FL_EDICT_PVSCHECK );
  62. }
  63. //-----------------------------------------------------------------------------
  64. // Purpose:
  65. // Input : &localOrigin -
  66. // &localAngles -
  67. // *pOwner -
  68. // flAltitude -
  69. // Output : CBaseEntity
  70. //-----------------------------------------------------------------------------
  71. CBaseEntity *CreateRotorWashEmitter( const Vector &localOrigin, const QAngle &localAngles, CBaseEntity *pOwner, float flAltitude )
  72. {
  73. CRotorWashEmitter *pEmitter = (CRotorWashEmitter *) CreateEntityByName( "env_rotorwash_emitter" );
  74. if ( pEmitter == NULL )
  75. return NULL;
  76. pEmitter->SetAbsOrigin( localOrigin );
  77. pEmitter->SetAbsAngles( localAngles );
  78. pEmitter->FollowEntity( pOwner );
  79. pEmitter->SetAltitude( flAltitude );
  80. pEmitter->SetEmit( false );
  81. return pEmitter;
  82. }