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.
- Listed in Global namespace: A to B
- Inherits or implements
MonoBehaviour - Documented in Smelting and forging
Constructors
| Member | What it is |
|---|---|
Bellows() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
38 private and internal fields
| Member | What it is |
|---|---|
private Vector3 alignVector | Local direction on the pivot that is turned to point at the hands. |
private float baseValue | Resting value the bellows fall back to. Defaults to 0.1. |
private Pickup bellowsHandlePickup | The handle pickup players grab to pump the bellows. |
private SoundEffectSet bellowSound | Sound played once per pump. |
private bool belowsHaveBeenOpened | True once the bellows have opened since the last pump sound. |
private Renderer coals | Renderer of the coals whose emission glows with the value. |
private AnimationCurve coalsBrightness | Curve from value progress to coal emission brightness. |
private float cooldownPerSecond | How much SteadyValue drops per second. Defaults to 0.1. |
private float down | Bellows angle, in degrees, that counts as fully closed. |
private AnimationCurve duringPumpAddition | Curve for the short-lived boost a pump adds, by how open the bellows are. |
private Vector3 handleRotatingAxis | Local axis the handle turns around to match the hand rotation. |
private Transform handleRotatingTransform | Handle transform that turns to follow the hands' grip. |
private bool isOffCenter | True while the bellows are still more than a degree away from neutral after being let go. |
private bool isPlayingParticles | True while the particle effects are showing. |
private float lastBellowSoundTime | Time.time of the last pump sound. |
private LightFader lightFader | Optional light fader brightened by the value. |
private float maxDifferenceFromNeutral | Furthest the bellows can rotate from neutral, in degrees. |
private float maximumLight | Light multiplier at full value. |
private float maxValue | Cap for Value and SteadyValue. Defaults to 1. |
private float minimumLight | Light multiplier at base value. |
private float minPercentageToTriggerBellowSound | How closed the bellows must get for the pump sound to play. |
private float minPercentToResetBellowSound | How open the bellows must get before the next pump sound can play. |
private float minSecondsBetweenBellowSounds | Minimum seconds between pump sounds. |
private Quaternion neutralRotation | Pivot rotation the bellows return to when nobody holds the handle. |
private float oldProgress | How open the bellows were last frame, used to measure the closing motion. |
private Transform[] particlePosition | Points where the pooled particle effects are spawned. |
private ParticleSystem[] particles | Particle systems found in the pooled particle objects. |
private AnimationCurve particlesAlpha | Curve from value progress to particle alpha. |
private PooledObjectDefinition particlesDefinition | Pooled object definition for the bellows particles. |
private PooledObject[] particlesObjects | Pooled particle objects currently taken from the pool. |
private Coroutine particlesStoppingCoroutine | Running delayed-release coroutine, if any. |
private Vector3 pivotAxis | Local axis the bellows pivot around. |
private Transform pivotTransform | Transform rotated by the faux joint as the handle moves. |
private AnimationCurve pumpEfficiency | Curve for how much a pump adds to SteadyValue, by how open the bellows are. |
private float pumpingValueMaxDecreaseSpeed | Fastest the pump boost can fall, per second. |
private float smoothPumpingValue | Smoothed short-lived boost from recent pumping, added on top of SteadyValue. |
private float up | Bellows angle, in degrees, that counts as fully open. |
private IUnityUpdateMethod updateMovement | Handle for the registered UpdateMovement method, null when idle. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event Action<Bellows, float> UpdatesSteadyValue | Raised every movement update with the bellows and the new SteadyValue. |
Methods
17 private and internal methods
| Member | What 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: