bevy_ecs_tilemap icon indicating copy to clipboard operation
bevy_ecs_tilemap copied to clipboard

Get by Entity functions for MapQuery

Open Seldom-SE opened this issue 4 years ago • 1 comments

For my game, I need to be able to get a Layer (for its LayerSettings) by its Entity, in the same system where I'm using MapQuery, but I cannot do so, since Query<&Layer> conflicts with MapQuery. I've added functions to MapQuery to get Layers by their Entitys, mutably or immutably. I also added similar functions for Maps and Chunks, since a similar problem could occur with those.

Alternatively, in my game, I could store my Layers' u16 IDs in the place of their Entitys, but I did not want to have to use MapQuery in systems that do not need it, for the sake of better parallelism, and I didn't think such a restriction was intended, so I decided to suggest the addition of these functions. Also, I wanted to avoid the O(N) operations of finding layers by ID.

Another solution could be to add some sort of variant of Commands (MapCommands?), replacing the need for mutable Querys in MapQuery, and avoiding this issue, as long as the user does not need to mutably query Layers, etc. This would take significantly more work.

Lmk if a different solution is desired. Also lmk if this solution is desired, because I have only slightly tested that these functions work.

Thank you!

Seldom-SE avatar Dec 12 '21 03:12 Seldom-SE

This looks fine as is.

StarArawn avatar Dec 21 '21 20:12 StarArawn