Skip to main content

PumpingMechanism

A class in Root.Township, the global namespace.

Bellows on a forge or recycler: turns the player pumping the handle into a heat-like value and gives forging experience. Runs on both sides; experience is only given on the server.

Constructors​

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

Fields​

20 private and internal fields
MemberWhat it is
private Vector3 alignVectorLocal direction on the pivot that is turned to point at the hands.
private float baseValueValue SteadyValue rests at and decays to.
private Pickup bellowsHandlePickupThe handle pickup the player grabs to pump.
private float cooldownPerSecondHow fast SteadyValue falls per second.
private float downBellows angle counted as fully pressed.
private AnimationCurve duringPumpAdditionCurve, by stroke position, for how much a stroke adds to the short-term pumping value.
private Vector3 handleRotatingAxisAxis the handle turns around to match the hands' grip.
private Transform handleRotatingTransformHandle transform turned to match the grip.
private bool isOffCenterTrue while the released bellows are still more than a degree from neutral, which keeps the update running.
private float maxDifferenceFromNeutralFurthest the pivot may turn from neutral, in degrees.
private float maxValueCap for SteadyValue, and the top of Value's range.
private Quaternion neutralRotationPivot's resting local rotation.
private float oldProgressStroke position from the previous frame, used to measure how far it moved.
private Vector3 pivotAxisAxis the pivot hinges around.
private Transform pivotTransformTransform hinged to follow the hands (a fake joint).
private AnimationCurve pumpEfficiencyCurve, by stroke position, for how much a stroke adds to SteadyValue.
private float pumpingValueMaxDecreaseSpeedFastest the short-term pumping value may fall per second.
private float smoothPumpingValueShort-term value from recent strokes; added to SteadyValue for Value and used for experience.
private float upBellows angle counted as fully open.
private IUnityUpdateMethod updateMovementHandle for the registered per-frame update, or null.

Properties​

MemberWhat it is
float SteadyValue { get; private set; }Slow value built up by pumping; decays by cooldownPerSecond towards baseValue and is capped at maxValue.
float Value { get; private set; }Current output from 0 to 1: steady plus short-term pumping value, scaled between base and max.

Events​

MemberWhat it is
event Filter CanPumpListeners can set the flag false to stop pumps from counting.
event Action<PumpingMechanism, float> UpdatesSteadyValueRaised every update with the new SteadyValue; Recycler listens to it.

Methods​

6 private and internal methods
MemberWhat it is
private float GetBellowAngle()Returns this transform's local Z angle in the range -180 to 180.
private void Start()Starts tracking when the handle is grabbed and sets SteadyValue to its base.
private void StartUpdatingBellows(Interactable arg1, Interactor arg2)Registers the per-frame update when the handle is grabbed.
private void TrackHands()Rotates the pivot and handle to follow the holding hands, or eases back to the neutral rotation when let go.
private void UpdateMovement()Per-frame tick; unregisters itself once the bellows are idle, released and back at neutral.
private void UpdateValue()Measures the downward stroke since last frame, updates both values and raises UpdatesSteadyValue. Server: gives the holder forging experience.

Used in​

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