Skip to main content

Pump

A class in Root.Township, the global namespace.

Turns lever strokes into a pouring strength that slowly drains, and sends it out through an event every frame while above zero.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private float currentPouringValueCurrent pump strength, clamped between min and max.
private AnimationCurve decreaseMultiplierPerStrengthCurve scaling the drain rate by how full the pump is.
private bool isPumpingDownwardsWhich lever direction counts as a pump stroke.
private Lever leverLever that drives the pump.
private float leverChangeMultiplierScales how much a lever movement adds.
private float pouringDecreasePerSecondBase drain per second.
private float pouringValueMaxHighest pouring value.
private float pouringValueMinLowest pouring value.
private FloatEvent pumpEventEvent given the pouring value each frame.

Methods​

5 private and internal methods
MemberWhat it is
private void Awake()Hooks the lever's value change.
private void CheckDisable()Disables the component once the pouring value reaches zero.
private void CheckEnable()Enables the component when the pouring value goes above zero.
private void IncreaseStrength(Lever lever, float oldValue, float newValue)Adds to the pouring value when the lever moves in the pumping direction.
private void Update()Sends the current value through pumpEvent, then drains it by a rate scaled by the strength curve.