KernelAPI reference
Class FrameClock
Namespace: MicroEngine.Kernel
Assembly: MicroEngine.Kernel.dll
Guide: Modules and the frame schedule
The loop’s clock: turns the time each frame stands for into fixed steps, following TimeSettings. The platform only supplies a monotonic clock; how much simulated time a frame adds, how many steps it runs, how far a slow frame catches up and the interpolation blend are decided here, the same way on every backend.
public sealed class FrameClockInheritance
Remarks
One frame is: BeginFrame with the frame’s elapsed time, TryStep until it returns false (or until the caller stops early), then EndSteps.
clock.BeginFrame(clock.ClampElapsed(now - last));while (clock.TryStep(out var step)) schedule.Run(FramePhase.FixedUpdate, step);clock.EndSteps();Constructors
FrameClock(TimeSettings)
A clock following settings.
public FrameClock(TimeSettings settings)Parameters
settings TimeSettings
Exceptions
settings is null.
A setting is out of range (Validate).
Properties
Blend
The current frame’s interpolation blend, set by EndSteps (Blend).
public float Blend { get; }Property Value
Context
The frame’s context for the phases that run once per frame.
public FrameContext Context { get; }Property Value
Delta
Seconds the current frame stands for (Delta).
public double Delta { get; }Property Value
FixedDelta
Seconds of one fixed step.
public double FixedDelta { get; }Property Value
FixedStep
Fixed steps completed so far.
public long FixedStep { get; }Property Value
Frame
Frames begun so far; the current frame’s number while one runs.
public long Frame { get; }Property Value
Mode
Whether time follows the wall clock or advances one step per frame.
public TimeMode Mode { get; }Property Value
Pending
Time added but not simulated yet, in seconds.
public double Pending { get; }Property Value
Settings
The policy this clock follows.
public TimeSettings Settings { get; }Property Value
StepsThisFrame
Steps run in the current frame.
public int StepsThisFrame { get; }Property Value
Methods
BeginFrame(double)
Starts a frame. In real time, elapsed seconds are added to the pending time (pass a value already
limited by ClampElapsed; negative values count as 0); in deterministic time exactly one step is added
and elapsed is ignored.
public void BeginFrame(double elapsed)Parameters
elapsed double
ClampElapsed(double)
The time a real-time frame may stand for: elapsed limited to 0..MaxFrameDelta.
The loop applies it to the time it measured before pacing that time to the display.
public double ClampElapsed(double elapsed)Parameters
elapsed double
Returns
DiscardPending()
Forgets the pending time, so time spent away (a suspended app) is not simulated when it comes back.
public void DiscardPending()EndSteps()
Ends the frame’s steps. A frame that ran MaxStepsPerFrame steps keeps at most one step pending (the rest is dropped: the game slows down rather than falling further behind). Then sets Blend: the pending fraction of a step in real time, 1 in deterministic time.
public void EndSteps()TryStep(out FrameContext)
Takes the next fixed step if one is due and the frame has not run MaxStepsPerFrame
yet. The caller runs the fixed phases with step when it returns true.
public bool TryStep(out FrameContext step)Parameters
step FrameContext
The step’s context: FixedStep is the index of this step, Blend is 0.