Nebula
Loading...
Searching...
No Matches
Game::Entity Struct Reference

#include <entity.h>

Detailed Description

An entity is essentially just an Id with some utility functions attached.

What actually makes up the entities are their components.

The id is split into two parts: The upper half is world id, the upper 10 bits of the lower half are used as a generation counter, so that we can easily reuse the lowest 22 bits as an index.

See also
Game::World::IsValid
api.h
component.h
world.h

Classes

struct  Traits
 

Public Member Functions

 Entity ()=default
 
constexpr Entity (uint64_t id)
 
constexpr Entity (uint32_t world, uint32_t generation, uint32_t index)
 
constexpr operator Ids::Id64 () const
 
constexpr uint32_t HashCode () const
 
Entityoperator= (uint64_t rhs)
 
const bool operator== (const Entity &rhs) const
 
const bool operator!= (const Entity &rhs) const
 
const bool operator< (const Entity &rhs) const
 
const bool operator> (const Entity &rhs) const
 

Static Public Member Functions

static constexpr Entity FromId (Ids::Id64 id)
 
static constexpr Entity Invalid ()
 

Public Attributes

uint32_t index: 22
 
uint32_t generation: 10
 
uint32_t world: 8
 
uint32_t reserved: 24
 

Constructor & Destructor Documentation

◆ Entity() [1/3]

Game::Entity::Entity ( )
default

◆ Entity() [2/3]

Game::Entity::Entity ( uint64_t id)
inlineconstexpr

◆ Entity() [3/3]

Game::Entity::Entity ( uint32_t world,
uint32_t generation,
uint32_t index )
inlineconstexpr

Member Function Documentation

◆ FromId()

Entity Game::Entity::FromId ( Ids::Id64 id)
inlinestaticconstexpr

◆ HashCode()

uint32_t Game::Entity::HashCode ( ) const
inlineconstexpr

◆ Invalid()

Entity Game::Entity::Invalid ( )
inlinestaticconstexpr

◆ operator Ids::Id64()

Game::Entity::operator Ids::Id64 ( ) const
explicitconstexpr

◆ operator!=()

const bool Game::Entity::operator!= ( const Entity & rhs) const
inline

◆ operator<()

const bool Game::Entity::operator< ( const Entity & rhs) const
inline

◆ operator=()

Entity & Game::Entity::operator= ( uint64_t rhs)
inline

◆ operator==()

const bool Game::Entity::operator== ( const Entity & rhs) const
inline

◆ operator>()

const bool Game::Entity::operator> ( const Entity & rhs) const
inline

Member Data Documentation

◆ generation

uint32_t Game::Entity::generation

◆ index

uint32_t Game::Entity::index

◆ reserved

uint32_t Game::Entity::reserved

◆ world

uint32_t Game::Entity::world

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