Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::ecs::Entity Class Reference

Represents an entity in the ECS (Entity-Component-System) architecture. More...

#include <Entity.hpp>

Collaboration diagram for rtp::ecs::Entity:

Public Member Functions

constexpr Entity (std::uint32_t index, std::uint32_t generation)
 
constexpr Entity (void)
 
constexpr std::uint32_t index (void) const
 
constexpr std::uint32_t generation (void) const
 
constexpr auto operator<=> (const Entity &) const =default
 
constexpr operator std::uint64_t (void) const noexcept
 
constexpr bool isNull (void) const noexcept
 

Static Public Attributes

static constexpr std::uint32_t MAX_INDEX
 
static constexpr std::uint64_t INDEX_MASK = MAX_INDEX
 
static constexpr std::uint64_t GEN_SHIFT = 32
 

Private Attributes

std::uint64_t _id
 The unique identifier for the entity.
 

Friends

struct std::hash< Entity >
 

Detailed Description

Represents an entity in the ECS (Entity-Component-System) architecture.

An Entity is represented as a 64-bit identifier combining a 32-bit index and a 32-bit generation counter. It serves as a unique identifier for entities within the ECS framework. Entities are used to associate components and systems in the ECS design pattern. The generation counter allows entity IDs to be recycled safely.

Definition at line 63 of file Entity.hpp.

Constructor & Destructor Documentation

◆ Entity() [1/2]

constexpr rtp::ecs::Entity::Entity ( std::uint32_t  index,
std::uint32_t  generation 
)
constexpr

◆ Entity() [2/2]

constexpr rtp::ecs::Entity::Entity ( void  )
constexpr

Member Function Documentation

◆ generation()

constexpr std::uint32_t rtp::ecs::Entity::generation ( void  ) const
constexpr

◆ index()

◆ isNull()

constexpr bool rtp::ecs::Entity::isNull ( void  ) const
constexprnoexcept

◆ operator std::uint64_t()

constexpr rtp::ecs::Entity::operator std::uint64_t ( void  ) const
constexprnoexcept

◆ operator<=>()

constexpr auto rtp::ecs::Entity::operator<=> ( const Entity ) const
constexprdefault

Friends And Related Symbol Documentation

◆ std::hash< Entity >

friend struct std::hash< Entity >
friend

Definition at line 88 of file Entity.hpp.

Member Data Documentation

◆ _id

std::uint64_t rtp::ecs::Entity::_id
private

The unique identifier for the entity.

Definition at line 88 of file Entity.hpp.

Referenced by std::hash< rtp::ecs::Entity >::operator()().

◆ GEN_SHIFT

constexpr std::uint64_t rtp::ecs::Entity::GEN_SHIFT = 32
staticconstexpr

Definition at line 68 of file Entity.hpp.

◆ INDEX_MASK

constexpr std::uint64_t rtp::ecs::Entity::INDEX_MASK = MAX_INDEX
staticconstexpr

Definition at line 67 of file Entity.hpp.

◆ MAX_INDEX

constexpr std::uint32_t rtp::ecs::Entity::MAX_INDEX
staticconstexpr
Initial value:
=
std::numeric_limits<std::uint32_t>::max()

Definition at line 65 of file Entity.hpp.

Referenced by rtp::ecs::Registry::spawn().


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