Skip to content

ConveyorPort

namespace Griff.Scenes;
public sealed class ConveyorPort : Component

Where a machine meets a Conveyor, at the cell it stands on: an In port takes what reaches the end of a belt pointing into its cell (or ending on it) into the machine, and an Out port puts what the machine made onto the belt on its cell, or one next to it leading away. Put one on the machine, or on an entity inside it where its way in or out is, so a machine’s prefab brings its ports with it.

It takes into and gives from what holds items on its entity or the one it’s inside (an Inventory), so a machine with an inventory needs no code: an In port with Holds stops taking once the machine has that many, and the line backs up behind it. With nothing holding items, an In port takes everything it’s offered (for a script listening to Received), and an Out port puts only what a script hands it with Give. An item it won’t take waits at the belt’s end (it’s Blocked) until something takes it off.

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

public Func<string, bool>? Accepts { get; set; }

A script’s say in what an In port takes, besides Items: return false to leave the item waiting at the belt’s end. Null takes whatever Items allows.

public bool Blocked { get; }

True if in the last step it held the line up: an In port left an item waiting it wouldn’t take (the wrong item, or the machine’s full), or an Out port had something to put on a belt that had no room.

public bool Full { get; }

True if an Out port with Holds has that many items waiting: its machine can stop making more until there’s room.

public int Holds { get; set; }

For an In port: it stops taking an item once the machine holds this many of it, so the line backs up until the machine uses some. For an Out port: how many items handed it with Give it keeps waiting for room on the belt (a machine’s out tray); once it has that many it’s Full and takes no more. 0 for no limit.

public string? Items { get; set; }

The items it takes or puts, e.g. “Deck, Report”; empty for any. An In port leaves others waiting at the belt’s end; an Out port with none named puts whatever its inventory holds.

public ConveyorPortKind Kind { get; set; }

In takes items off a belt’s end; Out puts them on a belt.

public string? Message { get; set; }

A message sent as it takes or puts an item, with the item’s name as its data (a Counter can count them).

public bool Open { get; set; }

While ticked it takes or puts items; untick it (or switch it off) to hold the line.

public IReadOnlyList<string> Waiting { get; }

What a script has handed an Out port with Give that isn’t on the belt yet, first first (Withdraw takes one back).

public IReadOnlyList<string> Clear()

Takes back everything an Out port is Waiting to put on the belt: returns those items, first first.

public bool Give(string item)

Hands an Out port item to put on its belt as soon as there’s room (after any it already has): false if it’s Full, and the item isn’t taken.

public bool Lets(string item)

True if Items lets it take or put item (its first word counts too: “Deck” lets “Deck 17” by).

public bool Withdraw(string item)

Takes back item an Out port was handed with Give before it’s on the belt (the one handed it last, if several are waiting; its first word counts too: “Deck” takes back a “Deck 17”), to go back to the machine’s tray or onto a cart: false if none is waiting. It’s never Sent.

public event Action<ConveyorPort, string>? Received

Raised once the step is over for each item an In port took, with the item.

public event Action<ConveyorPort, string>? Sent

Raised once the step is over for each item an Out port put on a belt, with the item.