Game.Prefabs.FireData
Assembly:
Game
Namespace:
Game.Prefabs
Type:
struct
Base:
System.ValueType
Summary:
Component data used by the game's ECS to describe fire-related behavior for an entity (e.g., initial chance to start a fire, intensity, escalation and spread parameters). Implements Unity.Entities.IComponentData so it can be attached to entities, and IQueryTypeParameter to support certain query patterns in the DOTS/ECS codebase. Fields are plain public value fields intended to be set by systems or prefab initialization code.
Fields
-
public EventTargetType m_RandomTargetType
Specifies what kind of in-game target is used when selecting random targets for fire-related events. (EventTargetType is expected to be an enum defined elsewhere in the codebase — use the appropriate enum value for buildings, props, vehicles, etc.) -
public float m_StartProbability
Probability that a fire starts on this entity within the relevant sampling/trigger window. Typical values are in the range [0, 1], where 0 means "never" and 1 means "always" (use fractional probabilities such as 0.01 for 1%). -
public float m_StartIntensity
Initial intensity (strength) of the fire when it starts. Interpretation depends on the game's fire system (e.g., visual scale, damage per second). Choose values appropriate for the system's expected units. -
public float m_EscalationRate
Rate at which fire intensity increases over time (for example, units per second). Used by systems that simulate fire growth. Can be zero for non-escalating fires. -
public float m_SpreadProbability
Probability that the fire will attempt to spread to nearby targets per spread evaluation. Typically in [0, 1]. -
public float m_SpreadRange
Maximum distance (in game units, e.g., meters) that the fire can spread from this entity when a spread attempt occurs.
Properties
- This type defines no properties. It uses public fields to store its data.
Constructors
public FireData()
As a struct, FireData has an implicit default parameterless constructor. All fields default to their zero values (enum default, floats = 0f). You can also initialize with an object initializer to set values.
Methods
- This type declares no methods. It only holds data and implements IComponentData and IQueryTypeParameter.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Create and attach FireData to an existing entity
var fire = new FireData
{
m_RandomTargetType = EventTargetType.Building, // example enum value
m_StartProbability = 0.02f,
m_StartIntensity = 1.0f,
m_EscalationRate = 0.15f,
m_SpreadProbability = 0.1f,
m_SpreadRange = 12f
};
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(someEntity, fire);
// Example usage inside a SystemBase
public partial class FireSystem : SystemBase
{
protected override void OnUpdate()
{
// Read/update fire data for all matching entities
Entities.ForEach((ref FireData fireData) =>
{
// Example: clamp probabilities and perform logic
fireData.m_StartProbability = math.clamp(fireData.m_StartProbability, 0f, 1f);
// ...fire simulation code...
}).ScheduleParallel();
}
}
Additional notes: - Probabilities are expected to be normalized (0 to 1). If values outside this range are possible, clamp or validate before use. - Because this is a plain IComponentData struct, prefer using EntityManager or the ECS query APIs to create, read, and modify instances rather than attaching them to MonoBehaviours. - Consult the project's EventTargetType definition to choose appropriate target selection semantics.