Unravel Engine C++ Reference
Loading...
Searching...
No Matches
id_component.cpp
Go to the documentation of this file.
1#include "id_component.hpp"
2#include "hpp/uuid.hpp"
6
7namespace unravel
8{
10{
11 entt::meta_factory<id_component>{}
12 .type("id_component"_hs)
14 entt::attribute{"name", "id_component"},
15 entt::attribute{"category", "BASIC"},
16 entt::attribute{"pretty_name", "Id"},
17 })
18 .func<&component_meta<id_component>::exists>("component_exists"_hs)
19 .func<&component_meta<id_component>::add>("component_add"_hs)
20 .func<&component_meta<id_component>::remove>("component_remove"_hs)
21 .func<&component_meta<id_component>::save>("component_save"_hs)
22 .func<&component_meta<id_component>::load>("component_load"_hs)
23 .data<nullptr, &id_component::id>("id"_hs)
24 .custom<entt::attributes>(entt::attributes{
25 entt::attribute{"name", "id"},
26 entt::attribute{"pretty_name", "Id"},
27 entt::attribute{"tooltip", "This is the unique id of the entity."},
28 });
29}
30
31
33{
34 try_save(ar, ser20::make_nvp("id", hpp::to_string(obj.id)));
35}
38
40{
41 std::string suuid;
42
43 if(try_load(ar, ser20::make_nvp("id", suuid)))
44 {
45 auto id = hpp::uuid::from_string(suuid);
46 obj.id = id.value_or(hpp::uuid{});
47 }
48}
49
52
53} // 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)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
Component that provides a unique identifier (UUID) for an entity.
hpp::uuid id
The unique identifier for the entity.