|
R-Type
Distributed multiplayer game engine in C++
|
Serializes and deserializes game state for network transmission. More...
#include <GameStateSerializer.hpp>

Static Public Member Functions | |
| static GameStateSnapshot | createFullSnapshot (ecs::wrapper::ECSWorld &world, uint32_t serverTick) |
| Create a full game state snapshot. | |
| static GameStateSnapshot | createDeltaUpdate (ecs::wrapper::ECSWorld &world, uint32_t serverTick, const GameStateSnapshot &lastSnapshot) |
| Create a delta update (changed entities only) | |
| static EntitySnapshot | serializeEntity (ecs::wrapper::ECSWorld &world, uint32_t entityId) |
| Serialize entity to network format. | |
Serializes and deserializes game state for network transmission.
Responsibilities:
Network Efficiency:
Definition at line 61 of file GameStateSerializer.hpp.
|
static |
Create a delta update (changed entities only)
| world | ECS world wrapper |
| serverTick | Current game tick |
| lastSnapshot | Previous snapshot for comparison |
Definition at line 45 of file GameStateSerializer.cpp.
References createFullSnapshot().

|
static |
Create a full game state snapshot.
| world | ECS world wrapper |
| serverTick | Current game tick |
Definition at line 22 of file GameStateSerializer.cpp.
References server::GameStateSnapshot::activePlayerCount, server::GameStateSnapshot::entities, ecs::wrapper::ECSWorld::query(), serializeEntity(), and server::GameStateSnapshot::serverTick.
Referenced by createDeltaUpdate().

|
static |
Serialize entity to network format.
| world | ECS world wrapper |
| entityId | Entity address |
Definition at line 57 of file GameStateSerializer.cpp.
References server::EntitySnapshot::currentHealth, server::EntitySnapshot::entityId, ecs::wrapper::Entity::get(), ecs::Health::getCurrentHealth(), ecs::Velocity::getDirection(), ecs::wrapper::ECSWorld::getEntity(), ecs::Health::getMaxHealth(), ecs::Player::getPlayerId(), ecs::Transform::getPosition(), ecs::Velocity::getSpeed(), ecs::wrapper::Entity::has(), server::EntitySnapshot::isAlive, LOG_ERROR, server::EntitySnapshot::maxHealth, server::EntitySnapshot::playerId, server::EntitySnapshot::posX, server::EntitySnapshot::posY, server::EntitySnapshot::velX, server::EntitySnapshot::velY, ecs::Transform::Vector2::x, and ecs::Transform::Vector2::y.
Referenced by createFullSnapshot().
