Bevy Coroutine
A simple Bevy library to run coroutines similar to Unity's coroutines.
Bevy Coroutine is very experimental and new versions may contain breaking changes !
Usage
The main motivation behind Bevy Coroutine is to allows you to spread the execution of a system across several frames. It also helps with managing and running systems in sequence over time.
use *;
use *;
Coroutines are systems. They can access any system parameter like Query
and Res
.
Coroutines don't use a 'yield' statement but instead return a CoResult
.
The CoResult
indicates if the coroutine should 'break' and stops its execution or 'continue' and be executed again at the next update.
In addition, a coroutine can run other coroutines and wait for their completion by adding them as subroutines to the CoResult
.
The state of execution of your coroutine can be stored between frames using Local
s as parameters in the coroutine system.
use *;
use *;
Performance
Each coroutine run in an exclusive system. They won't run in parallel with each other nor with other bevy systems.
For CPU intensive tasks, consider using bevy_tasks or bevy_defer.
Versions
bevy | bevy_coroutine |
---|---|
0.16 | 0.3.0 |
0.15 | 0.2.0 |
0.14 | 0.1.3 |
0.14 | 0.1.2 |
0.14 | 0.1.1 |
0.14.0-rc.4 | 0.1.0 |