60template<
typename Registry>
61void remove_all_components(entt::basic_handle<Registry>
handle)
63 auto& registry = *
handle.registry();
66 for(
auto [
id, storage] : registry.storage())
72auto get_scene_registry_impl() -> std::vector<scene*>&
74 static std::vector<scene*> scenes;
78void register_scene(scene* scn)
80 auto& scenes = get_scene_registry_impl();
81 scenes.emplace_back(scn);
84void unregister_scene(scene* scn)
86 auto& scenes = get_scene_registry_impl();
87 scenes.erase(std::remove(scenes.begin(), scenes.end(), scn), scenes.end());
91template<
typename ...Ts>
92void destroy_dependent_components(entt::registry& r, entt::entity e)
97template<
typename ...Ts>
98void destroy_dependent_components_recursive(entt::registry& r, entt::entity e)
104 destroy_dependent_components<Ts...>(
r,
e);
107 auto transform =
r.try_get<transform_component>(
e);
110 for(
auto child :
transform->get_children())
112 destroy_dependent_components_recursive<Ts...>(
r, child);
121 return get_scene_registry_impl();
127 register_scene(
this);
129 registry = std::make_unique<entt::registry>();
169 unregister_scene(
this);
175 auto reserved_entity =
registry->create();
215 entt::handle ent(r, r.create());
222 transform.set_parent(parent,
false);
230 return create_entity(*registry,
tag, parent);
237 auto* reg = clone_from.registry();
248 auto parent = clone_from_component.
get_parent();
290 auto* reg = clone_from.registry();
291 entt::handle clone_to(*reg, reg->create());
292 clone_entity(clone_to, clone_from, keep_parent);
303 remove_all_components(
handle);
309 entt::handle
handle(*registry, e);
315 entt::const_handle
handle(*registry, e);
327 if (id_comp && id_comp->id == target_uuid)
336 for (
auto child : transform->get_children())
338 auto found = find_entity_by_prefab_uuid(child, target_uuid);
Class that contains core data for meshes.
static void on_destroy_component(entt::registry &r, entt::entity e)
static void on_create_component(entt::registry &r, entt::entity e)
Component that wraps particle system emitter functionality.
Component that handles physics properties and behaviors.
Class that contains core data for audio listeners. There can only be one instance of it per scene.
bgfx::Transform transform
void clone_scene_from_stream(const scene &src_scene, scene &dst_scene)
auto load_from_prefab_out(const asset_handle< prefab > &pfb, entt::registry ®istry, entt::handle &obj) -> bool
auto load_from_prefab(const asset_handle< prefab > &pfb, entt::registry ®istry) -> entt::handle
void clone_entity_from_stream(entt::const_handle src_obj, entt::handle &dst_obj)
Represents a handle to an asset, providing access and management functions.
Component that provides a layer mask for an entity.
Component that holds a reference to a prefab asset and tracks property overrides.
Component that provides a unique identifier (UUID) for a prefab.
Root component structure for the ACE framework, serves as the base component.
Represents a scene in the ACE framework, managing entities and their relationships.
void clear_entity(entt::handle &handle)
asset_handle< scene_prefab > source
The source prefab asset handle for the scene.
auto load_from(const asset_handle< scene_prefab > &pfb) -> bool
Loads a scene from a prefab asset.
auto instantiate_out(const asset_handle< prefab > &pfb, entt::handle &e) -> bool
Instantiates a prefab in the scene.
static void clone_scene(const scene &src_scene, scene &dst_scene)
Clones the entities from one scene to another.
auto instantiate(const asset_handle< prefab > &pfb) -> entt::handle
~scene()
Destroys the scene and cleans up resources.
static auto get_all_scenes() -> const std::vector< scene * > &
auto create_entity(const std::string &tag={}, entt::handle parent={}) -> entt::handle
Creates an entity in the scene with an optional tag and parent.
auto clone_entity(entt::handle clone_from, bool keep_parent=true) -> entt::handle
Clones an existing entity in the scene.
void unload()
Unloads the scene, removing all entities.
std::unique_ptr< entt::registry > registry
The registry that manages all entities in the scene.
scene(const std::string &tag_name)
Constructs a new scene.
auto create_handle(entt::entity e) -> entt::handle
Creates an entity in the scene.
static auto find_entity_by_prefab_uuid(entt::handle root_entity, const hpp::uuid &target_uuid) -> entt::handle
Finds an entity by UUID in the scene.
Component that provides a tag (name or label) for an entity.
Component that holds a reference to a UI document for RmlUi rendering.