TheAtlasEngine
 
Loading...
Searching...
No Matches
atlas::scene Class Reference

Constructs a scene that defines an area where game objects are part of contained within an atlas::world. More...

#include <scene.hpp>

Public Member Functions

 scene (const std::string &p_name, event::event_bus &p_bus)
 
game_object entity (std::string_view p_name)
 Retrieves if an entity already exists within the registry, create new entity otherwise.
 
game_object entity (uint64_t p_id)
 Retrieves if an entity already exists within the registry, create new entity otherwise.
 
template<typename UEventType , typename UObject , typename UCallback >
void subscribe (UObject *p_instance, const UCallback &p_callback)
 subscribes an event to the event::bus to get invoked when publishers notify all subscribers when an update is incoming
 
template<typename... Comps, typename... Args>
flecs::query_builder< Comps... > query_builder (Args &&... args) const
 queries components, returning entities (game objects) that contain those components queried with.
 
uint32_t children_count (const game_object &p_parent)
 
bool defer_begin ()
 Defer operations until end of frame. When this operation is invoked while iterating, operations inbetween the defer_begin() and defer_end() operations are executed at the end of the frame.
 
bool defer_end ()
 
std::string name () const
 
event::event_busevent_handle () const
 
 operator flecs::world & ()
 Requires to return flecs::world is returned by reference to prevent making copies of flecs::world.
 

Detailed Description

Constructs a scene that defines an area where game objects are part of contained within an atlas::world.

Scenes are fundamentally building blocks that a game object may reside in. Composing of variety of properties such as sky lights, game objects, cameras, etc.

Which can represent corresponding resources that can be related to specific levels/scenes.

Scenes are apart of another container referred to as the world which helps manages these scenes and consider them as contexts that can be switched/toggled based on users transforms.

Constructor & Destructor Documentation

◆ scene()

atlas::scene::scene ( const std::string &  p_name,
event::event_bus p_bus 
)
Parameters
p_nameis the name given to this scene
p_busis the globalized event bus that is given access to the scene to subscribe events to it.

Member Function Documentation

◆ children_count()

uint32_t atlas::scene::children_count ( const game_object p_parent)
Returns
the number of children entities

Example Usage:

++
atlas::scene scene("New Scene");
// creating obj1 (parent) and obj2 (child)
atlas::game_object obj1 = scene.create("Parent");
atlas::game_object obj2 = scene.create("Chlid");
// obj2 is the child of obj1
// As obj1 is a parent node
obj2.child_of(obj1);
// Returns 1
uint32_t obj1_children = scene.children_count(obj1);
Creates a pointer wrapper which extends capabilities of flecs::entity.
Definition game_object.hpp:15
Constructs a scene that defines an area where game objects are part of contained within an atlas::wor...
Definition scene.hpp:24
uint32_t children_count(const game_object &p_parent)

◆ defer_begin()

bool atlas::scene::defer_begin ( )
inline

Defer operations until end of frame. When this operation is invoked while iterating, operations inbetween the defer_begin() and defer_end() operations are executed at the end of the frame.

This operation is thread safe.

Returns
true if world changed from non-deferred mode to deferred mode.

◆ defer_end()

bool atlas::scene::defer_end ( )
inline

End block of operations to defer. See defer_begin().

This operation is thread safe.

Returns
true if world changed from deferred mode to non-deferred mode.

◆ entity() [1/2]

game_object atlas::scene::entity ( std::string_view  p_name)

Retrieves if an entity already exists within the registry, create new entity otherwise.

Parameters
p_nameis a string to set the name of the entity

◆ entity() [2/2]

game_object atlas::scene::entity ( uint64_t  p_id)

Retrieves if an entity already exists within the registry, create new entity otherwise.

Parameters
p_entity_idis the ID to retrieve an entity if it exists, otherwise returns a new entity.

◆ event_handle()

event::event_bus * atlas::scene::event_handle ( ) const
inline
Returns
the event::bus handle for subscribing events

◆ name()

std::string atlas::scene::name ( ) const
inline
Returns
the name of the scene

◆ query_builder()

template<typename... Comps, typename... Args>
flecs::query_builder< Comps... > atlas::scene::query_builder ( Args &&...  args) const
inline

queries components, returning entities (game objects) that contain those components queried with.

Queries are a feature flecs allows us to do. Which query component parameters and gives us archetypes back.

Archetypes are list of entities that contain those list of parameters

Template Parameters
...Comps
...Args
Parameters
...args
Returns
flecs::query_builder<Comps...>

Example Usage:

++
auto query_physics = query_builder<atlas::transform,
query_physics.each([](flecs::entity, atlas::transform&,
// do stuff
});
flecs::query_builder< Comps... > query_builder(Args &&... args) const
queries components, returning entities (game objects) that contain those components queried with.
Definition scene.hpp:96
physics body data-driven representative
Definition components.hpp:34
Definition components.hpp:10

◆ subscribe()

template<typename UEventType , typename UObject , typename UCallback >
void atlas::scene::subscribe ( UObject *  p_instance,
const UCallback &  p_callback 
)
inline

subscribes an event to the event::bus to get invoked when publishers notify all subscribers when an update is incoming

Template Parameters
UEventType
UObject
UCallback
Parameters
p_instanceis the object instance to specify where the callback belongs to
p_callbackis the callback that contains an arbitrary task that gets invoked when incoming updates occur from the publisher

The documentation for this class was generated from the following file: