-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Entitas:] Add mechanism to filter entities based on component values in a reactive system #234
Comments
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, I'm thinking of deprecating 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 systemsThe text was updated successfully, but these errors were encountered: