R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
world_snapshot.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <rtype/snapshot.hpp>
5#include <rtype/tuning.hpp>
6
7#include <cstdint>
8#include <optional>
9
10namespace rtype {
11
12class GameInstance;
13
18[[nodiscard]] std::optional<EntityKind> kind_of_layer(std::uint32_t layer) noexcept;
19
24[[nodiscard]] constexpr bool snapshot_due(std::uint64_t tick) noexcept {
25 return tick % (tuning::tick_rate / tuning::snapshot_rate) == 0;
26}
27
33[[nodiscard]] Snapshot take_snapshot(GameInstance& instance);
34
35} // namespace rtype
The one game of the server, with up to tuning::max_players players.
Definition game_instance.hpp:37
constexpr std::uint32_t tick_rate
Simulation rate of the server, in ticks per second.
Definition tuning.hpp:15
constexpr std::uint32_t snapshot_rate
Snapshots the server sends each client per second (RFC section 4.3).
Definition tuning.hpp:18
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
Snapshot take_snapshot(GameInstance &instance)
Takes the state of the game, on the simulation thread.
std::optional< EntityKind > kind_of_layer(std::uint32_t layer) noexcept
Kind of the entities of a collision layer, for snapshots and events.
constexpr bool snapshot_due(std::uint64_t tick) noexcept
Tells whether a snapshot is due after a tick.
Definition world_snapshot.hpp:24
Snapshots of the world sent to the clients (RFC section 4.3).
The state of the world at one tick.
Definition snapshot.hpp:94
Gameplay values of R-Type: play area, speeds, sizes, health, lives and scores.