Skip to content

LoadedGame

namespace Griff.Runtime;
public sealed class LoadedGame

Everything needed to start a game: its component types, its start scene, how it loads its other scenes and prefabs, and the project it came from. Every host makes its games from one (NewGame): the player, windowed and as a server, the web player, the editor’s Play and Play with Players, and a balance simulation’s fights.

public ComponentRegistry Components { get; init; }

The component types its scenes are read with (its scripts’ too).

public PrefabLibrary? Library { get; init; }

The project’s prefabs, read once each and copied for every spawn: the host’s own, kept across games (the editor’s, which reads a prefab again when it’s saved), or else one made for this game, whose prefabs never change.

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

The modules whose systems its games run (Modules): those its project uses (ProjectModules), or every one this program has if null.

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

How an entity is made from a prefab by name, if not from the project’s prefabs.

public ProblemLog Problems { get; init; }

What loading it found wrong, said once (a game doesn’t say these again).

public Project? Project { get; init; }

The project (or exported game folder) it was loaded from, whose settings, scenes and prefabs it plays with. Null for a game made of a running one’s content (a simulation’s arena), which says how it loads scenes and prefabs itself.

public Scene Scene { get; init; }

The scene it starts in.

public string? SceneName { get; init; }

The start scene’s name, for SceneName.

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

How another scene loads by name, if not from the project’s files: the editor plays the open scene as it is there, unsaved changes included.

public int StepRate { get; init; }

Steps a second of game time: the project’s, unless set.

public void Deconstruct(out Project? Project, out ComponentRegistry Components, out Scene Scene, out ProblemLog Problems)
public override bool Equals(object? obj)
public bool Equals(LoadedGame? other)
public override int GetHashCode()
public Entity LoadPrefab(string nameOrPath)

Creates an entity from one of this game’s prefabs, for PrefabLoader.

public Scene LoadScene(string nameOrPath)

Loads another scene of this game by name, for SceneLoader.

public Game NewGame(GameHostOptions? host = null)

The game at its start scene, set up for the host that plays it (host: its input, sound, saves, network and where its problems are said): its other scenes and prefabs loaded from here, its title and components, and the project’s settings (UseProjectSettings). The one way a host makes a game, so a game starts the same in the editor, exported, in a browser and in a simulation.

public override string ToString()