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.

149 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Big pulsating ball inside the core of the citadel
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "baseentity.h"
  8. #define COREBALL_MODEL "models/props_combine/coreball.mdl"
  9. class CPropScalable : public CBaseAnimating
  10. {
  11. public:
  12. DECLARE_CLASS( CPropScalable, CBaseAnimating );
  13. DECLARE_DATADESC();
  14. DECLARE_SERVERCLASS();
  15. CPropScalable();
  16. virtual void Spawn( void );
  17. virtual void Precache( void );
  18. CNetworkVar( float, m_flScaleX );
  19. CNetworkVar( float, m_flScaleY );
  20. CNetworkVar( float, m_flScaleZ );
  21. CNetworkVar( float, m_flLerpTimeX );
  22. CNetworkVar( float, m_flLerpTimeY );
  23. CNetworkVar( float, m_flLerpTimeZ );
  24. CNetworkVar( float, m_flGoalTimeX );
  25. CNetworkVar( float, m_flGoalTimeY );
  26. CNetworkVar( float, m_flGoalTimeZ );
  27. void InputSetScaleX( inputdata_t &inputdata );
  28. void InputSetScaleY( inputdata_t &inputdata );
  29. void InputSetScaleZ( inputdata_t &inputdata );
  30. };
  31. LINK_ENTITY_TO_CLASS( prop_coreball, CPropScalable );
  32. LINK_ENTITY_TO_CLASS( prop_scalable, CPropScalable );
  33. BEGIN_DATADESC( CPropScalable )
  34. DEFINE_INPUTFUNC( FIELD_VECTOR, "SetScaleX", InputSetScaleX ),
  35. DEFINE_INPUTFUNC( FIELD_VECTOR, "SetScaleY", InputSetScaleY ),
  36. DEFINE_INPUTFUNC( FIELD_VECTOR, "SetScaleZ", InputSetScaleZ ),
  37. DEFINE_FIELD( m_flScaleX, FIELD_FLOAT ),
  38. DEFINE_FIELD( m_flScaleY, FIELD_FLOAT ),
  39. DEFINE_FIELD( m_flScaleZ, FIELD_FLOAT ),
  40. DEFINE_FIELD( m_flLerpTimeX, FIELD_FLOAT ),
  41. DEFINE_FIELD( m_flLerpTimeY, FIELD_FLOAT ),
  42. DEFINE_FIELD( m_flLerpTimeZ, FIELD_FLOAT ),
  43. DEFINE_FIELD( m_flGoalTimeX, FIELD_FLOAT ),
  44. DEFINE_FIELD( m_flGoalTimeY, FIELD_FLOAT ),
  45. DEFINE_FIELD( m_flGoalTimeZ, FIELD_FLOAT ),
  46. END_DATADESC()
  47. IMPLEMENT_SERVERCLASS_ST( CPropScalable, DT_PropScalable )
  48. SendPropFloat( SENDINFO(m_flScaleX), 0, SPROP_NOSCALE ),
  49. SendPropFloat( SENDINFO(m_flScaleY), 0, SPROP_NOSCALE ),
  50. SendPropFloat( SENDINFO(m_flScaleZ), 0, SPROP_NOSCALE ),
  51. SendPropFloat( SENDINFO(m_flLerpTimeX), 0, SPROP_NOSCALE ),
  52. SendPropFloat( SENDINFO(m_flLerpTimeY), 0, SPROP_NOSCALE ),
  53. SendPropFloat( SENDINFO(m_flLerpTimeZ), 0, SPROP_NOSCALE ),
  54. SendPropFloat( SENDINFO(m_flGoalTimeX), 0, SPROP_NOSCALE ),
  55. SendPropFloat( SENDINFO(m_flGoalTimeY), 0, SPROP_NOSCALE ),
  56. SendPropFloat( SENDINFO(m_flGoalTimeZ), 0, SPROP_NOSCALE ),
  57. END_SEND_TABLE()
  58. CPropScalable::CPropScalable( void )
  59. {
  60. m_flScaleX = 1.0f;
  61. m_flScaleY = 1.0f;
  62. m_flScaleZ = 1.0f;
  63. UseClientSideAnimation();
  64. }
  65. void CPropScalable::Spawn( void )
  66. {
  67. // Stomp our model name if we're the coreball (legacy)
  68. if ( FClassnameIs( this, "prop_coreball" ) )
  69. {
  70. PrecacheModel( COREBALL_MODEL );
  71. SetModel( COREBALL_MODEL );
  72. }
  73. else
  74. {
  75. char *szModel = (char *)STRING( GetModelName() );
  76. if (!szModel || !*szModel)
  77. {
  78. Warning( "prop_scalable at %.0f %.0f %0.f missing modelname\n", GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z );
  79. UTIL_Remove( this );
  80. return;
  81. }
  82. PrecacheModel( szModel );
  83. SetModel( szModel );
  84. }
  85. SetMoveType( MOVETYPE_NONE );
  86. BaseClass::Spawn();
  87. AddEffects( EF_NOSHADOW );
  88. SetSequence( 0 );
  89. SetPlaybackRate( 1.0f );
  90. }
  91. void CPropScalable::Precache( void )
  92. {
  93. BaseClass::Precache();
  94. }
  95. void CPropScalable::InputSetScaleX( inputdata_t &inputdata )
  96. {
  97. Vector vecScale;
  98. inputdata.value.Vector3D( vecScale );
  99. m_flScaleX = vecScale.x;
  100. m_flLerpTimeX = vecScale.y;
  101. m_flGoalTimeX = gpGlobals->curtime;
  102. }
  103. void CPropScalable::InputSetScaleY( inputdata_t &inputdata )
  104. {
  105. Vector vecScale;
  106. inputdata.value.Vector3D( vecScale );
  107. m_flScaleY = vecScale.x;
  108. m_flLerpTimeY = vecScale.y;
  109. m_flGoalTimeY = gpGlobals->curtime;
  110. }
  111. void CPropScalable::InputSetScaleZ( inputdata_t &inputdata )
  112. {
  113. Vector vecScale;
  114. inputdata.value.Vector3D( vecScale );
  115. m_flScaleZ = vecScale.x;
  116. m_flLerpTimeZ = vecScale.y;
  117. m_flGoalTimeZ = gpGlobals->curtime;
  118. }