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.

72 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "cbase.h"
  8. #include "tf_shareddefs.h"
  9. #include "tf_gamerules.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //-----------------------------------------------------------------------------
  13. // Purpose:
  14. //-----------------------------------------------------------------------------
  15. class C_FuncForceField : public C_BaseEntity
  16. {
  17. DECLARE_CLASS( C_FuncForceField, C_BaseEntity );
  18. public:
  19. DECLARE_CLIENTCLASS();
  20. virtual int DrawModel( int flags ) OVERRIDE;
  21. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
  22. };
  23. IMPLEMENT_CLIENTCLASS_DT( C_FuncForceField, DT_FuncForceField, CFuncForceField )
  24. END_RECV_TABLE()
  25. //-----------------------------------------------------------------------------
  26. // Purpose:
  27. //-----------------------------------------------------------------------------
  28. int C_FuncForceField::DrawModel( int flags )
  29. {
  30. // Don't draw for anyone during a team win
  31. if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
  32. return 1;
  33. return BaseClass::DrawModel( flags );
  34. }
  35. //-----------------------------------------------------------------------------
  36. // Purpose: Enemy players collide with us, except during a team win
  37. //-----------------------------------------------------------------------------
  38. bool C_FuncForceField::ShouldCollide( int collisionGroup, int contentsMask ) const
  39. {
  40. // Force fields are off during a team win
  41. if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
  42. return false;
  43. if ( GetTeamNumber() == TEAM_UNASSIGNED )
  44. return false;
  45. if ( collisionGroup == COLLISION_GROUP_PLAYER_MOVEMENT )
  46. {
  47. switch ( GetTeamNumber() )
  48. {
  49. case TF_TEAM_BLUE:
  50. if ( !( contentsMask & CONTENTS_BLUETEAM ) )
  51. return false;
  52. break;
  53. case TF_TEAM_RED:
  54. if ( !( contentsMask & CONTENTS_REDTEAM ) )
  55. return false;
  56. break;
  57. }
  58. return true;
  59. }
  60. return false;
  61. }