Skip to content

OutputAttribute

namespace Griff.Scenes;
public sealed class OutputAttribute : Attribute

Marks a property of a component as something it knows that anything in the game can read with no code: a Counter, a Bar or a Text shows it, and a wire (see the Contraptions module’s Wire) carries it. Outputs are found by this attribute, the way components are found, so a script component’s own properties count as soon as they’re marked. The property gives a number (Single), a whole number (Int32), true or false (Boolean) or a name (String, which only text shows), and reading it changes nothing and allocates nothing. Its /// summary says what it is, in the Inspector and to agents.

A method that takes one name and gives one of those is an output read by a name: a faction’s amount of “Gold” or an inventory’s count of “Key”, named “Amount:Gold” or “Count:Key” where it’s read.

public string? Example { get; init; }

For an output read by a name (a method that takes one): a name it’s read by, e.g. “Gold”, for the Inspector’s list and agents.

public string? Name { get; }

What it’s called, e.g. “Score”; the property’s own name if not given (“MovesLeft” reads “Moves Left”).

public string? OutOf { get; init; }

The property of the same component (an output or not) it’s out of, e.g. a board’s Score out of its Target Score: a bar is full at it, and a counter or text shows it as {1} (a counter’s {2}). Nothing (or 0) is out of nothing, and a bar keeps its own Max.