Skip to content

Game.Prefabs.Modes.HealthcareParametersMode

Assembly: Game
Namespace: Game.Prefabs.Modes

Type: class

Base: EntityQueryModePrefab

Summary:
Mode prefab used to configure global healthcare-related parameters in the game's ECS. This prefab exposes a small set of tunable values (transport warning time, penalty for no resources, building-destroy death rate and a death-rate curve). When ApplyModeData is invoked, the values are written into the HealthcareParameterData component (typically a singleton) so the live simulation systems use them. Note: the class wraps UnityEngine.AnimationCurve into the game's AnimationCurve1 wrapper when writing to the component.


Fields

  • public float m_TransportWarningTime = 15f
    Time (in seconds) used by healthcare systems to warn about patient transport delays. Default value: 15f.

  • public float m_NoResourceTreatmentPenalty = 0.5f
    Penalty multiplier applied when there are no medical resources available for treatment. Default value: 0.5f.

  • public float m_BuildingDestoryDeathRate = 0.5f
    Death-rate applied when a healthcare building is destroyed (note: name contains a misspelling "Destory"). Default value: 0.5f.

  • public AnimationCurve m_DeathRate
    Curve describing death rate behavior across some relevant parameter (serialized as a Unity AnimationCurve in the prefab). This is converted to AnimationCurve1 before being stored on the ECS component.

Properties

  • This class does not declare any additional public properties. It exposes fields for inspector editing and overrides methods from EntityQueryModePrefab.

Constructors

  • public HealthcareParametersMode()
    Default constructor (implicit). The fields are initialized with the inline default values shown above (m_TransportWarningTime = 15f, m_NoResourceTreatmentPenalty = 0.5f, m_BuildingDestoryDeathRate = 0.5f). No additional runtime initialization logic is present.

Methods

  • public override EntityQueryDesc GetEntityQueryDesc()
    Returns an EntityQueryDesc that targets entities containing HealthcareParameterData. The returned query descriptor has All = { ComponentType.ReadOnly() }.

  • protected override void RecordChanges(EntityManager entityManager, Entity entity)
    Called to record changes for the given entity. This implementation reads HealthcareParameterData via entityManager.GetComponentData(entity) (no mutation here), which can be used by the mode system to detect or record state.

  • public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
    Applies the mode's field values to the singleton HealthcareParameterData component selected by requestedQuery. Steps:

  • Get the singleton entity via requestedQuery.GetSingletonEntity().
  • Read the HealthcareParameterData component.
  • Overwrite fields on the component with the prefab's fields (m_TransportWarningTime, m_NoResourceTreatmentPenalty, m_BuildingDestoryDeathRate).
  • Convert m_DeathRate (AnimationCurve) into AnimationCurve1 and assign to componentData.m_DeathRate.
  • Set the component data back on the entity via entityManager.SetComponentData. Returns the incoming JobHandle deps unchanged.

  • public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
    Restores component data from the original prefab defaults. Implementation:

  • Uses the first entity in entities to locate the corresponding HealthcarePrefab via prefabSystem.GetPrefab(entity).
  • Reads the HealthcareParameterData component for the entity.
  • Copies default values from the HealthcarePrefab into the component (including wrapping the prefab's AnimationCurve into AnimationCurve1).
  • Writes the updated component back to the entity.

Usage Example

// Example: modify the prefab-mode values (e.g. in editor or initialization code)
// and then let the mode system apply them to the HealthcareParameterData singleton.
//
// Note: The game mode / prefab system calls ApplyModeData; this snippet illustrates
// intentally changing values before that happens.

HealthcareParametersMode mode = /* obtain reference to the prefab instance */;
mode.m_TransportWarningTime = 20f;
mode.m_NoResourceTreatmentPenalty = 0.4f;
mode.m_BuildingDestoryDeathRate = 0.6f;
mode.m_DeathRate = new AnimationCurve(/* keys */);

// Later the mode framework will call:
 // mode.ApplyModeData(entityManager, requestedQuery, deps);

// After ApplyModeData runs, the HealthcareParameterData singleton will contain the values above
// (m_DeathRate will be stored as an AnimationCurve1).

{{ Additional notes: - The code uses AnimationCurve1 (game-specific wrapper) to serialize AnimationCurve data into ECS component data. - The class is intended to be used as a prefab mode (inspectable in prefab assets) rather than a runtime-created MonoBehaviour. - The method ApplyModeData does not schedule or modify jobs; it performs synchronous component reads/writes and returns the passed JobHandle unchanged. }}