1 | /* Copyright (C) 2016 Wildfire Games.
|
---|
2 | * This file is part of 0 A.D.
|
---|
3 | *
|
---|
4 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
5 | * it under the terms of the GNU General Public License as published by
|
---|
6 | * the Free Software Foundation, either version 2 of the License, or
|
---|
7 | * (at your option) any later version.
|
---|
8 | *
|
---|
9 | * 0 A.D. is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | *
|
---|
14 | * You should have received a copy of the GNU General Public License
|
---|
15 | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include "precompiled.h"
|
---|
19 |
|
---|
20 | #include "SimContext.h"
|
---|
21 |
|
---|
22 | #include "ComponentManager.h"
|
---|
23 |
|
---|
24 | #include "ps/Game.h"
|
---|
25 |
|
---|
26 | CSimContext::CSimContext() :
|
---|
27 | m_ComponentManager(NULL), m_UnitManager(NULL), m_Terrain(NULL)
|
---|
28 | {
|
---|
29 | }
|
---|
30 |
|
---|
31 | CSimContext::~CSimContext()
|
---|
32 | {
|
---|
33 | }
|
---|
34 |
|
---|
35 | CComponentManager& CSimContext::GetComponentManager() const
|
---|
36 | {
|
---|
37 | return *m_ComponentManager;
|
---|
38 | }
|
---|
39 |
|
---|
40 | bool CSimContext::HasUnitManager() const
|
---|
41 | {
|
---|
42 | return m_UnitManager != NULL;
|
---|
43 | }
|
---|
44 |
|
---|
45 | CUnitManager& CSimContext::GetUnitManager() const
|
---|
46 | {
|
---|
47 | ENSURE(m_UnitManager);
|
---|
48 | return *m_UnitManager;
|
---|
49 | }
|
---|
50 |
|
---|
51 | CTerrain& CSimContext::GetTerrain() const
|
---|
52 | {
|
---|
53 | ENSURE(m_Terrain);
|
---|
54 | return *m_Terrain;
|
---|
55 | }
|
---|
56 |
|
---|
57 | void CSimContext::SetComponentManager(CComponentManager* man)
|
---|
58 | {
|
---|
59 | ENSURE(!m_ComponentManager);
|
---|
60 | m_ComponentManager = man;
|
---|
61 | }
|
---|
62 |
|
---|
63 | ScriptInterface& CSimContext::GetScriptInterface() const
|
---|
64 | {
|
---|
65 | return GetComponentManager().GetScriptInterface();
|
---|
66 | }
|
---|
67 |
|
---|
68 | int CSimContext::GetCurrentDisplayedPlayer() const
|
---|
69 | {
|
---|
70 | return g_Game ? g_Game->GetViewedPlayerID() : -1;
|
---|
71 | }
|
---|