I need it to pause on both update and fixed update as the user wishes
I should pause before the events happen
How to pause
I already have code to pause MonoBehaviour so I can use this to pause and unpause the game
On PreUpdate, before any UniTAS operation is done, check if game needs to be paused or not
How to unpause
I need to sync update offset with when it was paused
For example, if paused before FixedUpdate, this means FixedUpdate has yet to run and (assuming update happens with perfect timing), the offset would be 0
By reusing code that I use to restart the game, I should be able to sync the update timing to the right offset and continue running the game
While paused
Keep fps at config's fallback fps value as unpausing will handle the update offset problem
Pause state tracking
I could have an enum of the timing of when the pause happened
So either Update or FixedUpdate in my case
Pausable coroutines
I need to track all running coroutines
What I could do is modify IEnumerator firstly to not run MoveNext when paused (which doesn't update Current so I have control over that)
Coroutines have a Current to express what is the next wait period, so while paused, I can force return this property to whatever is the next coroutine yield (like for update pause, yield null) for all coroutines
So when pause happens, I need to store all Current for the coroutines for restoration later on
MoveNext can be invoked by unity specified by the event execution order
As for WaitForSeconds and WaitForSecondsRealTime, because these callbacks only happen after some time, i can't "pause" them so I have to modify their behaviour to be the exact same BUT waiting for n frames instead with a custom tracker for this
For WaitUntil and WaitWhile, I need to figure out timing on when they get yielded, but they should work fine with the normal hijacking as they just check for a condition and while paused, nothing should change
Tasks
[ ] #258
[x] what's the timing on WaitUntil yield
[x] what's the timing on WaitWhile yield
yield null -> yield WaitUntil -> yield WaitWhile
[ ] #259
[x] pause and resume with proper update offset
[x] implement
[x] test
[x] UpdateActual test class
[x] test unity project
[ ] #257
[ ] some parts of TimeEnv isn't paused, frame count and offset related trackers
I modified ISyncFixedUpdateCycle.OnSync to also allow for waiting at any index of FixedUpdate too
[x] Test ingame with logs
[x] Test with tests debug prints with UniTAS and watch out offset
When to pause
update
andfixed update
as the user wishesHow to pause
MonoBehaviour
so I can use this to pause and unpause the gameHow to unpause
While paused
Pause state tracking
Update
orFixedUpdate
in my casePausable coroutines
MoveNext
when paused (which doesn't updateCurrent
so I have control over that)Current
to express what is the next wait period, so while paused, I can force return this property to whatever is the next coroutine yield (like for update pause, yield null) for all coroutinesCurrent
for the coroutines for restoration later onMoveNext
can be invoked by unity specified by the event execution orderWaitForSeconds
andWaitForSecondsRealTime
, because these callbacks only happen after some time, i can't "pause" them so I have to modify their behaviour to be the exact same BUT waiting for n frames instead with a custom tracker for thisWaitUntil
andWaitWhile
, I need to figure out timing on when they get yielded, but they should work fine with the normal hijacking as they just check for a condition and while paused, nothing should changeTasks
WaitUntil
yieldWaitWhile
yieldyield null
->yield WaitUntil
->yield WaitWhile
TimeEnv
isn't paused, frame count and offset related trackersI modified
ISyncFixedUpdateCycle.OnSync
to also allow for waiting at any index ofFixedUpdate
too