Game.Prefabs.HospitalData
Assembly:
Assembly-CSharp (in-game)
Namespace:
Game.Prefabs
Type:
struct
Base:
System.ValueType — implements IComponentData, IQueryTypeParameter, ICombineData
Summary:
Represents configurable hospital data used by the game's ECS systems. Holds capacities (ambulance, medical helicopter, patients), a treatment bonus, an integer health range, and flags that indicate whether the hospital treats diseases and/or injuries. Designed to be combined with other HospitalData instances (e.g., when aggregating data from multiple sources) and to be serialized/deserialized via the Colossal.Serialization interfaces.
Fields
-
public System.Int32 m_AmbulanceCapacity
Amount of ambulance capacity provided by the hospital (number of ambulance units the facility can support). -
public System.Int32 m_MedicalHelicopterCapacity
Amount of medical helicopter capacity provided by the hospital (number of medical helicopters the facility can support). -
public System.Int32 m_PatientCapacity
Number of patients the hospital facility can hold / treat concurrently. -
public System.Int32 m_TreatmentBonus
An integer bonus applied to treatment (used by game logic to improve treatment outcomes, severity handling, or similar mechanics). -
public Unity.Mathematics.int2 m_HealthRange
A pair (min,max) representing a health range relevant to hospital logic (used/expanded when combining hospital data). -
public System.Boolean m_TreatDiseases
If true, this hospital treats diseases. -
public System.Boolean m_TreatInjuries
If true, this hospital treats injuries.
Properties
- None (no CLR properties are declared on this struct; it exposes public fields).
Constructors
public HospitalData()
Default value-type constructor — all integer fields default to 0, booleans to false, and m_HealthRange to (0,0) unless initialized explicitly.
Methods
public void Combine(HospitalData otherData)
Merges another HospitalData into this instance. Behavior:- Sums integer capacities and treatment bonus (ambulance, helicopter, patient, treatment bonus).
- Merges m_HealthRange by taking the minimum of the x (min) components and the maximum of the y (max) components.
-
Uses logical OR to combine m_TreatDiseases and m_TreatInjuries (result is true if either source treats that condition). Use case: aggregating contributions from multiple sources (e.g., combined building effects).
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the struct fields to the provided writer in the following order: - m_AmbulanceCapacity
- m_MedicalHelicopterCapacity
- m_PatientCapacity
- m_TreatmentBonus
- m_HealthRange
- m_TreatDiseases
-
m_TreatInjuries The writer must implement Colossal.Serialization.Entities.IWriter.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the struct fields from the provided reader in the same order used by Serialize. The reader must implement Colossal.Serialization.Entities.IReader. This restores the values into the struct's fields.
Usage Example
// Combine example
var baseHospital = new HospitalData {
m_AmbulanceCapacity = 2,
m_MedicalHelicopterCapacity = 1,
m_PatientCapacity = 50,
m_TreatmentBonus = 5,
m_HealthRange = new int2(10, 100),
m_TreatDiseases = true,
m_TreatInjuries = false
};
var addon = new HospitalData {
m_AmbulanceCapacity = 1,
m_MedicalHelicopterCapacity = 0,
m_PatientCapacity = 10,
m_TreatmentBonus = 2,
m_HealthRange = new int2(5, 120),
m_TreatDiseases = false,
m_TreatInjuries = true
};
baseHospital.Combine(addon);
// baseHospital now has summed capacities and bonus,
// health range min = 5, max = 120, and both treatment flags true.
// Serialization example (pseudo-code — use a concrete IWriter/IReader implementation)
using (var stream = new MemoryStream())
{
// Assume BinaryWriterAdapter implements IWriter for the Colossal serializer API
var writer = new BinaryWriterAdapter(stream);
baseHospital.Serialize(writer);
stream.Position = 0;
var reader = new BinaryReaderAdapter(stream); // implements IReader
var loaded = new HospitalData();
loaded.Deserialize(reader);
// 'loaded' now contains the same values as baseHospital
}