|
R-Type
Networked shoot'em up built on Aegis2D
|
Gameplay events sent to the clients (RFC section 4.4): spawns, destructions, deaths, and the players who join and leave. More...
#include <rtype/snapshot.hpp>#include <cstddef>#include <cstdint>#include <optional>#include <span>#include <string>#include <variant>#include <vector>Go to the source code of this file.
Classes | |
| struct | rtype::SpawnEvent |
| An entity appears, with its kind, position and velocity. More... | |
| struct | rtype::DestroyEvent |
| An entity disappears, at its last position. More... | |
| struct | rtype::DeathEvent |
| A player lost a life where its ship was. More... | |
| struct | rtype::PlayerJoinedEvent |
| A player joined the game. More... | |
| struct | rtype::PlayerLeftEvent |
A player left the game; the Destroy of its ship follows if it had one. More... | |
Namespaces | |
| namespace | rtype |
| R-Type game code, built on the Aegis2D engine. | |
Typedefs | |
| using | rtype::GameEvent = std::variant< SpawnEvent, DestroyEvent, DeathEvent, PlayerJoinedEvent, PlayerLeftEvent > |
| One of the gameplay events the server sends. | |
Enumerations | |
| enum class | rtype::EventType : std::uint8_t { rtype::Spawn = 1 , rtype::Destroy = 2 , rtype::Death = 3 , rtype::PlayerJoined = 4 , rtype::PlayerLeft = 5 , rtype::GameOver = 6 } |
| Type of an event, its first byte (RFC section 4.4). More... | |
| enum class | rtype::DestroyReason : std::uint8_t { rtype::Despawned = 0 , rtype::Killed = 1 , rtype::Consumed = 2 , rtype::PlayerLeft = 3 } |
| Why an entity was destroyed, which tells the client what to show. More... | |
| enum class | rtype::LeaveReason : std::uint8_t { rtype::Left = 0 , rtype::TimedOut = 1 , rtype::Kicked = 2 } |
Why a player left the game, in PlayerLeft. More... | |
Functions | |
| std::vector< std::byte > | rtype::write_event (const GameEvent &event) |
| Encodes an event as the bytes of RFC section 4.4: type, tick, then its fields. | |
| std::vector< std::vector< std::byte > > | rtype::write_events (std::span< const GameEvent > events) |
| Encodes events with write_event(), for ServerNetwork::send_events(). | |
| std::optional< GameEvent > | rtype::read_event (std::span< const std::byte > bytes) |
| Decodes the bytes of one event, as a client does (RFC section 6.4). | |
Variables | |
| constexpr std::uint8_t | rtype::no_player = 255 |
Player number meaning "no player", as the owner of an enemy. | |
| constexpr std::size_t | rtype::spawn_event_size = 27 |
Size of a Spawn event, type and tick included. | |
| constexpr std::size_t | rtype::destroy_event_size = 18 |
Size of a Destroy event, type and tick included. | |
| constexpr std::size_t | rtype::death_event_size = 15 |
Size of a Death event, type and tick included. | |
| constexpr std::size_t | rtype::player_left_event_size = 7 |
Size of a PlayerLeft event, type and tick included. | |
Gameplay events sent to the clients (RFC section 4.4): spawns, destructions, deaths, and the players who join and leave.