Skip to main content

CoinPress

A class in Root.Township, the global namespace.

A lever press that turns input items into coins. When the lever is pulled down fully, the server takes items from the input dock and adds output to the output dock.

Constructors​

MemberWhat it is
CoinPress()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

13 private and internal fields
MemberWhat it is
private float addMaxThresholdLever value under which items can be added to the input dock.
private float downHeightLocal height of the press when fully down.
private PickupDock inputDockDock that takes the item to be pressed.
private Lever leverThe lever that drives the press.
private int outputHow many output items one press makes (5 by default).
private PickupDock outputDockDock the made items go into. Spawns a new stack there or adds to the existing one.
private Item outputItemThe item the press makes.
private Transform pressTransform of the press head that moves with the lever.
private AnimationCurve pressCurveCurve from lever value to press height.
private AltaEvent pressedEvent raised on the server after each press.
private float pressMinThresholdLever value above which a press happens.
private int requiredInputHow many input items one press uses.
private float upHeightLocal height of the press when fully up.

Methods​

MemberWhat it is
override void Initialize()Adds the input dock filter.
3 private and internal methods
MemberWhat it is
private void Awake()Hooks the lever's ValueChanged.
private void InputFilter(Interactor interactor, Pickup pickup, ref bool result)Only allows docking into the input while the lever is near the top (below addMaxThreshold).
private void ValueChanged(Lever lever, float oldValue, float newValue)Moves the press with the lever. Server: when the lever passes pressMinThreshold with enough input, destroys requiredInput items and adds output items.