28 lines
871 B
C#
28 lines
871 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MoonTools.ECS
|
|
{
|
|
public class Filter
|
|
{
|
|
internal FilterSignature Signature;
|
|
private ComponentDepot ComponentDepot;
|
|
|
|
internal Filter(ComponentDepot componentDepot, HashSet<Type> included, HashSet<Type> excluded)
|
|
{
|
|
ComponentDepot = componentDepot;
|
|
Signature = new FilterSignature(included, excluded);
|
|
}
|
|
|
|
public IEnumerable<Entity> Entities => ComponentDepot.FilterEntities(this);
|
|
public IEnumerable<Entity> EntitiesInRandomOrder => ComponentDepot.FilterEntitiesRandom(this);
|
|
public Entity RandomEntity => ComponentDepot.FilterRandomEntity(this);
|
|
|
|
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);
|
|
}
|
|
}
|