summaryrefslogtreecommitdiff
path: root/game/shared/tf2/tf_gamemovement_chooser.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/tf2/tf_gamemovement_chooser.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/shared/tf2/tf_gamemovement_chooser.cpp')
-rw-r--r--game/shared/tf2/tf_gamemovement_chooser.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/game/shared/tf2/tf_gamemovement_chooser.cpp b/game/shared/tf2/tf_gamemovement_chooser.cpp
new file mode 100644
index 0000000..d059dae
--- /dev/null
+++ b/game/shared/tf2/tf_gamemovement_chooser.cpp
@@ -0,0 +1,76 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Auto Repair
+//
+// $NoKeywords: $
+//=============================================================================//
+#include "cbase.h"
+#include "tf_gamemovement_chooser.h"
+#include "tf_movedata.h"
+
+static CTFGameMovementChooser g_GameMovement;
+IGameMovement *g_pGameMovement = ( IGameMovement* )&g_GameMovement;
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+CTFGameMovementChooser::CTFGameMovementChooser()
+{
+ // Allocate memory for a movement type for each class (0 = undecided)
+ m_Movements.SetSize( TFCLASS_CLASS_COUNT );
+
+ // NOTE: the order here matches the enum order in tf_shareddefs.h
+ m_Movements[TFCLASS_RECON] = &m_ReconMovement;
+ m_Movements[TFCLASS_COMMANDO] = &m_CommandoMovement;
+ m_Movements[TFCLASS_MEDIC] = &m_MedicMovement;
+ m_Movements[TFCLASS_DEFENDER] = &m_DefenderMovement;
+ m_Movements[TFCLASS_SNIPER] = &m_SniperMovement;
+ m_Movements[TFCLASS_SUPPORT] = &m_SupportMovement;
+ m_Movements[TFCLASS_ESCORT] = &m_EscortMovement;
+ m_Movements[TFCLASS_SAPPER] = &m_SapperMovement;
+ m_Movements[TFCLASS_INFILTRATOR] = &m_InfiltratorMovement;
+ m_Movements[TFCLASS_PYRO] = &m_PyroMovement;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CTFGameMovementChooser::ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData )
+{
+ // Convert CMoveData to CTFMoveData
+ CTFMoveData *pTFMoveData = static_cast<CTFMoveData*>( pMoveData );
+
+ // Cache the current class id
+ m_nClassID = pTFMoveData->m_nClassID;
+
+ // Player class movement. (If possible)
+ if ( m_nClassID != TFCLASS_UNDECIDED )
+ {
+ m_Movements[m_nClassID]->ProcessClassMovement( (CBaseTFPlayer *)pPlayer, pTFMoveData );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+const Vector &CTFGameMovementChooser::GetPlayerMins( bool ducked ) const
+{
+ // Player class mins.
+ return m_Movements[m_nClassID]->GetPlayerMins( ducked );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+const Vector &CTFGameMovementChooser::GetPlayerMaxs( bool ducked ) const
+{
+ return m_Movements[m_nClassID]->GetPlayerMins( ducked );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+const Vector &CTFGameMovementChooser::GetPlayerViewOffset( bool ducked ) const
+{
+ return m_Movements[m_nClassID]->GetPlayerViewOffset( ducked );
+}