60 template <
typename TComponent,
typename... TArgs>
77 template <
typename TTempComponent,
typename... TArgs>
119static_assert(
sizeof(EntityId) ==
sizeof(
EntityId::ValueType),
"EntityId size must be equal to Id size");
125template <>
struct std::hash<
Engine::EntityId> {
135template <>
struct fmt::formatter<
Engine::EntityId> : fmt::formatter<std::string> {
143 template <
typename FormatContext>
auto format(
const Engine::EntityId &entityId, FormatContext &ctx)
const;
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
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
entt::id_type ValueType
Definition Id.hpp:48
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