R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
GameStateSerializer.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** rtype
4** File description:
5** GameStateSerializer.hpp - Game state serialization for network transmission
6*/
7
8#pragma once
9
10#include <cstdint>
11#include <memory>
12#include <vector>
13
14namespace ecs::wrapper {
15 class ECSWorld;
16}
17
18namespace server {
19
25 uint32_t entityId;
26 float posX;
27 float posY;
28 float velX;
29 float velY;
32 uint32_t playerId; // If player entity
33 bool isAlive;
34 };
35
41 uint32_t serverTick;
42 std::vector<EntitySnapshot> entities;
44 };
45
62 public:
69 static GameStateSnapshot createFullSnapshot(ecs::wrapper::ECSWorld &world, uint32_t serverTick);
70
78 static GameStateSnapshot createDeltaUpdate(ecs::wrapper::ECSWorld &world, uint32_t serverTick,
79 const GameStateSnapshot &lastSnapshot);
80
87 static EntitySnapshot serializeEntity(ecs::wrapper::ECSWorld &world, uint32_t entityId);
88 };
89
90} // namespace server
High-level ECS manager providing clean server-side API.
Definition ECSWorld.hpp:122
Serializes and deserializes game state for network transmission.
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.
static GameStateSnapshot createFullSnapshot(ecs::wrapper::ECSWorld &world, uint32_t serverTick)
Create a full game state snapshot.
Serialized entity state for network transmission.
Complete game state at a given tick.
std::vector< EntitySnapshot > entities