Game.Prefabs.HealthcarePrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab component that groups configuration and references for healthcare services (ambulance/hearse/facility notifications) used by the ECS side of the game. The class exposes editable fields (service prefab references, notification prefabs, timing and penalty parameters and an animation curve) and, during LateInitialize, writes a HealthcareParameterData component to the corresponding entity so systems can consume these settings. The class is decorated with [ComponentMenu("Settings/")] so it appears in the Unity component menu.
Fields
-
public PrefabBase m_HealthcareServicePrefab
Reference to the service prefab (the actual healthcare building/service entity) that healthcare systems will spawn/use. Added to dependencies so it's available on the ECS side. -
public NotificationIconPrefab m_AmbulanceNotificationPrefab
Prefab for the ambulance notification icon. Converted to an entity reference in LateInitialize. -
public NotificationIconPrefab m_HearseNotificationPrefab
Prefab for the hearse notification icon. Converted to an entity reference in LateInitialize. -
public NotificationIconPrefab m_FacilityFullNotificationPrefab
Prefab for the "facility full" notification icon. Converted to an entity reference in LateInitialize. -
public float m_TransportWarningTime = 15f
Healthcare transporting notification timeout in seconds (has a Tooltip attribute in the source). Controls how long a transport-related notification is considered before warning/timeout logic triggers. -
public float m_NoResourceTreatmentPenalty = 0.5f
Fractional penalty applied when there are insufficient resources to treat patients (decorated with [Range(0f, 1f)] in the source). -
public float m_BuildingDestoryDeathRate = 0.5f
Death rate applied when a building is destroyed while containing patients. Note: the field name contains a typo ("Destory") — functionally it's a float controlling death rate on building destruction. -
public AnimationCurve m_DeathRate
AnimationCurve used to map some severity/time metric to a death rate. Converted to an AnimationCurve1 when writing to HealthcareParameterData.
Properties
- None.
Constructors
public HealthcarePrefab()
Implicit parameterless constructor (no explicit constructor defined in source). Initialization of serialized fields is done via field initializers (e.g., m_TransportWarningTime defaulted to 15f).
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds referenced prefabs (m_HealthcareServicePrefab and the three notification prefabs) to the provided dependency list so those prefabs are processed/loaded before this prefab. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds ComponentType.ReadWrite() to the provided collection so the archetype will include the HealthcareParameterData component for prefab entities. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Overrides base but does not add additional archetype components in the provided implementation (calls base only). Left available for future archetype customization. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Converts the Unity-serialized references and parameters into runtime ECS component data. Retrieves the PrefabSystem from the entityManager's world, calls GetEntity on each referenced Prefab/NotificationPrefab to obtain their entity handles, and calls entityManager.SetComponentData to write a HealthcareParameterData instance populated with: - m_HealthcareServicePrefab (entity)
- m_AmbulanceNotificationPrefab (entity)
- m_HearseNotificationPrefab (entity)
- m_FacilityFullNotificationPrefab (entity)
- m_TransportWarningTime
- m_NoResourceTreatmentPenalty
- m_BuildingDestoryDeathRate
- m_DeathRate converted to AnimationCurve1
This is the bridge that exposes the prefab's editable settings to ECS systems.
Usage Example
// The prefab itself performs the conversion during LateInitialize.
// Example showing how the prefab values are packaged into HealthcareParameterData:
public override void LateInitialize(EntityManager entityManager, Entity entity)
{
base.LateInitialize(entityManager, entity);
var prefabSystem = entityManager.World.GetOrCreateSystemManaged<PrefabSystem>();
entityManager.SetComponentData(entity, new HealthcareParameterData
{
m_HealthcareServicePrefab = prefabSystem.GetEntity(m_HealthcareServicePrefab),
m_AmbulanceNotificationPrefab = prefabSystem.GetEntity(m_AmbulanceNotificationPrefab),
m_HearseNotificationPrefab = prefabSystem.GetEntity(m_HearseNotificationPrefab),
m_FacilityFullNotificationPrefab = prefabSystem.GetEntity(m_FacilityFullNotificationPrefab),
m_TransportWarningTime = m_TransportWarningTime,
m_NoResourceTreatmentPenalty = m_NoResourceTreatmentPenalty,
m_BuildingDestoryDeathRate = m_BuildingDestoryDeathRate,
m_DeathRate = new AnimationCurve1(m_DeathRate)
});
}
Notes and tips: - The prefab writes an AnimationCurve1 (a serializable/compact representation) from the Unity AnimationCurve to store curve data in ECS component data. - Ensure referenced prefabs (service and notification prefabs) are present and valid; otherwise PrefabSystem.GetEntity may return Entity.Null. - The m_BuildingDestoryDeathRate field name contains a typo; when reading or mapping data be careful to match the field name expected by HealthcareParameterData.