add Exists API call to check if entity exists
parent
24455bcaed
commit
323fb0e209
|
@ -51,4 +51,9 @@ public abstract class EntityComponentReader
|
|||
{
|
||||
return ref ComponentDepot.GetEntity<TComponent>();
|
||||
}
|
||||
|
||||
protected bool Exists(in Entity entity)
|
||||
{
|
||||
return EntityStorage.Exists(entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,11 @@ internal class EntityStorage
|
|||
return new Entity(idStorage.NextID());
|
||||
}
|
||||
|
||||
public bool Exists(in Entity entity)
|
||||
{
|
||||
return idStorage.Taken(entity.ID);
|
||||
}
|
||||
|
||||
public void Destroy(in Entity entity)
|
||||
{
|
||||
idStorage.Release(entity.ID);
|
||||
|
|
|
@ -20,6 +20,11 @@ internal class IDStorage
|
|||
}
|
||||
}
|
||||
|
||||
public bool Taken(int id)
|
||||
{
|
||||
return !availableIDs.Contains(id) && id < nextID;
|
||||
}
|
||||
|
||||
public void Release(int id)
|
||||
{
|
||||
availableIDs.Push(id);
|
||||
|
|
Loading…
Reference in New Issue