vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
codecs.h
1#pragma once
2
3#include <cstddef>
4
5#include <glm/glm.hpp>
6
7#include "ecs/component/core/transform.h"
8#include "ecs/component/physics/character_controller.h"
9#include "ecs/component/physics/ragdoll.h"
10#include "ecs/component/physics/rigidbody.h"
11#include "ecs/component/prefab/net_spawn.h"
12#include "net/wire/bit_stream.h"
13#include "net/wire/schema.h"
14
15namespace Vkm::Engine {
16
22constexpr size_t NET_PREFAB_PATH_MAX = 200;
23
30constexpr size_t NET_SPAWN_MAX_SLOTS = 32;
31
37constexpr size_t NET_SPAWN_MAX_BYTES = 1 + NET_PREFAB_PATH_MAX + 10 * sizeof(float)
38 + (6 + NET_SPAWN_MAX_SLOTS * (32 + 23) + 7) / 8;
39
45constexpr const char* NET_SPAWN_TYPE = "NetSpawn";
46
58glm::vec3 netScale(const glm::vec3& scale);
59
66void netEncode(const Transform& value, BitWriter& out);
67void netDecode(Transform& value, BitReader& in);
68
76void netEncode(const Rigidbody& value, BitWriter& out);
77void netDecode(Rigidbody& value, BitReader& in);
78
86void netEncode(const CharacterController& value, BitWriter& out);
87void netDecode(CharacterController& value, BitReader& in);
88
96void netEncode(const Ragdoll& value, BitWriter& out);
97void netDecode(Ragdoll& value, BitReader& in);
98
111bool isSayable(const NetSpawn& spawn);
112
120void netEncode(const NetSpawn& value, BitWriter& out);
121void netDecode(NetSpawn& value, BitReader& in);
122
131void registerEngineNetTypes(NetSchema& schema = NetSchema::get());
132
133} // namespace Vkm::Engine
Reads back what a BitWriter wrote, in the same order.
Definition bit_stream.h:145
Packs values to the bit into a byte buffer.
Definition bit_stream.h:19
The ordered list of what replicates, agreed by both ends before play.
Definition schema.h:39
static NetSchema & get()
The registry every end consults. Filled by ScriptModule::setupNetwork, read thereafter.
Turns a desired direction into velocity on a Rigidbody, and reports what the body stands on.
Definition character_controller.h:16
What a server built at this root after the scene loaded, so every client can build the same.
Definition net_spawn.h:19
Turns a rig over to physics, and back.
Definition ragdoll.h:49
Dynamics state for a physics body: motion, material response and mass.
Definition rigidbody.h:31
Local position, rotation and scale of an entity.
Definition transform.h:17