Skip to content

Game.Prefabs.Fire

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Represents a fire event prefab used by the game's event system. Exposes configurable prefab fields (probability, intensity, spread, target selection) which are written into a FireData component on the instantiated entity. This prefab contributes the required ECS components when creating the corresponding entity archetype so runtime systems can process fires (escalation, spread, targeting).


Fields

  • public EventTargetType m_RandomTargetType
    Controls how a random target is chosen for fire starts. Determines the kind of target element (for example: building, vehicle, tree, etc.) that a spontaneously starting fire can pick. This value is copied into FireData during Initialize.

  • public float m_StartProbability = 0.01f
    Chance that a fire will start for a given evaluation period (units depend on the calling system). Default shown in prefab is 0.01 (1%). Written to FireData.m_StartProbability.

  • public float m_StartIntensity = 1f
    Initial intensity of newly started fires. Higher values indicate stronger fires at spawn. Value is copied to FireData.m_StartIntensity.

  • public float m_EscalationRate = 1f / 60f
    Rate at which fire intensity increases over time. The default is 1/60 per time unit (commonly interpreted as per second/frame depending on the system). Assigned to FireData.m_EscalationRate.

  • public float m_SpreadProbability = 1f
    Probability that a fire will attempt to spread from a burning target to nearby targets during spread evaluation. Default is 1 (always attempt). Stored in FireData.m_SpreadProbability.

  • public float m_SpreadRange = 20f
    Maximum distance (units in world space) within which a fire can spread to another target. Default 20. Stored in FireData.m_SpreadRange.

Properties

  • This prefab class does not declare any C# properties. It exposes public fields that are copied into the ECS FireData component in Initialize.

Constructors

  • public Fire()
    Implicit default constructor. Typical usage is to configure fields in the prefab asset in the editor; no custom construction logic is defined in this class.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds runtime ECS component types required when this prefab is created as a prefab asset. Specifically, adds ComponentType.ReadWrite() so each instantiated entity gets a FireData component for runtime fire logic.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds component types that must be present on the entity archetype when this prefab is instantiated as an archetype. This implementation adds Game.Events.Fire (runtime marker/data used by event systems) and TargetElement (used for targeting/spread). These determine the entity layout used by fire-related systems.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is instantiated into an entity. Creates and populates a FireData struct from the prefab fields:

  • Copies m_RandomTargetType, m_StartProbability, m_StartIntensity, m_EscalationRate, m_SpreadProbability, and m_SpreadRange into a FireData instance and writes it to the given entity via entityManager.SetComponentData(entity, componentData).
  • Ensures the entity has the runtime data required for fire systems to operate.

Usage Example

// Example: The prefab's Initialize already maps inspector fields into the ECS component.
// This is equivalent to how the prefab writes values into the entity's FireData:

public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);

    FireData componentData = default(FireData);
    componentData.m_RandomTargetType = m_RandomTargetType;
    componentData.m_StartProbability = m_StartProbability;
    componentData.m_StartIntensity = m_StartIntensity;
    componentData.m_EscalationRate = m_EscalationRate;
    componentData.m_SpreadProbability = m_SpreadProbability;
    componentData.m_SpreadRange = m_SpreadRange;

    entityManager.SetComponentData(entity, componentData);
}

Additional notes: - Configure the public fields on the prefab asset in the editor to tune fire behavior (spawn chance, intensity, spread). - The actual runtime behavior (timing, spread checks, extinguishing) is implemented by systems that read Game.Events.Fire, TargetElement, and FireData from entities.