drop the now-dead payloads from the sim-backed state-change events
TickAdvanced, BuildingBlocksChanged, ExpansionCostChanged, BossWaveUpdated and ArtifactCountChanged all duplicated state the Simulation already owns. With every subscriber re-reading from the sim, the fields had no readers left, so the five events become payload-free refresh signals and the emitters keep the values only as locals for change detection. This makes the convention uniform: a state-change event backed by the simulation carries nothing. Events whose state lives in the view (selection, game speed, deconstruct and debug-draw modes) keep their payloads, since there is no sim getter behind them. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
This commit is contained in:
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
|
// Fired when the collected artifact count changes. Carries no payload —
|
||||||
|
// subscribers re-read Simulation::getArtifactCount(), and the win count from
|
||||||
|
// world.artifacts.artifactWinCount.
|
||||||
class ArtifactCountChangedEvent : public Event
|
class ArtifactCountChangedEvent : public Event
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
ArtifactCountChangedEvent(int count, int winCount) : count(count), winCount(winCount) {}
|
|
||||||
const int count;
|
|
||||||
const int winCount;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,16 +2,11 @@
|
|||||||
#define BOSS_WAVE_UPDATED_EVENT_H
|
#define BOSS_WAVE_UPDATED_EVENT_H
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "Tick.h"
|
|
||||||
|
|
||||||
|
// Fired when the boss wave counter or its countdown changes. Carries no payload —
|
||||||
|
// subscribers re-read Simulation::getBossWaveCounter() and getBossCountdownTicks().
|
||||||
class BossWaveUpdatedEvent : public Event
|
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
|
#endif // BOSS_WAVE_UPDATED_EVENT_H
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,10 @@
|
|||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
|
// Fired when the building block stock changes. Carries no payload — subscribers
|
||||||
|
// re-read Simulation::getBuildingBlocksStock().
|
||||||
class BuildingBlocksChangedEvent : public Event
|
class BuildingBlocksChangedEvent : public Event
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
explicit BuildingBlocksChangedEvent(int blocks) : blocks(blocks) {}
|
|
||||||
const int blocks;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BUILDING_BLOCKS_CHANGED_EVENT_H
|
#endif // BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,11 @@
|
|||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
// Fired when the current asteroid-expansion cost changes (REQ-EXP-COST): once at
|
// Fired when the current asteroid-expansion cost changes (REQ-EXP-COST): once at
|
||||||
// startup and again after each expansion is purchased. Carries the cost in
|
// startup and again after each expansion is purchased. Carries no payload — the
|
||||||
// building blocks so the header Expand button can update its caption/enabled
|
// header Expand button re-reads Simulation::getCurrentExpansionCost() to update
|
||||||
// state (REQ-UI-EXPAND-BUTTON).
|
// its caption and enabled state (REQ-UI-EXPAND-BUTTON).
|
||||||
class ExpansionCostChangedEvent : public Event
|
class ExpansionCostChangedEvent : public Event
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
explicit ExpansionCostChangedEvent(int cost) : cost(cost) {}
|
|
||||||
const int cost;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXPANSION_COST_CHANGED_EVENT_H
|
#endif // EXPANSION_COST_CHANGED_EVENT_H
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
#define TICK_ADVANCED_EVENT_H
|
#define TICK_ADVANCED_EVENT_H
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "Tick.h"
|
|
||||||
|
|
||||||
|
// Fired when the simulation tick advances. Carries no payload — subscribers
|
||||||
|
// re-read Simulation::getCurrentTick().
|
||||||
class TickAdvancedEvent : public Event
|
class TickAdvancedEvent : public Event
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
explicit TickAdvancedEvent(Tick tick) : tick(tick) {}
|
|
||||||
const Tick tick;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TICK_ADVANCED_EVENT_H
|
#endif // TICK_ADVANCED_EVENT_H
|
||||||
|
|
||||||
|
|||||||
@@ -403,26 +403,26 @@ void GameWorldView::onFrame()
|
|||||||
{
|
{
|
||||||
m_lastTick = newTick;
|
m_lastTick = newTick;
|
||||||
EventManager::getInstance()->sendEventImmediately(
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
std::make_shared<TickAdvancedEvent>(newTick));
|
std::make_shared<TickAdvancedEvent>());
|
||||||
}
|
}
|
||||||
if (newBlocks != m_lastBlocks)
|
if (newBlocks != m_lastBlocks)
|
||||||
{
|
{
|
||||||
m_lastBlocks = newBlocks;
|
m_lastBlocks = newBlocks;
|
||||||
EventManager::getInstance()->sendEventImmediately(
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
std::make_shared<BuildingBlocksChangedEvent>(newBlocks));
|
std::make_shared<BuildingBlocksChangedEvent>());
|
||||||
}
|
}
|
||||||
if (newExpCost != m_lastExpansionCost)
|
if (newExpCost != m_lastExpansionCost)
|
||||||
{
|
{
|
||||||
m_lastExpansionCost = newExpCost;
|
m_lastExpansionCost = newExpCost;
|
||||||
EventManager::getInstance()->sendEventImmediately(
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
std::make_shared<ExpansionCostChangedEvent>(newExpCost));
|
std::make_shared<ExpansionCostChangedEvent>());
|
||||||
}
|
}
|
||||||
if (newBoss != m_lastBossCounter || newCountdown != m_lastBossCountdown)
|
if (newBoss != m_lastBossCounter || newCountdown != m_lastBossCountdown)
|
||||||
{
|
{
|
||||||
m_lastBossCounter = newBoss;
|
m_lastBossCounter = newBoss;
|
||||||
m_lastBossCountdown = newCountdown;
|
m_lastBossCountdown = newCountdown;
|
||||||
EventManager::getInstance()->sendEventImmediately(
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
std::make_shared<BossWaveUpdatedEvent>(newBoss, newCountdown));
|
std::make_shared<BossWaveUpdatedEvent>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlocked building set changes only after a drop is applied or on Restart
|
// Unlocked building set changes only after a drop is applied or on Restart
|
||||||
@@ -485,8 +485,7 @@ void GameWorldView::onFrame()
|
|||||||
{
|
{
|
||||||
m_lastArtifactCount = currentArtifactCount;
|
m_lastArtifactCount = currentArtifactCount;
|
||||||
EventManager::getInstance()->sendEventImmediately(
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
std::make_shared<ArtifactCountChangedEvent>(
|
std::make_shared<ArtifactCountChangedEvent>());
|
||||||
currentArtifactCount, m_sim->getConfig().world.artifacts.artifactWinCount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|||||||
Reference in New Issue
Block a user