Skip to content

Game

namespace Griff.Runtime;
public sealed class Game : IKeepsState

Runs a scene in steps of the same length (see FixedDelta): each frame the screen shows, Advance takes as many as the real time since the last one holds, each going through the parts of the game’s Frame, phase by phase, from starting new behaviors through physics to sound. Spawning and destroying during a step are safe; destroys take effect at the end of the step.

public IEnumerable<GameSystem> AddedSystems { get; }

The systems scripts added (AddSystem), in the order they were: not Griff’s or its modules’.

public Entity? ArrivedAt { get; }

The entity the players arrived at in this scene (a door’s or hotspot’s Arrive At, or LoadScene’s arriveAt), or null if they didn’t arrive anywhere in particular.

public IAudio Audio { get; set; }

Set by the platform; silent by default (tests, headless). The player’s saved volumes are applied to it.

public float AudioOffset { get; set; }

How late this player hears the game’s sound beyond what the sound card says, in milliseconds: speakers with a delay of their own (Bluetooth headphones, a TV’s) are often 100 to 300 late. BeatClocks count the music’s beats this much later, so a tap on a beat as it’s heard counts as on time. It’s the player’s own setting: kept in SaveData, set by a Calibration (tap along to clicks) or a Slider bound to it, and never sent to the other players of a network game or saved with the scene. From -1000 to 1000; 0 by default.

public bool AutoReading { get; set; }

True while dialogue reads on by itself: once a line has typed out, the next comes after a pause as long as the line (see AutoDelay). It waits at choices. A Toggle set to Auto, or a script, turns it on and off; so does a visual novel stage’s Auto action. It stays on from one talk to the next.

public ComponentRegistry? Components { get; set; }

The component types the game uses, set by the host (editor or player), for sending entities over a network.

public DebugDraw Debug { get; }

Lines, boxes, circles and text drawn over the game for a frame, to see what code is doing.

public IEnumerable<IDebugDrawing> DebugDrawings { get; }

The drawings to debug with that this game’s systems make (see IDebugDrawing): a fighting game’s hitboxes.

public WindowSize? DisplayRoom { get; set; }

The most room the screen has for the game in a window, in pixels: its work area (without the taskbar) less the window’s frame. The host sets it (the built game and the editor, from the screen their window is on); null where it can’t say (a browser), when WindowSizes goes up to 1920x1080.

public bool? EdgeScroll { get; set; }

Whether this player has the screen’s edges pan the camera, for every CameraControls: null until they choose (each camera then goes by its own EdgeScroll, the designer’s), and once set it wins over all of them. A Toggle set to Edge Scroll turns it on and off, showing the designer’s choice until then. Remembered next time, and kept through a New Game.

public Entity? Eyes { get; }

The entity the game is seen through, when a system draws the world through someone’s eyes (a first-person view’s player); null when the camera looks down on it. Sounds are heard from it, facing the way it faces.

public float FadeAmount { get; }

How much of the screen the scene change’s FadeColor covers, from 0 (none) to 1 (all of it). See LoadScene.

public Color FadeColor { get; }

The color the screen fades through between scenes.

public Component? Focused { get; }

The Button or Slider the keyboard or gamepad has picked, if any (see IsFocused).

public IReadOnlyList<FrameStep> Frame { get; }

Every step of a frame in the order Tick takes them: Griff’s own, then in each phase the Systems scripts added.

public int FrameCap { get; set; }

The most frames drawn a second, 0 for no cap (the default): 30 or 60 to save a laptop’s battery or keep a fan quiet, or a high one with VSync off. With VSync on, frames still come on the screen’s beat, skipping some to keep under the cap (30 on a 60 Hz screen draws every other frame). A Choice set to Frame Cap offers Off, 30, 60, 120, 144, 165 and 240. The game’s steps are the same whatever the cap: a frame takes the steps its time holds, so a capped game plays at the same speed, drawn less often. It counts in the built game, the editor’s Game tab and a browser, and is remembered next time.

public bool Fullscreen { get; set; }

Whether the game fills the screen. A built game starts windowed until the player picks fullscreen (F11, or a Toggle set to it), and then remembers. In the editor it says whether the game is playing fullscreen (Game > Play Fullscreen, Alt+Enter) and setting it goes fullscreen and back, but Play always starts in the Game tab.

public Entity? Held { get; }

What this machine’s mouse is holding (a Draggable’s entity), or null.

public IHostInput HostInput { get; }

The same input as its host drives it: what the keyboard, mouse, touch and controllers do, the project’s controls and the player’s rebinding (see IHostInput). Gameplay code reads Input.

public IReadOnlyList<HudButton> HudButtons { get; }

The buttons the systems show on the screen this frame (a hotbar’s slots, building tools), each with what it does.

public IInput Input { get; }

This machine’s controls, always: what runs for another player on the host of a network game is handed theirs (see IPlayerTools, and InputOf for whoever plays a particular entity).

public bool IsChangingScene { get; }

True from LoadScene until the scene has switched (including the fade out).

public bool IsPaused { get; }

True while an open panel pauses the whole game (see PauseGame and IsPaused). One that pauses only a group (Pauses) leaves it false: see IsPaused.

public bool IsQuitting { get; }

True once Quit has been called.

public bool IsSkipping { get; }

True while dialogue is skipping: Skipping, or a skip key held.

public bool IsUncovering { get; }

True while a fade is clearing to show the new scene (or the screen after FadeThrough).

public SavedGame? LatestSave { get; }

The game saved most recently, in any slot (quick saves too), or null when none is: what a title screen’s Continue loads (see ContinueGame).

public bool LocalInputBlocked { get; }

A menu that would pause the game is open here: online the game goes on, but this player’s keys don’t reach it.

public LocalPlayers LocalPlayers { get; }

The people playing at this machine, each with their own keys or controller (see LocalPlayers).

public Entity? Minigame { get; }

The open minigame that has the screen and the player’s input (the root entity its scene was loaded under), or null while none is being played. See PlayMinigame.

public IReadOnlyList<GameModule> Modules { get; }

The modules whose systems it runs, by name: those its project uses (see Modules), or every one this program has for a game made without one.

public bool MouseOnHud { get; }

The mouse is over something a system shows on the screen (see MouseOnHud).

public bool MouseOnUi { get; }

The mouse is over this machine’s HUD, so a click there isn’t meant for the world. Only buttons showing count: one on a panel just closed keeps the hover it had. A press on a pop-up panel (Popup), or off it closing it, counts too.

public INetwork Network { get; }

Multiplayer (the game’s INetwork service): host a game, join one, see who’s playing, send messages to other machines. Its Session is there only while the game is networked.

public string? Notice { get; }

A short message a system’s HUD is showing (something made, a tool’s next step), or null.

public IReadOnlyList<Panel> OpenPanels { get; }

Every open panel, the one underneath the rest first.

public float PanSpeed { get; set; }

How many times as fast this player has the keys and the screen’s edges pan the camera, times each PanSpeed: 2 pans twice as fast. A Slider set to Pan Speed changes it; from 0.25 to 4, 1 by default (which changes nothing), and remembered next time.

public bool PausedThisFrame { get; }

Paused at any point this frame: the press that clicks Resume doesn’t also jump, or work a lever.

public Physics Physics { get; }

The physics world of the scene the game is playing: what its bodies touched, knocked and shoved, gravity, and questions about the scene (Raycast, OverlapBox…). Owned and stepped by the game’s physics system, which starts it afresh for each scene.

public bool PictureWanted { get; }

True while a game just saved waits for its screenshot: the host that draws the game then draws it once more without the panels open over it (BuildPicture) and hands the pixels to TakePicture.

public GamePictures Pictures { get; }

The pictures the game makes for itself: its saved games’ screenshots (see GamePictures).

public Func<string, Entity>? PrefabLoader { get; set; }

Creates entities from prefabs by name for Spawn. Set by the host (editor or player).

public ProblemLog Problems { get; }

Where a mistake in the game’s data goes, once each: a prefab that won’t load, a name that finds nothing, a Table Values naming a row that isn’t there. The editor shows it in Output and the Inspector, agents read it, and the game goes on; a mistake in code throws instead (see ProblemLog).

public FrameProfiler? Profiler { get; set; }

Where the frames the game shows are timed, for a profiler (the editor’s Profiler panel sets one while it’s on screen); null, as it starts, times nothing. The host that runs the game adds each frame it shows. While it’s set, each step the game takes also times each of its steps, each kind of script and each system a script added, with the garbage each makes (see Costs).

public string? Rebinding { get; }

The input action waiting for the player to press its new key or button, if any (see ListenForBinding).

public IReadOnlyCollection<string> RememberedScenes { get; }

The scenes the game remembers as they were left (see RememberScene): going back to one finds it so, until it’s forgotten.

public SaveData SaveData { get; set; }

Values kept between runs (high scores, progress). Set by the host; in memory only by default.

Players’ own input bindings (Rebind) and settings (volumes, sound on or off, fullscreen) are kept here too, and come back when it’s set.

public int SaveVersion { get; set; }

The version of the game’s saves: the project’s Save Version (Game > Save Version in the editor), 0 unless it’s set. Each saved game keeps the version it was saved by (Version). Raise it when a new version of the game changes its scripts or scenes so an older save needs bringing up to date, and add an ISaveUpgrader that does it. A saved game is read back by name whatever its version (entities, their components by type and their properties), so a property added keeps its default, one removed is ignored and a component whose type is gone is kept as saved, with a warning.

public IReadOnlyList<SavedGame> SavedGames { get; }

Every saved game, by slot name (numbers in order: 2 before 10).

public Scene Scene { get; }
public Func<string, Scene>? SceneLoader { get; set; }

Loads scenes by name for LoadScene. Set by the host (editor or player).

public string? SceneName { get; set; }

The current scene’s name, e.g. “Level1”, used by ReloadScene. The host sets it for the first scene; LoadScene keeps it up to date.

public Color ScreenFlash { get; }

The color FlashScreen is covering the screen with right now; transparent when there’s no flash.

public IGameServices Services { get; }

The services the game’s systems provide its components and scripts, asked for by type (see IGameService): Game.Services.Get<IFlags>().

public IReadOnlyDictionary<string, Simulation> Simulations { get; set; }

The project’s balance simulations by name (every .sim file in Assets), which Game.Simulate plays (Griff.Simulations). Every host sets it as the game starts (see UseProjectSettings).

public bool SkipHeld { get; set; }

Set each frame by what reads a skip key (a visual novel stage’s Skip action), while it’s held.

public bool Skipping { get; set; }

True while dialogue skips: each line read before is shown and passed in a moment, until a line not read before (unless the player’s setting goes through those too: see IReadingPreferences), choices or the end of the talk, which turn it off. A Toggle set to Skip, or a script, turns it on; a visual novel stage’s Skip action skips while it’s held.

public IReadOnlyList<GameSystem> Systems { get; }

The systems running: Griff’s that keep track of something while a scene plays, then those scripts added.

public TableSet Tables { get; set; }

The game’s tables, which scripts read (Tables.Get("Spells", "Fireball")["Damage"]) and TableValues components take their values from. Every host sets it as the game starts, from the project’s .table files (UseProjectSettings); a table changed while the game runs reaches it at the start of the next step (see Stage).

public Dialogue? Talking { get; }

The Dialogue being said right now, if any.

public Time Time { get; }
public string? Title { get; set; }

The game’s name, set by the host (editor or player). Only copies of the same game can play together.

public Panel? TopPanel { get; }

The open Panel the player’s input goes to (the one opened last), if any.

public EntityPairSet Touches { get; }

Who touched what in this frame’s physics, both ways round (triggers and what’s in them too), in the order physics found them, for systems that look for themselves without making garbage.

public ComponentList<TurnOrder> TurnOrdersNow { get; }

The turn orders running this frame, in the scene’s order.

public float UiScale { get; set; }

How many times its size the HUD is drawn, for a player who wants it bigger or smaller: everything pinned with a ScreenAnchor (drawn, placed from its corner and clicked at this size, with what’s inside it) and tooltips. It multiplies the camera’s HudScale. A Slider set to UI Scale changes it; from 0.25 to 4, 1 by default, and remembered next time.

public bool VSync { get; set; }

Whether frames keep in step with the screen, one for each it shows (a Toggle set to VSync turns it on and off). On (the default) is how Griff has always drawn, tear-free. Off draws each frame as soon as the last is done, as many as the computer can (up to FrameCap), for a game that feels quicker to the hand on a fast computer; the screen still shows only its own rate. The game’s steps are the same either way: frames only change how often the picture is drawn. A browser always draws in step with its screen, and the editor’s Game tab keeps in step too (the editor shares its thread), so there it only counts for the built game. Remembered next time.

public float ViewAspect { get; set; }

The view’s width divided by its height. Set by the host each frame; ScreenAnchor uses it.

public float VisualOffset { get; set; }

How late this player sees the screen, in milliseconds (a TV’s picture can lag 30 to 100): what’s drawn to the beat (a BeatPulse, notes coming down a lane) is drawn this much ahead, so it’s seen as the beat is heard. Like AudioOffset, it’s this player’s own, kept in SaveData, set by a Calibration measuring Visual, and only changes how things are drawn.

public WindowSize? WindowSize { get; set; }

The size of the built game’s window, in pixels of the game inside it (not counting its frame): null until the player picks one (a Choice set to Window Size offers WindowSizes), when the window opens at 1280x720. Setting it resizes the window, and it’s remembered: the window opens at it next time. Fullscreen is always the screen’s own resolution, borderless (the display’s mode never changes); a size picked while fullscreen is the window’s once it’s windowed again. In the editor and a browser there’s no window to size, so it’s kept for the built game and nothing changes.

public IReadOnlyList<WindowSize> WindowSizes { get; }

The window sizes a player can pick (WindowSize), smallest first: the common 16:9 ones (960x540 up to 3840x2160) that fit on the screen, as DisplayRoom says, and the one picked now if it isn’t among them.

public int WorkerCount { get; set; }

How many threads share this game’s big jobs (building a frame of thousands of sprites, running a crowd of scripts), its own included: Default to start with, from 1 (everything on the game’s thread) to 64. The host’s to choose (the web player keeps to 1), and this game’s alone: another game in the same process (Play with Players, a simulation, a test alongside) keeps its own. What the game does is the same whatever it is.

public ComponentList<T> Active<T>()

What this machine runs: everything offline and on the host; on a player’s machine, only its own things (HUD, menus). Not what’s paused (see Entity.IsPaused): it’s held still.

public T AddSystem<T>(T system)

Runs system every frame from now on (from this frame, if its phase hasn’t started), after Griff’s own steps in its Phase. A system of the same type is replaced. A script’s AddSystem ties it to the script’s entity instead, so it goes when that does.

public void Advance(double seconds)

A frame of the screen, seconds of real time after the last: takes as many steps of FixedDelta as that time holds (none on a fast screen’s frame, two on a slow one’s), keeping the rest for the next frame, so the game moves the same on any machine. Blend then says how far between its last two steps to draw it. Presses (and typing, scrolling, mouse movement) count in the next step taken, once: a frame with no step keeps them for the next. A frame covers at most MaxDelta; a longer one (a stall) slows the game down rather than running a burst of steps. Fast-forwarded (FastForward), it takes that many times the steps, spending at most a twentieth of a second on them: a machine that can’t keep up runs the game slower, never skipping a step.

public void AdvanceDialogue(Dialogue dialogue)

Moves a dialogue on, as Interact does: finishes typing the line if it’s still typing, else picks the choice the player is on (see Picked), or shows the next line (or ends it after the last).

public GameTimer After(float seconds, Action action, Entity? owner = null)

Calls action once, seconds of game time from now. With an owner, the timer is cancelled if that entity leaves the scene first.

public static Box AreaOf(Button button)

The world-space box a button can be clicked in.

public static Box AreaOf(Slider slider)

The world-space box a slider can be dragged in.

public float AspectOf(Entity camera)

The shape camera is drawn at, its width over its height: ViewAspect (the screen’s) for the main camera, its part of the screen’s for a Viewport’s. What a HUD laid out in its view, or a camera kept inside the level, goes by.

public float AutoDelay(string? said)

Seconds AutoReading waits after said has typed out before reading on: longer for a longer line, shorter the quicker the player likes it (see AutoSpeed).

public static Entity? BodyOwner(Entity entity)

What collects for a collider: its own entity’s body, or the nearest ancestor’s (a player’s hitbox child).

public bool CanHurt(Entity? source, Entity target)

False when source mustn’t hurt target: allies (on the same team, see TeamOf) don’t hurt each other (in a network game, unless FriendlyFire), and in a network game a player’s own shots don’t hurt them.

public static bool CanPass(GridWalls walls, ValueTuple<int, int> from, ValueTuple<int, int> by, bool avoidMovers, ValueTuple<int, int> goal)

Whether a step from a cell by a change of cell is open, as a step is: a diagonal can’t cut a wall’s corner (a hex map’s neighbours all share a side). The goal is open whoever stands in it (it’s where the target is).

public bool CanPay(Entity? entity, string? cost)

True if entity can pay cost, e.g. “150 Gold, 50 Wood” (see CountItems).

public static Vector2 CenterOf(Entity entity)

The middle of an entity: its collider’s, or its position.

public void ChooseDialogue(Dialogue dialogue, int choice)

Picks choice choice (from 0) of those dialogue offers now, as the player would: does its tags and goes where it leads. Does nothing when it isn’t being said or offers no such choice.

public void Claim(Entity spawned, Entity by)

In a network game, marks what by fired or made as its player’s: what it hits counts for them.

public BeatClock? ClockFor(string? name)

The clock something names (an entity with a Beat Clock), or the scene’s first when it names none.

public void ClosePanel(Panel? panel = null)

Closes panel (by default the top one) and any opened inside it, giving the keyboard back to what was picked before it opened. Closing a closed panel does nothing.

public bool ContinueGame(float fade = 0f)

Loads the game saved most recently (LatestSave), as LoadGame does: a title screen’s Continue. True if there was one, and it’s on its way.

public int CountItems(Entity? entity, string item)

How many of item``entity has to pay with: in what holds items on it or the entity it’s inside (an Inventory, a card hand’s mana), else its team’s (see Items).

public static bool Covers(Entity entity, Vector2 point)

A draggable’s or drop target’s shape: its collider’s, else its sprite’s, else a square a unit across.

public bool DeleteSave(string slot)

Forgets the game saved in slot. True if there was one.

public void Destroy(Entity entity)

Removes entity and its children at the end of the frame.

public int Do(Entity entity, string action, string? with = null)

Does action on entity, as a Trigger does: every component of it with an action called that (see ActionAttribute) does it, with with as its value (a number, true or false, or a name), or the action’s own default without one. “Health.Damage” names one component’s. Returns how many did it.

public int Do(Entity entity, string action, float value)

Like Do, with a number as the action’s value.

public int DoOn(Entity entity, string action, string? with, float? number)

Each of the entity’s components with an action of that name does it.

public void EndDialogue(Dialogue dialogue)

Ends dialogue at once, even partway through a line, as saying its last line would: its box hides, the pause it held is let go (the time scale back as it was), it’s done (IsDone), its Message is sent and Finished is raised, with CutShort true. The rows it didn’t reach aren’t said and their tags aren’t done. For a “Skip” button on a cutscene or a tour (the dialogue’s Stop action does it with no code). Does nothing when it isn’t being said.

public GameTimer Every(float seconds, Action action, Entity? owner = null)

Calls action every seconds of game time until cancelled.

public static void Face(Entity entity, int direction)

Turns an entity’s sprite to face direction (left when it is below 0, else right) by flipping it.

public void FadeThrough(float seconds, Action then, Color? color = default)

Fades the screen to color (black by default) over seconds of real time, calls then while it’s covered, and fades back in just as long: teleports, a jump to the next room, a cut in a cutscene. 0 seconds calls it straight away.

public Tween FadeTo(Entity entity, float alpha, float seconds, Func<float, float>? ease = null)

Fades entity’s sprite, text and tilemap to alpha (0 invisible, 1 opaque), e.g. FadeTo(0, 0.3f).Then(() => Destroy(Entity)).

public T? Find<T>()

The first component of type T in the scene, e.g. Game.Find<ScoreCounter>().

public Entity? Find(string name)

The entity called name; in a network game, this machine’s player’s own first (see FindNamed).

public IReadOnlyList<T> FindAll<T>()

Every component of type T in the scene, e.g. Game.FindAll<Enemy>().

public IReadOnlyList<Entity> FindAll(string name)

Every entity called name, e.g. all the copies of the “Enemy” prefab.

public T? FirstInSight<T>(ComponentList<T> components)

The first of `components` not behind the minigame that has the screen: the one a HUD shows.

public bool FlagHolds(string? needs)

True if needs holds, as a switch’s, door’s, spawner’s or panel’s Needs Flag says: empty always does, “Name” while that flag is set, and “not Name” (or “!Name”) while it isn’t. Asking every frame makes no garbage.

public void Flash(Entity entity, Color? color = default, float seconds = 0.1f)

Paints entity’s sprites and its children’s color (white by default) for seconds; see Flash.

public void FlashScreen(Color? color = default, float seconds = 0.15f)

Covers the whole screen in color (white by default), fading away over seconds of real time: a flash of light, red for getting hurt. Give the color some transparency for a gentler flash, e.g. Color.Red with { A = 0.3f }. A new flash replaces one in progress.

public static Vector2 Flat(Vector3 v)

A position in 3D without its height: the 2D point the world draws it at.

public void Focus(Entity entity)

Gives entity the player’s input, as its Focus action does: everything on it and inside it that takes input (see FocusAttribute) takes it, and everything else the same player plays stops, so a match-3 board and a platformer’s player in one scene don’t both move on the arrow keys. In a network game, a player’s own character only gives up focus to what that player (or everyone) plays, and so does one a PlayedBy gives to a player at this machine. Done where the game is run, the host.

public void Focus(Component? control)

Picks control (a Button or Slider) for the keyboard and gamepad, e.g. a panel’s first button as it opens. Null picks nothing; the first arrow key or D-pad press then picks the top one.

public bool ForgetScene(string scene)

Forgets how scene was left, so going there next starts it as its file has it (the dungeon reset once the boss is beaten). True if it was remembered.

public void ForgetScenes()

Forgets every scene remembered, as New Game does.

public T? GetSystem<T>()

The running system of type T, if there is one.

public void Give(Entity entity, string item, int count = 1)

Gives entity``count of item (takes them, for less than 0): into what holds that item for it or its team, or an Inventory added to it if nothing does.

public bool HasFlag(string name)

True if flag name is set: by a dialogue’s “[set Name]”, by SetFlag, or by anything else that saved true under that name in SaveData (a toggle’s Save As). Capitals don’t matter.

public static bool HasFocus(Component component)

True if component takes the player’s input now: everything it has marked FocusAttribute is on (a board’s Controllable), or it has nothing marked.

public static bool HasFocus(Entity entity)

True if entity takes the player’s input now: every component on it that can have focus (see FocusAttribute) has it, or none can. What else on it reads input (a hotbar’s number keys) goes by this.

public bool HasSave(string slot)

True if a game is saved in slot.

public void HitStop(float seconds = 0.08f)

Freezes the game for seconds of real time (a tenth of a second or less is plenty) so a big hit lands with a thud. Everything on game time stops; camera shake, fades and the screen keep going.

public ValueTuple<Vector2, float, float> HudView()

The view a HUD is laid out for on this machine’s screen: its camera’s.

public ValueTuple<Vector2, float, float> HudViewOf(IInput input)

The view a HUD is laid out for on the screen of the player whose input this is: theirs, if the host has been told it (a player on another machine), or this machine’s (see HudView).

public IInput InputOf(Entity? entity)

The controls of whoever plays entity: in a network game, the player it belongs to (their keys arrive from their machine); for something a PlayedBy gives to one of the players at this machine, their keys or controller (see LocalPlayers); otherwise this machine’s Input. Griff’s components use it, so each player’s character answers to its own player; scripts get it as Input.

public bool IsDestroying(Entity entity)

True if entity goes at the end of this frame (see Destroy).

public bool IsTyping(Dialogue dialogue)

True while the line dialogue shows is still typing out (its choices wait for it).

public void KeepBetweenScenes(Entity entity)

Carries entity (and its children) into the next scenes LoadScene switches to, still running: music players, a score kept across levels. It gets a KeepBetweenScenes (if it hasn’t one), which does it: it becomes a top-level entity there, in place of the very same entity there (say, back on the scene it came from) or one of the same name, so there’s never two.

public void KickCamera(Vector2 by, float duration = 0.2f)

Kicks the camera the game is viewed through, if there is one: pushes the view by (which way and how far, in world units) and eases it back over duration seconds. See Kick.

public static string? LayerOf(Entity entity)

The layer an entity’s Collider (or else its Tilemap) is on, or null.

public float LightAt(Vector2 point)

How lit point is, from 0 (pitch dark) to 1 (fully lit): the camera’s Ambient light plus every Light reaching it, as the game is drawn. In a scene that isn’t dark it’s always 1. For stealth: if (Game.LightAt(player) < 0.3f) return; // can't be seen

public float LightAt(Entity entity)

How lit entity is where it stands; see LightAt.

public void ListenForBinding(string action)

Waits for the player to press a key or gamepad button, then makes it do action: a key replaces the action’s keys and mouse buttons, a gamepad button its gamepad buttons. Esc (or the gamepad’s Start or Back) cancels. Meanwhile menus ignore input, and “{Jump}” in text shows “…”. What a Rebind button does.

public bool LoadGame(string slot, float fade = 0f)

Loads the game saved in slot at the end of this frame (after fading out over fade seconds, if more than 0, and back in as long): its scene as it was saved, the stage, the talk going on from the line it was on, and the flags as they were. One saved by an earlier SaveVersion is brought up to date first (see ISaveUpgrader). Nothing happens if the slot is empty, and a damaged save or one from a newer Griff says why in the game’s problems instead. Not in a network game. True if it’s on its way.

public void LoadScene(string nameOrPath)

Switches to another scene (“Level2” or “Scenes/Level2.scene”) at the end of this frame. The current scene’s behaviors get OnDestroy; music keeps playing.

public void LoadScene(string nameOrPath, float fade, Color? color = default)

Like LoadScene, first fading the screen to color (black by default) over fade seconds while the game keeps running, then fading back in just as long once it’s switched. Fades use real time, so they work from a paused menu. Loading again mid-fade just changes where it’s headed.

public void LoadScene(string nameOrPath, float fade, Color? color, string? arriveAt)

Like LoadScene, with the players arriving at the entity called arriveAt in the next scene (a door there, the way back), as a door’s Arrive At does: the characters the players move stand where it is, and don’t go straight back through a door there. A scene that remembers how it was left (see RememberScene) comes back so.

public void LoadScene(string nameOrPath, float fade, Color? color, string? arriveAt, Entity? traveller, bool fresh)

Where a door sends whoever used it: they arrive at the spot, even if no player moves them.

public bool LooksThrough(Entity entity)

True if the game is seen through entity’s eyes on its player’s screen (see LooksThrough): a first-person game’s player, and online each player’s own character.

public bool LoseMinigame(Entity? inside = null, int? score = default)

Like WinMinigame, as lost: whatever opened it sends its Lost Message.

public static void Lunge(GridMovement m, GridCells grid, ValueTuple<int, int> toward, Vector2 direction, float progress)

Stays in its cell, lunging part way toward the next and back over a step’s time.

public ComponentList<T> Mine<T>(bool evenPaused = false)

What this player has (their hotbar, their tools): in a network game, what’s on their own character. Not what’s paused, unless `evenPaused` (for a HUD that still shows what a paused player has).

public bool MouseIn(Entity camera, out Vector2 world)

True if the mouse is over camera’s part of the screen: the whole screen for the main camera, a Viewport’s part for its camera (false while it isn’t showing, or for a camera that’s neither). Either way world is the point in the world under the mouse as that camera sees it (its own size, shape, position and turn), for clicking on a minimap or on one player’s half of the screen. For the main camera it’s exactly MouseWorld and the answer IsMouseInView.

public static bool MouseOnUiOf(IInput input)

True if the mouse of the player whose input this is, on another machine, is over their UI.

public static void MoveTo(Entity entity, Vector2 world)

Puts it at a world position, whatever its parent.

public Tween MoveTo(Entity entity, Vector2 position, float seconds, Func<float, float>? ease = null)

Glides entity to position (in its parent’s space), keeping its Z.

public static float MoveTowards(float from, float to, float step)

Moves from towards to by at most step, stopping on it.

public static Vector2 MoveTowards(Vector2 from, Vector2 to, float step)

Moves from towards to by at most step, stopping on it.

public static bool Moves(Entity entity)

True if this machine moves entity: what it runs, except other players’ own characters.

public ComponentList<T> Moving<T>()

What this machine moves: what it runs, less other players’ own characters, plus this player’s own; not what’s paused.

public void NewGame(string scene, float fade = 0f)

Starts the game over, as a New Game button does: forgets the progress in the save data (flags, carried inventories, health and counts, best scores; not the player’s settings and controls, saved games or lines read) and every scene remembered, then goes to scene as its file has it.

public MessageListener On(string message, Action<object> action, Entity? owner = null)

Calls action with the data of every message sent from now on, until cancelled. With an owner, it stops if that entity leaves the scene.

public bool OnBeat(string? clock, int every, int offset)

Whether something stepping to a clock every so many beats steps this frame.

public void OpenPanel(Panel panel)

Opens panel on top of any already open: its entity shows, its top control (or its First) is picked, and it pauses the game if it says so. Opening an open panel does nothing.

public Panel OpenPanel(string name)

Opens the panel on the entity called name, e.g. “Options”, and returns it.

public ComponentList<T> Owned<T>(NetPlayer? player, bool evenPaused = false)

What player has (their hotbar, their tools): in a network game, what’s on their own character; for this machine’s player (or null), the same as Mine. For what runs for another player on the host.

public Panel? PanelNamed(string name)

The first Panel on the entity named name in the scene, or null.

public void Pause(Entity entity)

Pauses entity and everything inside it, as its PauseGroup’s Pause does (giving it one if it hasn’t): from the start of the next step nothing in it moves, animates or runs its scripts, while the rest of the game runs on. See IsPaused.

public bool Pay(Entity? entity, string? cost)

Pays cost from entity’s items (or its team’s) if it can; returns whether it did.

public void PlayIfSet(string? sound)

Plays the sound called sound if it names one (a blank or null name plays nothing).

public bool PlayMinigame(string scene, Entity? from = null)

Plays the scene called scene on top of this one as a minigame: it’s loaded under an entity of its own (with a MinigameRoot) beside the rest of the world, takes the screen (its own camera, HUD and menus) and the player’s input, and pauses everything else, as from’s Minigame says (or with its defaults without one). It ends with WinMinigame or LoseMinigame (a trigger’s Win Minigame or Lose Minigame in it), and the result comes back as from’s Won or Lost message with the score. True if it’s on its way; not during a network game, nor while the screen is fading to something else.

public void PlayShared(string sound)

Plays a sound here and, on the host of a network game, for everyone.

public void PlaySoundAt(string sound, Vector2 position, float volume = 1f, float pitch = 1f)

Plays a sound as if it came from position: from the left or right speaker as it’s to the left or right of the middle of the screen, and quieter the further it is off screen, out to a screen’s width beyond the edge (where it can’t be heard at all).

public IEnumerable<IInput> PlayerInputs()

Everyone’s controls that this machine knows: its own, and on the host, every other player’s too.

public static void Power(Entity entity, bool on)

Switches entity on or off as a Switch does: its movers, grid patrols, spawners and shooters run, particles emit, animations play and doors unlock (whatever its components mark PoweredAttribute, a script’s too); if it has none of those, it appears or disappears.

public ComponentList<T> Present<T>()

What this machine runs, paused or not: for what reads or shows how things are rather than moving them on.

public bool QuickLoad(float fade = 0f)

Loads the game saved in the QuickSlot, as LoadGame does.

public bool QuickSave()

Saves the game in the QuickSlot, as SaveGame does.

public void Quit()

Asks the host to close the game; in the editor, play mode stops.

public void ReloadScene()

Starts the current scene over from its saved state at the end of this frame, e.g. after the player dies. A scene that remembers how it was left (see RememberScene) forgets it, and starts as its file has it.

public void ReloadScene(float fade, Color? color = default)

Like ReloadScene, fading out and back in as LoadScene does.

public bool Remembers(string scene)

True if the game remembers how scene was left (see RememberScene).

public bool RemoveSystem(GameSystem system)

Stops running system (one a script added). Returns whether it was running.

public void Resume(Entity entity)

Starts a group paused with Pause (or its PauseGroup) again, from the next step.

public Tween RotateTo(Entity entity, float degrees, float seconds, Func<float, float>? ease = null)

Turns entity to degrees around Z (360 or more spins it round).

public ComponentList<T> RunHere<T>()

Everything this machine runs, active or not.

public static bool Runs(Entity entity)

True if this machine runs entity’s gameplay: everything offline and on the host.

public bool SaveGame(string slot)

Saves the game in slot (a name of your own: “1”, “Quick”, “Chapter 2”), replacing what was there: the scene as it is now (the stage, where a talk has got to, every component’s properties, scripts’ too, as a scene file keeps them), with the panels open over it closed, and the flags set now. Loading it (LoadGame) puts all of it back. Kept in SaveData, so it’s there next time (in a browser, in its storage), with a screenshot taken as the game is next drawn. Not in a network game, which isn’t this machine’s alone. True if it was saved.

public SavedGame? SavedGameIn(string slot)

The game saved in slot, or null when there’s none.

public Tween ScaleTo(Entity entity, Vector2 scale, float seconds, Func<float, float>? ease = null)

Grows or shrinks entity to scale on X and Y, keeping its Z scale.

public int Send(string message, object? data = null)

Tells everyone listening for message (with On, a Trigger, a Counter…) straight away, passing along data. Returns how many heard it; nobody listening is fine.

public int Send(string message, object? data, Entity? from)

Like Send, saying who sent it: a Trigger whose From names from (or something it’s inside) hears it, and if from or something it’s inside has a MessageScope, only the part of the scene the scope says does. Griff’s own components send their messages this way.

public int SendTo(Entity to, string message, object? data = null, bool children = false, Entity? from = null)

Sends message only to to (and with children, everything inside it): its counters, triggers, sound players, panels and scripts listening with On, so one of two boards can be told something. from says who sent it, for a Trigger’s From.

public void SetFlag(string name, bool on = true)

Sets flag name (or clears it, with on false), as a dialogue’s “[set Name]” does. Flags are kept in SaveData, so they’re still set the next time the game runs, until a New Game (NewGame) forgets them; a saved game (SaveGame) keeps the ones set when it was saved, and loading it puts them back. A flag whose name starts “run.” (“run.Contracts”) lasts only while the game runs: the next time it starts, the flag isn’t set (see LastsOneRun).

public void ShakeCamera(float strength = 0.3f, float duration = 0.25f)

Shakes the camera the game is viewed through, if there is one. See Shake.

public void ShakeFor(Entity entity, float strength, float duration)

Shakes the camera of whoever plays entity: here, or on their own machine.

public void ShowAsIs()

Draws things where they are now, rather than between the last two steps, until the game next takes a step: for a host holding the game still (the editor paused, or rewound), so what’s on the screen is what the Inspector shows.

public void ShowDebugDrawing(string name, bool show)

Shows (or hides) the drawing to debug with called name, if a system of this game makes one.

public ComponentList<T> Showing<T>()

Everything showing, wherever it’s run: for what only changes how things look.

public void SlowMotion(float scale = 0.3f, float seconds = 0.6f)

Slows the game to scale (0.3 is a third of normal speed) for seconds of real time, easing back to full speed at the end: the last enemy falling, a near miss. It works on top of Scale; see SlowMotionScale.

public Entity Spawn(Entity entity, Entity? parent = null)

Adds entity to the scene. Its behaviors start on the next frame; its TableValues set their values straight away. One spawned with no parent where a minigame is being played (see PlayMinigame), such as a bullet or a falling piece, goes into the minigame, staying where it is.

public Entity Spawn(string prefab, Entity? parent = null)

Adds a new copy of a prefab (“Bullet” or “Prefabs/Bullet.prefab”) to the scene.

public Entity Spawn(string prefab, Vector2 position, Entity? parent = null)

Adds a new copy of a prefab at position (in the parent’s space, or the world without one). The prefab’s own Z is kept.

public Coroutine StartCoroutine(IEnumerator routine, Entity? owner = null)

Runs routine over several frames: see Coroutine for what it can wait for. It runs straight away up to its first yield return. With an owner, it stops if that entity leaves the scene first.

public void StartDialogue(Dialogue dialogue)

Starts dialogue straight away, as if the player had pressed Interact beside it: from a script, a cutscene, a boss appearing. Does nothing while another dialogue is being said, or if it has no lines; one whose flags let none of its lines be said ends straight away.

public void Stop()

Calls OnDestroy on every started behavior and waits for its saves to be written (Flush). The game can’t be ticked afterwards.

public void TakePicture(byte[] rgba, int width, int height)

Hands over the pixels of the picture PictureWanted asked for (top-down RGBA rows, width by height): they’re shrunk and kept as the saved game’s screenshot.

public static void TargetsOf(Entity owner, string? targets, List<Entity> into)

Fills into with the entities targets names (a name, or a list of names), or with the owner itself when it names none.

public string TeamOf(TurnTaker taker)

The team a turn taker acts for: its own, else the team it’s on some other way (a Team on it or above it), or in a network game with teams, its player’s team.

public string TeamOf(Entity? entity)

The team entity is on (see Of), or in a network game with teams, the team of the player who plays it. Empty for none.

public void Tick(double seconds)

Takes one step of exactly seconds (at most MaxDelta), as a frame of its own drawn as it ends (Blend 1): stepping a game by hand, for tests and tools, or one step at a time while paused. The caller ends the input’s frame (EndFrame) after. A running game uses Advance.

public IEnumerable<ValueTuple<Entity, string>> TouchersOf(Entity entity)

Who’s touching what this frame, for checkpoints, doors and dialogue: the thing touched, and whatever touched it (the body that owns the collider, so a player’s hitbox child counts as the player), with its collider’s layer.

public Entity? TryLoadPrefab(string prefab, Component? by, string what)

A new copy of a prefab for by’s field, or null, with a warning (once), if it won’t load: no such prefab, a file that doesn’t read, or a game with no prefabs. A prefab named in the game’s data is data, so a missing one never stops the game. what says what the prefab is for in the warning (“its Effect”).

public Entity? TrySpawn(string prefab, Component? by, string what, Entity? parent = null)

Adds a new copy of a prefab to the scene as Spawn does, or warns and returns null if it won’t load (see TryLoadPrefab).

public Entity? TrySpawn(string prefab, Component? by, string what, Vector2 position, Entity? parent = null)

Adds a new copy of a prefab at position as Spawn does, or warns and returns null if it won’t load.

public TurnOrder? TurnOrderOf(Entity? entity)

The turn order entity takes turns in (see Within), if any.

public Tween Tween(float seconds, Action<float> apply, Func<float, float>? ease = null, Entity? owner = null)

Calls apply every frame for seconds of game time with progress from 0 to 1, shaped by ease (OutQuad by default). The last call is always exactly 1. With an owner, the tween is cancelled if that entity leaves the scene first.

public void UseAction(Entity entity)

An attack swung or a shot fired on its turn uses one of its turn taker’s actions.

public static ValueTuple<Vector2, float, float>? ViewOf(IInput input)

The view (center, half height, aspect) on the screen of the player whose input this is, if the host has been told it (a player on another machine), or null.

public bool Waiting(Entity? entity)

True if entity acts for a turn taker that has to wait: it isn’t its turn, or it has used its actions.

public void Warn(string message)

Each problem once a game, so one that comes up every step isn’t said every step.

public void Warn(Component component, string message)

Says a mistake in the data of component, once, naming it and its entity so the Inspector can flag it. The game goes on.

public bool WinMinigame(Entity? inside = null, int? score = default)

Ends the minigame inside is in (or the one with the screen) as won, with score (or, without one, the minigame’s own score: its first Score output, or its first counter’s count). It closes, the input goes back to what had it, and whatever opened it sends its Won Message with the score. Played on its own (not as a minigame), it just sends “Minigame Won”. True if there was one to end.

public event Action<string, bool>? FlagChanged

Raised when a flag is set or cleared, with its name and whether it’s set now.

public event EventHandler? FullscreenChanged

Raised when Fullscreen changes, for the host to resize its window.

public event Action<string>? GameLoaded

Raised when a saved game has been loaded (its scene is the one running now), with its slot.

public event Action<string>? GameSaved

Raised when a game has been saved, with its slot.

public event EventHandler? QuitRequested

Raised when gameplay code calls Quit. The host closes the game (the editor stops playing).

public event EventHandler<Scene>? SceneChanged

Raised after LoadScene switches to a new scene.

public event EventHandler? Stepped

Raised after each step the game takes (see Advance), once its input is done with: controls set here count for the next step. The editor keeps its rewind snapshots here.

public event EventHandler? WindowSizeChanged

Raised when WindowSize changes, for the host to resize its window.

public const string AudioOffsetSaveKey

Where AudioOffset is kept in SaveData.

public const string AutoSlot

The slot an Autosave saves in unless it says otherwise.

public const string CarriedNamesKey

Where the names of the values carried between scenes are kept in SaveData (one a line): what an inventory’s, a health’s or a counter’s Save As keeps, so a saved game knows to put them back as they were.

public const float CursorRepeatDelay

How long an arrow has to be held before a cursor (on a board, a grid) repeats, and how often it does then.

public const float CursorRepeatEvery

Seconds between moves of a menu’s cursor while a direction is held.

public const string EdgeScrollSaveKey

Where EdgeScroll is kept in SaveData.

public const string FlagNamesKey

Where the names of the flags the game has set are kept in SaveData (one a line), so a saved game knows which to put back.

public const string FrameCapSaveKey

Where FrameCap is kept in SaveData.

public const string FullscreenSaveKey

Where Fullscreen is kept in SaveData.

public const float GridDeadZone

How far the stick has to lean before it counts as a way.

public const int GridSearchLimit

The most cells a grid search looks at before it gives up.

public const int GridSearchMargin

How far past the two ends a search for a way goes with no map to keep it in, in cells; and the most cells it looks at.

public const float MaxOffset

The furthest either offset goes, in milliseconds, early or late.

public const string MusicVolumeSaveKey

Where MusicVolume is kept in SaveData.

public const string MutedSaveKey

Where Muted is kept in SaveData.

public const float NavigateStick

A stick pushed further than this counts as a direction.

public const string PanSpeedSaveKey

Where PanSpeed is kept in SaveData.

public const string QuickSlot

The slot QuickSave and QuickLoad use.

public const int SaveFormat

The way Griff writes saved games (2: each says the version of the game it was saved by). A game saved by a newer Griff, in a later way, isn’t loaded: it says so instead.

public const string SavedGameKey

Where each saved game is kept in SaveData: this, then the slot’s name (“griff.save.1”), holds when it was saved, the line, the flags and the screenshot; SavedSceneKey holds the scene.

public const string SavedSceneKey

Where each saved game’s scene is kept in SaveData: this, then the slot’s name.

public const string SavedScenesKey

Where each saved game’s remembered scenes are kept in SaveData: this, then the slot’s name.

public const string SoundVolumeSaveKey

Where SoundVolume is kept in SaveData.

public const string UiScaleSaveKey

Where UiScale is kept in SaveData.

public const string VSyncSaveKey

Where VSync is kept in SaveData.

public const string VisualOffsetSaveKey

Where VisualOffset is kept in SaveData.

public const string VolumeSaveKey

Where Volume is kept in SaveData.

public const string WindowSizeSaveKey

Where WindowSize is kept in SaveData, as “1600x900”.