8#include <entt/entt.hpp>
55 template <
typename TComponent>
inline decltype(
auto)
AddComponent(TComponent &&component)
57 return _entityId.AddComponent(
GetCore(), std::forward<TComponent>(component));
66 template <
typename TComponent,
typename... TArgs>
inline decltype(
auto)
AddComponent(TArgs &&...args)
68 return _entityId.AddComponent<TComponent>(
GetCore(), std::forward<TArgs>(args)...);
79 return _entityId.AddComponentIfNotExists<TComponent>(
GetCore(), std::forward<TArgs>(args)...);
89 template <
typename TTempComponent,
typename... TArgs>
inline decltype(
auto)
AddTemporaryComponent(TArgs &&...args)
91 return _entityId.AddTemporaryComponent<TTempComponent>(
GetCore(), std::forward<TArgs>(args)...);
127 template <
typename... TComponent>
inline decltype(
auto)
GetComponents()
const
176template <>
struct fmt::formatter<
Engine::Entity> : fmt::formatter<Engine::EntityId> {
186 return fmt::formatter<Engine::EntityId>::format(entity.
Id(), ctx);
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
Wrapper class providing a convenient interface for entity manipulation with the Core....
Definition Entity.hpp:20
decltype(auto) AddComponentIfNotExists(TArgs &&...args)
Add a component to an entity if it does not already exist.
Definition Entity.hpp:77
~Entity()=default
Default destructor for Entity. It does not perform any special cleanup, as the Core is responsible fo...
decltype(auto) GetComponents() const
Get components of type TComponent from the entity.
Definition Entity.hpp:127
EntityId Id() const
Get the EntityId associated with this Entity.
Definition Entity.hpp:39
static void RemoveTemporaryComponents(Core &core)
Remove all temporary components from the registry.
Definition Entity.hpp:98
bool operator==(const EntityId &rhs) const
Equality operator for Entity and EntityId. It compares the underlying EntityId value of the Entity wi...
Definition Entity.hpp:154
decltype(auto) AddTemporaryComponent(TArgs &&...args)
Add a temporary component to an entity. Temporary component are removed when calling RemoveTemporaryC...
Definition Entity.hpp:89
Entity(Core &core, EntityId entityId)
Create an Entity from EntityId and the Core it belongs to.
Definition Entity.hpp:26
constexpr Core & GetCore() const
Get a reference to the Core instance that this Entity belongs to. This is used internally to access t...
Definition Entity.hpp:161
decltype(auto) AddComponent(TComponent &&component)
Add a component to an entity.
Definition Entity.hpp:55
decltype(auto) TryGetComponent()
Try to get a component of type TComponent from the entity. It returns a pointer to the component if i...
Definition Entity.hpp:137
bool IsAlive() const
Check if the entity is alive.
Definition Entity.cpp:3
bool HasComponents() const
Check if entity have one or multiple component's type.
Definition Entity.hpp:109
bool operator==(const Entity &rhs) const
Equality operator for Entity. It compares the underlying EntityId values to determine if two Entity i...
Definition Entity.hpp:147
EntityId _entityId
The EntityId that identifies the entity in the Core's registry. This is the underlying identifier for...
Definition Entity.hpp:168
decltype(auto) GetComponents()
Get components of type TComponent from the entity.
Definition Entity.hpp:118
void Kill()
Kill the entity, removing all components and making it invalid. After calling this method,...
Definition Entity.cpp:5
std::reference_wrapper< Core > _core
A reference to the Core instance that this Entity belongs to.
Definition Entity.hpp:164
void RemoveComponent()
Remove a component from an entity.
Definition Entity.hpp:103
decltype(auto) AddComponent(TArgs &&...args)
Add a component to an entity.
Definition Entity.hpp:66
TValue value
The underlying value of the ID.
Definition Id.hpp:20
Represents a unique identifier for an entity in the Engine's entity-component system....
Definition EntityId.hpp:14
static void RemoveTemporaryComponents(Core &core)
Remove all temporary components from the registry. This system should be called at the end of each lo...
Definition EntityId.hpp:173