Skip to content

Game.Prefabs.WeatherPhenomenon

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: Class

Base: ComponentBase

Summary:
This ComponentBase-derived prefab component configures a weather phenomenon (disaster/event) used by the game's event system and converted to ECS data via the prefab→archetype pipeline. It exposes tuning fields (occurrence probability, temperature/rain bounds, duration, radii, lightning interval, hotspot instability, damage/danger levels and behavioral flags) and, on Initialize, writes a WeatherPhenomenonData component onto the entity and sets appropriate DangerFlags. This prefab is intended to be attached to a prefab asset that will be converted into an ECS archetype representing a weather event.


Fields

  • public float m_OccurrenceProbability
    Controls relative chance/frequency of this phenomenon occurring. Default in source: 10f.

  • public Bounds1 m_OccurenceTemperature
    Temperature bounds in which the phenomenon may occur. Default: new Bounds1(0f, 15f).

  • public Bounds1 m_OccurenceRain
    Rain (precipitation) bounds in which the phenomenon may occur. Default: new Bounds1(0f, 1f).

  • public Bounds1 m_Duration
    Duration bounds (in seconds) for the phenomenon. Default: new Bounds1(15f, 90f).

  • public Bounds1 m_PhenomenonRadius
    Overall radius of the phenomenon in world units. Default: new Bounds1(500f, 1000f).

  • public Bounds1 m_HotspotRadius
    Normalized radius (0..1) for “hotspot” region inside the phenomenon. Default: new Bounds1(0.8f, 0.9f).

  • public Bounds1 m_LightningInterval
    Interval bounds for lightning strikes. Default: new Bounds1(0f, 0f) (disabled if zero).

  • [Range(0f, 1f)] public float m_HotspotInstability
    Controls instability/behavior inside hotspot (0..1). Default: 0.1f.

  • [Range(0f, 100f)] public float m_DamageSeverity
    Magnitude of damage inflicted by the phenomenon. Default: 10f.

  • [Tooltip("How dangerous the disaster is for the cims in the city. Determines how likely cims will leave shelter while the disaster is ongoing")] [Range(0f, 1f)] public float m_DangerLevel
    Controls how dangerous the event is for citizens (used by AI/behavior). Default: 1f.

  • public bool m_Evacuate
    If true, sets the DangerFlags.Evacuate flag on the data (causes evacuation behavior).

  • public bool m_StayIndoors
    If true, sets the DangerFlags.StayIndoors flag on the data (causes sheltering behavior).

Properties

  • This class does not expose any C# properties. All configuration is via public fields that are transferred to the WeatherPhenomenonData component in Initialize.

Constructors

  • public WeatherPhenomenon()
    No explicit constructor is defined in source — uses default parameterless construction (typical for Unity components). Initialization of serialized fields happens via field initializers and the Unity inspector.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the prefab component set so converted entities will contain the runtime data container for this phenomenon.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the runtime ECS components required by the phenomenon archetype:

  • Game.Events.WeatherPhenomenon
  • HotspotFrame
  • Duration
  • DangerLevel
  • TargetElement
  • InterpolatedTransform These components define how the phenomenon behaves and is processed by ECS systems.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Creates a WeatherPhenomenonData struct, copies all tunable fields from the prefab (occurrence probability, hotspot instability, damage severity, danger level, radii, lightning interval, duration, temperature and rain bounds), and sets DangerFlags depending on m_Evacuate / m_StayIndoors. Finally it writes the component data to the provided entity via entityManager.SetComponentData(entity, componentData). Note: if both m_Evacuate and m_StayIndoors are true, the latter assignment will overwrite the flag set previously (source sets flags sequentially, not bitwise-combining them).

Usage Example

// Create a prefab GameObject and configure the WeatherPhenomenon fields.
// (Typical usage would be editing this component on a prefab asset in the editor.)
var go = new GameObject("TornadoPrefab");
var wp = go.AddComponent<Game.Prefabs.WeatherPhenomenon>();

wp.m_OccurrenceProbability = 20f;
wp.m_Duration = new Bounds1(30f, 120f);
wp.m_PhenomenonRadius = new Bounds1(600f, 1200f);
wp.m_HotspotInstability = 0.2f;
wp.m_DamageSeverity = 25f;
wp.m_DangerLevel = 0.9f;
wp.m_Evacuate = true;
wp.m_StayIndoors = false;

// During prefab conversion the Initialize method will copy these values into
// a WeatherPhenomenonData component that the ECS systems will use.

Additional notes: - The class is intended to be used as part of the prefab → ECS conversion pipeline. The Runtime component WeatherPhenomenonData is the actual data consumed by gameplay systems. - Bounds1 is used throughout to represent min/max ranges; expect random sampling of those ranges at spawn time by event systems. - DangerFlags usage in Initialize is sequential assignment; if you need combined flags, modify the prefab or the conversion logic accordingly.