R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
event_tracker.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <aegis2d/ecs/entity.hpp>
5
6#include <rtype/events.hpp>
7#include <rtype/snapshot.hpp>
8
9#include <cstddef>
10#include <cstdint>
11#include <unordered_map>
12#include <vector>
13
14namespace rtype {
15
16class GameInstance;
17
32public:
38 [[nodiscard]] std::vector<GameEvent> update(GameInstance& instance);
39
45 [[nodiscard]] std::vector<GameEvent> spawns(GameInstance& instance);
46
49 [[nodiscard]] std::size_t tracked() const noexcept;
50
51private:
52 struct Tracked {
53 std::uint32_t id = 0;
55 float x = 0.0F;
56 float y = 0.0F;
57 std::uint8_t owner = no_player;
58 };
59
60 void follow(GameInstance& instance);
61
62 std::unordered_map<aegis2d::ecs::Entity, Tracked> entities_;
63 std::uint64_t game_ = 0;
64};
65
66} // namespace rtype
Finds what changed in the game at each tick, as events.
Definition event_tracker.hpp:31
std::vector< GameEvent > update(GameInstance &instance)
Events of the last tick: what changed since the previous call.
std::vector< GameEvent > spawns(GameInstance &instance)
A Spawn of every entity alive, for a player who joins (RFC section 4.6).
std::size_t tracked() const noexcept
Entities followed.
The one game of the server, with up to tuning::max_players players.
Definition game_instance.hpp:37
Gameplay events sent to the clients (RFC section 4.4): spawns, destructions, deaths,...
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
EntityKind
Kind of an entity in snapshots and events (RFC section 4.1).
Definition snapshot.hpp:19
@ BydosSlave
A Bydos slave.
constexpr std::uint8_t no_player
Player number meaning "no player", as the owner of an enemy.
Definition events.hpp:59
Snapshots of the world sent to the clients (RFC section 4.3).