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.

133 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "c_prop_vehicle.h"
  8. #include "c_vehicle_jeep.h"
  9. #include "movevars_shared.h"
  10. #include "view.h"
  11. #include "flashlighteffect.h"
  12. #include "c_baseplayer.h"
  13. #include "c_te_effect_dispatch.h"
  14. #include "hl2_vehicle_radar.h"
  15. #include "usermessages.h"
  16. #include "hud_radar.h"
  17. // memdbgon must be the last include file in a .cpp file!!!
  18. #include "tier0/memdbgon.h"
  19. //=============================================================================
  20. //
  21. // Client-side Episodic Jeep (Jalopy) Class
  22. //
  23. class C_PropJeepEpisodic : public C_PropJeep
  24. {
  25. DECLARE_CLASS( C_PropJeepEpisodic, C_PropJeep );
  26. public:
  27. DECLARE_CLIENTCLASS();
  28. public:
  29. C_PropJeepEpisodic();
  30. void OnEnteredVehicle( C_BasePlayer *pPlayer );
  31. void Simulate( void );
  32. public:
  33. int m_iNumRadarContacts;
  34. Vector m_vecRadarContactPos[ RADAR_MAX_CONTACTS ];
  35. int m_iRadarContactType[ RADAR_MAX_CONTACTS ];
  36. };
  37. C_PropJeepEpisodic *g_pJalopy = NULL;
  38. IMPLEMENT_CLIENTCLASS_DT( C_PropJeepEpisodic, DT_CPropJeepEpisodic, CPropJeepEpisodic )
  39. //CNetworkVar( int, m_iNumRadarContacts );
  40. RecvPropInt( RECVINFO(m_iNumRadarContacts) ),
  41. //CNetworkArray( Vector, m_vecRadarContactPos, RADAR_MAX_CONTACTS );
  42. RecvPropArray( RecvPropVector(RECVINFO(m_vecRadarContactPos[0])), m_vecRadarContactPos ),
  43. //CNetworkArray( int, m_iRadarContactType, RADAR_MAX_CONTACTS );
  44. RecvPropArray( RecvPropInt( RECVINFO(m_iRadarContactType[0] ) ), m_iRadarContactType ),
  45. END_RECV_TABLE()
  46. //-----------------------------------------------------------------------------
  47. // Purpose:
  48. //-----------------------------------------------------------------------------
  49. void __MsgFunc_UpdateJalopyRadar(bf_read &msg)
  50. {
  51. // Radar code here!
  52. if( !GetHudRadar() )
  53. return;
  54. // Sometimes we update more quickly when we need to track something in high resolution.
  55. // Usually we do not, so default to false.
  56. GetHudRadar()->m_bUseFastUpdate = false;
  57. for( int i = 0 ; i < g_pJalopy->m_iNumRadarContacts ; i++ )
  58. {
  59. if( g_pJalopy->m_iRadarContactType[i] == RADAR_CONTACT_DOG )
  60. {
  61. GetHudRadar()->m_bUseFastUpdate = true;
  62. break;
  63. }
  64. }
  65. float flContactTimeToLive;
  66. if( GetHudRadar()->m_bUseFastUpdate )
  67. {
  68. flContactTimeToLive = RADAR_UPDATE_FREQUENCY_FAST;
  69. }
  70. else
  71. {
  72. flContactTimeToLive = RADAR_UPDATE_FREQUENCY;
  73. }
  74. for( int i = 0 ; i < g_pJalopy->m_iNumRadarContacts ; i++ )
  75. {
  76. GetHudRadar()->AddRadarContact( g_pJalopy->m_vecRadarContactPos[i], g_pJalopy->m_iRadarContactType[i], flContactTimeToLive );
  77. }
  78. }
  79. //-----------------------------------------------------------------------------
  80. //-----------------------------------------------------------------------------
  81. C_PropJeepEpisodic::C_PropJeepEpisodic()
  82. {
  83. if( g_pJalopy == NULL )
  84. {
  85. usermessages->HookMessage( "UpdateJalopyRadar", __MsgFunc_UpdateJalopyRadar );
  86. }
  87. g_pJalopy = this;
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose:
  91. //-----------------------------------------------------------------------------
  92. void C_PropJeepEpisodic::Simulate( void )
  93. {
  94. // Keep trying to hook to the radar.
  95. if( GetHudRadar() != NULL )
  96. {
  97. // This is not our ideal long-term solution. This will only work if you only have
  98. // one jalopy in a given level. The Jalopy and the Radar Screen are currently both
  99. // assumed to be singletons. This is appropriate for EP2, however. (sjb)
  100. GetHudRadar()->SetVehicle( this );
  101. }
  102. BaseClass::Simulate();
  103. }
  104. //-----------------------------------------------------------------------------
  105. // Purpose:
  106. //-----------------------------------------------------------------------------
  107. void C_PropJeepEpisodic::OnEnteredVehicle( C_BasePlayer *pPlayer )
  108. {
  109. BaseClass::OnEnteredVehicle( pPlayer );
  110. }