feat(ecs): introduce component view

Closes: #1
This commit is contained in:
2026-09-07 23:05:39 +02:00
parent 320eb29957
commit 6639127bcf
4 changed files with 285 additions and 2 deletions
+7
View File
@@ -1,6 +1,7 @@
#ifndef LIBCATBOY_ECS_ECS_HPP
#define LIBCATBOY_ECS_ECS_HPP
#include "component_view.hpp"
#include "fwd.hpp"
#include "sparseSet.hpp"
@@ -83,6 +84,12 @@ public:
if (m_alive.find(entity) == m_alive.end()) throw std::runtime_error("entity is dead");
get_set<T>().erase(entity);
}
public:
template <typename... Sum>
requires(sizeof...(Sum) >= 1)
component_view<Entity, Sum...> view() {
return { { (&get_set<Sum>())... } };
}
private:
template <typename T>
sparse_set<T>& get_set() {