The positions of the enemies over the last tuning::position_history_ticks ticks.
More...
#include <rtype/position_history.hpp>
|
| void | record (std::uint64_t tick, aegis2d::ecs::Registry ®istry) |
| | Keeps the positions of the enemies after a tick.
|
| |
| std::optional< aegis2d::Vec2 > | position (aegis2d::ecs::Entity entity, std::uint64_t tick) const |
| | Where an enemy was at a past tick.
|
| |
| std::vector< std::pair< aegis2d::ecs::Entity, aegis2d::Vec2 > > | enemies (std::uint64_t tick) const |
| | The enemies at a past tick.
|
| |
| std::optional< std::uint64_t > | oldest () const noexcept |
| | Oldest tick kept.
|
| |
| std::optional< std::uint64_t > | newest () const noexcept |
| | Newest tick kept.
|
| |
| std::size_t | size () const noexcept |
| | Number of ticks kept.
|
| |
| void | clear () noexcept |
| | Forgets every tick.
|
| |
The positions of the enemies over the last tuning::position_history_ticks ticks.
record() keeps, after a tick, the center of every entity of the enemy collision layer; position() gives back where one was at a past tick. A player's missiles can then be checked against the enemies as that player saw them, its round trip time and interpolation delay ago (lag compensation). Older ticks are forgotten. Not thread-safe: use it from the simulation thread.
◆ clear()
| void rtype::PositionHistory::clear |
( |
| ) |
|
|
noexcept |
◆ enemies()
| std::vector< std::pair< aegis2d::ecs::Entity, aegis2d::Vec2 > > rtype::PositionHistory::enemies |
( |
std::uint64_t |
tick | ) |
const |
The enemies at a past tick.
- Parameters
-
- Returns
- Their handles and centers, by increasing
Entity::id(); empty if the tick is not kept.
◆ newest()
| std::optional< std::uint64_t > rtype::PositionHistory::newest |
( |
| ) |
const |
|
noexcept |
Newest tick kept.
- Returns
- It, or nothing before the first record().
◆ oldest()
| std::optional< std::uint64_t > rtype::PositionHistory::oldest |
( |
| ) |
const |
|
noexcept |
Oldest tick kept.
- Returns
- It, or nothing before the first record().
◆ position()
| std::optional< aegis2d::Vec2 > rtype::PositionHistory::position |
( |
aegis2d::ecs::Entity |
entity, |
|
|
std::uint64_t |
tick |
|
) |
| const |
Where an enemy was at a past tick.
- Parameters
-
| entity | The enemy, as its handle was then (a reused slot is another entity). |
| tick | Tick to read, one of the last capacity recorded. |
- Returns
- Its center, or nothing if the tick is not kept or the enemy was not there.
◆ record()
| void rtype::PositionHistory::record |
( |
std::uint64_t |
tick, |
|
|
aegis2d::ecs::Registry & |
registry |
|
) |
| |
Keeps the positions of the enemies after a tick.
A tick not newer than the last one recorded starts the history again (a new game); beyond capacity, the oldest tick is forgotten.
- Parameters
-
| tick | Number of the tick, ServerGame::ticks() once it ran. |
| registry | World of the game: every entity with an ecs::Collider of layer::enemy and an ecs::Transform. Only read, but Registry::view() needs it mutable. |
◆ size()
| std::size_t rtype::PositionHistory::size |
( |
| ) |
const |
|
noexcept |
Number of ticks kept.
- Returns
- 0 to capacity.
◆ capacity
Ticks kept: 500 ms at 60 ticks per second.
The documentation for this class was generated from the following file: