summaryrefslogtreecommitdiff
path: root/game/client/tf/c_func_forcefield.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/client/tf/c_func_forcefield.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/tf/c_func_forcefield.cpp')
-rw-r--r--game/client/tf/c_func_forcefield.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/game/client/tf/c_func_forcefield.cpp b/game/client/tf/c_func_forcefield.cpp
new file mode 100644
index 0000000..4053d88
--- /dev/null
+++ b/game/client/tf/c_func_forcefield.cpp
@@ -0,0 +1,73 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================
+#include "cbase.h"
+#include "tf_shareddefs.h"
+#include "tf_gamerules.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+class C_FuncForceField : public C_BaseEntity
+{
+ DECLARE_CLASS( C_FuncForceField, C_BaseEntity );
+public:
+ DECLARE_CLIENTCLASS();
+
+ virtual int DrawModel( int flags ) OVERRIDE;
+ virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
+};
+
+IMPLEMENT_CLIENTCLASS_DT( C_FuncForceField, DT_FuncForceField, CFuncForceField )
+END_RECV_TABLE()
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+int C_FuncForceField::DrawModel( int flags )
+{
+ // Don't draw for anyone during a team win
+ if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
+ return 1;
+
+ return BaseClass::DrawModel( flags );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Enemy players collide with us, except during a team win
+//-----------------------------------------------------------------------------
+bool C_FuncForceField::ShouldCollide( int collisionGroup, int contentsMask ) const
+{
+ // Force fields are off during a team win
+ if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
+ return false;
+
+ if ( GetTeamNumber() == TEAM_UNASSIGNED )
+ return false;
+
+ if ( collisionGroup == COLLISION_GROUP_PLAYER_MOVEMENT )
+ {
+ switch ( GetTeamNumber() )
+ {
+ case TF_TEAM_BLUE:
+ if ( !( contentsMask & CONTENTS_BLUETEAM ) )
+ return false;
+ break;
+
+ case TF_TEAM_RED:
+ if ( !( contentsMask & CONTENTS_REDTEAM ) )
+ return false;
+ break;
+ }
+
+ return true;
+ }
+
+ return false;
+} \ No newline at end of file