KernelAPI reference
Class EngineBuilder
Namespace: MicroEngine.Kernel
Assembly: MicroEngine.Kernel.dll
Guide: Modules and the frame schedule
Composes an Engine: modules are added in order, each registering services, frame systems and capabilities; settings records are edited; Build then fixes the schedule and the time policy. Nothing is discovered by reflection.
public sealed class EngineBuilderInheritance
Examples
var builder = new EngineBuilder() .Configure<TimeSettings>(time => time with { FixedRate = 120 }) .Add(new PhysicsModule());builder.Schedule.Add(FramePhase.Update, "mygame.camera", frame => camera.Follow(frame.Blend));Engine engine = builder.Build();Constructors
EngineBuilder()
public EngineBuilder()Properties
Capabilities
The optional features declared so far (CapabilityRegistry).
public CapabilityRegistry Capabilities { get; }Property Value
Lifecycle
The engine’s events; modules may subscribe while they are configured.
public EngineLifecycle Lifecycle { get; }Property Value
Schedule
The frame systems, by phase (FrameSchedule).
public FrameSchedule Schedule { get; }Property Value
Services
The services modules register and read (ServiceRegistry).
public ServiceRegistry Services { get; }Property Value
Methods
Add<TModule>(TModule)
Adds module and runs its Configure now.
public EngineBuilder Add<TModule>(TModule module) where TModule : IEngineModuleParameters
module TModule
Returns
This builder, to chain calls.
Type Parameters
TModule
Exceptions
module is null.
A module of the same type was already added, or the engine was built.
Build()
Builds the engine, once. Registers the defaults of what nobody registered (TimeSettings, a ConsoleLog as ILog, the lifecycle as IEngineLifecycle), resolves and fixes the frame schedule and creates the loop’s FrameClock.
public Engine Build()Returns
Exceptions
The engine was already built, or the schedule’s order cannot be resolved (a cycle, or a constraint naming a missing system or one in another phase).
A TimeSettings value is out of range.
Configure<TSettings>(Func<TSettings, TSettings>)
Edits the settings record TSettings: edit receives the current value
(Settings``1) and returns the new one, which becomes the registered service. Settings are
values: the engine reads them once, when it is built.
public EngineBuilder Configure<TSettings>(Func<TSettings, TSettings> edit) where TSettings : class, new()Parameters
edit Func<TSettings, TSettings>
Returns
This builder, to chain calls.
Type Parameters
TSettings
Exceptions
edit is null.
edit returned null, or the engine was built.
HasModule<TModule>()
Whether a module of type TModule was added.
public bool HasModule<TModule>() where TModule : IEngineModuleReturns
Type Parameters
TModule
Settings<TSettings>()
The settings record TSettings as configured so far: the registered service, or a new
instance with its defaults when none was registered.
public TSettings Settings<TSettings>() where TSettings : class, new()Returns
TSettings
Type Parameters
TSettings