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.
- Listed in Items, inventory and logic
- Inherits or implements
NetworkEntityBehaviour - Derived types
Crank - Documented in Other systems
Constructors
| Member | What it is |
|---|---|
protected Mechanism() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private UnityEvent activatedEffects | Unity event fired on activation, for effects. |
private UnityEvent activatedOnServer | Unity event fired on activation, on the server only. |
private Pickup activationPickup | Backing field for ActivationPickup. |
private Pickup basePickup | Pickup that must be held before the activation pickup can be grabbed, when hand based. |
private Coroutine checkingTurn | The running CheckAction coroutine. |
private bool isHandBased | Whether basePickup must be held first. |
Properties
| Member | What it is |
|---|---|
Pickup ActivationPickup { get; } | The pickup players grab to work the mechanism. |
Methods
| Member | What 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
| Member | What 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. |