Unravel Engine C++ Reference
Loading...
Searching...
No Matches
prefab_component.h
Go to the documentation of this file.
1#pragma once
2
3#include "basic_component.h"
4#include "id_component.h"
6#include <unordered_map>
7#include <string>
8#include <set>
9#include <uuid/uuid.h>
10
11namespace unravel
12{
13
19{
20 hpp::uuid entity_uuid; // Entity UUID for stable identification
21 std::string component_path; // Component type + property path (e.g., "transform_component/position/x")
22 std::string pretty_component_path; // Human-readable component path (e.g., "Transform/Position/X")
23
25 prefab_property_override_data(const hpp::uuid& uuid, const std::string& path);
26 prefab_property_override_data(const hpp::uuid& uuid, const std::string& path, const std::string& pretty_path);
27
28 auto operator==(const prefab_property_override_data& other) const -> bool;
29 auto operator<(const prefab_property_override_data& other) const -> bool;
30
31};
32
37struct prefab_component : public component_crtp<prefab_component, owned_component>
38{
39 static constexpr bool in_place_delete = false;
40
45
51 std::set<prefab_property_override_data> property_overrides;
52
53 std::set<hpp::uuid> removed_entities;
54
55 bool changed = false;
56
60 void clear_overrides();
61
67 void add_override(const hpp::uuid& entity_uuid, const std::string& component_path);
68
75 void add_override(const hpp::uuid& entity_uuid, const std::string& component_path, const std::string& pretty_component_path);
76
83 auto has_override(const hpp::uuid& entity_uuid, const std::string& component_path) const -> bool;
84
90 void remove_override(const hpp::uuid& entity_uuid, const std::string& component_path);
91
96 void remove_entity(const hpp::uuid& entity_uuid);
97
98
103 auto get_all_overrides() const -> const std::set<prefab_property_override_data>&;
104
110 auto has_serialization_override(const std::string& serialization_path) const -> bool;
111};
112
121
122
123} // namespace unravel
Hash specialization for batch_key to enable use in std::unordered_map.
Thread-safe handle to an asset.
CRTP (Curiously Recurring Template Pattern) base structure for components.
Component that holds a reference to a prefab asset and tracks property overrides.
void remove_override(const hpp::uuid &entity_uuid, const std::string &component_path)
Remove a property override.
void clear_overrides()
Clear all overrides (for applying all changes to prefab)
auto has_serialization_override(const std::string &serialization_path) const -> bool
Check if a serialization path has an override (for backward compatibility)
auto has_override(const hpp::uuid &entity_uuid, const std::string &component_path) const -> bool
Check if a property is overridden.
std::set< hpp::uuid > removed_entities
std::set< prefab_property_override_data > property_overrides
Storage of property overrides Each override is identified by entity UUID + component path This allows...
void remove_entity(const hpp::uuid &entity_uuid)
Remove an entity from the prefab.
void add_override(const hpp::uuid &entity_uuid, const std::string &component_path)
Add a property override.
asset_handle< prefab > source
Handle to the prefab asset.
static constexpr bool in_place_delete
auto get_all_overrides() const -> const std::set< prefab_property_ override _data > &
Get all overrides.
Component that provides a unique identifier (UUID) for a prefab.
Represents a property override with entity UUID and component/property path.
auto operator==(const prefab_property_override_data &other) const -> bool
auto operator<(const prefab_property_override_data &other) const -> bool