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.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
NetworkEntityBehaviour,ISavableFull<HeatSourceBaseSaveData>,ISavable<HeatSourceBaseSaveData>,ISavableSave<HeatSourceBaseSaveData>,ISavableSaveBase,ISavableFull - Derived types
EnergyBasedHeatSource,Fire,HeatSourceBaseSaveData - Documented in Heat, Update modules
Constructors
| Member | What it is |
|---|---|
HeatSourceBase() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected PooledObject activeEffect | The fire effect currently shown. |
protected HeatPoint attachedHeatPoint | Heat point that lights the source and that it heats. |
protected PooledObjectDefinition fireEffect | Pooled fire effect to show while lit. |
protected bool hasHeatPoint | Server: true if there is an attached heat point. |
protected static UpdateModule heatUpdateModule | Shared fixed-update module that runs ConductToHeatPoint. |
protected bool isExtinguishing | True while the fire is going out. |
protected bool isSerializing | Set while a save is loading, cleared half a second after. |
protected float litProgress | How far through its lit duration a timed source is, 0 to 1. |
19 private and internal fields
| Member | What it is |
|---|---|
private AmbientTemperatureChecker ambientChecker | Private: reads the ambient temperature, the minimum the source conducts to its heat point. |
private HeatArea attachedHeatArea | Optional HeatArea that the server turns on while lit. |
private NetworkEntity destroyTarget | Optional entity broken or destroyed when the fire burns out on its own. |
private AltaCoroutine extinguishCoroutine | Private: the running extinguish coroutine. |
private AnimationCurve fireProgressToTemperature | Temperature the source pushes into its heat point over burn progress. |
private Rigidbody fireRigidbody | Private: the rigidbody added while lit, removed when put out. |
private bool? hasMessage | Private: a lit state received while the object was inactive, applied on the next Light. |
private IUnityUpdateMethod heatPointOperation | Private: the registered update that conducts heat while lit. |
private float ignitionTemperature | Heat point temperature at which the source lights. Defaults to 100. |
private bool isAddingRigidbodyWhenLit | If set, a kinematic rigidbody is added shortly after lighting. |
private bool isAsphixiable | Backing field for IsAsphixiable. |
private bool isAsphyxiated | Private: set by Asphixiate. Stops lighting and heat conduction until released. |
private bool isIgnoringAmbientWhileBurning | Whether the heat point ignores ambient temperature while burning. Defaults to true. |
private bool isLit | Backing field for IsLit. |
private AltaCoroutine lightingCoroutine | Private: the running burn timer coroutine. |
private float litDuration | Seconds the source burns before going out by itself. |
private float putOutTemperature | Heat point temperature below which a lit source goes out. Defaults to 80. |
private FireSettings settings | Backing field for Settings. |
private MethodSync sync | Private: the state sync message. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event Action BreakExtinguish | Raised when it goes out by burning up, as opposed to being forced out. |
event Action Extinguished | Raised when it starts going out. |
event Action<bool> InvertedToggleEvent | Raised with the opposite of ToggleEvent: false when lit, true when out. |
event Action<bool> ToggleEvent | Raised with true when it lights and false when it goes out. |
Methods
| Member | What 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
| Member | What 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: