GameSystem
namespace Griff.Runtime;
public abstract class GameSystem : IKeepsStateOne part of what the game does each frame, run in its Phase after Griff’s own steps there. A script adds one with AddSystem (it stops when that script’s entity goes) or AddSystem (for the rest of the game). A game has one system of each type: adding another replaces it. Override Update to do something every frame, for a whole kind of thing at once; something the system keeps track of in a scene is forgotten in SceneChanged. Override Draw to draw what the system knows of that no one entity draws (a HUD, markers over things); an entity’s own look is a component’s (see IDrawable).
Properties
Section titled “Properties”protected Game Game { get; }The game the system runs in. Available once it’s added.
public virtual string Name { get; }What the frame calls the system’s step (see Frame); its type’s name unless it says.
public Behavior? Owner { get; }The script whose entity the system goes away with, if a script added it.
public virtual FramePhase Phase { get; }The phase Update runs in; Logic unless the system says.
Tables
Section titled “Tables”protected TableSet Tables { get; }The game’s tables (see Tables).
protected Time Time { get; }Methods
Section titled “Methods”protected virtual void Draw(FrameDrawing frame)Called as each frame is drawn, after every entity has drawn itself and the systems before this one have drawn, to add to what’s drawn or change it: see FrameDrawing. Griff’s own systems draw a strategy game’s fog and HUD, a tactics game’s reachable cells and a block world’s hotbar this way. It’s called for each view: the main one and each Viewport’s (Viewport says which), so a HUD of the whole screen goes in the main view only.
OnLoaded
Section titled “OnLoaded”protected virtual void OnLoaded()Called once a saved game has been loaded (LoadGame), after the scene’s scripts have started and every script’s saved fields are back (a system of a script’s has its fields saved as a script’s are), to start again what can’t be saved: a coroutine, a timer. Nothing by default.
Restored
Section titled “Restored”protected virtual void Restored()Called once a rewind has put the game back, the system’s fields with it (see IKeepsState), to work out again what its fields marked NotStateAttribute hold. Nothing by default.
SceneChanged
Section titled “SceneChanged”protected virtual void SceneChanged()Called when the game has switched to another scene (before its scripts start), to forget what the system kept track of in the last one.
Update
Section titled “Update”protected virtual void Update()Called every step of the game (60 a second, see StepRate) in Phase. A system that pushes bodies runs in Simulate, just before they move.