GameModule
namespace Griff.Runtime;
public abstract class GameModuleA part of Griff that lives in a place of its own: a folder under src/Modules with a namespace to match (Griff.Modules.Match3), holding everything of a genre such as Match-3 or Strategy. Its running parts (components, systems, drawing, network state) are an assembly of their own, Griff.Modules.Match3, built on Griff alone; its editor parts (templates and their art, the entities the editor’s Entity menu makes) are another in its Editor folder, Griff.Modules.Match3.Editor. Griff names no module, and no module another. Most of a module is found by type: its components (and how they draw and what they send), its templates (Griff.Templates.ProjectTemplate) and its Entity menu presets (Griff.Editing.EntityPreset). What can’t be found is how it runs, which the module registers once, in AddTo: its systems, where their steps go in the frame, and what players’ machines may ask its host to do. Modules are found from the module assemblies a program has (see All and ModuleAssemblies), so adding one is adding a folder with a module class and its two projects in it; a game builds the systems of the modules it uses (Modules), and an export carries only those.
Properties
Section titled “Properties”public static IReadOnlyList<GameModule> All { get; }Every module this program has (those in All), by name. A game adds the systems of those it uses in this order (see AddTo).
public abstract string Name { get; }What it’s called, e.g. “Match-3”.
Namespace
Section titled “Namespace”public string Namespace { get; }The namespace its types are in: the module class’s own. Types in it, or in one inside it, belong to the module.
Methods
Section titled “Methods”protected internal abstract void AddTo(GameSetup game)Adds what the module runs to a game as it’s made: its systems (AddSystem), each step of theirs next to the step of the frame it has to follow or go before (StepAfter), and the commands players’ machines send the host (OnNetCommand) and the host sends a player’s machine (OnHostCommand).
AddToWarmUp
Section titled “AddToWarmUp”public virtual void AddToWarmUp(Scene scene, bool turning)Adds the module’s part to a scene a host plays out of sight before a game starts, so the code a game of it runs is ready when the game begins (the web player’s warm-up, whose interpreter prepares each method the first time it’s called): things of the module’s that a game’s first moments set going. turning is true for a game with bodies that turn, whose first collapse the warm-up plays (Griff adds a bin of tumbling shapes for it). Most modules add nothing.
public static GameModule? Named(string name)The module named name (“Match-3”), or null if this program hasn’t one.
public static GameModule? Of(Type type)The module type belongs to (by its namespace), or null for one of the core’s.
public static GameModule? Of(string? ns)The module whose namespace is ns or holds it, or null.
ToString
Section titled “ToString”public override string ToString()