Files
esengine/source/src/ECS/Utils/Matcher.ts

26 lines
747 B
TypeScript
Raw Normal View History

2020-06-08 18:26:05 +08:00
class Matcher{
2020-06-08 20:11:58 +08:00
protected allSet = new BitSet();
protected exclusionSet = new BitSet();
protected oneSet = new BitSet();
2020-06-08 18:26:05 +08:00
public static empty(){
return new Matcher();
}
2020-06-08 20:11:58 +08:00
public IsIntersted(e: Entity){
if (!this.allSet.isEmpty()){
for (let i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)){
if (!e.componentBits.get(i))
return false;
}
}
if (!this.exclusionSet.isEmpty() && this.exclusionSet.intersects(e.componentBits))
return false;
if (!this.oneSet.isEmpty() && !this.oneSet.intersects(e.componentBits))
return false;
return true;
}
2020-06-08 18:26:05 +08:00
}