Skip to content
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

Closed
sschmid opened this issue Dec 13, 2016 · 2 comments
Assignees
Milestone

Comments

@sschmid
Copy link
Owner

sschmid commented Dec 13, 2016

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

[...] It's very convenient, but it has an overall negative effect on performance [...]

Suggestion:
Add a new interface, e.g. IFilterEntities which can be implemented by reactive systems

@sschmid sschmid changed the title [Entitas:] Add mechanism to filter entities based on values in a reactive system [Entitas:] Add mechanism to filter entities based on component values in a reactive system Dec 13, 2016
@sschmid sschmid self-assigned this Dec 13, 2016
@ghost ghost added needs review and removed in progress labels Dec 13, 2016
@sschmid
Copy link
Owner Author

sschmid commented Dec 13, 2016

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?

@sschmid sschmid added the rfc label Dec 13, 2016
@MoritzVossKing
Copy link

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).

@sschmid sschmid removed the rfc label Dec 14, 2016
@ghost ghost removed the needs review label Dec 14, 2016
sschmid added a commit that referenced this issue Dec 14, 2016
@sschmid sschmid added this to the 0.36.0 milestone Jan 6, 2017
@sschmid sschmid added this to Entitas Jul 2, 2023
@github-project-automation github-project-automation bot moved this to Todo in Entitas Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants