diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp')
| -rw-r--r-- | mp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/mp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp b/mp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp new file mode 100644 index 00000000..4627bbfb --- /dev/null +++ b/mp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp @@ -0,0 +1,133 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#include "cbase.h"
+#include "c_prop_vehicle.h"
+#include "c_vehicle_jeep.h"
+#include "movevars_shared.h"
+#include "view.h"
+#include "flashlighteffect.h"
+#include "c_baseplayer.h"
+#include "c_te_effect_dispatch.h"
+#include "hl2_vehicle_radar.h"
+#include "usermessages.h"
+#include "hud_radar.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//=============================================================================
+//
+// Client-side Episodic Jeep (Jalopy) Class
+//
+class C_PropJeepEpisodic : public C_PropJeep
+{
+
+ DECLARE_CLASS( C_PropJeepEpisodic, C_PropJeep );
+
+public:
+ DECLARE_CLIENTCLASS();
+
+public:
+ C_PropJeepEpisodic();
+
+ void OnEnteredVehicle( C_BasePlayer *pPlayer );
+ void Simulate( void );
+
+public:
+ int m_iNumRadarContacts;
+ Vector m_vecRadarContactPos[ RADAR_MAX_CONTACTS ];
+ int m_iRadarContactType[ RADAR_MAX_CONTACTS ];
+};
+C_PropJeepEpisodic *g_pJalopy = NULL;
+
+IMPLEMENT_CLIENTCLASS_DT( C_PropJeepEpisodic, DT_CPropJeepEpisodic, CPropJeepEpisodic )
+ //CNetworkVar( int, m_iNumRadarContacts );
+ RecvPropInt( RECVINFO(m_iNumRadarContacts) ),
+
+ //CNetworkArray( Vector, m_vecRadarContactPos, RADAR_MAX_CONTACTS );
+ RecvPropArray( RecvPropVector(RECVINFO(m_vecRadarContactPos[0])), m_vecRadarContactPos ),
+
+ //CNetworkArray( int, m_iRadarContactType, RADAR_MAX_CONTACTS );
+ RecvPropArray( RecvPropInt( RECVINFO(m_iRadarContactType[0] ) ), m_iRadarContactType ),
+
+END_RECV_TABLE()
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void __MsgFunc_UpdateJalopyRadar(bf_read &msg)
+{
+ // Radar code here!
+ if( !GetHudRadar() )
+ return;
+
+ // Sometimes we update more quickly when we need to track something in high resolution.
+ // Usually we do not, so default to false.
+ GetHudRadar()->m_bUseFastUpdate = false;
+
+ for( int i = 0 ; i < g_pJalopy->m_iNumRadarContacts ; i++ )
+ {
+ if( g_pJalopy->m_iRadarContactType[i] == RADAR_CONTACT_DOG )
+ {
+ GetHudRadar()->m_bUseFastUpdate = true;
+ break;
+ }
+ }
+
+ float flContactTimeToLive;
+
+ if( GetHudRadar()->m_bUseFastUpdate )
+ {
+ flContactTimeToLive = RADAR_UPDATE_FREQUENCY_FAST;
+ }
+ else
+ {
+ flContactTimeToLive = RADAR_UPDATE_FREQUENCY;
+ }
+
+ for( int i = 0 ; i < g_pJalopy->m_iNumRadarContacts ; i++ )
+ {
+ GetHudRadar()->AddRadarContact( g_pJalopy->m_vecRadarContactPos[i], g_pJalopy->m_iRadarContactType[i], flContactTimeToLive );
+ }
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+C_PropJeepEpisodic::C_PropJeepEpisodic()
+{
+ if( g_pJalopy == NULL )
+ {
+ usermessages->HookMessage( "UpdateJalopyRadar", __MsgFunc_UpdateJalopyRadar );
+ }
+
+ g_pJalopy = this;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void C_PropJeepEpisodic::Simulate( void )
+{
+ // Keep trying to hook to the radar.
+ if( GetHudRadar() != NULL )
+ {
+ // This is not our ideal long-term solution. This will only work if you only have
+ // one jalopy in a given level. The Jalopy and the Radar Screen are currently both
+ // assumed to be singletons. This is appropriate for EP2, however. (sjb)
+ GetHudRadar()->SetVehicle( this );
+ }
+
+ BaseClass::Simulate();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void C_PropJeepEpisodic::OnEnteredVehicle( C_BasePlayer *pPlayer )
+{
+ BaseClass::OnEnteredVehicle( pPlayer );
+}
|