Skip to main content

Mechanism

An abstract class in Root.Township, Alta.Mechanisms.

Base for hand-driven mechanisms such as Crank: grabbing the activation pickup starts a server coroutine that checks for activation and fires events.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private UnityEvent activatedEffectsUnity event fired on activation, for effects.
private UnityEvent activatedOnServerUnity event fired on activation, on the server only.
private Pickup activationPickupBacking field for ActivationPickup.
private Pickup basePickupPickup that must be held before the activation pickup can be grabbed, when hand based.
private Coroutine checkingTurnThe running CheckAction coroutine.
private bool isHandBasedWhether basePickup must be held first.

Properties​

MemberWhat it is
Pickup ActivationPickup { get; }The pickup players grab to work the mechanism.

Methods​

MemberWhat it is
protected abstract IEnumerator CheckAction()Coroutine the subclass writes to watch for activation; runs on the server while held.
protected void OnActivated()Fires activatedEffects, and activatedOnServer on the server.
protected virtual void OnInteracted(Interactable interactable, Interactor interactor)Called when the activation pickup is grabbed; empty by default.
4 private and internal methods
MemberWhat it is
private void Awake()Hooks the activation pickup's grab and release, and adds the hand filter if hand based.
private void FilterHand(Interactor interactor, Interactable interactable, ref bool result)Only allows grabbing the activation pickup while basePickup is held.
private void StartCheck(Interactable interactable, Interactor interactor)On grab, calls OnInteracted and, on the server, restarts CheckAction.
private void StopCheck(Interactable interactable, Interactor interactor)On release, stops the CheckAction coroutine.