Event Requeuing (EventReader/EventWriter) #2442
-
I'm curious how to go about requeuing events with EventReader/EventWriter. For example, I made snake as a "learn bevy" project and got everything working. I then decided I wanted to add fruits that do different things and my first one was, grow 3 instead of 1. The way I originally planned to do this was by queuing a Grow(3) event where struct Grow (i32) is the event type. Then when I read that event, I grow and queue a new event Grow(2) and so on until I have no grow amount left. I ran into the issue that you cannot send mut EventReader and mut EventWriter to a system and will cause a runtime panic. I'm curious what the ideal/expected solution for this would be if anyone knows. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can work with |
Beta Was this translation helpful? Give feedback.
-
I ran into the same issue with my learning project as well, I suggest using components for delayed elements instead of events. |
Beta Was this translation helpful? Give feedback.
You can work with
ManualEventReader<T>
(I think) or the rawResMut<Events<T>>
to do this. This isn't the first time this has come up; I think there should be an example demonstrating this functionality.