Skip to content

KernelAPI reference

Class CoroutineRunner

Namespace: MicroEngine.Scenes
Assembly: MicroEngine.dll
Guide: Scenes

Runs iterator-based sequences one step per update. A coroutine may yield null (next update), Seconds, Until or another IEnumerator (awaited as a sub-routine). Ideal for cutscenes, dialogue flow and timed effects without hand-written state machines.

C#
public sealed class CoroutineRunner : IStateHashed

Inheritance

object ← CoroutineRunner

Implements

IStateHashed

Constructors

CoroutineRunner()

C#
public CoroutineRunner()

Properties

Count

Number of coroutines that are running or waiting to start.

C#
public int Count { get; }

Property Value

int

Methods

HashState(StateHasher)

Adds the runner’s state to the per-step state hash: for each coroutine, running or waiting to start, its nesting depth, the seconds left to wait and whether it waits for a condition. The iterators’ own variables are not visible to it; a scene adds the state its coroutines change from its own HashState.

C#
public void HashState(StateHasher hash)

Parameters

hash StateHasher

Start(IEnumerator)

Starts a coroutine. Its first step runs on the next Update, not immediately.

C#
public CoroutineHandle Start(IEnumerator routine)

Parameters

routine IEnumerator

The iterator, usually from a method that uses yield return.

Returns

CoroutineHandle

A handle to cancel the coroutine or check whether it finished.

Exceptions

ArgumentNullException

routine is null.

StopAll()

Stops every coroutine, including those started but not yet run.

C#
public void StopAll()

Update(float)

Advances every coroutine by one step. A scene calls this for its own Coroutines; call it yourself only for a runner you created.

C#
public void Update(float dt)

Parameters

dt float

Elapsed time in seconds, consumed by Seconds.

Exceptions

InvalidOperationException

A coroutine yielded a value other than null, a wait instruction or an IEnumerator.