Fire
A class in Root.Township, Alta.Heat.
A heat source that burns, either on a timer or on fuel from a dock and a fuel area (campfires, the smelter's inner fire, tinder). The server lights and puts it out; it goes out if docked somewhere that doesn't allow fire.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
HeatSourceBase,IFlammable,IEntityReplaceHandler,ISavable<FireSaveData>,ISavableSave<FireSaveData>,ISavableSaveBase - Derived types
FireDissolve,FireSaveData - Nested types
FuelConsumptionState - Attributes
SavingInfo,RequireComponent - Documented in Heat, Health and damage
Constructors
| Member | What it is |
|---|---|
Fire() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
20 private and internal fields
| Member | What it is |
|---|---|
private PooledFireEffect activeFireEffect | The current fire effect, if it's a PooledFireEffect. |
private float baseFuel | Fuel the fire starts with, from 0 to 1, before any added fuel. Defaults to 0.3. |
private float baseFuelDuration | Seconds the base fuel burns for. |
private Fire.FuelConsumptionState consumptionState | Pooled tracking of fuel in the fuel area while it burns. |
private CraftingPart craftingPart | Crafting part on the prefab root. When set, the fire follows the root's pickup. |
private static List<Pickup> destroyed | Static scratch list of destroyed fuel pickups for TickFuelConsumption. |
private GameObject destroyOnExtinguish | Object destroyed when the fire goes out. |
private Collider fireCollider | The fire's collider, turned back on after docking into a dock that isn't physical. |
private PickupArea fuelArea | Area whose contained pickups burn as fuel. |
private float fuelConsumptionDuration | Seconds per docked fuel item when simulating time passed. |
private float fuelConsumptionProgress | Progress burning the current docked fuel item, from 0 to 1. Synced and saved. |
private PickupDock fuelDock | Dock whose stored fuel burns one item at a time. |
private bool isFuelBased | Whether the fire burns fuel. When false it runs on a lit timer instead. |
private bool isIgnoringSparks | When true, sparks from SimulateSparks don't light this fire. |
private bool isInNoFireDock | True after the fire's pickup was docked somewhere fire isn't allowed; blocks lighting until it's undocked. |
private bool isPreWarmingEffect | Set on a replacement fire so its effect starts already warmed up. |
private static Logger logger | NLog logger for this class. |
private float maximumEfficiency | Efficiency at which the fire burns at full strength. Defaults to 10. |
private float minTimeDifferenceToSimulate | Fuel-based fires only simulate time gaps longer than this, in seconds. Defaults to 10. |
private Pickup pickup | The pickup this fire is on, whose docking can put it out. |
Properties
| Member | What it is |
|---|---|
protected override IEnumerator LightCoroutine { get; } | What runs while lit: the lit timer, or the fuel burn for fuel-based fires. |
1 private and internal property
| Member | What it is |
|---|---|
private bool Alta.Heat.IFlammable.IsIgnoringSparks { get; } | Explicit IFlammable property: returns isIgnoringSparks. |
Methods
| Member | What it is |
|---|---|
void CheckExtinguish(Interactor interactor, Pickup pickup, PickupDock dock) | Dock handler: puts the fire out when its item is docked where fire isn't allowed (or called with no dock, as on disable). |
void ForceProgress(float progress) | Sets how far through its burn the fire is; a fuel fire instead shortens its base fuel time. |
override void Initialize() | Hooks dock events on the item's pickup, or on the crafting root once it is known. |
static void SimulateSparks(Vector3 position, float radius, float chance) | Tries to light every flammable thing within a radius, with a chance. |
void StopExtinguish(Interactor interactor, Pickup pickup, PickupDock dock) | Undock handler: stops watching the dock's sub-docks. |
void TryLight() | Server: lights the fire if it isn't lit, isn't in a no-fire dock and, for fuel fires, has base fuel or fuel to burn. |
protected override void GetEffect() | Gets the fire effect (not on headless) and sets it lit. |
protected override void Light() | Lights the fire, unless on the server while it sits in a no-fire dock. |
protected override void ReleaseEffect() | Releases the fire effect. |
protected override void Reset() | Resets the fire; a timer fire also restarts its timer. |
protected virtual void RootSet(CraftingPart root) | Hooks dock events on the crafting root's pickup. |
protected override void SerializeProperties(Stream stream) | Adds the fuel consumption progress to the synced heat source state. |
protected override void SetProgress(float progress) | Sets burn progress and updates the fire effect. |
protected override void SimulateTime(float timeDifference) | Catches up after time away: a fuel fire burns off fuel if the gap is long enough, a timer fire moves its timer. |
16 private and internal methods
| Member | What it is |
|---|---|
private void AllowLighting(Interactor interactor, Pickup pickup, PickupDock dock) | When the pickup leaves the dock that put the fire out, lets it be lit again. |
private static void CalculateEfficiency(Fire.FuelConsumptionState consumptionState, ref float efficiency, ref float distribution) | Sums the heat efficiency and burn priority of all fuel in the fuel area. |
private void ConsumeFuel(Fire.FuelConsumptionState consumptionState, Fuel fuel, float fuelDamage, Pickup pickup) | Burns down one fuel pickup. Server: when its life runs out it becomes its burnt version or is destroyed. |
private IEnumerator DelayedFuelSimulation(float timeDifference) (iterator) | After a long gap, destroys docked fuel for the time passed and burns the fuel area forward in one tick. |
private IEnumerator DelayReenableCollider() (iterator) | Turns the fire collider back on at the end of the frame. |
private IEnumerator FuelDock() (iterator) | Coroutine that burns docked fuel one item at a time, setting fire strength from what's left. |
private Fuel GetFuel(Pickup pickup) | Gets the Fuel data for a pickup's item and physical material. |
private IEnumerator GraduallyConsumeFuel() (iterator) | Coroutine that burns everything in the fuel area each frame until it's empty, and counts the campfire-lit stat. |
private void HandleFuelAdded(Pickup pickup, Fire.FuelConsumptionState consumptionState, bool isSimulation) | Starts tracking a fuel pickup with a randomised life, adding its volume to the heat point. |
private void HandleFuelRemoved(Pickup pickup, Fire.FuelConsumptionState consumptionState) | Stops tracking a fuel pickup and takes its volume off the heat point. |
private void OnDisable() | Runs the extinguish check when the fire is disabled, unless it's being destroyed or the game is quitting. |
private void PickupSet(Pickup newPickup) | Hooks the dock and undock events of the pickup the fire belongs to. |
private void Alta.Networking.IEntityReplaceHandler.ReplacedWith(NetworkEntity entity, ReplaceAvoidFlags replaceAvoidFlags) | Explicit IEntityReplaceHandler method: carries the fire's progress and lit state to the replacement, unless the replace skips charge. |
private IEnumerator RunFuel() (iterator) | Coroutine for fuel-based fires: burns the base fuel, then the fuel dock, then the fuel area, then the server puts it out. |
private void Subdocked(Interactor interactor, PickupDock subDock, Pickup subDockPickup, PickupDock topDock) | Puts the fire out when something is docked under it in a dock that doesn't allow fire. |
private void TickFuelConsumption(Fire.FuelConsumptionState consumptionState, float deltaTime) | One step of burning the fuel area: sets fire strength and spreads the burn over the fuel by priority. |
Used in
Members of other types that take, return or hold a Fire: