Unravel Engine C++ Reference
Loading...
Searching...
No Matches
scene.h
Go to the documentation of this file.
1#pragma once
2#include <engine/engine_export.h>
3
4#include "prefab.h"
5#include <base/basetypes.hpp>
6#include <context/context.hpp>
8#include <entt/entt.hpp>
9
10using namespace entt::literals;
11
12namespace unravel
13{
14
15#define ENTT_TAG(name) entt::tag<name##_hs>
20struct scene
21{
25 scene(const std::string& tag_name);
26
30 ~scene();
31
32 static auto get_all_scenes() -> const std::vector<scene*>&;
38 auto load_from(const asset_handle<scene_prefab>& pfb) -> bool;
39
43 void unload();
44
50 auto instantiate_out(const asset_handle<prefab>& pfb, entt::handle& e) -> bool;
51 auto instantiate(const asset_handle<prefab>& pfb) -> entt::handle;
52 auto instantiate(const asset_handle<prefab>& pfb, entt::handle parent) -> entt::handle;
53
54 void clear_entity(entt::handle& handle);
60 auto create_handle(entt::entity e) -> entt::handle;
61
67 auto create_handle(entt::entity e) const -> entt::const_handle;
68
75 auto create_entity(const std::string& tag = {}, entt::handle parent = {}) -> entt::handle;
76
83 auto clone_entity(entt::handle clone_from, bool keep_parent = true) -> entt::handle;
84 void clone_entity(entt::handle& clone_to, entt::handle clone_from, bool keep_parent = true);
85
93 static auto create_entity(entt::registry& r, const std::string& name = {}, entt::handle parent = {}) -> entt::handle;
94
100 static void clone_scene(const scene& src_scene, scene& dst_scene);
101
107 static auto find_entity_by_prefab_uuid(entt::handle root_entity, const hpp::uuid& target_uuid) -> entt::handle;
108
113
117 std::unique_ptr<entt::registry> registry{};
118
119
120 std::string tag{};
121};
122
123#define TAG_COMPONENT(name) entt::tag<name##_hs>
124
125} // namespace unravel
std::string name
Definition hub.cpp:27
Represents a handle to an asset, providing access and management functions.
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:21
void clear_entity(entt::handle &handle)
Definition scene.cpp:298
asset_handle< scene_prefab > source
The source prefab asset handle for the scene.
Definition scene.h:112
auto load_from(const asset_handle< scene_prefab > &pfb) -> bool
Loads a scene from a prefab asset.
Definition scene.cpp:176
auto instantiate_out(const asset_handle< prefab > &pfb, entt::handle &e) -> bool
Instantiates a prefab in the scene.
Definition scene.cpp:186
static void clone_scene(const scene &src_scene, scene &dst_scene)
Clones the entities from one scene to another.
Definition scene.cpp:293
auto instantiate(const asset_handle< prefab > &pfb) -> entt::handle
Definition scene.cpp:192
~scene()
Destroys the scene and cleans up resources.
Definition scene.cpp:163
static auto get_all_scenes() -> const std::vector< scene * > &
Definition scene.cpp:119
auto create_entity(const std::string &tag={}, entt::handle parent={}) -> entt::handle
Creates an entity in the scene with an optional tag and parent.
Definition scene.cpp:225
auto clone_entity(entt::handle clone_from, bool keep_parent=true) -> entt::handle
Clones an existing entity in the scene.
Definition scene.cpp:283
std::string tag
Definition scene.h:120
void unload()
Unloads the scene, removing all entities.
Definition scene.cpp:169
std::unique_ptr< entt::registry > registry
The registry that manages all entities in the scene.
Definition scene.h:117
scene(const std::string &tag_name)
Constructs a new scene.
Definition scene.cpp:124
auto create_handle(entt::entity e) -> entt::handle
Creates an entity in the scene.
Definition scene.cpp:304
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.
Definition scene.cpp:316
gfx::uniform_handle handle
Definition uniform.cpp:9