Skip to content

Game.UI.InGame.DeathcareSection

Assembly: Game
Namespace: Game.UI.InGame

Type: class

Base: InfoSectionBase

Summary:
DeathcareSection is a UI info section used by the in-game building inspector to display deathcare-related stats for the selected building (e.g., cemetery or crematorium). It reads deathcare component data and buffers from the EntityManager (selectedEntity) to compute and expose the current stored bodies, storage capacity, processing speed and processing capacity. The section is CompilerGenerated and uses Preserve attributes to ensure it remains accessible through the game's reflection/serialization systems.


Fields

  • private int bodyCount
    Tracks the current number of bodies known to the section (includes long-term stored bodies and buffered Patient entries). Implemented as a private auto-property backing field in the class source; used to compute and serialize UI data.

  • private int bodyCapacity
    Holds the storage capacity (m_StorageCapacity) read from the DeathcareFacilityData for the selected prefab.

  • private float processingSpeed
    Current effective processing rate (processingCapacity multiplied by facility efficiency). Set to 0 when there are no bodies waiting.

  • private float processingCapacity
    Base processing rate read from DeathcareFacilityData (m_ProcessingRate). Represents the facility's raw processing capability before efficiency is applied.

Properties

  • protected override string group { get; }
    Returns the group identifier used by the UI system: "DeathcareSection". This is a read-only override of InfoSectionBase.group used for grouping or localization keys.

  • private int bodyCount { get; set; }
    Private auto-property backing the bodyCount value exposed by the section.

  • private int bodyCapacity { get; set; }
    Private auto-property for storage capacity.

  • private float processingSpeed { get; set; }
    Private auto-property for computed processing speed.

  • private float processingCapacity { get; set; }
    Private auto-property for base processing capacity.

Constructors

  • public DeathcareSection()
    Default constructor. Marked with [Preserve] attribute in source to avoid stripping; performs no explicit initialization beyond default values (the Reset method initializes values when needed).

Methods

  • protected override void Reset()
    Resets the section's tracked values to defaults:
  • bodyCount = 0
  • bodyCapacity = 0
  • processingSpeed = 0f
  • processingCapacity = 0f

  • private bool Visible()
    Returns true when the currently selected entity has a Game.Buildings.DeathcareFacility component (i.e., the selected building is a deathcare facility). Uses base.EntityManager.HasComponent(selectedEntity).

  • [Preserve] protected override void OnUpdate()
    Called each update tick by the UI framework. This override sets base.visible according to Visible(). Marked with [Preserve] to prevent removal.

  • protected override void OnProcess()
    Main data-gathering method. Actions performed:

  • Attempts to get DeathcareFacilityData for the selected entity (TryGetComponentWithUpgrades). If available:
    • Sets bodyCapacity to data.m_StorageCapacity.
    • Adds a tooltip key: "Cemetery" if data.m_LongTermStorage is true, otherwise "Crematorium".
  • Reads an Efficiency DynamicBuffer (if present) and computes processingSpeed as data.m_ProcessingRate * BuildingUtils.GetEfficiency(buffer).
  • Reads the DeathcareFacility component to get m_LongTermStoredCount and starts bodyCount from that value.
  • Sets processingCapacity = data.m_ProcessingRate.
  • Adds any Patient buffer length to bodyCount.
  • If bodyCount <= 0, sets processingSpeed = 0f to indicate no active processing.

Note: This method relies on several game types: DeathcareFacilityData, DeathcareFacility, DynamicBuffer, DynamicBuffer, BuildingUtils, and the EntityManager helpers provided by InfoSectionBase.

  • public override void OnWriteProperties(IJsonWriter writer)
    Serializes the section properties to a JSON writer. Writes the following properties:
  • "bodyCount" -> bodyCount
  • "bodyCapacity" -> bodyCapacity
  • "processingSpeed" -> processingSpeed
  • "processingCapacity" -> processingCapacity

Usage Example

[Preserve]
protected override void OnUpdate()
{
    // keep visibility up-to-date based on whether the selected entity is a DeathcareFacility
    base.visible = Visible();
}

// The section will gather values in OnProcess() and expose them via OnWriteProperties(IJsonWriter writer)
// Example JSON output call (executed by UI/inspector framework):
// {
//   "bodyCount": 5,
//   "bodyCapacity": 200,
//   "processingSpeed": 0.75,
//   "processingCapacity": 1.0
// }

Additional notes: - This section depends on InfoSectionBase for access to selectedEntity and EntityManager helpers (TryGetComponentWithUpgrades, TryGetBuffer, GetComponentData, etc.). - The class is intended to be used by the game's UI system — direct instantiation is typically unnecessary; the modding/UI framework will create and manage instances.