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.

96 lines
2.7 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_FuncRespawnRoom : public C_BaseEntity
  16. {
  17. DECLARE_CLASS( C_FuncRespawnRoom, C_BaseEntity );
  18. public:
  19. DECLARE_CLIENTCLASS();
  20. };
  21. IMPLEMENT_CLIENTCLASS_DT( C_FuncRespawnRoom, DT_FuncRespawnRoom, CFuncRespawnRoom )
  22. END_RECV_TABLE()
  23. //-----------------------------------------------------------------------------
  24. // Purpose:
  25. //-----------------------------------------------------------------------------
  26. class C_FuncRespawnRoomVisualizer : public C_BaseEntity
  27. {
  28. DECLARE_CLASS( C_FuncRespawnRoomVisualizer, C_BaseEntity );
  29. public:
  30. DECLARE_CLIENTCLASS();
  31. virtual int DrawModel( int flags );
  32. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
  33. };
  34. IMPLEMENT_CLIENTCLASS_DT( C_FuncRespawnRoomVisualizer, DT_FuncRespawnRoomVisualizer, CFuncRespawnRoomVisualizer )
  35. END_RECV_TABLE()
  36. //-----------------------------------------------------------------------------
  37. // Purpose: Don't draw for friendly players
  38. //-----------------------------------------------------------------------------
  39. int C_FuncRespawnRoomVisualizer::DrawModel( int flags )
  40. {
  41. // Don't draw for anyone in endround
  42. if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
  43. {
  44. return 1;
  45. }
  46. // Don't draw for teammates of the visualizer
  47. C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
  48. if ( pLocalPlayer && pLocalPlayer->GetTeamNumber() == GetTeamNumber() )
  49. {
  50. return 1;
  51. }
  52. return BaseClass::DrawModel( flags );
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose: Enemy players collide with us, except in endround
  56. //-----------------------------------------------------------------------------
  57. bool C_FuncRespawnRoomVisualizer::ShouldCollide( int collisionGroup, int contentsMask ) const
  58. {
  59. // Respawn rooms are open in win state
  60. if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
  61. return false;
  62. if ( GetTeamNumber() == TEAM_UNASSIGNED )
  63. return false;
  64. if ( collisionGroup == COLLISION_GROUP_PLAYER_MOVEMENT )
  65. {
  66. switch( GetTeamNumber() )
  67. {
  68. case TF_TEAM_BLUE:
  69. if ( !(contentsMask & CONTENTS_BLUETEAM) )
  70. return false;
  71. break;
  72. case TF_TEAM_RED:
  73. if ( !(contentsMask & CONTENTS_REDTEAM) )
  74. return false;
  75. break;
  76. }
  77. return true;
  78. }
  79. return false;
  80. }