Skip to content

InventoryBar

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

An adventure’s inventory, with no code: a bar along the bottom of the screen showing what the walker’s Inventory holds, each item’s icon and name. Click an item to pick it up (the pointer turns into it), then click a hotspot to walk over and use it there (the hotspot’s UseWith for that item says what happens) or another item to put the two together (Combinations); a right click on an item looks at it (its Descriptions line), and a right click, or a click on it again, puts it back. Anything that doesn’t go together gets the hotspot’s Wrong Item Line or this bar’s WrongLine. Taps do the same on a touch screen, and the keys and a controller go over the items with the walker’s Items, Use, Look and Cancel actions.

Items come from the Inventory (a hotspot’s Use Gives, a Use With’s Gives, a combination, a Pickup or a script put them there). Each item’s icon is its row in Icons, its row of the Table, the picture of a hotspot in the scene that gives it, or else a tile with its name. Combinations can come from a table too (CombinationsTable). What’s on the pointer (Holding) is kept with the scene, so rewinds and saves keep it.

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

public Color BarColor { get; set; }

The color of the bar behind the items.

public IReadOnlyList<string> Combinations { get; set; }

Items that go together, one per row: what they make, “=”, the two items joined with “+”, and after a colon what the walker says, e.g. “Grappling Hook = Rope + Hook: I tie the rope to the hook.” Both are used up and what it makes is put in; to keep one, make it again (“Knife + Short Rope = Knife + Rope”).

public string? CombinationsTable { get; set; }

A table of combinations, e.g. “Combinations”: a row for each, named like what it makes, whose Combine column is the two items (“Rope + Hook”) and whose Line column is what the walker says. Combinations win over it.

public string? CombineSound { get; set; }

A sound played as two items are put together.

public int Cursor { get; set; }

The item the keys or a controller are on, counting from 0, while they’re on the bar; -1 while they’re not.

public IReadOnlyList<string> Descriptions { get; set; }

What the walker says on looking at each item, one per row: the item, a colon and the line, e.g. “Key: A rusty old key.”

public string? GetSound { get; set; }

A sound played as an item is put in it, e.g. “Sounds/get.wav”.

public string? Holding { get; set; }

The item on the pointer, picked from the bar to use on something; empty for none. Read as the “Holding” output.

public IReadOnlyList<string> Icons { get; set; }

Each item’s picture, one per row: the item, a colon and an image in Assets, e.g. “Key: Sprites/key.png”, or a frame of a sprite sheet with its columns and rows and the frame, “Rope: Sprites/items.png 4x2 5”. An item with none uses the picture of a hotspot in the scene that gives it, or a tile with its name.

public string? PickSound { get; set; }

A sound played as an item is picked up onto the pointer.

public BarPlace Place { get; set; }

Along the bottom of the screen or the top.

public int Scroll { get; set; }

How far the bar is scrolled: the first item shown, counting from 0.

public bool ShowEmpty { get; set; }

Shows the bar while it has nothing in it too; otherwise it shows up with the first item.

public bool ShowNames { get; set; }

Writes each item’s name under its icon.

public int Slots { get; set; }

The most items shown at once, up to 12: arrows at its ends scroll through more.

public string? Table { get; set; }

A table of items, e.g. “Items”: a row for each, named like the item, whose Description column is what’s said on looking at it and whose Icon column is its picture (as in Icons). The rows above win over it.

public Color TextColor { get; set; }

The color of the items’ names, and of the line round the one the keys are on.

public string? WrongLine { get; set; }

What the walker says when an item is used on a hotspot that has no UseWith for it (and no Wrong Item Line of its own), or two items that don’t go together are put together. Empty says nothing.

public Combination? CombinationOf(string first, string second, TableSet? tables = null)

What first and second make together (either way round), or null if they don’t go together.

public void Combine(string? items)

Puts two items together, “Rope + Hook”, as clicking one with the other does, at the start of the next frame.

public string? DescriptionOf(string item, TableSet? tables = null)

What’s said on looking at item: its row of Descriptions, or of the table; null for none.

public ItemIcon? IconOf(string item, TableSet? tables = null)

The picture item has of its own (its row of Icons, or of the table), or null.

public void LookAt(string? item)

Has the walker look at item and say its description, at the start of the next frame.

public void Pick(string? item)

Picks item up onto the pointer, if the inventory holds one, as clicking it does.

public void PutBack()

Puts back the item on the pointer.

public override string? SetupNote()

A line for the Inspector about rows it can’t read.

public event Action<string, string, IReadOnlyList<string>>? Combined

Raised as two items are put together, with the two and what they made (nothing, for two that don’t go together).

public event Action<string>? Looked

Raised as an item is looked at, with its name.

public event Action<string>? Picked

Raised as an item is picked up onto the pointer (with its name) or put back (with null).