2012-01-29 11:28:19 -08:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
2011-12-26 12:57:12 -08:00
|
|
|
#include "cSimulatorManager.h"
|
2012-01-29 11:28:19 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-26 12:57:12 -08:00
|
|
|
|
|
|
|
cSimulatorManager::cSimulatorManager()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-13 13:47:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-26 12:57:12 -08:00
|
|
|
cSimulatorManager::~cSimulatorManager()
|
|
|
|
{
|
2012-02-13 13:47:03 -08:00
|
|
|
for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr )
|
|
|
|
{
|
|
|
|
delete *itr;
|
|
|
|
} // for itr - m_Simulators[]
|
2011-12-26 12:57:12 -08:00
|
|
|
}
|
|
|
|
|
2012-02-13 13:47:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-26 12:57:12 -08:00
|
|
|
void cSimulatorManager::Simulate( float a_Dt )
|
|
|
|
{
|
|
|
|
m_Ticks++;
|
2012-02-13 13:47:03 -08:00
|
|
|
for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr )
|
2011-12-26 12:57:12 -08:00
|
|
|
{
|
|
|
|
if(m_Ticks % (*itr)->second == 0)
|
|
|
|
(*itr)->first->Simulate(a_Dt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 13:47:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-26 12:57:12 -08:00
|
|
|
void cSimulatorManager::WakeUp(int a_X, int a_Y, int a_Z)
|
|
|
|
{
|
2012-02-13 13:47:03 -08:00
|
|
|
for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr )
|
2011-12-26 12:57:12 -08:00
|
|
|
{
|
|
|
|
(*itr)->first->WakeUp(a_X, a_Y, a_Z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 13:47:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-26 12:57:12 -08:00
|
|
|
void cSimulatorManager::RegisterSimulator(cSimulator *a_Simulator, short a_Rate)
|
|
|
|
{
|
|
|
|
//TODO needs some checking
|
|
|
|
std::pair<cSimulator *, short> *Pair = new std::pair<cSimulator *, short>(a_Simulator, a_Rate);
|
|
|
|
|
|
|
|
m_Simulators.push_back(Pair);
|
2012-02-13 13:47:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|