add Filter.NthEntity
parent
bb359d339b
commit
a9032603ec
|
@ -185,6 +185,11 @@ namespace MoonTools.ECS
|
|||
}
|
||||
}
|
||||
|
||||
public Entity FilterNthEntity(Filter filter, int index)
|
||||
{
|
||||
return new Entity(filterSignatureToEntityIDs[filter.Signature][index]);
|
||||
}
|
||||
|
||||
public Entity FilterRandomEntity(Filter filter)
|
||||
{
|
||||
var randomIndex = RandomGenerator.Next(FilterCount(filter));
|
||||
|
|
|
@ -20,5 +20,8 @@ namespace MoonTools.ECS
|
|||
|
||||
public int Count => ComponentDepot.FilterCount(this);
|
||||
public bool Empty => Count == 0;
|
||||
|
||||
// WARNING: this WILL crash if the index is out of range!
|
||||
public Entity NthEntity(int index) => ComponentDepot.FilterNthEntity(this, index);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue