galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::core::Registry Class Referencefinal

Wrapper around entt::registry to expand functionality. More...

#include <Registry.hpp>

+ Collaboration diagram for galaxy::core::Registry:

Public Member Functions

 Registry ()
 Constructor.
 
 Registry (Registry &&)
 Move constructor.
 
Registryoperator= (Registry &&)
 Move assignment operator.
 
 ~Registry ()
 Destructor.
 
entt::entity create ()
 Create an entity with some default components.
 
entt::entity create_from_prefab (const std::string &name)
 Create an entity from a prefab.
 
bool is_valid (const entt::entity entity)
 Validate an entity to make sure all components have met their requirements as defined by register_dependencies().
 
void update (b2World &b2World)
 Updates pending component data.
 
void clear ()
 Clear any pending data.
 

Public Attributes

entt::registry m_entt
 Scene entities.
 

Private Types

using B2BodyConstruction = meta::vector<std::pair<components::RigidBody*, components::Transform*>>
 Typedef for creating b2 bodies from components.
 

Private Member Functions

 Registry (const Registry &)=delete
 Copy constructor.
 
Registryoperator= (const Registry &)=delete
 Copy assignment operator.
 
void construct_rigidbody (entt::registry &registry, entt::entity entity)
 Function that integrates a box2d construction with entt.
 
void destroy_rigidbody (entt::registry &registry, entt::entity entity)
 Function that integrates a box2d destruction with entt.
 
void construct_script (entt::registry &registry, entt::entity entity)
 Function that integrates lua init with entt on construct event.
 
void destruct_script (entt::registry &registry, entt::entity entity)
 Function that integrates lua destroy with entt on destruction event.
 
void construct_nui (entt::registry &registry, entt::entity entity)
 Function that integrates nuklear init with entt on construct event.
 
void destruct_nui (entt::registry &registry, entt::entity entity)
 Function that integrates nuklear destroy with entt on destruction event.
 
void enable_entity (entt::registry &registry, entt::entity entity)
 Function that runs when an entity is enabled.
 
void disable_entity (entt::registry &registry, entt::entity entity)
 Function that runs when an entity is disabled.
 

Private Attributes

B2BodyConstruction m_bodies_to_construct
 List of rigid bodies that need to be constructed.
 

Detailed Description

Wrapper around entt::registry to expand functionality.

Definition at line 20 of file Registry.hpp.

Member Typedef Documentation

◆ B2BodyConstruction

Typedef for creating b2 bodies from components.

Definition at line 25 of file Registry.hpp.

Constructor & Destructor Documentation

◆ Registry() [1/3]

galaxy::core::Registry::Registry ( )

Constructor.

Definition at line 23 of file Registry.cpp.

◆ Registry() [2/3]

galaxy::core::Registry::Registry ( Registry && r)

Move constructor.

Definition at line 34 of file Registry.cpp.

◆ ~Registry()

galaxy::core::Registry::~Registry ( )

Destructor.

Definition at line 51 of file Registry.cpp.

◆ Registry() [3/3]

galaxy::core::Registry::Registry ( const Registry & )
privatedelete

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

Registry & galaxy::core::Registry::operator= ( Registry && r)

Move assignment operator.

Definition at line 40 of file Registry.cpp.

◆ create()

entt::entity galaxy::core::Registry::create ( )

Create an entity with some default components.

Returns
Created entity, or entt::null if failed.

Definition at line 55 of file Registry.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_from_prefab()

entt::entity galaxy::core::Registry::create_from_prefab ( const std::string & name)

Create an entity from a prefab.

Parameters
nameName of the prefab to load.
Returns
Created entity, or entt::null if failed.

Definition at line 67 of file Registry.cpp.

◆ is_valid()

bool galaxy::core::Registry::is_valid ( const entt::entity entity)
nodiscard

Validate an entity to make sure all components have met their requirements as defined by register_dependencies().

Parameters
entityEntity to validate.
Returns
True if entity is valid.

Definition at line 81 of file Registry.cpp.

◆ update()

void galaxy::core::Registry::update ( b2World & b2World)

Updates pending component data.

For example, box2d bodies.

Parameters
b2WorldBox2d world data.

Definition at line 96 of file Registry.cpp.

+ Here is the caller graph for this function:

◆ clear()

void galaxy::core::Registry::clear ( )

Clear any pending data.

Definition at line 127 of file Registry.cpp.

+ Here is the caller graph for this function:

◆ operator=() [2/2]

Registry & galaxy::core::Registry::operator= ( const Registry & )
privatedelete

Copy assignment operator.

◆ construct_rigidbody()

void galaxy::core::Registry::construct_rigidbody ( entt::registry & registry,
entt::entity entity )
private

Function that integrates a box2d construction with entt.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 133 of file Registry.cpp.

◆ destroy_rigidbody()

void galaxy::core::Registry::destroy_rigidbody ( entt::registry & registry,
entt::entity entity )
private

Function that integrates a box2d destruction with entt.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 144 of file Registry.cpp.

◆ construct_script()

void galaxy::core::Registry::construct_script ( entt::registry & registry,
entt::entity entity )
private

Function that integrates lua init with entt on construct event.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 157 of file Registry.cpp.

◆ destruct_script()

void galaxy::core::Registry::destruct_script ( entt::registry & registry,
entt::entity entity )
private

Function that integrates lua destroy with entt on destruction event.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 198 of file Registry.cpp.

◆ construct_nui()

void galaxy::core::Registry::construct_nui ( entt::registry & registry,
entt::entity entity )
private

Function that integrates nuklear init with entt on construct event.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 214 of file Registry.cpp.

+ Here is the call graph for this function:

◆ destruct_nui()

void galaxy::core::Registry::destruct_nui ( entt::registry & registry,
entt::entity entity )
private

Function that integrates nuklear destroy with entt on destruction event.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 256 of file Registry.cpp.

◆ enable_entity()

*void galaxy::core::Registry::enable_entity ( entt::registry & registry,
entt::entity entity )
private

Function that runs when an entity is enabled.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 265 of file Registry.cpp.

◆ disable_entity()

void galaxy::core::Registry::disable_entity ( entt::registry & registry,
entt::entity entity )
private

Function that runs when an entity is disabled.

Parameters
registryRegistry component belongs to.
entityEntity component belongs to.

Definition at line 274 of file Registry.cpp.

Member Data Documentation

◆ m_entt

entt::registry galaxy::core::Registry::m_entt

Scene entities.

Definition at line 166 of file Registry.hpp.

◆ m_bodies_to_construct

B2BodyConstruction galaxy::core::Registry::m_bodies_to_construct
private

List of rigid bodies that need to be constructed.

Definition at line 172 of file Registry.hpp.


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