Skip to main content

PickupWeightScale

A class in Root.Township, the global namespace.

A weighing scale: adds up the weight of loose pickups and players standing in its trigger and shows it on a gauge and text.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private HashSet<Pickup> containedPickupsPickups in the trigger.
private GaugeProgressBar gaugeProgressBarGauge that shows the weight.
private float maxWeightWeight that maps to the max notch on the gauge.
private float maxWeightNotchPositionGauge fill (0 to 1) of the max weight notch.
private float minWeightUnused minimum weight setting.
private HashSet<PlayerWeight> playersPlayers standing in the trigger.
private TextRenderer textOptional text showing the total weight.

Methods​

7 private and internal methods
MemberWhat it is
private void Docked(Interactor arg1, Pickup pickup, PickupDock arg3)Stops counting a pickup once it docks somewhere, and refreshes.
private void DockEventWeightUpdate(Interactor interactor, Pickup pickup, PickupDock dock)Refreshes the reading when something docks into or leaves a pickup on the scale.
private void Grabbed(Interactable pickup, Interactor interactor)Refreshes the reading when a pickup on the scale is grabbed or let go.
private void OnTriggerEnter(Collider other)Starts tracking a pickup (not a crafted child) or player that enters, and hooks its events.
private void OnTriggerExit(Collider other)Stops tracking a pickup or player that leaves, and unhooks its events.
private void UpdateWeightDisplay()Queues a reading update for later in the frame.
private void UpdateWeightDisplayInternal()Sums the weight of tracked pickups that aren't held or docked, plus players, and updates the gauge and text.