55// /
66
77#include " EntityFu.h"
8+ #include < algorithm>
89using namespace std ;
910
1011// / Turn this on to have a faster yet riskier ECS.
@@ -136,7 +137,7 @@ void Entity::addComponent(Cid cid, Eid eid, Component* c)
136137 }
137138 if (verbosity > 0 )
138139 {
139- Log (" " );
140+ Log (" " );
140141 Entity::log (cid);
141142 Log (" Adding component cid %u eid %u (%x)" , cid, eid, (int )(long )c);
142143 }
@@ -171,7 +172,7 @@ void Entity::removeComponent(Cid cid, Eid eid)
171172
172173 if (verbosity > 1 )
173174 {
174- Log (" " );
175+ Log (" " );
175176 Entity::log (cid);
176177 Log (" Removing component cid %u eid %u (%x)" , cid, eid, (int )(long )ptr);
177178 }
@@ -217,7 +218,7 @@ const vector<Eid>& Entity::getAll(Cid cid)
217218unsigned Entity::count ()
218219{
219220 int ret = 0 ;
220- if (entities != nullptr )
221+ if (entities != nullptr )
221222 {
222223 for (Eid eid = 1 ; eid < kMaxEntities ; ++eid)
223224 if (entities[eid])
@@ -226,14 +227,14 @@ unsigned Entity::count()
226227 return ret;
227228}
228229
229- bool Entity::exists (Eid eid )
230+ unsigned Entity::count (Cid cid )
230231{
231- return entities != nullptr && entities[eid] ;
232+ return ( unsigned ) Entity::getAll (cid). size () ;
232233}
233234
234- unsigned Entity::count (Cid cid )
235+ bool Entity::exists (Eid eid )
235236{
236- return ( unsigned ) Entity::getAll (cid). size () ;
237+ return entities != nullptr && entities[eid] ;
237238}
238239
239240void Entity::log (Cid cid)
0 commit comments