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.
- Listed in Global namespace: P
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
Pump() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private float currentPouringValue | Current pump strength, clamped between min and max. |
private AnimationCurve decreaseMultiplierPerStrength | Curve scaling the drain rate by how full the pump is. |
private bool isPumpingDownwards | Which lever direction counts as a pump stroke. |
private Lever lever | Lever that drives the pump. |
private float leverChangeMultiplier | Scales how much a lever movement adds. |
private float pouringDecreasePerSecond | Base drain per second. |
private float pouringValueMax | Highest pouring value. |
private float pouringValueMin | Lowest pouring value. |
private FloatEvent pumpEvent | Event given the pouring value each frame. |
Methods
5 private and internal methods
| Member | What 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. |