Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
snapshot.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
24namespace snapshot {
25
26// Serialization helpers
36void write_string(std::vector<uint8_t>& out, const std::string& str);
37
49bool read_string(const std::vector<uint8_t>& data, size_t& offset,
50 std::string& out);
51
62void write_bytes(std::vector<uint8_t>& out, const void* data, size_t size);
63
76bool read_bytes(const std::vector<uint8_t>& data, size_t& offset, void* out,
77 size_t size);
78
87 DefaultMessageTypes messageType);
88
102 DefaultMessageTypes messageType);
103
119void apply_full_snapshot(Scene& scene, const Message& msg);
120
127void apply_delta_snapshot(Scene& scene, const Message& msg);
128
129} // namespace snapshot
Represents a scene within the engine. A scene contains multiple GameObjects and manages their lifecyc...
Definition scene.h:19
Snapshot serialization/deserialization utilities for networked state synchronization.
bool read_string(const std::vector< uint8_t > &data, size_t &offset, std::string &out)
Reads a length-prefixed string from a binary buffer.
void write_bytes(std::vector< uint8_t > &out, const void *data, size_t size)
Writes raw bytes to a binary buffer.
void write_string(std::vector< uint8_t > &out, const std::string &str)
Writes a length-prefixed string to a binary buffer.
void apply_full_snapshot(Scene &scene, const Message &msg)
Applies a full snapshot to a scene, creating/updating GameObjects as needed.
Message create_delta_snapshot(const Scene &scene, DefaultMessageTypes messageType)
Builds a delta snapshot message containing only changed (dirty) networked objects.
void apply_delta_snapshot(Scene &scene, const Message &msg)
Applies a delta snapshot to a scene, updating only the listed objects.
bool read_bytes(const std::vector< uint8_t > &data, size_t &offset, void *out, size_t size)
Reads raw bytes from a binary buffer.
Message create_full_snapshot(const Scene &scene, DefaultMessageTypes messageType)
Builds a full snapshot message containing all networked GameObjects in a scene.
DefaultMessageTypes
Built-in protocol message types used for core connection events.
Definition network_message.h:14
Represents a complete network message including type and payload.
Definition network_message.h:105