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.

84 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "entity_roundwin.h"
  8. #include "teamplayroundbased_gamerules.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //=============================================================================
  12. //
  13. // CTeamplayRoundWin tables.
  14. //
  15. BEGIN_DATADESC( CTeamplayRoundWin )
  16. DEFINE_KEYFIELD( m_bForceMapReset, FIELD_BOOLEAN, "force_map_reset" ),
  17. DEFINE_KEYFIELD( m_bSwitchTeamsOnWin, FIELD_BOOLEAN, "switch_teams" ),
  18. DEFINE_KEYFIELD( m_iWinReason, FIELD_INTEGER, "win_reason" ),
  19. // Inputs.
  20. DEFINE_INPUTFUNC( FIELD_INTEGER, "SetTeam", InputSetTeam ),
  21. DEFINE_INPUTFUNC( FIELD_VOID, "RoundWin", InputRoundWin ),
  22. // Outputs.
  23. DEFINE_OUTPUT( m_outputOnRoundWin, "OnRoundWin" ),
  24. END_DATADESC()
  25. LINK_ENTITY_TO_CLASS( game_round_win, CTeamplayRoundWin );
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Constructor.
  28. //-----------------------------------------------------------------------------
  29. CTeamplayRoundWin::CTeamplayRoundWin()
  30. {
  31. // default win reason for map-fired event (map may change it)
  32. m_iWinReason = WINREASON_DEFEND_UNTIL_TIME_LIMIT;
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. //-----------------------------------------------------------------------------
  37. void CTeamplayRoundWin::RoundWin( void )
  38. {
  39. CTeamplayRoundBasedRules *pGameRules = dynamic_cast<CTeamplayRoundBasedRules *>( GameRules() );
  40. if ( pGameRules )
  41. {
  42. int iTeam = GetTeamNumber();
  43. if ( iTeam > LAST_SHARED_TEAM )
  44. {
  45. if ( !m_bForceMapReset )
  46. {
  47. pGameRules->SetWinningTeam( iTeam, m_iWinReason, m_bForceMapReset );
  48. }
  49. else
  50. {
  51. pGameRules->SetWinningTeam( iTeam, m_iWinReason, m_bForceMapReset, m_bSwitchTeamsOnWin );
  52. }
  53. }
  54. else
  55. {
  56. pGameRules->SetStalemate( STALEMATE_TIMER, m_bForceMapReset, m_bSwitchTeamsOnWin );
  57. }
  58. }
  59. // Output.
  60. m_outputOnRoundWin.FireOutput( this, this );
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. //-----------------------------------------------------------------------------
  65. void CTeamplayRoundWin::InputRoundWin( inputdata_t &inputdata )
  66. {
  67. RoundWin();
  68. }