Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::scene Struct Reference

Represents a scene in the ACE framework, managing entities and their relationships. More...

#include <scene.h>

Public Member Functions

 scene (const std::string &tag_name)
 Constructs a new scene.
 
 ~scene ()
 Destroys the scene and cleans up resources.
 
auto load_from (const asset_handle< scene_prefab > &pfb) -> bool
 Loads a scene from a prefab asset.
 
void unload ()
 Unloads the scene, removing all entities.
 
auto instantiate_out (const asset_handle< prefab > &pfb, entt::handle &e) -> bool
 Instantiates a prefab in the scene.
 
auto instantiate (const asset_handle< prefab > &pfb) -> entt::handle
 
auto instantiate (const asset_handle< prefab > &pfb, entt::handle parent) -> entt::handle
 
void clear_entity (entt::handle &handle)
 
auto create_handle (entt::entity e) -> entt::handle
 Creates an entity in the scene.
 
auto create_handle (entt::entity e) const -> entt::const_handle
 Creates an entity in the scene (const version).
 
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 clone_entity (entt::handle &clone_to, entt::handle clone_from, bool keep_parent=true)
 

Static Public Member Functions

static auto get_all_scenes () -> const std::vector< scene * > &
 
static auto create_entity (entt::registry &r, const std::string &name={}, entt::handle parent={}) -> entt::handle
 Creates an entity in the specified registry with an optional name and parent.
 
static void clone_scene (const scene &src_scene, scene &dst_scene)
 Clones the entities from one scene to another.
 
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.
 

Public Attributes

asset_handle< scene_prefabsource
 The source prefab asset handle for the scene.
 
std::unique_ptr< entt::registry > registry {}
 The registry that manages all entities in the scene.
 
std::string tag {}
 

Detailed Description

Represents a scene in the ACE framework, managing entities and their relationships.

Definition at line 20 of file scene.h.

Constructor & Destructor Documentation

◆ scene()

unravel::scene::scene ( const std::string & tag_name)

Constructs a new scene.

Definition at line 124 of file scene.cpp.

◆ ~scene()

unravel::scene::~scene ( )

Destroys the scene and cleans up resources.

Definition at line 163 of file scene.cpp.

Member Function Documentation

◆ clear_entity()

void unravel::scene::clear_entity ( entt::handle & handle)

Definition at line 298 of file scene.cpp.

◆ clone_entity() [1/2]

void unravel::scene::clone_entity ( entt::handle & clone_to,
entt::handle clone_from,
bool keep_parent = true )

Definition at line 230 of file scene.cpp.

◆ clone_entity() [2/2]

auto unravel::scene::clone_entity ( entt::handle clone_from,
bool keep_parent = true ) -> entt::handle

Clones an existing entity in the scene.

Parameters
eThe handle to the entity to clone.
keep_parentWhether to keep the parent relationship.
Returns
A handle to the cloned entity.

Definition at line 283 of file scene.cpp.

◆ clone_scene()

void unravel::scene::clone_scene ( const scene & src_scene,
scene & dst_scene )
static

Clones the entities from one scene to another.

Parameters
src_sceneThe source scene.
dst_sceneThe destination scene.

Definition at line 293 of file scene.cpp.

◆ create_entity() [1/2]

auto unravel::scene::create_entity ( const std::string & tag = {},
entt::handle parent = {} ) -> entt::handle

Creates an entity in the scene with an optional tag and parent.

Parameters
tagThe tag for the entity.
parentThe parent entity handle.
Returns
A handle to the created entity.

Definition at line 225 of file scene.cpp.

◆ create_entity() [2/2]

auto unravel::scene::create_entity ( entt::registry & r,
const std::string & name = {},
entt::handle parent = {} ) -> entt::handle
static

Creates an entity in the specified registry with an optional name and parent.

Parameters
rThe registry to create the entity in.
nameThe name for the entity.
parentThe parent entity handle.
Returns
A handle to the created entity.

Definition at line 210 of file scene.cpp.

◆ create_handle() [1/2]

auto unravel::scene::create_handle ( entt::entity e) -> entt::handle

Creates an entity in the scene.

Parameters
eThe entity identifier.
Returns
A handle to the created entity.

Definition at line 304 of file scene.cpp.

◆ create_handle() [2/2]

auto unravel::scene::create_handle ( entt::entity e) const -> entt::const_handle

Creates an entity in the scene (const version).

Parameters
eThe entity identifier.
Returns
A constant handle to the created entity.

Definition at line 310 of file scene.cpp.

◆ find_entity_by_prefab_uuid()

auto unravel::scene::find_entity_by_prefab_uuid ( entt::handle root_entity,
const hpp::uuid & target_uuid ) -> entt::handle
static

Finds an entity by UUID in the scene.

Parameters
uuidThe UUID of the entity to find.
Returns
The entity handle if found, otherwise an empty handle.

Definition at line 316 of file scene.cpp.

◆ get_all_scenes()

auto unravel::scene::get_all_scenes ( ) -> const std::vector<scene*>&
static

Definition at line 119 of file scene.cpp.

◆ instantiate() [1/2]

auto unravel::scene::instantiate ( const asset_handle< prefab > & pfb) -> entt::handle

Definition at line 192 of file scene.cpp.

◆ instantiate() [2/2]

auto unravel::scene::instantiate ( const asset_handle< prefab > & pfb,
entt::handle parent ) -> entt::handle

Definition at line 198 of file scene.cpp.

◆ instantiate_out()

auto unravel::scene::instantiate_out ( const asset_handle< prefab > & pfb,
entt::handle & e ) -> bool

Instantiates a prefab in the scene.

Parameters
pfbThe asset handle to the prefab.
Returns
A handle to the instantiated entity.

Definition at line 186 of file scene.cpp.

◆ load_from()

auto unravel::scene::load_from ( const asset_handle< scene_prefab > & pfb) -> bool

Loads a scene from a prefab asset.

Parameters
pfbThe asset handle to the scene prefab.
Returns
True if the scene was loaded successfully, false otherwise.

Definition at line 176 of file scene.cpp.

◆ unload()

void unravel::scene::unload ( )

Unloads the scene, removing all entities.

Definition at line 169 of file scene.cpp.

Member Data Documentation

◆ registry

std::unique_ptr<entt::registry> unravel::scene::registry {}

The registry that manages all entities in the scene.

Definition at line 117 of file scene.h.

◆ source

asset_handle<scene_prefab> unravel::scene::source

The source prefab asset handle for the scene.

Definition at line 112 of file scene.h.

◆ tag

std::string unravel::scene::tag {}

Definition at line 120 of file scene.h.


The documentation for this struct was generated from the following files: