2#include <engine/engine_export.h>
10#include <entt/entt.hpp>
11#include <entt/signal/sigh.hpp>
14using namespace entt::literals;
22 using sink_t =
typename entt::sink<entt::sigh<void(entt::registry&, entt::entity)>>;
23 entt::sigh<void(entt::registry&, entt::entity)>
sig;
29 auto& ctx = reg.ctx();
40 return reg.on_construct<T>();
44inline auto on_update(entt::registry& reg) ->
decltype(
auto)
46 return reg.on_update<T>();
50inline auto on_destroy(entt::registry& reg) ->
decltype(
auto)
52 return reg.on_destroy<T>();
60 bus->sig.publish(reg, e);
64#define ENTT_TAG(name) entt::tag<name##_hs>
93 void reload(
bool call_callbacks =
true);
122 auto create_handle(entt::entity e)
const -> entt::const_handle;
130 auto create_entity(
const std::string&
tag = {}, entt::handle parent = {}) -> entt::handle;
138 auto clone_entity(entt::handle clone_from,
bool keep_parent =
true,
bool call_callbacks =
true) -> entt::handle;
139 void clone_entity(entt::handle& clone_to, entt::handle clone_from,
bool keep_parent =
true,
bool call_callbacks =
true);
148 static auto create_entity(entt::registry& r,
const std::string&
name = {}, entt::handle parent = {}) -> entt::handle;
194#define TAG_COMPONENT(name) entt::tag<name##_hs>
199ENGINE_EXPORT
auto find_entity_by_uuid(entt::registry& registry,
const hpp::uuid& target_uuid) -> entt::handle;
217 auto operator==(const
uhandle& other) const ->
bool
219 return registry == other.registry &&
uuid == other.uuid;
223 return !(*
this == other);
auto make_uhandle(entt::handle handle) -> uhandle
auto on_destroy(entt::registry ®) -> decltype(auto)
auto on_update(entt::registry ®) -> decltype(auto)
auto on_construct(entt::registry ®) -> decltype(auto)
auto on_load(entt::registry ®) -> typename on_load_bus< T >::sink_t
auto find_entity_by_uuid(entt::registry ®istry, const hpp::uuid &target_uuid) -> entt::handle
Finds an entity by id_component UUID in a registry (no scene wrapper required).
void emit_on_load(entt::registry ®, entt::entity e)
Thread-safe handle to an asset.
auto operator=(const uhandle &other) -> uhandle &=default
entt::registry * registry
auto resolve() const -> entt::handle
uhandle(uhandle &&other)=default
auto operator=(uhandle &&other) -> uhandle &=default
uhandle(entt::registry ®istry, const hpp::uuid &uuid)
uhandle(const uhandle &other)=default
auto operator!=(const uhandle &other) const -> bool
entt::sigh< void(entt::registry &, entt::entity)> sig
typename entt::sink< entt::sigh< void(entt::registry &, entt::entity)> > sink_t
Represents a scene in the ACE framework, managing entities and their relationships.
auto find_entity_by_uuid(const hpp::uuid &target_uuid) const -> entt::handle
Finds an entity by UUID in the scene.
void clear_entity(entt::handle &handle)
auto instantiate_out(const asset_handle< prefab > &pfb, entt::handle &, bool call_callbacks=true) -> bool
Instantiates a prefab in the scene.
asset_handle< scene_prefab > source
The source prefab asset handle for the scene.
~scene()
Destroys the scene and cleans up resources.
auto load_from(const asset_handle< scene_prefab > &pfb, bool call_callbacks=true) -> bool
Loads a scene from a prefab asset.
static auto get_all_scenes() -> const std::vector< scene * > &
auto clone_entity(entt::handle clone_from, bool keep_parent=true, bool call_callbacks=true) -> entt::handle
Clones an existing entity in the scene.
auto instantiate(const asset_handle< prefab > &pfb, bool call_callbacks=true) -> entt::handle
auto create_entity(const std::string &tag={}, entt::handle parent={}) -> entt::handle
Creates an entity in the scene with an optional tag and parent.
static auto get_scene(entt::handle entity) -> scene *
Gets the scene from an entity handle.
void unload()
Unloads the scene, removing all entities.
static void clone_scene(const scene &src_scene, scene &dst_scene, bool call_callbacks=true)
Clones the entities from one scene to another.
std::unique_ptr< entt::registry > registry
The registry that manages all entities in the 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.