Skip to content

Game.Buildings.DeathcareFacility

Assembly: Assembly-CSharp
Namespace: Game.Buildings

Type: struct (public)

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents the ECS component data for a deathcare facility (e.g., crematoriums, graveyards) in Cities: Skylines 2. Stores the entity target request, internal flags, processing progress/state, and a count used for long-term storage of bodies. Implements ISerializable to support save/load and implements IComponentData so it can be attached to entities and used in Unity DOTS systems.


Fields

  • public Unity.Entities.Entity m_TargetRequest
    Holds an Entity reference used as a service/request target for the facility. This field is serialized conditionally depending on the saved game version (see Deserialize).

  • public DeathcareFacilityFlags m_Flags
    Bitflags enum describing facility-specific state (e.g., enabled/disabled, special modes). Serialized as a single byte.

  • public float m_ProcessingState
    Floating-point value representing the facility's processing progress or internal state used by systems to track ongoing processing.

  • public int m_LongTermStoredCount
    Integer count representing the number of stored bodies kept for long-term storage logic.

Properties

  • None (this struct exposes only public fields; no C# properties are declared).

Constructors

  • public DeathcareFacility() (implicit default)
    As a value type (struct), a parameterless default constructor is provided implicitly. Code commonly initializes this component by creating an instance with initializer syntax setting the fields as needed.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes component data to the provided writer in the following order:
  • m_TargetRequest (Entity)
  • m_Flags as a single byte
  • m_ProcessingState (float)
  • m_LongTermStoredCount (int)
    This method is used when saving the game state.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Restores component data from the provided reader. Behavior:

  • If reader.context.version >= Version.reverseServiceRequests2, m_TargetRequest is read from the stream (backwards compatibility check).
  • Reads a byte into a temporary value and later casts it to DeathcareFacilityFlags and assigns to m_Flags.
  • Reads m_ProcessingState (float) and m_LongTermStoredCount (int).
    This method handles compatibility with older save formats by conditionally reading the target request only for newer versions.

Usage Example

// Create and attach the component to an entity
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = em.CreateEntity();
em.AddComponentData(entity, new Game.Buildings.DeathcareFacility {
    m_TargetRequest = Entity.Null,
    m_Flags = DeathcareFacilityFlags.None,
    m_ProcessingState = 0f,
    m_LongTermStoredCount = 0
});

// Example of calling Serialize/Deserialize (pseudo-code; actual writer/reader instances come from the game's save system)
var comp = em.GetComponentData<Game.Buildings.DeathcareFacility>(entity);
// writer and reader are provided by the game's serialization infrastructure
comp.Serialize(writer);
// later, when loading:
comp.Deserialize(reader);
em.SetComponentData(entity, comp);

{{ Additional notes: - This struct is intended to be used within Unity's DOTS/ECS environment; systems operate on this component to implement deathcare logic. - The conditional read in Deserialize uses Version.reverseServiceRequests2 to maintain backwards compatibility. When adding or changing serialized fields, ensure version checks are updated accordingly. - Because the enum is serialized as a byte, adding new enum values beyond byte range requires migration. }}