add event system and use it to propagate to print traces
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "CombatSystem.h"
|
||||
#include "DynamicBodySystem.h"
|
||||
#include "FactionComponent.h"
|
||||
#include "EventManager.h"
|
||||
#include "HealthComponent.h"
|
||||
#include "ModuleOwnerComponent.h"
|
||||
#include "MovementIntentSystem.h"
|
||||
@@ -71,9 +72,13 @@ Simulation::Simulation(GameConfig config, unsigned int seed)
|
||||
}
|
||||
|
||||
placeInitialStructures();
|
||||
registerForEvents();
|
||||
}
|
||||
|
||||
Simulation::~Simulation() = default;
|
||||
Simulation::~Simulation()
|
||||
{
|
||||
unregisterForEvents();
|
||||
}
|
||||
|
||||
const GameConfig& Simulation::config() const
|
||||
{
|
||||
@@ -88,6 +93,7 @@ void Simulation::reset(GameConfig newConfig, unsigned int seed)
|
||||
|
||||
void Simulation::reset(unsigned int seed)
|
||||
{
|
||||
EventManager::destroyInstance();
|
||||
m_rng.seed(seed);
|
||||
m_currentTick = 0;
|
||||
m_nextDepartureTick = secondsToTicks(m_config.world.departureIntervalSeconds);
|
||||
@@ -147,6 +153,8 @@ void Simulation::reset(unsigned int seed)
|
||||
|
||||
void Simulation::tick()
|
||||
{
|
||||
EventManager::getInstance()->processEvents();
|
||||
|
||||
// Step 1: wave scheduler
|
||||
m_waveSystem->tickWaveScheduler(m_currentTick, *m_shipSystem,
|
||||
m_config.world.heightTiles);
|
||||
@@ -199,8 +207,6 @@ void Simulation::tick()
|
||||
m_scrapSystem->tickDespawn(m_currentTick);
|
||||
|
||||
++m_currentTick;
|
||||
|
||||
PRINT_TRACES();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -642,6 +648,11 @@ const EntityAdmin& Simulation::admin() const
|
||||
return m_admin;
|
||||
}
|
||||
|
||||
void Simulation::handleEvent(std::shared_ptr<const TracePrintRequestedEvent> event)
|
||||
{
|
||||
PRINT_TRACES();
|
||||
}
|
||||
|
||||
BuildingId Simulation::allocateBuildingId()
|
||||
{
|
||||
return m_nextBuildingId++;
|
||||
|
||||
Reference in New Issue
Block a user