2011-01-12 13:29:00 +01:00
|
|
|
/* Copyright (C) 2011 Wildfire Games.
|
2010-01-09 20:20:14 +01:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "SimContext.h"
|
|
|
|
|
2010-05-01 11:48:39 +02:00
|
|
|
#include "ComponentManager.h"
|
|
|
|
|
2010-09-23 14:13:13 +02:00
|
|
|
#include "ps/Game.h"
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
CSimContext::CSimContext() :
|
|
|
|
m_ComponentManager(NULL), m_UnitManager(NULL), m_Terrain(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CSimContext::~CSimContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CComponentManager& CSimContext::GetComponentManager() const
|
|
|
|
{
|
2011-04-30 15:01:45 +02:00
|
|
|
ENSURE(m_ComponentManager);
|
2010-01-09 20:20:14 +01:00
|
|
|
return *m_ComponentManager;
|
|
|
|
}
|
|
|
|
|
2010-02-08 23:05:05 +01:00
|
|
|
bool CSimContext::HasUnitManager() const
|
|
|
|
{
|
|
|
|
return m_UnitManager != NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
CUnitManager& CSimContext::GetUnitManager() const
|
|
|
|
{
|
2011-04-30 15:01:45 +02:00
|
|
|
ENSURE(m_UnitManager);
|
2010-01-09 20:20:14 +01:00
|
|
|
return *m_UnitManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
CTerrain& CSimContext::GetTerrain() const
|
|
|
|
{
|
2011-04-30 15:01:45 +02:00
|
|
|
ENSURE(m_Terrain);
|
2010-01-09 20:20:14 +01:00
|
|
|
return *m_Terrain;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSimContext::SetComponentManager(CComponentManager* man)
|
|
|
|
{
|
2011-04-30 15:01:45 +02:00
|
|
|
ENSURE(!m_ComponentManager);
|
2010-01-09 20:20:14 +01:00
|
|
|
m_ComponentManager = man;
|
|
|
|
}
|
2010-05-01 11:48:39 +02:00
|
|
|
|
|
|
|
ScriptInterface& CSimContext::GetScriptInterface() const
|
|
|
|
{
|
|
|
|
return GetComponentManager().GetScriptInterface();
|
|
|
|
}
|
2010-09-23 14:13:13 +02:00
|
|
|
|
|
|
|
int CSimContext::GetCurrentDisplayedPlayer() const
|
|
|
|
{
|
|
|
|
if (!g_Game)
|
|
|
|
return -1;
|
|
|
|
return g_Game->GetPlayerID();
|
|
|
|
}
|