sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7k stars 1.11k forks source link

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

Closed eterlan closed 1 year ago

eterlan commented 1 year ago

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.

sschmid commented 1 year ago

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;