File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,16 @@ ECSACT_CORE_API_FN(void, ecsact_destroy_registry)
50
50
ecsact_registry_id registry
51
51
);
52
52
53
+ /**
54
+ * Creates a new registry from an existing one with all its entities and
55
+ * components intact.
56
+ */
57
+ ECSACT_CORE_API_FN (ecsact_registry_id , ecsact_clone_registry )
58
+ ( //
59
+ ecsact_registry_id registry ,
60
+ const char * registry_name
61
+ );
62
+
53
63
/**
54
64
* Destroy all entities
55
65
*/
@@ -296,6 +306,7 @@ ECSACT_CORE_API_FN(ecsact_stream_error, ecsact_stream)
296
306
# define FOR_EACH_ECSACT_CORE_API_FN (fn , ...) \
297
307
fn(ecsact_create_registry, __VA_ARGS__); \
298
308
fn(ecsact_destroy_registry, __VA_ARGS__); \
309
+ fn(ecsact_clone_registry, __VA_ARGS__); \
299
310
fn(ecsact_clear_registry, __VA_ARGS__); \
300
311
fn(ecsact_create_entity, __VA_ARGS__); \
301
312
fn(ecsact_ensure_entity, __VA_ARGS__); \
Original file line number Diff line number Diff line change @@ -635,6 +635,13 @@ public:
635
635
return ecsact_create_entity (_id);
636
636
}
637
637
638
+ ECSACT_ALWAYS_INLINE auto clone (const char * name) const -> registry {
639
+ auto cloned_registry_id = ecsact_clone_registry (_id, name);
640
+ auto cloned_registry = registry{cloned_registry_id};
641
+ cloned_registry._owned = true ;
642
+ return cloned_registry;
643
+ }
644
+
638
645
template <typename Component, typename ... AssocFields>
639
646
requires (!std::is_empty_v<Component>)
640
647
ECSACT_ALWAYS_INLINE auto get_component ( //
You can’t perform that action at this time.
0 commit comments