Table of Contents

Class Simulation

Namespace
SimulationFramework
Assembly
SimulationFramework.dll

e The base class for all simulations. Inherit this class or use Create(Action?, Action<ICanvas>?) to create a simulation.

public abstract class Simulation
Inheritance
Simulation
Inherited Members

Methods

Create(Action?, Action<ICanvas>?)

Creates a Simulation from callbacks.

public static Simulation Create(Action? initialize, Action<ICanvas>? render)

Parameters

initialize Action

Called once when the simulation should initialize.

render Action<ICanvas>

Called every frame when the simulation should render.

Returns

Simulation

A new Simulation which calls the given delegates.

CreateAndRun(Action?, Action<ICanvas>?)

Creates a simulaton from callbacks, and then runs it, automatically determining the platform.

public static void CreateAndRun(Action? initialize, Action<ICanvas>? render)

Parameters

initialize Action

Called once when the simulation should initialize.

render Action<ICanvas>

Called every frame when the simulation should render.

CreateAndRun(Action?, Action<ICanvas>?, ISimulationPlatform?)

Creates a simulaton from callbacks, and then runs it using the provided platform

public static void CreateAndRun(Action? initialize, Action<ICanvas>? render, ISimulationPlatform? platform)

Parameters

initialize Action

Called once when the simulation should initialize.

render Action<ICanvas>

Called every frame when the simulation should render.

platform ISimulationPlatform

The platform to run the simulation on. If this value is null, the platform is automatically determined.

OnButtonPressed(MouseButton)

Called when a button is pressed on the mouse.

public virtual void OnButtonPressed(MouseButton button)

Parameters

button MouseButton

The button that was pressed.

OnButtonReleased(MouseButton)

Called when a button is released on the mouse.

public virtual void OnButtonReleased(MouseButton button)

Parameters

button MouseButton

The button that was released.

OnInitialize()

Called when the simulation should initialize.

public abstract void OnInitialize()

OnKeyPressed(Key)

Called when a key is pressed on the keyboard.

public virtual void OnKeyPressed(Key key)

Parameters

key Key

The key that was pressed.

OnKeyReleased(Key)

Called when a key is released on the keyboard.

public virtual void OnKeyReleased(Key key)

Parameters

key Key

The key that was released.

OnKeyTyped(char)

Called when a key is typed. This is usually used for text input.

public virtual void OnKeyTyped(char character)

Parameters

character char

The character that was typed.

OnRender(ICanvas)

Called when the simulation should render.

public abstract void OnRender(ICanvas canvas)

Parameters

canvas ICanvas

OnResize(int, int)

Called when the simulation's video output is resized.

public virtual void OnResize(int width, int height)

Parameters

width int

The new width of the simulation's video output.

height int

The new height of the simulation's video output.

OnUninitialize()

Called when the simulation should uninitialize.

public virtual void OnUninitialize()

Run()

Runs the simulation, automatically determining a platform.

public void Run()

Run(ISimulationPlatform?)

Runs the simulation using the provided platform.

public void Run(ISimulationPlatform? platform)

Parameters

platform ISimulationPlatform

The platform to run the simulation on. If this value is null, the platform is automatically determined.

SetFixedResolution(int, int, Color, bool, bool, bool)

Configures the simulation to render to an fixed-size off-screen texture then render that to fit the window.

public void SetFixedResolution(int width, int height, Color backgroundColor, bool transparent = false, bool subpixelInput = false, bool stretchToFit = false)

Parameters

width int

The width of the off-screen texture.

height int

The height of the off-screen texture.

backgroundColor Color

The color to fill the window area not covered by the texture.

transparent bool

Whether the framebuffer should be rendered to the window with transparency.

subpixelInput bool

Whether resolution dependent input values (such as Position) should report values more precise than one pixel (when possible).

stretchToFit bool

Whether the off-screen texture should be stretched to fit the window.

Start<TSimulation>()

Runs a simulation of the given type, automatically determining a platform. This method initializes a SimulationHost before creating the simulation so that the constructor of TSimulation can use SimulationFramework components (like Time and Graphics).

public static void Start<TSimulation>() where TSimulation : Simulation, new()

Type Parameters

TSimulation

The type of simulation to run.

Start<TSimulation>(ISimulationPlatform?)

Runs a simulation of the given type using the provided platform. This method initializes a SimulationHost before creating the simulation so that the constructor of TSimulation can use SimulationFramework components (like Time and Graphics).

public static void Start<TSimulation>(ISimulationPlatform? platform) where TSimulation : Simulation, new()

Parameters

platform ISimulationPlatform

The platform to run the simulation on. If this value is null, the platform is automatically determined.

Type Parameters

TSimulation

The type of simulation to run.