sschmid/Entitas

Can ReactiveSystem only react to part of the component in the group?

eterlan opened this issue · 1 comments

Hi guys! Want some help. Do you know how to create collector for reactiveSystem which only respond on part of the group? For example, a group has humanTag and velocity, I only want the system only react to when velocity change.

Hi @eterlan!
You can use velocity as a trigger and filter for humanTag

protected override ICollector<GameEntity> GetTrigger(IContext<GameEntity> context) =>
    context.CreateCollector(Velocity);

protected override bool Filter(GameEntity entity) => entity.hasVelocity && entity.isHuman;