Unravel Engine C++ Reference
Loading...
Searching...
No Matches
prefab_component.cpp
Go to the documentation of this file.
3
7
8namespace unravel
9{
10
12{
13 entt::meta_factory<prefab_property_override_data>{}
14 .type("prefab_property_override_data"_hs)
16 entt::attribute{"name", "prefab_property_override_data"},
17 entt::attribute{"pretty_name", "Prefab Property Override Data"},
18 })
19 .data<&prefab_property_override_data::entity_uuid>("entity_uuid"_hs)
21 entt::attribute{"name", "entity_uuid"},
22 entt::attribute{"pretty_name", "Entity UUID"},
23 })
24 .data<&prefab_property_override_data::component_path>("component_path"_hs)
26 entt::attribute{"name", "component_path"},
27 entt::attribute{"pretty_name", "Component Path"},
28 })
29 .data<&prefab_property_override_data::pretty_component_path>("pretty_component_path"_hs)
31 entt::attribute{"name", "pretty_component_path"},
32 entt::attribute{"pretty_name", "Pretty Component Path"},
33 });
34}
35
37{
38 try_save(ar, ser20::make_nvp("entity_uuid", obj.entity_uuid));
39 try_save(ar, ser20::make_nvp("component_path", obj.component_path));
40 try_save(ar, ser20::make_nvp("pretty_component_path", obj.pretty_component_path));
41}
43{
44 try_load(ar, ser20::make_nvp("entity_uuid", obj.entity_uuid));
45 try_load(ar, ser20::make_nvp("component_path", obj.component_path));
46 try_load(ar, ser20::make_nvp("pretty_component_path", obj.pretty_component_path));
47}
48
50{
51 entt::meta_factory<prefab_component>{}
52 .type("prefab_component"_hs)
54 entt::attribute{"name", "prefab_component"},
55 entt::attribute{"category", "BASIC"},
56 entt::attribute{"pretty_name", "Prefab"},
57 })
58 .func<&component_meta<prefab_component>::exists>("component_exists"_hs)
59 .func<&component_meta<prefab_component>::add>("component_add"_hs)
60 .func<&component_meta<prefab_component>::remove>("component_remove"_hs)
61 .func<&component_meta<prefab_component>::save>("component_save"_hs)
62 .func<&component_meta<prefab_component>::load>("component_load"_hs)
63 .data<&prefab_component::source>("source"_hs)
64 .custom<entt::attributes>(entt::attributes{
65 entt::attribute{"name", "source"},
66 entt::attribute{"pretty_name", "Source"},
67 })
68 .data<&prefab_component::property_overrides>("property_overrides"_hs)
70 entt::attribute{"name", "property_overrides"},
71 entt::attribute{"pretty_name", "Property Overrides"},
72 })
73 .data<&prefab_component::removed_entities>("removed_entities"_hs)
75 entt::attribute{"name", "removed_entities"},
76 entt::attribute{"pretty_name", "Removed Entities"},
77 });
78}
79
81{
82 try_save(ar, ser20::make_nvp("source", obj.source));
83 try_save(ar, ser20::make_nvp("property_overrides", obj.property_overrides));
84 try_save(ar, ser20::make_nvp("removed_entities", obj.removed_entities));
85}
88
90{
91 try_load(ar, ser20::make_nvp("source", obj.source));
92 try_load(ar, ser20::make_nvp("property_overrides", obj.property_overrides));
93 try_load(ar, ser20::make_nvp("removed_entities", obj.removed_entities));
94}
97
99{
100 entt::meta_factory<prefab_id_component>{}
101 .type("prefab_id_component"_hs)
103 entt::attribute{"name", "prefab_id_component"},
104 entt::attribute{"category", "BASIC"},
105 entt::attribute{"pretty_name", "Prefab Id"},
106 })
107 .func<&component_meta<prefab_id_component>::exists>("component_exists"_hs)
108 .func<&component_meta<prefab_id_component>::add>("component_add"_hs)
109 .func<&component_meta<prefab_id_component>::remove>("component_remove"_hs)
110 .func<&component_meta<prefab_id_component>::save>("component_save"_hs)
111 .func<&component_meta<prefab_id_component>::load>("component_load"_hs)
112 .data<nullptr, &prefab_id_component::id>("id"_hs)
113 .custom<entt::attributes>(entt::attributes{
114 entt::attribute{"name", "id"},
115 entt::attribute{"pretty_name", "Id"},
116 entt::attribute{"tooltip", "This is the unique id of the entity in the prefab."},
117 });
118}
119
120
122{
123 try_save(ar, ser20::make_nvp("id", hpp::to_string(obj.id)));
124}
127
129{
130 std::string suuid;
131
132 if(try_load(ar, ser20::make_nvp("id", suuid)))
133 {
134 auto id = hpp::uuid::from_string(suuid);
135 obj.id = id.value_or(hpp::uuid{});
136 }
137}
138
141
142} // namespace unravel
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
#define REFLECT(cls)
Definition reflection.h:133
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
#define LOAD_INLINE(cls)
#define SAVE_INLINE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
Component that holds a reference to a prefab asset and tracks property overrides.
asset_handle< prefab > source
Handle to the prefab asset.
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.