add restart button to game over screen
This commit is contained in:
@@ -49,6 +49,45 @@ Simulation::Simulation(const GameConfig& config, unsigned int seed)
|
||||
|
||||
Simulation::~Simulation() = default;
|
||||
|
||||
void Simulation::reset(unsigned int seed)
|
||||
{
|
||||
m_rng.seed(seed);
|
||||
m_currentTick = 0;
|
||||
m_nextId = 1;
|
||||
m_buildingBlocksStock = m_config.world.startingBuildingBlocks;
|
||||
m_gameOver = false;
|
||||
m_hqId = kInvalidEntityId;
|
||||
m_playerStation1Id = kInvalidEntityId;
|
||||
m_playerStation2Id = kInvalidEntityId;
|
||||
m_currentEnemyStationIds[0] = kInvalidEntityId;
|
||||
m_currentEnemyStationIds[1] = kInvalidEntityId;
|
||||
m_fireEvents.clear();
|
||||
m_blueprintDropEvents.clear();
|
||||
|
||||
m_beltSystem = BeltSystem(m_config.world.beltSpeedTilesPerSecond);
|
||||
m_buildingSystem = std::make_unique<BuildingSystem>(
|
||||
m_config,
|
||||
m_beltSystem,
|
||||
[this]() { return allocateId(); },
|
||||
[this](int amount) { m_buildingBlocksStock += amount; },
|
||||
m_rng);
|
||||
m_shipSystem = std::make_unique<ShipSystem>(m_config, [this]() { return allocateId(); });
|
||||
m_scrapSystem = std::make_unique<ScrapSystem>([this]() { return allocateId(); });
|
||||
m_waveSystem = std::make_unique<WaveSystem>(m_config, m_rng);
|
||||
m_combatSystem = std::make_unique<CombatSystem>(m_config);
|
||||
|
||||
m_blueprintLevels.clear();
|
||||
for (const ShipDef& def : m_config.ships.ships)
|
||||
{
|
||||
BlueprintState state;
|
||||
state.unlocked = def.availableFromStart;
|
||||
state.level = def.availableFromStart ? def.blueprint.playerProductionLevel : 0;
|
||||
m_blueprintLevels[def.id] = state;
|
||||
}
|
||||
|
||||
placeInitialStructures();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// tick
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user