Game.Prefabs.DeathcareFacility
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs
Type:
class
Base:
ComponentBase, IServiceUpgrade
Summary:
Prefab component that defines configuration and archetype composition for deathcare buildings (e.g., cemeteries, funeral homes). The class exposes configurable fields for hearse capacity, patient storage capacity, processing rate and whether long-term storage is used. It participates in prefab-to-entity conversion by supplying required ECS ComponentTypes for both initial prefab components and runtime archetypes, and it implements IServiceUpgrade to provide components needed for upgraded versions of the building. The class is annotated with a ComponentMenu attribute so it appears in the editor under Buildings/CityServices/ and is associated with BuildingPrefab, BuildingExtensionPrefab and MarkerObjectPrefab prefab types.
Fields
-
public int m_HearseCapacity = 5
Default number of hearses the facility can own/dispatch. Used when initializing the DeathcareFacilityData component for the entity. -
public int m_StorageCapacity = 100
Default patient storage capacity. When non-zero, the prefab adds a Patient component type to the archetype so patient entities can be stored/processed. -
public float m_ProcessingRate = 10f
Rate at which stored patients are processed (e.g., bodies processed or cleared). Written into DeathcareFacilityData on initialization. -
public bool m_LongTermStorage
Flag indicating whether the facility uses long-term storage behaviour. Stored in DeathcareFacilityData on initialization.
Properties
- This class does not declare additional public properties. It exposes its data via public fields and through the ECS components it adds during initialization.
Constructors
public DeathcareFacility()
Implicit default constructor (no custom constructor is defined in the source). Instances are typically created/edited as Unity prefab components in the editor.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds component types that should be present on the prefab entity before conversion to a runtime archetype. This class adds:- DeathcareFacilityData (ReadWrite)
-
UpdateFrameData (ReadWrite)
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds component types required for the runtime archetype when this prefab is instantiated as an entity. Behavior details: - Always adds Game.Buildings.DeathcareFacility (ReadWrite).
-
If the prefab does not already have a ServiceUpgrade component:
- If it has a CityServiceBuilding component, adds Efficiency (ReadWrite).
- Adds OwnedVehicle (ReadWrite), ServiceDispatch (ReadWrite) and ServiceDistrict (ReadWrite).
- If m_StorageCapacity != 0, adds Patient (ReadWrite). This method controls what runtime components a building entity will have depending on the prefab's configuration and presence of upgrade components.
-
public void GetUpgradeComponents(HashSet<ComponentType> components)
Implements IServiceUpgrade method: provides the set of component types to apply when this building is used as an upgrade prefab. Adds: - Game.Buildings.DeathcareFacility (ReadWrite)
- ServiceDispatch (ReadWrite)
- OwnedVehicle (ReadWrite)
-
Patient (ReadWrite) if m_StorageCapacity != 0
-
public override void Initialize(EntityManager entityManager, Entity entity)
Writes initial data into the entity's components during conversion/initialization. Specifically sets: - DeathcareFacilityData with m_HearseCapacity, m_StorageCapacity, m_LongTermStorage and m_ProcessingRate.
- UpdateFrameData with a value of 2 (scheduling/update frame offset). This is where the prefab's public fields are transferred into ECS component data used at runtime.
Usage Example
// Example: a prefab initializer or editor script could tweak fields,
// and during conversion Initialize will write them into ECS components.
public class ExamplePrefabSetup
{
public void ConfigurePrefab(DeathcareFacility prefab)
{
prefab.m_HearseCapacity = 8;
prefab.m_StorageCapacity = 150;
prefab.m_ProcessingRate = 12f;
prefab.m_LongTermStorage = true;
}
}
// During entity conversion the engine will call:
// prefab.GetPrefabComponents(...) -> registers DeathcareFacilityData, UpdateFrameData
// prefab.GetArchetypeComponents(...) -> registers runtime component types based on config
// prefab.Initialize(entityManager, entity) -> writes DeathcareFacilityData and UpdateFrameData