blob: 7bbe2b56e3c5116d1ed6252ab0b2564be04df158 (
plain) (
blame)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//===========================================================================//
#include "cbase.h"
#include "igamesystem.h"
#include "toolframework/iserverenginetools.h"
#include "init_factory.h"
//-----------------------------------------------------------------------------
// Purpose: This is an autogame system which is used to call back into the engine at appropriate points
// so that IToolSystems can get these hooks at the correct time
//-----------------------------------------------------------------------------
class CToolFrameworkServer : public CAutoGameSystemPerFrame, public IToolFrameworkServer
{
public:
virtual bool Init();
// Level init, shutdown
virtual void LevelInitPreEntity();
// entities are created / spawned / precached here
virtual void LevelInitPostEntity();
virtual void LevelShutdownPreEntity();
// Entities are deleted / released here...
virtual void LevelShutdownPostEntity();
// Called each frame before entities think
virtual void FrameUpdatePreEntityThink();
// called after entities think
virtual void FrameUpdatePostEntityThink();
virtual void PreClientUpdate();
virtual void PreSetupVisibility();
IServerEngineTools *m_pTools;
};
// Singleton
static CToolFrameworkServer g_ToolFrameworkServer;
IToolFrameworkServer *g_pToolFrameworkServer = &g_ToolFrameworkServer;
#ifndef NO_TOOLFRAMEWORK
bool ToolsEnabled()
{
return g_ToolFrameworkServer.m_pTools && g_ToolFrameworkServer.m_pTools->InToolMode() && !engine->IsDedicatedServer();
}
#endif
bool CToolFrameworkServer::Init()
{
factorylist_t list;
FactoryList_Retrieve( list );
// Latch onto internal interface
m_pTools = ( IServerEngineTools * )list.engineFactory( VSERVERENGINETOOLS_INTERFACE_VERSION, NULL );
if ( !m_pTools && !engine->IsDedicatedServer() )
{
return false;
}
return true;
}
void CToolFrameworkServer::LevelInitPreEntity()
{
if ( !m_pTools )
{
return;
}
m_pTools->LevelInitPreEntityAllTools();
}
void CToolFrameworkServer::LevelInitPostEntity()
{
if ( !m_pTools )
{
return;
}
m_pTools->LevelInitPostEntityAllTools();
}
void CToolFrameworkServer::LevelShutdownPreEntity()
{
if ( !m_pTools )
{
return;
}
m_pTools->LevelShutdownPreEntityAllTools();
}
void CToolFrameworkServer::LevelShutdownPostEntity()
{
if ( !m_pTools )
{
return;
}
m_pTools->LevelShutdownPostEntityAllTools();
}
void CToolFrameworkServer::FrameUpdatePreEntityThink()
{
if ( !m_pTools )
{
return;
}
m_pTools->FrameUpdatePreEntityThinkAllTools();
}
void CToolFrameworkServer::FrameUpdatePostEntityThink()
{
if ( !m_pTools )
{
return;
}
m_pTools->FrameUpdatePostEntityThinkAllTools();
}
void CToolFrameworkServer::PreClientUpdate()
{
if ( !m_pTools )
{
return;
}
m_pTools->PreClientUpdateAllTools();
}
void CToolFrameworkServer::PreSetupVisibility()
{
if ( !m_pTools )
{
return;
}
m_pTools->PreSetupVisibilityAllTools();
}
|