Potato Engine
Hobby Game Engine Project
Public Types | Public Member Functions | Static Public Attributes | List of all members
up::World Class Reference

A world contains a collection of Entities, Archetypes, and their associated Components. More...

#include <world.h>

Public Types

using RawSelectSignature = void(size_t, EntityId const *, view< void * >)
 

Public Member Functions

 World (World &&)=delete
 
Worldoperator= (World &&)=delete
 
view< box< Archetype > > archetypes () const noexcept
 
template<typename... Components>
EntityId createEntity (Components const &... components) noexcept
 Creates a new Entity with the provided list of Component data.
 
void deleteEntity (EntityId entity) noexcept
 Deletes an existing Entity.
 
template<typename Component >
void addComponent (EntityId entityId, Component const &component) noexcept
 Adds a new Component to an existing Entity. More...
 
void removeComponent (EntityId entityId, ComponentId componentId) noexcept
 Removes a Component from an existing Entity. More...
 
template<typename Component >
Component * getComponentSlow (EntityId entity) noexcept
 Retrieves a pointer to a Component on the specified Entity. More...
 
void * getComponentSlowUnsafe (EntityId entity, ComponentId component) noexcept
 Retrieves a pointer to a Component on the specified Entity. More...
 
void selectRaw (view< ComponentId > sortedComponents, view< ComponentId > callbackComponents, delegate_ref< RawSelectSignature > callback) const
 

Static Public Attributes

static constexpr uint32 maxSelectComponents = 64
 Maximum number of Components that can be selected (used in a Query)
 
static constexpr uint32 maxArchetypeComponents = 256
 Maximum number of Components that can exist on an Archetype (and hence any single Entity)
 

Detailed Description

A world contains a collection of Entities, Archetypes, and their associated Components.

Entities from different Worlds cannot interact.

Member Function Documentation

◆ addComponent()

template<typename Component >
void up::World::addComponent ( EntityId  entityId,
Component const &  component 
)
noexcept

Adds a new Component to an existing Entity.

Changes the Entity's Archetype and home Chunk

◆ getComponentSlow()

template<typename Component >
Component * up::World::getComponentSlow ( EntityId  entity)
noexcept

Retrieves a pointer to a Component on the specified Entity.

This is typically a slow operation. It will incur several table lookups and searches. This should only be used by tools and debug aids, typically, and a Query should be used for runtime code.

◆ getComponentSlowUnsafe()

void* up::World::getComponentSlowUnsafe ( EntityId  entity,
ComponentId  component 
)
noexcept

Retrieves a pointer to a Component on the specified Entity.

This is a type-unsafe variant of getComponentSlow.

◆ removeComponent()

void up::World::removeComponent ( EntityId  entityId,
ComponentId  componentId 
)
noexcept

Removes a Component from an existing Entity.

Changes the Entity's Archetype and home Chunk


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