Hi- I've made a change to my app where instead of directly changing its main State<T>, I defer that to a system update_state() that runs in a specific stage (1), in an attempt to limit the random points where the app can change state.
Unfortunately, now there's (randomly, race condition; sometimes it works, sometimes not) several systems scheduled for on_update() running before the system scheduled for the on_enter() of the same State<T>, which causes obvious issues/crashes.
(1) It doesn't seem to matter when the update_state() system is scheduled; I've tried CoreStage::First, CoreStage::Update, and CoreStage::Last, and tried at_start(), at_end() and nothing (unspecified). In all cases I have random crashes.
a. I don't understand why this makes any difference with directly changing the State<T>?
b. I suspect that the on_enter() somehow "misses" the state change and gets skipped if the associated system doesn't run in the same stage as update_state().
c. All of that looks extremely brittle. Can we only change a State<T> in a single stage?