One part of the game I’m building to play around with Amethyst needs to maintain an index built over a particular component type. In this case, I’m keeping track of where blocks are on a Tetris board in order to detect full rows, but I’m using this as a model to try out implementation patterns (i.e, I’m interested in which patterns would work if there were a lot more items to index than there are in Tetris).
It looks like with
specs, I would put my blocks into a
FlaggedStorage, subscribe to change events, and update my index when I got a new event – the index is easy to maintain incrementally.
When a block is removed,
specs sends a
ComponentEvent::Removed. The equivalent of
FlaggedStorage in Legion is the
maybe_changed query filter. Unless I’m missing something, this will never return a removed entity (there’s no way for it to even indicate that the entity was removed).
Is there any other way to process events when components are removed? If not, I think I’ll have to either process all entities with the component, or do some manual work to maintain the index in-line when a component is removed. The latter option should work fine and is efficient, but seems like it’s blurring the lines between subsystems in exactly the way that ECS helps to avoid.
That said, I am extremely aware that automatic change detection and tracking is neither free nor easy, so I’m not going to complain too much if it’s not feasible . I was mostly wondering because it seems like a lost feature that isn’t mentioned in the Legion RFC, so I was wondering if there’s a plan to bring it back in the future, or an alternative that I missed.