Skip to content

SimulationHost

namespace Griff.Simulations;
public sealed class SimulationHost

What a balance simulation plays with: the game’s tables, its component types (scripts’ too), how it loads scenes and prefabs, its step rate and its script simulations. The editor makes one from the open project; a game makes one of itself with Of.

public ComponentRegistry Components { get; init; }

The component types the arena’s scene is read with (the project’s scripts’ too).

public IReadOnlyDictionary<string, IReadOnlyList<InputBinding>> Controls { get; init; }

The game’s input actions and their bindings, as the project’s Controls say, so a script asking for an action by name finds it as in Play. Nothing is ever pressed in a run; the names are what count.

public Func<string, Entity>? LoadPrefab { get; init; }

Makes an entity from a prefab by name, for what the arena’s game spawns. Called on every thread a simulation runs its fights on at once, so it must be safe to (a PrefabLibrary is).

public Func<string, Scene>? LoadScene { get; init; }

Loads a scene by name: the arena, and any scene its game loads.

public IReadOnlyList<GameModule>? Modules { get; init; }

The modules its fights run the systems of (see Modules): every one this program has if null.

public int SaveVersion { get; init; }

The version of the game’s saved games, as the project says (SaveVersion).

public IReadOnlyList<Type> ScriptTypes { get; init; }

Types that can be script simulations (classes deriving from SimulationScript), besides those beside the components.

public Func<object>? ScriptsNow { get; init; }

Says which build of the project’s scripts is running now (the editor’s: its assembly), so a run that fails while they were rebuilt under it says so. Null when the scripts can’t change under a run (a game’s).

public int StepRate { get; init; }

Steps a second of game time, as the project says.

public TableSet Tables { get; init; }

The game’s tables, as the rows and the sweeps’ steps come from them.

public static SimulationHost Of(Game game)

A host playing as game does: its tables, components, modules, scenes, prefabs and step rate.

public IReadOnlyList<Type> Scripts()

The script simulation types it knows: ScriptTypes, those in the assemblies of the components it reads, and those in an exported game’s scripts (loaded once, never swapped).