SimulationTree.Simulation 0.3.9

Prefix Reserved
dotnet add package SimulationTree.Simulation --version 0.3.9
                    
NuGet\Install-Package SimulationTree.Simulation -Version 0.3.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimulationTree.Simulation" Version="0.3.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimulationTree.Simulation" Version="0.3.9" />
                    
Directory.Packages.props
<PackageReference Include="SimulationTree.Simulation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimulationTree.Simulation --version 0.3.9
                    
#r "nuget: SimulationTree.Simulation, 0.3.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimulationTree.Simulation@0.3.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimulationTree.Simulation&version=0.3.9
                    
Install as a Cake Addin
#tool nuget:?package=SimulationTree.Simulation&version=0.3.9
                    
Install as a Cake Tool

Simulation

Test

Library providing a way to broadcast messages to added listeners.

Running simulators

Simulators contain and update systems:

public static void Main()
{
    using Simulator simulator = new();
    simulator.Add(new ProgramSystems());
    // do work
    simulator.Remove<ProgramSystems>();
}

public class ProgramSystems : IDisposable
{
    public ProgramSystems()
    {
        //before addition
    }

    public void Dispose()
    {
        //after removal
    }
}

Receiving messages

A system that is partial, and implementing the IListener<T> interface will allow it to receive messages broadcast by the simulator:

simulator.Broadcast(32f);
simulator.Broadcast(32f);
simulator.Broadcast(32f);

public partial class ListenerSystem : IListener<float>
{
    void IListener<float>.Receive(ref float message)
    {
    }
}

Messages can also be broadcast by reference, allowing systems to modify them, and use it to communicate between different projects:

LoadRequest request = new();
simulator.Broadcast(ref request);
Assert.That(request.loaded, Is.True);

public partial class LoadSystem : IListener<LoadRequest>
{
    void IListener<float>.Receive(ref LoadRequest message)
    {
        message.loaded = true;
    }
}

public struct LoadRequest
{
    public bool loaded;
}

Global simulator

Another way to have listeners and broadcasting setup, is using the included GlobalSimulator type. This approach is slimmer than with the Simulator, at the cost of the listeners being global to the entire runtime.

public class Program
{
    public static void Main()
    {
        GlobalSimulatorLoader.Load();
        GlobalSimulator.Broadcast(32f);
        GlobalSimulator.Broadcast(32f);
        GlobalSimulator.Broadcast(32f);
    }
}

public static class Systems
{
    [Listener<float>]
    public static void Update(ref float message)
    {
    }
}

Contributing and design

This library is created for composing behaviour of programs using systems, ideally created by separate isolated projects.

Contributions to this goal are welcome.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.9 286 9/24/2025
0.3.6 370 9/15/2025