Skip to main content

AutomaticDockArea

A class in Root.Township, Alta.Inventory.

A trigger area that docks loose pickups dropped into it, first into a dock of the same item type and then into any dock that takes it. Server only; clients turn its colliders off.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Collider[] collidersThe trigger colliders of this area.
private PickupDock[] docksBacking field for Docks.
private static Logger loggerNLog logger for this class.
private int recheckCountCounter that sets how often OnTriggerStay retries; starts at a random value so areas don't all recheck together.
private IUnityUpdateMethod updateThe registered budgeted update for UpdateCount.

Properties​

MemberWhat it is
PickupDock[] Docks { get; set; }The docks pickups are put into, in order of preference.
1 private and internal property
MemberWhat it is
private int IBuildRendererBakeable.SortingOrder { get; }Bake order, always 0.

Methods​

MemberWhat it is
protected virtual void HandleReject(Pickup pickup)Called when no dock would take a pickup. Does nothing here; subclasses can override it.
9 private and internal methods
MemberWhat it is
private void IBuildRendererBakeable.Bake(bool isSaving)Build bake hook. Does nothing.
private void IBuildRendererBakeable.Clean()Build bake clean hook. Does nothing.
private void Initialize(NetworkEntity entity)Once the first dock's entity is ready: the server starts the recheck counter; clients disable the trigger colliders.
private void OnDisable()Stops the recheck counter update.
private void OnTriggerEnter(Collider other)Server: docks a loose, unheld, non-kinematic pickup into the first matching dock, then any accepting dock, else calls HandleReject.
private void OnTriggerStay(Collider other)Retries docking for objects still in the trigger, once every 30 budgeted updates.
private void OnValidate()Editor: warns about null docks and, if no colliders are set, fills colliders with the trigger colliders on this object or its rigidbody.
private void Start()Removes the component if it has no docks, otherwise initializes once the first dock's entity is ready.
private void UpdateCount()Budgeted update that steps recheckCount round from 0 to 29.

Used in​

Members of other types that take, return or hold a AutomaticDockArea: