I'm trying to wrap my head around ECS for toy projects, and have run into an issue a couple of times that I'm having trouble solving. I'm not a purist, but would still like to know how to deal with this.
At a high level, how do I create a system where one type (entity with a specific component) has a specific effect on another type (entity with some other component), when systems in most ECS implementations are designed to process a single flat list of entities with one or more matching components.
Examples:
Most recently, I had an object which reduces the player speed (and other types of entities) when they're nearby, based on proximity.
I have two components, one indicating that it makes other entities slow (slow_emitter or some such), and another indicating that an entity may be affected by this slowness (slow_receiver).
In a non-ecs system, I might loop over every slow_emitter, and apply some effect to each slow_receiver based on range.
A similar issue might be: When a player is nearby a button and presses the 'use' key, something should happen. An input component might be responsible for marking the player as `using`. Any entity with the `button` component, within some range of an entity with the `using` component should activate. This probably makes more sense as an 'event', but shows the issue.
Hope that makes sense.
Context: This is a love2d game. My components and entities are simple data objects.