prefab_builder
| Type | Class |
| Namespace | conjure::scene |
| Include File Path | engine/include/conjure/scene/prefab.h |
| Source File Path | engine/src/scene/prefab.cpp |
| API ↗ | Scenes, hierarchy and prefabs, Scene files, prefabs and snapshots |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | explicit prefab_builder(
const ecs::component_registry ®istry); |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~prefab_builder(); | Destroys the component images. |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mIds | scene_component_ids | {} | |
| private | mNodes | std::vector<node> | {} | |
| private | mRegistry | const ecs:: | nullptr | |
| public | NO_PARENT | static constexpr u32 | 0xFFFFFFFFu |
Functions
Public
add_component_json
add_component_json[[nodiscard]] core::result<void> add_component_json(
u32 nodeIndex,
core::string_id component,
const core::json::value &value);Adds a component by registered name from JSON. UNKNOWN_COMPONENT for an unknown name, SERIALIZATION_FAILED for malformed JSON, BUILDER_INVALID for an unknown node or a component the builder writes itself (parent, children, guid, prefab_link, name, local_transform, depth tags, companions, inactive): name and transform come from add_node.
add_component_raw
add_component_raw[[nodiscard]] core::result<void> add_component_raw(
u32 nodeIndex,
ecs::component_id component,
std::span<const std::byte> bytes);Adds a component from an object image of exactly the registered size.
add_node
add_node[[nodiscard]] u32 add_node(
u32 parentIndex,
std::string_view name,
const local_transform &transform = {});Adds a node and returns its index. parentIndex is NO_PARENT for the root; an unknown parent makes build() fail with BUILDER_INVALID.
add_tag
add_tag[[nodiscard]] core::result<void> add_tag(
u32 nodeIndex,
ecs::component_id component);Adds a tag component. BUILDER_INVALID when the id is not a tag.
build
build[[nodiscard]] core::result<prefab_document> build(
std::string_view name) const;Produces the document: guids generated, parent and siblingIndex from insertion order, prefab_link on every entry, entries in hierarchy order. BUILDER_INVALID unless exactly one root exists and every parent index names an earlier-or-later node without a cycle.
Private
destroy_images
destroy_imagesvoid destroy_images() noexcept;is_reserved
is_reserved[[nodiscard]] bool is_reserved(
ecs::component_id id) const noexcept;