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
Registry.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_CORE_REGISTRY_HPP_
9#define GALAXY_CORE_REGISTRY_HPP_
10
11#include <entt/entity/registry.hpp>
12
13namespace galaxy
14{
15 namespace core
16 {
20 class Registry final
21 {
25 using B2BodyConstruction = meta::vector<std::pair<components::RigidBody*, components::Transform*>>;
26
27 public:
31 Registry();
32
37
42
46 ~Registry();
47
53 [[maybe_unused]] entt::entity create();
54
62 [[maybe_unused]] entt::entity create_from_prefab(const std::string& name);
63
71 [[nodiscard]] bool is_valid(const entt::entity entity);
72
80 void update(b2World& b2World);
81
85 void clear();
86
87 private:
91 Registry(const Registry&) = delete;
92
96 Registry& operator=(const Registry&) = delete;
97
104 void construct_rigidbody(entt::registry& registry, entt::entity entity);
105
112 void destroy_rigidbody(entt::registry& registry, entt::entity entity);
113
120 void construct_script(entt::registry& registry, entt::entity entity);
121
128 void destruct_script(entt::registry& registry, entt::entity entity);
129
136 void construct_nui(entt::registry& registry, entt::entity entity);
137
144 void destruct_nui(entt::registry& registry, entt::entity entity);
145
152 void enable_entity(entt::registry& registry, entt::entity entity);
153
160 void disable_entity(entt::registry& registry, entt::entity entity);
161
162 public:
166 entt::registry m_entt;
167
168 private:
173 };
174 } // namespace core
175} // namespace galaxy
176
177#endif
Wrapper around entt::registry to expand functionality.
Definition Registry.hpp:21
void construct_script(entt::registry &registry, entt::entity entity)
Function that integrates lua init with entt on construct event.
Definition Registry.cpp:157
void clear()
Clear any pending data.
Definition Registry.cpp:127
Registry & operator=(Registry &&)
Move assignment operator.
Definition Registry.cpp:40
void construct_nui(entt::registry &registry, entt::entity entity)
Function that integrates nuklear init with entt on construct event.
Definition Registry.cpp:214
void destruct_nui(entt::registry &registry, entt::entity entity)
Function that integrates nuklear destroy with entt on destruction event.
Definition Registry.cpp:256
void destruct_script(entt::registry &registry, entt::entity entity)
Function that integrates lua destroy with entt on destruction event.
Definition Registry.cpp:198
void disable_entity(entt::registry &registry, entt::entity entity)
Function that runs when an entity is disabled.
Definition Registry.cpp:274
void destroy_rigidbody(entt::registry &registry, entt::entity entity)
Function that integrates a box2d destruction with entt.
Definition Registry.cpp:144
entt::entity create()
Create an entity with some default components.
Definition Registry.cpp:55
void construct_rigidbody(entt::registry &registry, entt::entity entity)
Function that integrates a box2d construction with entt.
Definition Registry.cpp:133
~Registry()
Destructor.
Definition Registry.cpp:51
meta::vector< std::pair< components::RigidBody *, components::Transform * > > B2BodyConstruction
Typedef for creating b2 bodies from components.
Definition Registry.hpp:25
void update(b2World &b2World)
Updates pending component data.
Definition Registry.cpp:96
Registry & operator=(const Registry &)=delete
Copy assignment operator.
entt::entity create_from_prefab(const std::string &name)
Create an entity from a prefab.
Definition Registry.cpp:67
Registry()
Constructor.
Definition Registry.cpp:23
Registry(const Registry &)=delete
Copy constructor.
void enable_entity(entt::registry &registry, entt::entity entity)
Function that runs when an entity is enabled.
Definition Registry.cpp:265
B2BodyConstruction m_bodies_to_construct
List of rigid bodies that need to be constructed.
Definition Registry.hpp:172
entt::registry m_entt
Scene entities.
Definition Registry.hpp:166
bool is_valid(const entt::entity entity)
Validate an entity to make sure all components have met their requirements as defined by register_dep...
Definition Registry.cpp:81
Animated.cpp galaxy.
Definition Animated.cpp:16