Game.Prefabs.DisasterConfigurationPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
DisasterConfigurationPrefab is a Unity prefab class used to configure disaster-related settings for the game (notifications, flood damage rate, and emergency shelter behavior). During prefab initialization it writes a DisasterConfigurationData component to the entity, converting prefab references to entity references and converting an AnimationCurve to the runtime-friendly AnimationCurve1 form. This prefab is intended for use by the PrefabSystem to supply disaster configuration data to runtime systems.
Fields
-
public NotificationIconPrefab m_WeatherDamageNotificationPrefab
Reference to the notification prefab used when weather causes damage. Will be converted to an Entity reference and stored in DisasterConfigurationData during LateInitialize. -
public NotificationIconPrefab m_WeatherDestroyedNotificationPrefab
Reference to the notification prefab used when weather destroys buildings. Converted to an Entity in LateInitialize. -
public NotificationIconPrefab m_WaterDamageNotificationPrefab
Reference to the notification prefab used when water (flooding) causes damage. Converted to an Entity in LateInitialize. -
public NotificationIconPrefab m_WaterDestroyedNotificationPrefab
Reference to the notification prefab used when water destroys buildings. Converted to an Entity in LateInitialize. -
public NotificationIconPrefab m_DestroyedNotificationPrefab
Generic destroyed notification prefab reference. Converted to an Entity in LateInitialize. -
public float m_FloodDamageRate = 200f
Float that controls flood damage rate. The default value in the prefab is 200f and this value is copied into the DisasterConfigurationData component during LateInitialize. -
public AnimationCurve m_EmergencyShelterDangerLevelExitProbability
AnimationCurve describing correlation between general city danger level (0.0–1.0) and the probability that a citizen will exit a shelter if there is no imminent danger to their home/work/school. The tooltip in the prefab indicates the curve is sampled as 1024 rolls per day; the curve's y value at 0.0 determines how quickly cims will leave when there's no danger. Converted to AnimationCurve1 and stored in DisasterConfigurationData during LateInitialize. -
public float m_InoperableEmergencyShelterExitProbability = 0.1f
Probability (0.0–1.0) that a citizen will exit an inoperable emergency shelter (1024 rolls per day). Marked with a Unity [Range(0f, 1f)] attribute; default is 0.1. This value is copied into DisasterConfigurationData during LateInitialize.
Properties
- None declared on this prefab class. All configuration values are exposed as public fields and transferred into the ECS component DisasterConfigurationData in LateInitialize.
Constructors
public DisasterConfigurationPrefab()
Default parameterless constructor (inherited behavior). No custom construction logic is defined in the source.
Methods
public override void GetDependencies(List<PrefabBase> prefabs)
Adds the notification prefabs referenced by this prefab to the provided dependency list. Implementation:- Calls base.GetDependencies(prefabs)
-
Adds m_WeatherDamageNotificationPrefab, m_WeatherDestroyedNotificationPrefab, m_WaterDamageNotificationPrefab, m_WaterDestroyedNotificationPrefab, and m_DestroyedNotificationPrefab to prefabs. This ensures the notification prefabs are loaded/available when this prefab is processed.
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Registers the ECS component types this prefab will provide on the resulting entity. Implementation: - Calls base.GetPrefabComponents(components)
-
Adds ComponentType.ReadWrite
() to the components set, indicating the prefab writes a DisasterConfigurationData component to the entity. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Writes the DisasterConfigurationData component to the provided entity, converting prefab references to entity references: - Obtains the PrefabSystem via entityManager.World.GetExistingSystemManaged
(). - Calls existingSystemManaged.GetEntity(...) for each NotificationIconPrefab reference to obtain an Entity handle for each notification prefab.
- Constructs and sets a new DisasterConfigurationData with:
- m_WeatherDamageNotificationPrefab (Entity)
- m_WeatherDestroyedNotificationPrefab (Entity)
- m_WaterDamageNotificationPrefab (Entity)
- m_WaterDestroyedNotificationPrefab (Entity)
- m_DestroyedNotificationPrefab (Entity)
- m_FloodDamageRate (float)
- m_EmergencyShelterDangerLevelExitProbability converted to AnimationCurve1
- m_InoperableEmergencyShelterExitProbability (float) This method ensures the runtime ECS world has the configuration data in a form usable by game systems.
Usage Example
// Example: reading the DisasterConfigurationData from the entity created for this prefab.
Entity configEntity = /* obtain the entity associated with the DisasterConfigurationPrefab */;
DisasterConfigurationData config = entityManager.GetComponentData<DisasterConfigurationData>(configEntity);
float floodRate = config.m_FloodDamageRate;
AnimationCurve1 shelterExitCurve = config.m_EmergencyShelterDangerLevelExitProbability;
Entity weatherDamageNotifEntity = config.m_WeatherDamageNotificationPrefab;
Additional notes: - This prefab bridges authoring-time Unity objects (NotificationIconPrefab, AnimationCurve) and runtime ECS data (entities and AnimationCurve1). If you create or modify instances of this prefab, ensure referenced notification prefabs are valid and included in prefab dependencies so they resolve to entities at runtime.