4#include <aegis2d/core/clock.hpp>
5#include <aegis2d/core/loop.hpp>
6#include <aegis2d/core/profiler.hpp>
69 [[nodiscard]] std::uint64_t
ticks() const noexcept;
75 [[nodiscard]] const aegis2d::core::Profiler&
profiler() const noexcept;
79 [[nodiscard]] std::uint32_t
rate() const noexcept;
83 void step(aegis2d::core::Duration step);
89 aegis2d::core::MainLoop loop_;
92 std::atomic<std::uint64_t> ticks_{0};
93 std::atomic<bool> stopping_{
false};
95 std::chrono::steady_clock::time_point report_since_;
96 std::uint64_t report_ticks_ = 0;
97 aegis2d::core::Profiler profiler_;
The one game of the server, with up to tuning::max_players players.
Definition game_instance.hpp:37
Runs a GameInstance on its own thread, tuning::tick_rate times per second.
Definition simulation.hpp:30
~Simulation()
Stops the thread and waits for it.
Simulation(GameInstance &instance, std::uint32_t rate=tuning::tick_rate, TickHandler after_tick={}, bool trace=false)
Starts the thread.
Simulation & operator=(const Simulation &)=delete
const aegis2d::core::Profiler & profiler() const noexcept
The timings of the ticks, recorded with trace: a frame per tick, the tick and its systems,...
void stop()
Stops the thread after its current tick and waits for it. Thread-safe, but not from a command; callin...
Simulation(Simulation &&)=delete
std::function< void(GameInstance &instance)> TickHandler
Called on the simulation thread after each tick, to read the game.
Definition simulation.hpp:36
Simulation & operator=(Simulation &&)=delete
std::uint32_t rate() const noexcept
Ticks per second the thread aims at.
std::uint64_t ticks() const noexcept
Number of ticks run. Thread-safe.
Simulation(const Simulation &)=delete
static constexpr std::chrono::seconds report_period
How often the measured rate is logged.
Definition simulation.hpp:39
std::function< void(GameInstance &instance)> Command
A change to make to the game, run on the simulation thread.
Definition simulation.hpp:33
void post(Command command)
Queues a command for the simulation thread. Thread-safe.
The game run by the server, and the players of the sessions in it.
constexpr std::uint32_t tick_rate
Simulation rate of the server, in ticks per second.
Definition tuning.hpp:15
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
Gameplay values of R-Type: play area, speeds, sizes, health, lives and scores.