NcEngine
SceneSerialization.h
Go to the documentation of this file.
1
5#pragma once
6
8#include "ncengine/ecs/Ecs.h"
10
11#include <iosfwd>
12
13namespace nc
14{
16constexpr auto g_sceneFragmentMagicNumber = 0x3ff0e17b;
17
20
23{
24 uint32_t magicNumber = g_sceneFragmentMagicNumber;
25 uint32_t version = g_currentSceneFragmentVersion;
26};
27
29using EntityToFragmentIdMap = std::unordered_map<Entity, uint32_t, Entity::Hash>;
30
32using FragmentIdToEntityMap = std::unordered_map<uint32_t, Entity>;
33
36{
37 EntityToFragmentIdMap entityMap;
38 ecs::Ecs ecs;
39};
40
43{
44 FragmentIdToEntityMap entityMap;
45 ecs::Ecs ecs;
46};
47
49void SaveSceneFragment(std::ostream& stream,
50 ecs::Ecs ecs,
51 const asset::AssetMap& assets,
52 std::move_only_function<bool(Entity)> entityFilter = nullptr);
53
55void LoadSceneFragment(std::istream& stream,
56 ecs::Ecs ecs,
57 ModuleProvider modules);
58} // namespace nc
std::unordered_map< asset::AssetType, std::vector< std::string > > AssetMap
A map of AssetType to a list of asset paths of that type.
Definition: NcAsset.h:31
constexpr auto g_sceneFragmentMagicNumber
Initial value in a binary scene fragment blob.
Definition: SceneSerialization.h:16
void SaveSceneFragment(std::ostream &stream, ecs::Ecs ecs, const asset::AssetMap &assets, std::move_only_function< bool(Entity)> entityFilter=nullptr)
Save current game state to a binary stream.
std::unordered_map< uint32_t, Entity > FragmentIdToEntityMap
A map of fragment ids to entities.
Definition: SceneSerialization.h:32
void LoadSceneFragment(std::istream &stream, ecs::Ecs ecs, ModuleProvider modules)
Load game state from a binary stream.
std::unordered_map< Entity, uint32_t, Entity::Hash > EntityToFragmentIdMap
A map of entities to their fragment ids.
Definition: SceneSerialization.h:29
constexpr auto g_currentSceneFragmentVersion
Version number serialized with a scene fragment.
Definition: SceneSerialization.h:19
Identifies an object in the registry.
Definition: Entity.h:18
Provides access to registered Modules.
Definition: ModuleProvider.h:15
Interface for higher-level entity and component operations with optional type access restriction.
Definition: Ecs.h:18
Context object passed to deserialization functions.
Definition: SceneSerialization.h:43
Header for a binary scene fragment blob.
Definition: SceneSerialization.h:23
Context object passed to serialization functions.
Definition: SceneSerialization.h:36