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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Implements populator interface entity. Used for map
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "tf_population_manager.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
extern ConVar tf_populator_debug;
class CPointPopulatorInterface : public CPointEntity
{
DECLARE_CLASS( CPointPopulatorInterface, CPointEntity );
public:
// Input handlers
void InputPauseBotSpawning(inputdata_t &inputdata);
void InputUnpauseBotSpawning(inputdata_t &inputdata);
void InputChangeBotAttributes(inputdata_t &inputdata);
void InputChangeDefaultEventAttributes(inputdata_t &inputdata);
DECLARE_DATADESC();
};
BEGIN_DATADESC( CPointPopulatorInterface )
// Inputs
DEFINE_INPUTFUNC( FIELD_VOID, "PauseBotSpawning", InputPauseBotSpawning ),
DEFINE_INPUTFUNC( FIELD_VOID, "UnpauseBotSpawning", InputUnpauseBotSpawning ),
DEFINE_INPUTFUNC( FIELD_STRING, "ChangeBotAttributes", InputChangeBotAttributes ),
DEFINE_INPUTFUNC( FIELD_STRING, "ChangeDefaultEventAttributes", InputChangeDefaultEventAttributes ),
END_DATADESC()
LINK_ENTITY_TO_CLASS( point_populator_interface, CPointPopulatorInterface );
void CPointPopulatorInterface::InputPauseBotSpawning( inputdata_t &inputdata )
{
Assert( g_pPopulationManager );
if( g_pPopulationManager )
{
g_pPopulationManager->PauseSpawning();
}
}
void CPointPopulatorInterface::InputUnpauseBotSpawning( inputdata_t &inputdata )
{
Assert( g_pPopulationManager );
if( g_pPopulationManager )
{
g_pPopulationManager->UnpauseSpawning();
}
}
void CPointPopulatorInterface::InputChangeBotAttributes( inputdata_t &inputdata )
{
const char* pszEventName = inputdata.value.String();
if ( tf_populator_debug.GetBool() && g_pPopulationManager && !g_pPopulationManager->HasEventChangeAttributes( pszEventName ) )
{
Warning( "ChangeBotAttributes: Failed to find event [%s] in the pop file\n", pszEventName );
return;
}
if ( TFGameRules()->IsMannVsMachineMode() )
{
CUtlVector< CTFBot* > botVector;
CollectPlayers( &botVector, TF_TEAM_PVE_INVADERS, COLLECT_ONLY_LIVING_PLAYERS );
for ( int i=0; i<botVector.Count(); ++i )
{
const CTFBot::EventChangeAttributes_t* pEvent = botVector[i]->GetEventChangeAttributes( pszEventName );
if ( pEvent )
{
botVector[i]->OnEventChangeAttributes( pEvent );
}
}
}
}
void CPointPopulatorInterface::InputChangeDefaultEventAttributes(inputdata_t &inputdata)
{
const char* pszEventName = inputdata.value.String();
if ( tf_populator_debug.GetBool() && g_pPopulationManager && !g_pPopulationManager->HasEventChangeAttributes( pszEventName ) )
{
Warning( "ChangeBotAttributes: Failed to find event [%s] in the pop file\n", pszEventName );
return;
}
if ( g_pPopulationManager )
{
g_pPopulationManager->SetDefaultEventChangeAttributesName( pszEventName );
}
}
|