Skip to content

Trigger

namespace Griff.Scenes;
public sealed class Trigger : Component

When a message arrives, does something with no code: “when Score arrives, Damage the Boss by 2”, “when Beat arrives, End Turn”, “when Matched arrives from Board A, Fire the Cannon”. It hears its Message (from anyone, or only from the entity named From) and does the action Do names on its Targets, or on its own entity without any: whatever their components can do (a switch’s On, a door’s Open, a spawner’s Spawn, a health’s Damage…; see each component’s actions), scripts’ own actions included. Give an entity a Trigger for each thing it reacts to. The Scene view draws a line from it to what it drives.

The action is done where the game is run: offline, or on the host of a network game (things only this player sees, such as their panels and sounds, on their own machine). A trigger can’t set itself off over and over in the same moment: a chain of triggers stops after a few steps.

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

public string? Do { get; set; }

What to do, e.g. “Damage”, “Open” or “Spawn”: an action of the Targets’ components (or this entity’s). “Health.Damage” names one component’s when two have an action called the same; without that, every component with one does it.

public int Fired { get; }

How many times it has gone off.

public string? From { get; set; }

Only hear the message when this entity sent it (it, or something inside it, such as a goal on a board), e.g. “Board A”. Empty hears it from anyone.

public string? Message { get; set; }

The message it waits for, e.g. “Score” or “PlayerDied”: one a component sends, a dialogue’s [send], or a script’s Game.Send.

public string? Targets { get; set; }

The entities to do it on, by name, separated by commas (those inside this one first). Empty does it on this entity.

public bool UseMessageNumber { get; set; }

Hear it with the message’s own number as the value, when it sends one (a beat’s number, the points scored), rather than With.

public string? With { get; set; }

What to do it with, for an action that takes a value: how much (Damage 2), a name (Set Flag “MetGuide”) or true or false. Empty uses the action’s own default (1 for an amount).

public override string? LinkLabel(string property)
public override string? SetupNote()
public string Summary()

What it does, in a few words, e.g. “When Score arrives from Board A, Damage 2 on Boss”.

public override bool Uses(string property)
public event Action<object>? Went

Raised each time it goes off, with the message’s data.