|
R-Type
Networked shoot'em up built on Aegis2D
|
Finds what changed in the game at each tick, as events. More...
#include </__w/project-rtype/project-rtype/server/include/rtype/event_tracker.hpp>
Public Member Functions | |
| 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. | |
Finds what changed in the game at each tick, as events.
Keeps the replicated entities of the game (those of the snapshots) from one tick to the next. An entity that appeared is a Spawn: a ship, owned by its player, an enemy, or a missile, owned by its shooter's player, which is the shot itself. An entity that disappeared is a Destroy at its last position, whose reason comes from the tick's reports: Killed if its health ran out, Consumed for a missile spent on its hit, Despawned if it left the screen, PlayerLeft for the ship of a player who left. A life lost is a Death where the ship was, before the Destroy of the ship when it was the last life.
An entity created and destroyed within one tick is never seen. When the instance starts a new game, the entities of the old one are forgotten without events. Use it from the simulation thread.
| std::vector< GameEvent > rtype::EventTracker::spawns | ( | GameInstance & | instance | ) |
A Spawn of every entity alive, for a player who joins (RFC section 4.6).
The entities known at the last update(): an entity created since, such as the ship of the player who joins, comes with the next update().
| instance | Game being played. |
|
noexcept |
Entities followed.
| std::vector< GameEvent > rtype::EventTracker::update | ( | GameInstance & | instance | ) |
Events of the last tick: what changed since the previous call.
Call it after each tick, before the next one. Spawns come first, then deaths, then destructions.
| instance | Game that just ticked. |