Skip to main content

PickupDockingChecker

A class in Root.Township, the global namespace.

Tracks which dock a held pickup is hovering over, fires hover events, plays haptics and auto docks. Each Pickup creates one; it runs while a local player holds it.

Constructors​

MemberWhat it is
PickupDockingChecker(Pickup pickup)Creates a PickupDockingChecker from pickup.

Fields​

6 private and internal fields
MemberWhat it is
private static HashSet<PickupDock> checkedDocksShared scratch set so each dock is only checked once per search.
private AltaCoroutine currentCheckingCoroutineThe running hover coroutine.
private Interactor interactorOverDockThe interactor that is over the current dock.
private float lastUndockTimeTime left on the cooldown after undocking, in seconds.
private PickupDock overDockBacking field for DockCandidate.
private Pickup pickupThe pickup being checked.

Properties​

MemberWhat it is
PickupDock DockCandidate { get; }The dock the pickup is currently hovering over, or null.

Events​

MemberWhat it is
event PickupDockInteractionHandler HoverOverDockEndedFires when the pickup stops hovering over a dock.
event PickupDockInteractionHandler HoverOverDockStartedFires when the pickup starts hovering over a dock.

Methods​

MemberWhat it is
void ClearCurrentDock()Drops the hovered dock and lowers its hover count.
void ForceDockCheck()Runs one hover check straight away.
void StartCheckingForDock()Restarts the hover coroutine. Called by Pickup when a local interactor grabs it.
7 private and internal methods
MemberWhat it is
private void CheckAutoDock(Interactor interactor)Docks the pickup into the hovered dock if that dock docks automatically, the interactor is local and the undock cooldown is over.
private IEnumerator CheckHover() (iterator)Coroutine that updates the hovered dock every frame while the pickup is held, then clears it.
private int GetClosestDock(out PickupDock closest, out Interactor interactor)Finds the nearest allowed dock overlapping any of the pickup's interactors. Returns how many allowed docks it found.
private void OnHoverEnded(Interactor interactor, PickupDock dock)Raises HoverOverDockEnded.
private void OnHoverStarted(Interactor interactor, PickupDock dock)Raises HoverOverDockStarted.
private void ResetLastUndockedTime(Interactor interactor, Pickup pickup, PickupDock dock)Starts a 0.1 second cooldown after the pickup is undocked, so it isn't auto docked straight back.
private void UpdateOverDock()Works out the closest dock, fires hover start and end events, plays haptics and updates hover counts.

Used in​

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