15 Log::Debug(fmt::format(
"[EntityID:{}] AddComponent: {}",
value,
typeid(TComponent).name()));
16 return core.
GetRegistry().emplace<TComponent>(
value, std::forward<TComponent>(component));
19template <
typename TComponent,
typename... TArgs>
23 Log::Debug(fmt::format(
"[EntityID:{}] AddComponent: {}",
value,
typeid(TComponent).name()));
24 return core.
GetRegistry().emplace<TComponent>(
value, std::forward<TArgs>(args)...);
27template <
typename TComponent,
typename... TArgs>
42template <
typename TTempComponent,
typename... TArgs>
48 Log::Debug(fmt::format(
"RemoveTemporaryComponent: {}",
typeid(TTempComponent).name()));
49 c.GetRegistry().clear<TTempComponent>();
74 Log::Debug(fmt::format(
"[EntityID:{}] RemoveComponent: {}",
value,
typeid(TComponent).name()));
94 return std::hash<entt::id_type>{}(entityId.value);
97template <
typename FormatContext>
98auto fmt::formatter<Engine::EntityId>::format(
const Engine::EntityId &entityId, FormatContext &ctx)
const
102 return fmt::formatter<std::string>::format(
"null_entity", ctx);
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
bool IsEntityValid(Id entity) const
Check if entity is valid in the context of the registry. It check if the id of the entity exist.
Definition Core.cpp:99
Registry & GetRegistry()
Get the entt::registry that contains all components. It should be used to update component through sy...
Definition Core.cpp:44
std::string EntityToDebugString(const T &entity)
Definition EntityToIDString.hpp:12
void Debug(const T &msg) noexcept(false)
Definition Logger.hpp:28
constexpr bool IsNull(void) const
Checks if the ID is null/invalid by comparing its value to the null value defined by the derived clas...
Definition Id.ipp:12
entt::id_type value
Definition Id.hpp:20
Represents a unique identifier for an entity in the Engine's entity-component system....
Definition EntityId.hpp:14
Id::ValueType ValueType
The underlying value type of the EntityId, which is the same as Engine::Id::ValueType.
Definition EntityId.hpp:16
decltype(auto) AddComponentIfNotExists(Engine::Core &core, TArgs &&...args)
Add a component to an entity if it does not already exist.
Definition EntityId.ipp:28
static constexpr EntityId Null()
Returns a null EntityId. A null EntityId is an EntityId that does not correspond to any valid entity ...
Definition EntityId.ipp:8
bool IsValid(const Engine::Core &core) const
Checks if the EntityId is valid. An EntityId is considered valid if it corresponds to an existing ent...
Definition EntityId.ipp:10
decltype(auto) AddTemporaryComponent(Engine::Core &core, TArgs &&...args)
Add a temporary component to an entity. Temporary component are removed when calling RemoveTemporaryC...
Definition EntityId.ipp:43
void RemoveComponent(Engine::Core &core)
Remove a component from an entity.
Definition EntityId.ipp:71
bool HasComponents(const Engine::Core &core) const
Check if entity have one or multiple component's type.
Definition EntityId.ipp:37
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.ipp:78
decltype(auto) TryGetComponent(Engine::Core &core)
Try to get a component of type TComponent from the entity. It returns a pointer to the component if i...
Definition EntityId.ipp:66
decltype(auto) GetComponents(Engine::Core &core)
Get components of type TComponent from an entity.
Definition EntityId.ipp:56
constexpr EntityId(ValueType value_=NullValue())
Constructs an EntityId with the given value. By default, it constructs a null EntityId.
Definition EntityId.ipp:4
decltype(auto) AddComponent(Engine::Core &core, TComponent &&component)
Add a component to an entity.
Definition EntityId.ipp:12
static std::unordered_map< std::type_index, std::function< void(Core &)> > temporaryComponent
Definition EntityId.hpp:112
constexpr Id(ValueType value_=NullValue())
Constructor for Id.
Definition Id.ipp:17
static constexpr ValueType NullValue(void)
Get the null value for this ID type. This returns the null value defined by EnTT's id_type,...
Definition Id.ipp:21
std::size_t operator()(const Engine::EntityId &entityId) const noexcept
Hash function for EntityId. It uses the hash of the underlying ValueType to compute the hash of the E...
Definition EntityId.ipp:92