56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <random>
|
|
#include <vector>
|
|
|
|
#include "BeltSystem.h"
|
|
#include "BlueprintDropEvent.h"
|
|
#include "EntityId.h"
|
|
#include "FireEvent.h"
|
|
#include "GameConfig.h"
|
|
#include "Tick.h"
|
|
|
|
class BuildingSystem;
|
|
|
|
class Simulation
|
|
{
|
|
public:
|
|
explicit Simulation(const GameConfig& config, unsigned int seed = 0);
|
|
~Simulation();
|
|
|
|
// Advances the simulation by one tick. Tick order per architecture.md §Tick Order.
|
|
void tick();
|
|
|
|
// Returns all fire events accumulated since the last drain, clearing the
|
|
// internal queue. Call once per rendered frame (REQ-SHP-FIRING-BEAM).
|
|
std::vector<FireEvent> drainFireEvents();
|
|
|
|
// Returns all blueprint drop events since the last drain.
|
|
std::vector<BlueprintDropEvent> drainBlueprintDropEvents();
|
|
|
|
Tick currentTick() const;
|
|
int buildingBlocksStock() const;
|
|
|
|
BuildingSystem& buildings();
|
|
const BuildingSystem& buildings() const;
|
|
BeltSystem& belts();
|
|
const BeltSystem& belts() const;
|
|
|
|
private:
|
|
EntityId allocateId(); // Strictly increasing; never returns kInvalidEntityId.
|
|
|
|
const GameConfig& m_config;
|
|
std::mt19937 m_rng;
|
|
|
|
Tick m_currentTick;
|
|
EntityId m_nextId;
|
|
int m_buildingBlocksStock;
|
|
|
|
BeltSystem m_beltSystem;
|
|
std::unique_ptr<BuildingSystem> m_buildingSystem;
|
|
|
|
std::vector<FireEvent> m_fireEvents;
|
|
std::vector<BlueprintDropEvent> m_blueprintDropEvents;
|
|
};
|