Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::Entity Struct Referencefinal

Identifier of an entity or component instance in the world. Packs the entity index, generation, kind and flags into one 64-bit value. More...

#include <id.h>

Classes

struct  InternalData
 Bit-packed storage layout of an entity identifier. More...
 

Public Member Functions

template<typename T , typename = std::enable_if_t<std::is_same_v<T, Identifier>>>
constexpr Entity (T value) noexcept
 We need the entity to be braces-constructible and at the same type prevent it from getting constructed accidentally from an int (e.g .Entity::id()). Therefore, only allow Entity(Identifier) to be used.
 
 Entity (EntityId id, IdentifierData gen) noexcept
 Special constructor for cnt::ilist.
 
 Entity (EntityId id, IdentifierData gen, bool isEntity, bool isPair, EntityKind kind) noexcept
 
GAIA_NODISCARD constexpr auto id () const noexcept
 Entity index in the entity array.
 
GAIA_NODISCARD constexpr auto gen () const noexcept
 Generation index of the entity.
 
GAIA_NODISCARD constexpr bool entity () const noexcept
 Whether this id refers to an entity.
 
GAIA_NODISCARD constexpr bool pair () const noexcept
 Whether this id refers to a relationship pair.
 
GAIA_NODISCARD constexpr bool comp () const noexcept
 Whether this id refers to a component.
 
GAIA_NODISCARD constexpr auto kind () const noexcept
 Entity kind of this id.
 
GAIA_NODISCARD constexpr auto value () const noexcept
 Raw identifier value.
 
GAIA_NODISCARD constexpr bool operator== (Entity other) const noexcept
 
GAIA_NODISCARD constexpr bool operator!= (Entity other) const noexcept
 
GAIA_NODISCARD constexpr bool operator< (Entity other) const noexcept
 
GAIA_NODISCARD constexpr bool operator<= (Entity other) const noexcept
 
GAIA_NODISCARD constexpr bool operator> (Entity other) const noexcept
 
GAIA_NODISCARD constexpr bool operator>= (Entity other) const noexcept
 
template<typename Serializer >
void save (Serializer &s) const
 Serializes the entity id.
 
template<typename Serializer >
void load (Serializer &s)
 Deserializes the entity id, remapping it to the current world.
 

Public Attributes

union { 
 
   InternalData   data 
 Structured view of the packed value.
 
   Identifier   val 
 Raw 64-bit value.
 
};  
 

Static Public Attributes

static constexpr uint32_t IdMask = IdentifierIdBad
 Bit mask covering all valid entity indices.
 

Detailed Description

Identifier of an entity or component instance in the world. Packs the entity index, generation, kind and flags into one 64-bit value.

Member Function Documentation

◆ comp()

GAIA_NODISCARD constexpr bool gaia::ecs::Entity::comp ( ) const
inlineconstexprnoexcept

Whether this id refers to a component.

Returns
True when a component.

◆ entity()

GAIA_NODISCARD constexpr bool gaia::ecs::Entity::entity ( ) const
inlineconstexprnoexcept

Whether this id refers to an entity.

Returns
True for an entity, false for a component.

◆ gen()

GAIA_NODISCARD constexpr auto gaia::ecs::Entity::gen ( ) const
inlineconstexprnoexcept

Generation index of the entity.

Returns
Generation index.

◆ id()

GAIA_NODISCARD constexpr auto gaia::ecs::Entity::id ( ) const
inlineconstexprnoexcept

Entity index in the entity array.

Returns
Entity index.

◆ kind()

GAIA_NODISCARD constexpr auto gaia::ecs::Entity::kind ( ) const
inlineconstexprnoexcept

Entity kind of this id.

Returns
Entity kind.

◆ load()

template<typename Serializer >
void gaia::ecs::Entity::load ( Serializer &  s)
inline

Deserializes the entity id, remapping it to the current world.

Template Parameters
Serializerserializer type.
Parameters
sserializer to read from.

◆ pair()

GAIA_NODISCARD constexpr bool gaia::ecs::Entity::pair ( ) const
inlineconstexprnoexcept

Whether this id refers to a relationship pair.

Returns
True when a pair.

◆ save()

template<typename Serializer >
void gaia::ecs::Entity::save ( Serializer &  s) const
inline

Serializes the entity id.

Template Parameters
Serializerserializer type.
Parameters
sserializer to write to.

◆ value()

GAIA_NODISCARD constexpr auto gaia::ecs::Entity::value ( ) const
inlineconstexprnoexcept

Raw identifier value.

Returns
Raw 64-bit value.

The documentation for this struct was generated from the following file: