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.
- Listed in Global namespace: C to D
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
DockCounter() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private PickupDock dock | The dock being counted. |
private bool isActive | Whether the threshold is currently reached. |
private bool isRunOnClient | Whether to run on clients. |
private bool isRunOnServer | Whether to run on the server. |
private int threshold | Item count that triggers the events (10 by default). |
private AltaEvent thresholdDropped | Fired when the count drops back below the threshold. |
private AltaEvent thresholdReached | Fired when the count reaches the threshold. |
Methods
4 private and internal methods
| Member | What 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. |