Skip to content

Game.Prefabs.DisasterConfigurationData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
Component data used by the disaster system to configure notifications and behavior for weather/water disasters (e.g., floods). Stores Entity prefab references for notifications, numeric rates for damage, and probability data used when citizens exit emergency shelters. This is a Unity ECS component (plain value type) intended to be attached to a prefab/entity that represents a disaster configuration.


Fields

  • public Entity m_WeatherDamageNotificationPrefab
    Entity reference to the notification prefab shown when weather causes damage. Typically a small UI/notification entity spawned by the disaster system.

  • public Entity m_WeatherDestroyedNotificationPrefab
    Entity reference to the notification prefab shown when weather destroys something (higher-severity notification).

  • public Entity m_WaterDamageNotificationPrefab
    Entity reference to the notification prefab shown when water (flood) causes damage.

  • public Entity m_WaterDestroyedNotificationPrefab
    Entity reference to the notification prefab shown when water destroys something.

  • public Entity m_DestroyedNotificationPrefab
    General "destroyed" notification prefab used when an object is destroyed by a disaster.

  • public float m_FloodDamageRate
    Float rate applied to calculate flood damage. Interpreted by the disaster/damage systems to scale damage per tick or per event.

  • public AnimationCurve1 m_EmergencyShelterDangerLevelExitProbability
    Curve describing the exit probability from emergency shelters as a function of danger level. Sample this curve to determine the probability an occupant will leave a shelter given the current danger level. (AnimationCurve1 is a custom curve type provided by the Colossal/engine codebase.)

  • public float m_InoperableEmergencyShelterExitProbability
    Fallback probability used when an emergency shelter is inoperable (e.g., damaged/unusable) — the probability occupants will exit despite shelter being inoperable.

Properties

  • None.
    This struct exposes only public fields and does not define properties.

Constructors

  • public DisasterConfigurationData() (default)
    No custom constructors are defined; use the default parameterless constructor or aggregate initialization to create instances before adding them as component data.

Methods

  • None.
    This is a plain data component (no methods). Behavior and logic are implemented in systems that read this component.

Usage Example

// Example: create and attach a DisasterConfigurationData component to an entity
using Unity.Entities;
using Colossal.Collections;

// Assume these are valid Entity references obtained elsewhere:
Entity weatherDamagePrefab = ...;
Entity weatherDestroyedPrefab = ...;
Entity waterDamagePrefab = ...;
Entity waterDestroyedPrefab = ...;
Entity destroyedPrefab = ...;

// Create an AnimationCurve1 instance as appropriate for your project.
// The exact construction depends on the AnimationCurve1 API; placeholder shown:
AnimationCurve1 shelterExitCurve = new AnimationCurve1(/* keyframes or params */);

var config = new DisasterConfigurationData
{
    m_WeatherDamageNotificationPrefab = weatherDamagePrefab,
    m_WeatherDestroyedNotificationPrefab = weatherDestroyedPrefab,
    m_WaterDamageNotificationPrefab = waterDamagePrefab,
    m_WaterDestroyedNotificationPrefab = waterDestroyedPrefab,
    m_DestroyedNotificationPrefab = destroyedPrefab,
    m_FloodDamageRate = 0.75f,
    m_EmergencyShelterDangerLevelExitProbability = shelterExitCurve,
    m_InoperableEmergencyShelterExitProbability = 0.5f
};

EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity configEntity = entityManager.CreateEntity();
entityManager.AddComponentData(configEntity, config);

Notes: - As an ECS component, modify instances via EntityManager or within systems; avoid changing field values directly on components obtained from IJob/parallel contexts. - The fields are public and named with an m_ prefix to match existing codebase conventions and (de)serialization expectations for prefab data.