Skip to main content

HeatSourceBase

A class in Root.Township, Alta.Heat.

Something that burns. On the server it lights when its attached heat point passes the ignition temperature, heats that point while lit, and goes out when it cools or its burn time runs out. The lit state is synced and saved.

Constructors​

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

Fields​

MemberWhat it is
protected PooledObject activeEffectThe fire effect currently shown.
protected HeatPoint attachedHeatPointHeat point that lights the source and that it heats.
protected PooledObjectDefinition fireEffectPooled fire effect to show while lit.
protected bool hasHeatPointServer: true if there is an attached heat point.
protected static UpdateModule heatUpdateModuleShared fixed-update module that runs ConductToHeatPoint.
protected bool isExtinguishingTrue while the fire is going out.
protected bool isSerializingSet while a save is loading, cleared half a second after.
protected float litProgressHow far through its lit duration a timed source is, 0 to 1.
19 private and internal fields
MemberWhat it is
private AmbientTemperatureChecker ambientCheckerPrivate: reads the ambient temperature, the minimum the source conducts to its heat point.
private HeatArea attachedHeatAreaOptional HeatArea that the server turns on while lit.
private NetworkEntity destroyTargetOptional entity broken or destroyed when the fire burns out on its own.
private AltaCoroutine extinguishCoroutinePrivate: the running extinguish coroutine.
private AnimationCurve fireProgressToTemperatureTemperature the source pushes into its heat point over burn progress.
private Rigidbody fireRigidbodyPrivate: the rigidbody added while lit, removed when put out.
private bool? hasMessagePrivate: a lit state received while the object was inactive, applied on the next Light.
private IUnityUpdateMethod heatPointOperationPrivate: the registered update that conducts heat while lit.
private float ignitionTemperatureHeat point temperature at which the source lights. Defaults to 100.
private bool isAddingRigidbodyWhenLitIf set, a kinematic rigidbody is added shortly after lighting.
private bool isAsphixiableBacking field for IsAsphixiable.
private bool isAsphyxiatedPrivate: set by Asphixiate. Stops lighting and heat conduction until released.
private bool isIgnoringAmbientWhileBurningWhether the heat point ignores ambient temperature while burning. Defaults to true.
private bool isLitBacking field for IsLit.
private AltaCoroutine lightingCoroutinePrivate: the running burn timer coroutine.
private float litDurationSeconds the source burns before going out by itself.
private float putOutTemperatureHeat point temperature below which a lit source goes out. Defaults to 80.
private FireSettings settingsBacking field for Settings.
private MethodSync syncPrivate: the state sync message.

Properties​

MemberWhat it is
bool IsAsphixiable { get; }Whether Asphixiate has any effect.
bool IsLit { get; protected set; }Whether it is burning.
float Progress { get; private set; }Burn progress shown to subclasses, from 0 to 1 for a timed source.
FireSettings Settings { get; }Fire effect settings.
protected bool HasEffect { get; set; }Whether this copy shows a fire effect.
protected virtual IEnumerator LightCoroutine { get; }The coroutine run while lit. By default WaitLitTimer.

Events​

MemberWhat it is
event Action BreakExtinguishRaised when it goes out by burning up, as opposed to being forced out.
event Action ExtinguishedRaised when it starts going out.
event Action<bool> InvertedToggleEventRaised with the opposite of ToggleEvent: false when lit, true when out.
event Action<bool> ToggleEventRaised with true when it lights and false when it goes out.

Methods​

MemberWhat it is
void Asphixiate()Smothers the source if it is asphyxiable: puts it out and stops it lighting until released.
void ForceExtinguish(bool isInstant)Puts the fire out without breaking anything, optionally at once.
override void Initialize()Sets up the sync message and, on the server, watches the heat point to light or put out.
override void OnConnected(Player player)Server: sends a joining player the lit state.
void ReleaseAsphyxiate()Lets an asphyxiated source light again.
protected virtual void Awake()Sets up the ambient temperature check and whether to show the fire effect (never on a headless server).
protected virtual void ConductToHeatPoint()Server, every fixed update while lit: heats the point from the burn-progress curve, at least to ambient.
protected IEnumerator Extinguish(bool isbreaking = true, bool isInstant = false) (iterator)Coroutine that puts the fire out over about a second, then resets and may break or destroy the target.
protected virtual void GetEffect()Spawns the fire effect on this transform.
protected virtual void Light()Lights the source. On the server it syncs, forces the point up to ignition temperature, turns on the heat area and starts the burn timer.
protected virtual void OnValidate()Editor hook. Empty.
protected virtual void ReleaseEffect()Releases the fire effect.
protected virtual void Reset()Hook called when the fire has gone out. Empty by default.
protected virtual void SerializeProperties(Stream stream)Writes or reads extra sync data. By default the lit progress.
protected virtual void SetProgress(float progress)Sets Progress. Subclasses override it to react.
protected virtual void SimulateTime(float timeDifference)Advances the burn for time passed while unloaded, going out if it would have burned up.
protected void StartExtuinguish(bool isbreaking = true, bool isInstant = false)Starts the Extinguish coroutine, replacing any running one.
protected IEnumerator WaitLitTimer() (iterator)Counts litProgress up to 1 over the lit duration, then the server puts the fire out.
10 private and internal methods
MemberWhat it is
private void ConductToHeatPointOperation()Private: update module callback that runs ConductToHeatPoint each fixed update while lit.
private IEnumerator DelayedConclude() (iterator)Private: clears isSerializing half a second after a lit source loads.
private void ExtinguishEnd()Private: last step of putting out the fire. Releases the effect, turns off the heat area, syncs and raises the toggle events.
private void Alta.Chunks.ISavableFull.LoadSetup()After loading, relights a lit source or sets the heat point just under ignition and checks it again.
private void OnDestroy()Private: stops the heat point update.
private void OnIsLitChanged(bool newIsLitValue)Private: stops the heat point update when the source goes out.
private void StopLightingAndExtinguishingCoroutines()Private: stops any running burn or extinguish coroutine.
private void SyncSerialize(IPlayer player, Stream stream)Private: syncs lit, extinguishing and lit progress. Clients light, extinguish or restart the burn timer from it.
private void UpdateHeat(HeatPoint point)Private, server: lights the source above ignitionTemperature and puts it out below putOutTemperature.
private IEnumerator WaitToReset() (iterator)Private: half a second after lighting, adds a kinematic rigidbody for isAddingRigidbodyWhenLit.

Used in​

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