Class GravitasCoroutineService
Owns lockstep coroutine state for one GravitasWorldContext.
public sealed class GravitasCoroutineService
- Inheritance
-
GravitasCoroutineService
- Inherited Members
Constructors
GravitasCoroutineService(GravitasWorldContext)
Initializes a new coroutine service for the supplied context.
public GravitasCoroutineService(GravitasWorldContext context)
Parameters
contextGravitasWorldContextThe owning world context.
Properties
ActiveCoroutineCount
Gets the number of active coroutines owned by this context.
public int ActiveCoroutineCount { get; }
Property Value
Context
Gets the owning world context.
public GravitasWorldContext Context { get; }
Property Value
Methods
Deactivate()
Deactivates this coroutine service, disposes all active coroutine state, and rejects new work.
public void Deactivate()
Remarks
A manually deactivated service can be reactivated by Initialize() while its context remains active.
Initialize()
Clears context-local coroutine state and reactivates a manually deactivated service.
public void Initialize()
Exceptions
- InvalidOperationException
The service is already resetting or its context has been disposed.
Reset()
Stops all active coroutines and clears service state.
public void Reset()
Simulate()
Advances active coroutines once for the current simulation frame.
public void Simulate()
StartCoroutine(IEnumerator<ILockedYieldInstruction>)
Starts a context-local coroutine.
public LSCoroutine StartCoroutine(IEnumerator<ILockedYieldInstruction> enumerator)
Parameters
enumeratorIEnumerator<ILockedYieldInstruction>The lockstep yield instruction enumerator to run.
Returns
- LSCoroutine
The started coroutine handle.
Exceptions
- ArgumentNullException
enumeratoris null.- InvalidOperationException
The service is resetting or deactivated, or its context has been disposed.
StopCoroutine(LSCoroutine)
Stops a context-local coroutine.
public void StopCoroutine(LSCoroutine coroutine)
Parameters
coroutineLSCoroutineThe coroutine to stop.
WaitForFrames(int)
Creates a frame-count wait instruction bound to this service's context.
public WaitForFrames WaitForFrames(int frames)
Parameters
framesint
Returns
WaitForNextSimulate()
Creates a next-simulation-frame wait instruction bound to this service's context.
public WaitForNextSimulate WaitForNextSimulate()
Returns
WaitForRealSeconds(Fixed64)
Creates a fixed-duration wait instruction bound to this service's context.
public WaitForRealSeconds WaitForRealSeconds(Fixed64 seconds)
Parameters
secondsFixed64