Engine → Scene → scene_snapshot.h
scene_snapshot
| Type | Struct |
| Namespace | conjure::scene |
| Include File Path | engine/include/conjure/scene/scene_snapshot.h |
| Source File Path | engine/src/scene/scene_snapshot.cpp |
| API ↗ | Scenes, hierarchy and prefabs, Scene files, prefabs and snapshots |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | explicit scene_snapshot(
const ecs::component_registry ®istry) noexcept; | |
| public | scene_snapshot(
scene_snapshot &&) noexcept = default; |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~scene_snapshot(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| public | archive | ecs::entity_archive | — | |
| public | guidIndex | std:: | {} | |
| public | name | std::string | {} | |
| public | rootEntries | std::vector<u32> | {} | |
| public | rootOwners | std::vector<scene_id> | {} | |
| public | settings | core::json::document | core:: | |
| public | structure | u64 | 0 |
Functions
Public
component_json
component_json[[nodiscard]] core::result<core::json::document> component_json(
const core::uuid &guid,
ecs::component_id id,
const scene &live) const;The component of the entry carrying the guid as JSON, in the form the editor reads the live component of live (component_to_json plus the protocol's entity references), so a component the play session did not change reads equal to its live JSON, with two exceptions. What a serializer writes from outside the component's bytes is not in the copy: a running script's live JSON comes from its instance (its "started" and "created" flags, which the script component's copy drops, and every field of its class), the snapshot's from the component (the fields set before play). And a reflected reference to an entity destroyed since the capture reads as the entry's guid here and as null live. A reflected entity field that names a snapshot entry becomes that entry's guid string (null for a null reference or an entry without a guid); a reference outside the archive (a hand-built snapshot) becomes the guid of that entity in live, or null. A component whose serializer owns its JSON form (no reflection, a remapEntities hook: the script component) is copied, its references remapped through the hook to the entities of live that carry the referenced entries' guids (NULL_ENTITY when none does), written with its serializer and destroyed again; that costs one guid lookup per snapshot entry. A tag is {}. GUID_NOT_FOUND for a guid the snapshot does not hold, UNKNOWN_COMPONENT for an id the registry does not know, COMPONENT_NOT_PRESENT when the entry lacks the component; the serializer's error otherwise.
contains
contains[[nodiscard]] bool contains(
const core::uuid &guid) const noexcept;True when an entry of the snapshot carries the guid: the entity existed when the snapshot was taken. O(log n) through guidIndex.
entry_guid
entry_guid[[nodiscard]] std::optional<core::uuid> entry_guid(
u32 entry) const noexcept;The guid of an archive entry, or nullopt when the entry has none (or is out of range).
find_entry
find_entry[[nodiscard]] std::optional<u32> find_entry(
const core::uuid &guid) const noexcept;The archive index of the entry carrying the guid, or nullopt. O(log n) through guidIndex.
has_component
has_component[[nodiscard]] bool has_component(
const core::uuid &guid,
ecs::component_id id) const noexcept;True when the entry carrying the guid held the component when the snapshot was taken (a tag counts). False for an unknown guid and for TRANSIENT components, which a snapshot never holds.
index_guids
index_guidsvoid index_guids();Rebuilds guidIndex from the archive (one pass plus a sort). Entries without a guid, or with the null guid, are not indexed; when two entries share a guid the first in archive order wins.
subtree_guids
subtree_guids[[nodiscard]] std::vector<core::uuid> subtree_guids(
const core::uuid &guid) const;The guids of the subtree the entry carrying the guid had in the snapshot: the entry first, then its descendants in archive order (entries without a guid left out). Empty for an unknown guid. O(n) over the archive's parent links.
Operator Overloads
Public
operator=
operator=scene_snapshot &operator=(
scene_snapshot &&) noexcept = default;