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.

69 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "func_passtime_goalie_zone.h"
  9. #include "tf_player.h"
  10. #include "passtime_convars.h"
  11. //-----------------------------------------------------------------------------
  12. BEGIN_DATADESC( CFuncPasstimeGoalieZone )
  13. END_DATADESC()
  14. //-----------------------------------------------------------------------------
  15. LINK_ENTITY_TO_CLASS( func_passtime_goalie_zone, CFuncPasstimeGoalieZone )
  16. IMPLEMENT_AUTO_LIST( IFuncPasstimeGoalieZoneAutoList );
  17. //-----------------------------------------------------------------------------
  18. void CFuncPasstimeGoalieZone::Spawn()
  19. {
  20. AddSpawnFlags( SF_TRIGGER_ALLOW_CLIENTS );
  21. BaseClass::Spawn();
  22. InitTrigger();
  23. }
  24. //-----------------------------------------------------------------------------
  25. bool CFuncPasstimeGoalieZone::BPlayerInAny( CTFPlayer *pPlayer )
  26. {
  27. auto &all = AutoList();
  28. for ( int i = 0; i < all.Count(); ++i )
  29. {
  30. auto *pZone = (CFuncPasstimeGoalieZone *)all[i];
  31. if ( pZone->IsTouching( pPlayer ) )
  32. return true;
  33. }
  34. return false;
  35. }
  36. //-----------------------------------------------------------------------------
  37. bool CFuncPasstimeGoalieZone::BPlayerInFriendly( CTFPlayer *pPlayer )
  38. {
  39. auto &all = AutoList();
  40. int iPlayerTeam = pPlayer->GetTeamNumber();
  41. for ( int i = 0; i < all.Count(); ++i )
  42. {
  43. auto *pZone = (CFuncPasstimeGoalieZone *)all[i];
  44. if ( (pZone->GetTeamNumber() == iPlayerTeam) && pZone->IsTouching( pPlayer ) )
  45. return true;
  46. }
  47. return false;
  48. }
  49. //-----------------------------------------------------------------------------
  50. bool CFuncPasstimeGoalieZone::BPlayerInEnemy( CTFPlayer *pPlayer )
  51. {
  52. auto &all = AutoList();
  53. int iPlayerTeam = pPlayer->GetTeamNumber();
  54. for ( int i = 0; i < all.Count(); ++i )
  55. {
  56. auto *pZone = (CFuncPasstimeGoalieZone *)all[i];
  57. if ( (pZone->GetTeamNumber() != iPlayerTeam) && pZone->IsTouching( pPlayer ) )
  58. return true;
  59. }
  60. return false;
  61. }