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)
5050 ecsact_registry_id registry
5151);
5252
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+
5363/**
5464 * Destroy all entities
5565 */
@@ -296,6 +306,7 @@ ECSACT_CORE_API_FN(ecsact_stream_error, ecsact_stream)
296306# define FOR_EACH_ECSACT_CORE_API_FN (fn , ...) \
297307 fn(ecsact_create_registry, __VA_ARGS__); \
298308 fn(ecsact_destroy_registry, __VA_ARGS__); \
309+ fn(ecsact_clone_registry, __VA_ARGS__); \
299310 fn(ecsact_clear_registry, __VA_ARGS__); \
300311 fn(ecsact_create_entity, __VA_ARGS__); \
301312 fn(ecsact_ensure_entity, __VA_ARGS__); \
Original file line number Diff line number Diff line change @@ -635,6 +635,13 @@ public:
635635 return ecsact_create_entity (_id);
636636 }
637637
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+
638645 template <typename Component, typename ... AssocFields>
639646 requires (!std::is_empty_v<Component>)
640647 ECSACT_ALWAYS_INLINE auto get_component ( //
You can’t perform that action at this time.
0 commit comments