-some usefull functions for IDManager
-added EntityManager.removeEntity(EntityID) -EntitiesBlock now has ID usefull for updating first_free_block in EntityInfo
This commit is contained in:
parent
ae53e13d42
commit
d3222eefbb
4 changed files with 109 additions and 25 deletions
|
|
@ -30,6 +30,19 @@ struct IDManager
|
|||
m_ids_array[entity.id.id].entity = &entity;
|
||||
}
|
||||
|
||||
Entity* getEntityPointer(EntityID id)
|
||||
{
|
||||
Data* data = &m_ids_array[id.id];
|
||||
if(data.counter != id.counter)return null;
|
||||
else return data.entity;
|
||||
}
|
||||
|
||||
bool isExist(EntityID id)
|
||||
{
|
||||
Data* data = &m_ids_array[id.id];
|
||||
return data.counter == id.counter;
|
||||
}
|
||||
|
||||
struct Data
|
||||
{
|
||||
uint counter = 0;
|
||||
|
|
@ -61,5 +74,7 @@ unittest
|
|||
assert(id1 == EntityID(1,2));
|
||||
assert(id2 == EntityID(0,2));
|
||||
assert(id3 == EntityID(2,1));
|
||||
assert(manager.isExist(id3));
|
||||
assert(!manager.isExist(EntityID(0,1)));
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue