4#include <aegis2d/ecs/components.hpp>
5#include <aegis2d/ecs/entity.hpp>
6#include <aegis2d/ecs/waves.hpp>
22 std::optional<aegis2d::ecs::Entity>
ship;
28 std::optional<std::uint16_t>
input;
43 GameInstance(std::optional<std::uint64_t> seed, aegis2d::ecs::WaveSchedule waves,
51 aegis2d::ecs::Entity
join(std::uint8_t player);
56 bool leave(std::uint8_t player);
66 bool set_input(std::uint8_t player, aegis2d::ecs::PlayerInput input, std::uint16_t sequence);
73 bool set_rewind(std::uint8_t player, std::uint32_t ticks);
78 [[nodiscard]] std::optional<aegis2d::ecs::Entity>
ship(std::uint8_t player)
const;
85 [[nodiscard]] std::optional<PlayerState>
player_state(std::uint8_t player);
89 [[nodiscard]] std::size_t
players() const noexcept;
98 [[nodiscard]] std::uint64_t
games() const noexcept;
110 std::optional<std::uint64_t> seed_;
111 aegis2d::ecs::WaveSchedule waves_;
115 std::array<std::optional<aegis2d::ecs::Entity>, tuning::max_players> ships_;
116 std::array<std::uint32_t, tuning::max_players> scores_{};
118 std::uint64_t games_ = 0;
119 bool over_told_ =
false;
The one game of the server, with up to tuning::max_players players.
Definition game_instance.hpp:37
std::size_t players() const noexcept
Players in the game, out of lives or not.
std::uint64_t games() const noexcept
Number of games played: 1, then 1 more each time the last player leaves.
std::optional< aegis2d::ecs::Entity > ship(std::uint8_t player) const
Ship of a player.
GameInstance(std::optional< std::uint64_t > seed, aegis2d::ecs::WaveSchedule waves, GameRules rules={})
Creates an empty game.
ServerGame & game() noexcept
The game being played.
bool take_game_over()
Tells once per game that it is over: every player who joined is out.
bool leave(std::uint8_t player)
Removes a player from the game; its ship disappears.
bool set_input(std::uint8_t player, aegis2d::ecs::PlayerInput input, std::uint16_t sequence)
Sets the actions a player holds, applied at every tick until the next call.
bool set_rewind(std::uint8_t player, std::uint32_t ticks)
Sets how many ticks back a player's missiles meet the enemies (lag compensation, ServerGame::set_rewi...
aegis2d::ecs::Entity join(std::uint8_t player)
Adds the ship of a player to the game.
std::optional< PlayerState > player_state(std::uint8_t player)
State of a player.
One R-Type game on the server: the world, its systems in order, and the players.
Definition server_game.hpp:75
constexpr std::size_t max_players
Players in one game, as the subject requires.
Definition tuning.hpp:33
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
The R-Type simulation run by the server: world, systems and players.
How a game plays: the rules of its room, as the gameplay reads them.
Definition server_game.hpp:35
What the game says of a player, for the snapshots.
Definition game_instance.hpp:20
std::optional< std::uint16_t > input
Sequence of the last input applied to its ship, or nothing before the first.
Definition game_instance.hpp:28
std::uint32_t score
Score; once out, the last score of its ship.
Definition game_instance.hpp:26
std::uint32_t lives
Lives left, 0 once out.
Definition game_instance.hpp:24
std::optional< aegis2d::ecs::Entity > ship
Its ship, or std::nullopt once out of lives.
Definition game_instance.hpp:22
Gameplay values of R-Type: play area, speeds, sizes, health, lives and scores.