Skip to main content

DockCounter

A class in Root.Township, the global namespace.

Fires events when the number of items in a PickupDock reaches or drops below a threshold. Can be limited to server or client.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private PickupDock dockThe dock being counted.
private bool isActiveWhether the threshold is currently reached.
private bool isRunOnClientWhether to run on clients.
private bool isRunOnServerWhether to run on the server.
private int thresholdItem count that triggers the events (10 by default).
private AltaEvent thresholdDroppedFired when the count drops back below the threshold.
private AltaEvent thresholdReachedFired when the count reaches the threshold.

Methods​

4 private and internal methods
MemberWhat it is
private void Awake()If it should run on this side, hooks the dock events and checks the current count.
private void ItemDocked(Interactor interactor, Pickup pickup, PickupDock dock)Fires thresholdReached when the stored count reaches the threshold.
private void ItemUndocked(Interactor interactor, Pickup pickup, PickupDock dock)Fires thresholdDropped when the stored count falls below the threshold.
private bool ShouldRun()Whether to run here, by isRunOnServer and isRunOnClient; always in local test.