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.

106 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "baseparticleentity.h"
  9. #include "sendproxy.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //-----------------------------------------------------------------------------
  13. // Purpose:
  14. //-----------------------------------------------------------------------------
  15. class CEnvStarfield : public CBaseEntity
  16. {
  17. DECLARE_CLASS( CEnvStarfield, CBaseEntity );
  18. public:
  19. DECLARE_SERVERCLASS();
  20. DECLARE_DATADESC();
  21. virtual void Precache();
  22. virtual void Spawn( void );
  23. virtual int UpdateTransmitState(void);
  24. // Inputs
  25. void InputTurnOn( inputdata_t &inputdata );
  26. void InputTurnOff( inputdata_t &inputdata );
  27. void InputSetDensity( inputdata_t &inputdata );
  28. private:
  29. CNetworkVar( bool, m_bOn );
  30. CNetworkVar( float, m_flDensity );
  31. };
  32. BEGIN_DATADESC( CEnvStarfield )
  33. DEFINE_FIELD( m_bOn, FIELD_BOOLEAN ),
  34. DEFINE_FIELD( m_flDensity, FIELD_FLOAT ),
  35. DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ),
  36. DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ),
  37. DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDensity", InputSetDensity ),
  38. END_DATADESC()
  39. IMPLEMENT_SERVERCLASS_ST( CEnvStarfield, DT_EnvStarfield )
  40. SendPropInt( SENDINFO(m_bOn), 1, SPROP_UNSIGNED ),
  41. SendPropFloat( SENDINFO(m_flDensity), 0, SPROP_NOSCALE),
  42. END_SEND_TABLE()
  43. LINK_ENTITY_TO_CLASS( env_starfield, CEnvStarfield );
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. void CEnvStarfield::Spawn()
  48. {
  49. BaseClass::Spawn();
  50. m_flDensity = 1.0;
  51. m_bOn = false;
  52. Precache();
  53. }
  54. void CEnvStarfield::Precache()
  55. {
  56. BaseClass::Precache();
  57. PrecacheMaterial( "effects/spark_noz" );
  58. }
  59. //-----------------------------------------------------------------------------
  60. // Purpose:
  61. //-----------------------------------------------------------------------------
  62. int CEnvStarfield::UpdateTransmitState()
  63. {
  64. return SetTransmitState( FL_EDICT_ALWAYS );
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Purpose:
  68. //-----------------------------------------------------------------------------
  69. void CEnvStarfield::InputTurnOn( inputdata_t &inputdata )
  70. {
  71. m_bOn = true;
  72. }
  73. //-----------------------------------------------------------------------------
  74. // Purpose:
  75. // Input : &inputdata -
  76. //-----------------------------------------------------------------------------
  77. void CEnvStarfield::InputTurnOff( inputdata_t &inputdata )
  78. {
  79. m_bOn = false;
  80. }
  81. //-----------------------------------------------------------------------------
  82. // Purpose:
  83. // Input : &inputdata -
  84. //-----------------------------------------------------------------------------
  85. void CEnvStarfield::InputSetDensity( inputdata_t &inputdata )
  86. {
  87. m_flDensity = inputdata.value.Float();
  88. }