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::Registry Class Reference

#include <Registry.hpp>

Collaboration diagram for rtp::ecs::Registry:

Public Member Functions

 ~Registry () noexcept=default
 
auto spawn (void) -> std::expected< Entity, rtp::Error >
 
void kill (Entity entity)
 
template<Component T, typename Self >
auto subscribe (this Self &self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >
 
bool isAlive (Entity entity) const noexcept
 
template<Component T, typename... Args>
auto add (Entity entity, Args &&...args) -> std::expected< std::reference_wrapper< T >, rtp::Error >
 
template<Component T, typename Self >
auto get (this const Self &self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >
 
template<Component T>
bool has (Entity entity) const noexcept
 
template<Component T>
void remove (Entity entity) noexcept
 
void clear (void) noexcept
 
void purge (void) noexcept
 
template<Component... Ts, typename Self >
auto view (this Self &self)
 
template<Component... Ts, typename Self >
auto zipView (this Self &self)
 
std::size_t entityCount (void) const noexcept
 
template<Component... Ts>
std::size_t componentCount (void) const noexcept
 

Private Member Functions

template<Component T, typename Self >
auto getArray (this Self &self) -> ConstLikeRef< Self, SparseArray< T > >
 
template<Component T, Component... Ts, typename Self >
auto & getSmallestArray (this Self &self)
 
template<Component... Ts>
bool hasAllComponents (Entity entity) const noexcept
 

Private Attributes

std::unordered_map< std::type_index, std::unique_ptr< ISparseArray > > _arrays
 Registered component arrays.
 
std::vector< std::uint32_t > _generations
 Generation counters for entities.
 
std::deque< std::size_t > _freeIndices
 Recyclable entity indices.
 
std::shared_mutex _mutex
 Mutex for thread-safe operations.
 

Detailed Description

Definition at line 45 of file Registry.hpp.

Constructor & Destructor Documentation

◆ ~Registry()

rtp::ecs::Registry::~Registry ( )
defaultnoexcept

Member Function Documentation

◆ add()

◆ clear()

◆ componentCount()

template<Component... Ts>
std::size_t rtp::ecs::Registry::componentCount ( void  ) const
noexcept

◆ entityCount()

std::size_t rtp::ecs::Registry::entityCount ( void  ) const
noexcept

Definition at line 127 of file Registry.cpp.

◆ get()

template<Component T, typename Self >
auto rtp::ecs::Registry::get ( this const Self &  self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >

Referenced by rtp::server::GameManager::GameManager(), rtp::server::EntitySystem::applyWeaponToEntity(), rtp::server::Room::broadcastRoomState(), rtp::client::scenes::LobbyScene::buildUi(), rtp::client::Application::changeState(), rtp::client::UISystem::clearAllTextInputFocus(), rtp::server::BulletCleanupSystem::despawn(), rtp::server::CollisionSystem::despawn(), rtp::server::RoomSystem::despawnPlayerEntity(), rtp::client::UISystem::focusTextInputAt(), rtp::client::scenes::PlayingScene::handleEvent(), rtp::server::NetworkSyncSystem::handleInput(), rtp::client::UISystem::handleKeyPressed(), rtp::client::UISystem::handleMouseClick(), rtp::client::UISystem::handleMouseMove(), rtp::server::GameManager::handlePlayerDisconnect(), rtp::client::UISystem::handleTextEntered(), rtp::client::NetworkSyncSystem::onBeamState(), rtp::client::scenes::MenuScene::onEnter(), rtp::client::scenes::PlayingScene::onEnter(), rtp::client::scenes::RoomWaitingScene::onEnter(), rtp::client::NetworkSyncSystem::onEntityDeath(), rtp::client::NetworkSyncSystem::onRoomUpdate(), rtp::client::NetworkSyncSystem::onSpawnEntityFromServer(), rtp::client::scenes::PlayingScene::openChat(), rtp::client::scenes::RoomWaitingScene::openChat(), rtp::client::scenes::GamepadSettingsScene::refreshButtonLabel(), rtp::client::scenes::KeyBindingScene::refreshButtonLabel(), rtp::client::systems::UIRenderSystem::renderButtons(), rtp::client::systems::UIRenderSystem::renderDropdowns(), rtp::client::systems::UIRenderSystem::renderSliders(), rtp::client::systems::UIRenderSystem::renderSpritePreviews(), rtp::client::systems::UIRenderSystem::renderTextInputs(), rtp::client::systems::UIRenderSystem::renderTexts(), rtp::client::scenes::PlayingScene::sendChatMessage(), rtp::client::scenes::RoomWaitingScene::sendChatMessage(), rtp::server::GameManager::sendEntitySpawnToSessions(), rtp::server::GameManager::sendRoomEntitySpawnsToSession(), rtp::server::PlayerShootSystem::spawnBullet(), rtp::server::PlayerShootSystem::spawnChargedBullet(), rtp::server::LevelSystem::spawnEntityForRoom(), rtp::client::EntityBuilder::update(), rtp::client::scenes::MenuScene::update(), rtp::client::scenes::PlayingScene::update(), rtp::client::scenes::RoomWaitingScene::update(), rtp::client::ShieldSystem::update(), rtp::client::UISystem::update(), rtp::server::BoomerangSystem::update(), rtp::server::BulletCleanupSystem::update(), rtp::server::CollisionSystem::update(), rtp::server::EnemyAISystem::update(), rtp::server::HomingSystem::update(), rtp::server::PlayerShootSystem::update(), rtp::client::InputSystem::update(), rtp::client::scenes::PlayingScene::updateChatHistoryText(), rtp::client::scenes::RoomWaitingScene::updateChatHistoryText(), and rtp::client::scenes::MenuScene::updateWeaponDisplay().

◆ getArray()

template<Component T, typename Self >
auto rtp::ecs::Registry::getArray ( this Self &  self) -> ConstLikeRef< Self, SparseArray< T > >
private

◆ getSmallestArray()

template<Component T, Component... Ts, typename Self >
auto & rtp::ecs::Registry::getSmallestArray ( this Self &  self)
private

◆ has()

template<Component T>
bool rtp::ecs::Registry::has ( Entity  entity) const
noexcept

◆ hasAllComponents()

template<Component... Ts>
bool rtp::ecs::Registry::hasAllComponents ( Entity  entity) const
privatenoexcept

◆ isAlive()

bool rtp::ecs::Registry::isAlive ( Entity  entity) const
noexcept

Definition at line 90 of file Registry.cpp.

◆ kill()

◆ purge()

void rtp::ecs::Registry::purge ( void  )
noexcept

Definition at line 113 of file Registry.cpp.

◆ remove()

◆ spawn()

◆ subscribe()

template<Component T, typename Self >
auto rtp::ecs::Registry::subscribe ( this Self &  self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >

◆ view()

template<Component... Ts, typename Self >
auto rtp::ecs::Registry::view ( this Self &  self)

◆ zipView()

Member Data Documentation

◆ _arrays

std::unordered_map<std::type_index, std::unique_ptr<ISparseArray> > rtp::ecs::Registry::_arrays
private

Registered component arrays.

Definition at line 103 of file Registry.hpp.

Referenced by kill().

◆ _freeIndices

std::deque<std::size_t> rtp::ecs::Registry::_freeIndices
private

Recyclable entity indices.

Definition at line 105 of file Registry.hpp.

Referenced by kill().

◆ _generations

std::vector<std::uint32_t> rtp::ecs::Registry::_generations
private

Generation counters for entities.

Definition at line 104 of file Registry.hpp.

Referenced by kill().

◆ _mutex

std::shared_mutex rtp::ecs::Registry::_mutex
mutableprivate

Mutex for thread-safe operations.

Definition at line 106 of file Registry.hpp.

Referenced by kill().


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