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