Skip to main content

Bellows

A class in Root.Township, the global namespace.

The smelter's bellows. Tracks the handle as players pump it and turns that into a heat value the Smelter reads; also drives the coal glow, light, particles and sound. Runs on both sides.

Constructors​

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

Fields​

38 private and internal fields
MemberWhat it is
private Vector3 alignVectorLocal direction on the pivot that is turned to point at the hands.
private float baseValueResting value the bellows fall back to. Defaults to 0.1.
private Pickup bellowsHandlePickupThe handle pickup players grab to pump the bellows.
private SoundEffectSet bellowSoundSound played once per pump.
private bool belowsHaveBeenOpenedTrue once the bellows have opened since the last pump sound.
private Renderer coalsRenderer of the coals whose emission glows with the value.
private AnimationCurve coalsBrightnessCurve from value progress to coal emission brightness.
private float cooldownPerSecondHow much SteadyValue drops per second. Defaults to 0.1.
private float downBellows angle, in degrees, that counts as fully closed.
private AnimationCurve duringPumpAdditionCurve for the short-lived boost a pump adds, by how open the bellows are.
private Vector3 handleRotatingAxisLocal axis the handle turns around to match the hand rotation.
private Transform handleRotatingTransformHandle transform that turns to follow the hands' grip.
private bool isOffCenterTrue while the bellows are still more than a degree away from neutral after being let go.
private bool isPlayingParticlesTrue while the particle effects are showing.
private float lastBellowSoundTimeTime.time of the last pump sound.
private LightFader lightFaderOptional light fader brightened by the value.
private float maxDifferenceFromNeutralFurthest the bellows can rotate from neutral, in degrees.
private float maximumLightLight multiplier at full value.
private float maxValueCap for Value and SteadyValue. Defaults to 1.
private float minimumLightLight multiplier at base value.
private float minPercentageToTriggerBellowSoundHow closed the bellows must get for the pump sound to play.
private float minPercentToResetBellowSoundHow open the bellows must get before the next pump sound can play.
private float minSecondsBetweenBellowSoundsMinimum seconds between pump sounds.
private Quaternion neutralRotationPivot rotation the bellows return to when nobody holds the handle.
private float oldProgressHow open the bellows were last frame, used to measure the closing motion.
private Transform[] particlePositionPoints where the pooled particle effects are spawned.
private ParticleSystem[] particlesParticle systems found in the pooled particle objects.
private AnimationCurve particlesAlphaCurve from value progress to particle alpha.
private PooledObjectDefinition particlesDefinitionPooled object definition for the bellows particles.
private PooledObject[] particlesObjectsPooled particle objects currently taken from the pool.
private Coroutine particlesStoppingCoroutineRunning delayed-release coroutine, if any.
private Vector3 pivotAxisLocal axis the bellows pivot around.
private Transform pivotTransformTransform rotated by the faux joint as the handle moves.
private AnimationCurve pumpEfficiencyCurve for how much a pump adds to SteadyValue, by how open the bellows are.
private float pumpingValueMaxDecreaseSpeedFastest the pump boost can fall, per second.
private float smoothPumpingValueSmoothed short-lived boost from recent pumping, added on top of SteadyValue.
private float upBellows angle, in degrees, that counts as fully open.
private IUnityUpdateMethod updateMovementHandle for the registered UpdateMovement method, null when idle.

Properties​

MemberWhat it is
Smelter Smelter { get; set; }The smelter these bellows feed. Pumping only adds to SteadyValue while it is smelting.
float SteadyValue { get; private set; }Heat value built up by pumping while smelting. Cools by cooldownPerSecond down to baseValue.
float Value { get; private set; }Current total heat value: SteadyValue plus the short boost from the current pump, capped at maxValue.

Events​

MemberWhat it is
event Action<Bellows, float> UpdatesSteadyValueRaised every movement update with the bellows and the new SteadyValue.

Methods​

17 private and internal methods
MemberWhat it is
private bool AreBellowsOpen(float progress)True when the bellows are open past minPercentToResetBellowSound, which re-arms the pump sound.
private bool CanTriggerBellowSound(float progress)True when the bellows have been reopened, are now nearly closed and enough time has passed since the last sound.
private void EvaluateAudio(float progress)Client: plays the bellow sound once per pump, when the bellows close after being opened.
private float GetBellowAngle()Returns the bellows' local Z rotation, wrapped to the range -180 to 180 degrees.
private void OnDestroy()Stops the movement update and cleans up the coal material instance.
private void Start()Hooks the handle pickup's InteractionStarted and sets SteadyValue to the base value.
private void StartParticleSystems()Client: takes pooled particle effects at each particlePosition and starts showing them.
private void StartUpdatingBellows(Interactable arg1, Interactor arg2)Registers UpdateMovement with the update loop when a player grabs the handle.
private void StopParticleSystems()Client: marks particles as stopped and releases them back to the pool after two seconds.
private IEnumerator StopParticleSystemsDelayed() (iterator)Coroutine that waits two seconds, then releases the pooled particle objects.
private void TrackHands()Rotates the bellows toward the hands holding the handle, or back toward the neutral rotation when let go.
private void UpdateCoals(float lightProgress)Client: sets the coals' emission brightness from the coalsBrightness curve.
private void UpdateLightFader(float lightProgress)Client: sets the light fader's multiplier between minimumLight and maximumLight.
private void UpdateMovement()Per-frame update while pumped or settling. Tracks hands and updates the value; deregisters once at rest.
private void UpdateParticleSystemAlpha(float alpha)Client: sets the start colour alpha of the playing particle systems.
private void UpdateParticleSystems(float lightProgress)Client: sets particle alpha from the curve and starts or stops the particles when it crosses zero.
private void UpdateValue()Turns the closing motion into SteadyValue and Value, grants Forging experience on the server and fires UpdatesSteadyValue.

Used in​

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