Skip to content

Walker

namespace Griff.Modules.Adventures;
public sealed class Walker : Component, IDrawEffect, IPlaytestReport

The player’s character in a point-and-click adventure, with no code: a click on the floor (a WalkArea) walks there, round whatever’s in the way along the shortest way; a click off it walks as close as it can; a click on a Hotspot walks over to it and uses it, a right click looks at it. The pointer shows the name of what’s under it and changes over things to click. It says what it sees over its head, faces the way it walks, and plays its Animation’s Walk and Idle clips if it has them (and WalkUp, WalkDown, IdleUp and IdleDown, going up or down the screen). Its feet are the bottom of its sprite (or its position without one), drawn smaller further up a walk area that scales with depth. A click or tap also moves dialogue on, so the whole game plays with the mouse or a touch screen.

It takes clicks while it’s Controllable, which Focus hands over (an adventure inside another game). Its Verb is what a left click on a hotspot does: buttons whose Action is Do can switch it (Choose Look, Choose Use) for a verb bar. With an InventoryBar, an item picked from it and clicked on a hotspot is used there. The keys and a controller play it too: left and right go from hotspot to hotspot in view, its UseAction and LookAction use or look at the one they’re on, and its ItemsAction goes over to the inventory bar. A trigger or script can walk it with Walk To, stop it and make it say something. It ignores gravity. In a network game, each player’s walker answers to their own mouse and keys, and the host walks it.

This is a component: its saved properties are on its component page.

public string? Camera { get; set; }

The camera whose view its clicks are read through, for an adventure seen through a Viewport. Empty is the main view.

public string? CancelAction { get; set; }

The input action that puts back the item on the pointer, or leaves the bar: “Dash” is Shift or the gamepad’s B.

public bool Controllable { get; set; }

Whether it walks where the player clicks. Untick it (from a script, in a cutscene) to ignore clicks; Walk To still works. Its Focus action ticks it and unticks it on everything else the player plays.

public Vector2 Facing { get; set; }

The way it faces, as a unit vector: down to start with. The game sets it as it walks.

public Vector2 Feet { get; }

Where its feet are in the world: the middle of the bottom of its sprite (as the transform places it), or its position without one. It’s its feet that walk on a walk area.

public bool FlipSprite { get; set; }

Flip its sprite to face left or right as it walks (art should face right).

public string? Heading { get; set; }

The entity of the hotspot it’s walking over to, to look at or use once it’s there; empty for none.

public string? HeadingItem { get; set; }

The item it’s going to use on the hotspot it’s walking to (Heading); empty to just use or look at it.

public AdventureVerb HeadingVerb { get; set; }

What it does with the hotspot it’s walking to (Heading) once it gets there.

public string? Hovered { get; }

The name of the hotspot under the pointer, on this machine; empty for none. Read as the “Hovered” output.

public Hotspot? HoveredHotspot { get; }

The hotspot under the pointer on this machine, or null.

public string? HoveredItem { get; }

The item on its InventoryBar under the pointer on this machine, or null.

public bool IsWalking { get; }

True while it’s walking somewhere.

public string? ItemsAction { get; set; }

The input action that takes the keys to the inventory bar and back: “Interact” is E, Enter or the gamepad’s Y.

public string? LookAction { get; set; }

The input action that looks at the hotspot or item the keys are on: “Attack” is X, L or the gamepad’s X.

public Color NameColor { get; set; }

The color of the name shown by the pointer.

public string? Pointed { get; set; }

The entity of the hotspot the keys or a controller are on, to use or look at with their Use and Look actions; empty while they’re not (the mouse is in use).

public bool RightClickLooks { get; set; }

A right click on a hotspot looks at it, whatever the Verb.

public string? Route { get; set; }

Where it’s still to walk, in the world: “x y” points separated by semicolons, the last where it stops. Empty while it stands. The game sets it as it walks.

public string? Said { get; set; }

What it’s saying, over its head; empty for nothing. Read as the “Said” output.

public string? SaveRoomAs { get; set; }

Keeps the scene it’s in in the game’s save data under this name, e.g. “Room”, as it gets there, so the menu’s Play button (a Load Scene button whose Saved Scene is this name) carries on in the room the player left. Empty keeps nothing.

public float SayLeft { get; set; }

Seconds before what it’s saying goes. Counted down where the game is run (its line goes from every screen then).

public float SayTime { get; set; }

Seconds a line it says stays up, and a twentieth of a second more for each letter. A click moves on sooner.

public bool ShowNames { get; set; }

Shows the name of what’s under the pointer by it.

public Color SpeechColor { get; set; }

The color of what it says, over its head.

public float Speed { get; set; }

World units per second (slower further up a walk area that scales with depth).

public string? UseAction { get; set; }

The input action that, played with the keys or a controller, uses the hotspot they’re on (with the item picked from the inventory bar, if any), or picks the item they’re on in the bar: “Jump” is Space or the gamepad’s A. The arrows, A and D, the d-pad or the stick go from one hotspot (or item) to the next.

public AdventureVerb Verb { get; set; }

What a left click on a hotspot does: use it, or look at it. A verb bar’s buttons switch it with Choose Look and Choose Use.

public string VerbName { get; }

The Verb as a name, “Use” or “Look”, for a text on a verb bar.

public void ChooseLook()

Makes a left click on a hotspot look at it, for a verb bar’s Look button.

public void ChooseUse()

Makes a left click on a hotspot use it, for a verb bar’s Use button.

public void Say(string? line)

Says line over its head, as it does a hotspot’s line.

public void Stop()

Stops where it is, forgetting where it was going and what it would do there.

public void WalkTo(string? place)

Walks to place: an entity’s name (a hotspot’s stand point, or where anything else is), or a point in the world, “x, y”. Round whatever’s in the way, as a click does, and whether or not it’s Controllable.

public event Action<Walker>? Arrived

Raised when it gets where it was walking to.

public event Action<Walker, Hotspot, AdventureVerb>? Did

Raised as it looks at or uses a hotspot.

public event Action<Walker, string>? Spoke

Raised as it says a line, with the line.

public event Action<Walker, Hotspot, string, bool>? UsedItem

Raised as it uses an item on a hotspot, with whether the hotspot had a UseWith for it.