3#include <unordered_map>
15 template <Val
idEntity EntityType,
size_t pool_size>
25 : m_sparseSets{sparseSets}, m_leadSet(leadSet), m_lead_iterator(leadIter)
66 return (m_lead_iterator == other.m_lead_iterator);
71 return (!(*
this == other));
76 return *m_lead_iterator;
81 bool all_of(EntityType
entity)
83 for (
auto & set : m_sparseSets)
85 if (!set->contains(
entity))
93 while(m_lead_iterator != m_leadSet->end() && !all_of(*m_lead_iterator))
99 while (m_lead_iterator != m_leadSet->begin() && !all_of(*m_lead_iterator))
108 template <ValidEntity EntityType,
typename... ComponentTypes>
114 typedef std::array<std::shared_ptr<entitySet>,
sizeof... (ComponentTypes)>
entitySetArray;
120 auto func = [&]<
typename ComponentType>()
123 std::shared_ptr<ComponentSet> set = storage.template getSetPtr<ComponentType>();
125 m_sparseSets[index::template get<ComponentType>()] = set;
127 (func.template operator()<ComponentTypes>(), ...);
136 m_sparseSets = other.m_sparseSets;
141 m_sparseSets = std::move(other.m_sparseSets);
147 m_sparseSets = other.m_sparseSets;
153 m_sparseSets = std::move(other.m_sparseSets);
163 return iterator(m_sparseSets, m_sparseSets[m_lead], m_sparseSets[m_lead]->
begin());
168 return iterator(m_sparseSets, m_sparseSets[m_lead], m_sparseSets[m_lead]->
end());
176 size_t min = std::numeric_limits<size_t>::max();
177 for (
size_t i = 0; i < m_sparseSets.size(); i++)
179 auto set = m_sparseSets[i];
180 if (set->size() < min)
Definition: ComponentStorage.hpp:12
This class is the main class of the ECS system you can use it to create entitites,...
Definition: Manager.hpp:34
Definition: SparseSet.hpp:20
dense_type::iterator iterator
Definition: SparseSet.hpp:26
entitySet::iterator entityIterator
Definition: View.hpp:20
ViewIterator & operator=(ViewIterator &&other)=default
~ViewIterator()
Definition: View.hpp:30
bool operator==(const ViewIterator &other) const
Definition: View.hpp:64
ViewIterator & operator--()
Definition: View.hpp:50
ViewIterator operator++(int)
Definition: View.hpp:43
ViewIterator operator--(int)
Definition: View.hpp:57
ViewIterator(const ViewIterator &other)=default
bool operator!=(const ViewIterator &other) const
Definition: View.hpp:69
SparseSet< EntityType > entitySet
Definition: View.hpp:19
EntityType operator*()
Definition: View.hpp:74
ViewIterator(ViewIterator &&other)=default
ViewIterator & operator=(const ViewIterator &other)=default
ViewIterator(SparseSetArray &sparseSets, SparseSetPtr leadSet, entityIterator leadIter=entityIterator())
Definition: View.hpp:24
std::shared_ptr< entitySet > SparseSetPtr
Definition: View.hpp:21
std::array< SparseSetPtr, pool_size > SparseSetArray
Definition: View.hpp:22
ViewIterator & operator++()
Definition: View.hpp:36
~View()
Definition: View.hpp:133
View(Manager< EntityType > &storage)
Definition: View.hpp:117
View(View &&other)
Definition: View.hpp:139
View & operator=(View &&other)
Definition: View.hpp:151
IndexOf< ComponentTypes... > index
Definition: View.hpp:113
View(const View &other)
Definition: View.hpp:134
View()
Definition: View.hpp:132
View & operator=(const View &other)
Definition: View.hpp:145
iterator begin()
Definition: View.hpp:160
ViewIterator< EntityType, sizeof...(ComponentTypes)> iterator
Definition: View.hpp:115
std::array< std::shared_ptr< entitySet >, sizeof...(ComponentTypes)> entitySetArray
Definition: View.hpp:114
iterator end()
Definition: View.hpp:166
SparseSet< EntityType > entitySet
Definition: View.hpp:112
Definition: ComponentStorage.hpp:9
uint32_t entity
Definition: ecs_CONSTANTS.hpp:10
Definition: ecs_utils.hpp:18