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"
5#include <unordered_map>
6#include <string>
7#include <set>
8#include <uuid/uuid.h>
9
10namespace unravel
11{
12
18{
19 hpp::uuid entity_uuid; // Entity UUID for stable identification
20 std::string component_path; // Component type + property path (e.g., "transform_component/position/x")
21 std::string pretty_component_path; // Human-readable component path (e.g., "Transform/Position/X")
22
24 prefab_property_override_data(const hpp::uuid& uuid, const std::string& path);
25 prefab_property_override_data(const hpp::uuid& uuid, const std::string& path, const std::string& pretty_path);
26
27 auto operator==(const prefab_property_override_data& other) const -> bool;
28 auto operator<(const prefab_property_override_data& other) const -> bool;
29
30};
31
36struct prefab_component : public component_crtp<prefab_component, owned_component>
37{
38 static constexpr bool in_place_delete = false;
39
44
50 std::set<prefab_property_override_data> property_overrides;
51
52 std::set<hpp::uuid> removed_entities;
53
54 bool changed = false;
55
59 void clear_overrides();
60
66 void add_override(const hpp::uuid& entity_uuid, const std::string& component_path);
67
74 void add_override(const hpp::uuid& entity_uuid, const std::string& component_path, const std::string& pretty_component_path);
75
82 auto has_override(const hpp::uuid& entity_uuid, const std::string& component_path) const -> bool;
83
89 void remove_override(const hpp::uuid& entity_uuid, const std::string& component_path);
90
95 void remove_entity(const hpp::uuid& entity_uuid);
96
97
102 auto get_all_overrides() const -> const std::set<prefab_property_override_data>&;
103
109 auto has_serialization_override(const std::string& serialization_path) const -> bool;
110};
111
117 {
119 {
120 id = generate_uuid();
121 }
122
124 {
125 if(id.is_nil())
126 {
127 id = generate_uuid();
128 }
129 }
133 hpp::uuid id;
134 };
135
136
137} // namespace unravel
auto generate_uuid() -> hpp::uuid
Definition uuid.cpp:25
Represents a handle to an asset, providing access and management functions.
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.
hpp::uuid id
The unique identifier for the entity.
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