Closed sschmid closed 7 years ago
Hi, I added IFilterEntities
Initially, this should enable us to filter entities based on component values, e.g.
public class KillSystem : IReactiveSystem, IFilterEntities {
public TriggerOnEvent trigger { get { return CoreMatcher.Health.OnEntityAdded(); } }
public bool filter(Entity entity) {
return entity.health.value <= 0;
}
public void Execute(List<Entity> entities) {
foreach(var e in entities) {
// no need to check for health here anymore, yay
e.flagDestroy = true;
}
}
}
Basically, IFilterEntities
can now potentially replace the other existing interfaces IEnsureComponents
and IExcludeComponents
, since we can now express that in one simple filter(entity)
method. This will also simplify the internal implementation of ReactiveSystem since we only have to check on single method now.
I'm thinking of deprecating IEnsureComponents
and IExcludeComponents
in favour of IFilterEntities
.
What do you guys think?
If this O(n) filter implementation scales equally well as IEnsureComponents did, sure!
In a recent gamejam project, I actually had to create an "Impassible" negative entity because IEnsureComponents couldn't reliably filter based on some external rules (a boolean array containing a collision map).
This issue attempts to provide a solution for #165 History: PR #189 added filter condition to matchers After implementing a solution I removed it in a future version, see #190
Suggestion: Add a new interface, e.g.
IFilterEntities
which can be implemented by reactive systems