replace combined stateUpdated signal with individual events
This commit is contained in:
@@ -117,6 +117,12 @@ void EventManager::processEvents()
|
||||
}
|
||||
}
|
||||
|
||||
void EventManager::clearEvents()
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(m_eventsMutex);
|
||||
m_events.clear();
|
||||
}
|
||||
|
||||
bool EventManager::hasEvents() const
|
||||
{
|
||||
return !m_events.empty();
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
void sendEventImmediately(std::shared_ptr<Event> event);
|
||||
void addEvent(std::shared_ptr<Event> event);
|
||||
void processEvents();
|
||||
void clearEvents();
|
||||
|
||||
bool hasEvents() const;
|
||||
|
||||
|
||||
17
src/lib/eventsystem/event/BossWaveUpdatedEvent.h
Normal file
17
src/lib/eventsystem/event/BossWaveUpdatedEvent.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef BOSS_WAVE_UPDATED_EVENT_H
|
||||
#define BOSS_WAVE_UPDATED_EVENT_H
|
||||
|
||||
#include "Event.h"
|
||||
#include "Tick.h"
|
||||
|
||||
class BossWaveUpdatedEvent : public Event
|
||||
{
|
||||
public:
|
||||
BossWaveUpdatedEvent(int counter, Tick countdownTicks)
|
||||
: counter(counter), countdownTicks(countdownTicks) {}
|
||||
const int counter;
|
||||
const Tick countdownTicks;
|
||||
};
|
||||
|
||||
#endif // BOSS_WAVE_UPDATED_EVENT_H
|
||||
|
||||
14
src/lib/eventsystem/event/BuildingBlocksChangedEvent.h
Normal file
14
src/lib/eventsystem/event/BuildingBlocksChangedEvent.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||
#define BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class BuildingBlocksChangedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit BuildingBlocksChangedEvent(int blocks) : blocks(blocks) {}
|
||||
const int blocks;
|
||||
};
|
||||
|
||||
#endif // BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
SET(HDRS
|
||||
${HDRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TracePrintRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TickAdvancedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BuildingBlocksChangedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameSpeedChangedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BossWaveUpdatedEvent.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
||||
14
src/lib/eventsystem/event/GameSpeedChangedEvent.h
Normal file
14
src/lib/eventsystem/event/GameSpeedChangedEvent.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GAME_SPEED_CHANGED_EVENT_H
|
||||
#define GAME_SPEED_CHANGED_EVENT_H
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class GameSpeedChangedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit GameSpeedChangedEvent(double speed) : speed(speed) {}
|
||||
const double speed;
|
||||
};
|
||||
|
||||
#endif // GAME_SPEED_CHANGED_EVENT_H
|
||||
|
||||
15
src/lib/eventsystem/event/TickAdvancedEvent.h
Normal file
15
src/lib/eventsystem/event/TickAdvancedEvent.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef TICK_ADVANCED_EVENT_H
|
||||
#define TICK_ADVANCED_EVENT_H
|
||||
|
||||
#include "Event.h"
|
||||
#include "Tick.h"
|
||||
|
||||
class TickAdvancedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit TickAdvancedEvent(Tick tick) : tick(tick) {}
|
||||
const Tick tick;
|
||||
};
|
||||
|
||||
#endif // TICK_ADVANCED_EVENT_H
|
||||
|
||||
@@ -93,7 +93,7 @@ void Simulation::reset(GameConfig newConfig, unsigned int seed)
|
||||
|
||||
void Simulation::reset(unsigned int seed)
|
||||
{
|
||||
EventManager::destroyInstance();
|
||||
EventManager::getInstance()->clearEvents();
|
||||
m_rng.seed(seed);
|
||||
m_currentTick = 0;
|
||||
m_nextDepartureTick = secondsToTicks(m_config.world.departureIntervalSeconds);
|
||||
|
||||
Reference in New Issue
Block a user