Skip to content

Game.UI.InGame.GarbageSection

Assembly:
Assembly-CSharp (game code / modding assembly)

Namespace: Game.UI.InGame

Type:
class

Base:
InfoSectionBase

Summary:
GarbageSection is a UI info panel section for garbage-related buildings (landfills, recycling centers, incinerators, hazardous waste facilities). It reads component data from the selected entity and any associated storage areas to present current garbage amount, storage capacity, and processing rates. It also collects tooltip keys describing special facility features (e.g., Landfill, RecyclingCenter, Incinerator, HazardousWaste) and exposes those values via JSON in OnWriteProperties for the UI/frontend.


Fields

  • private enum LoadKey
    Defines which resource load the facility accepts or reports. Values:
  • IndustrialWaste — facility handles industrial/hazardous waste only.
  • Garbage — facility handles normal garbage. This enum is used to serialize the load type in OnWriteProperties and to adjust UI labels/behavior.

(No explicit private backing fields are declared in source; most data is stored in private properties.)

Properties

  • protected override string group { get; }
    Returns the UI group identifier "GarbageSection". Used by the base InfoSection system to categorize this section.

  • private int garbage { get; set; }
    Current amount of garbage/resources stored in the facility and any linked storage areas (sum of facility storage + area storage).

  • private int garbageCapacity { get; set; }
    Total capacity for garbage (facility base capacity + capacities contributed by linked storage areas).

  • private int processingSpeed { get; set; }
    Current processing rate read from the GarbageFacility component (m_ProcessingRate).

  • private int processingCapacity { get; set; }
    Processing capacity taken from the facility prefab data (GarbageFacilityData.m_ProcessingSpeed).

  • private LoadKey loadKey { get; set; }
    Indicates whether the facility is normal Garbage or IndustrialWaste-only. Default is LoadKey.Garbage; set to IndustrialWaste when the prefab indicates m_IndustrialWasteOnly.

Constructors

  • public GarbageSection()
    Parameterless constructor. Marked with [Preserve] in source to avoid stripping by code stripping tools. The constructor does no extra initialization beyond base initialization.

Methods

  • protected override void Reset()
    Resets the section's tracked values to defaults:
  • garbage = 0
  • garbageCapacity = 0
  • processingSpeed = 0
  • processingCapacity = 0
  • loadKey = LoadKey.Garbage

  • private bool Visible()
    Returns true if the selectedEntity has a Game.Buildings.GarbageFacility component. Used to determine whether this section should be shown.

  • [Preserve] protected override void OnUpdate()
    Called each update to evaluate visibility. Sets base.visible = Visible().

  • protected override void OnProcess()
    Core processing method: gathers data from the selected garbage facility and any linked storage areas.

  • If the selected entity has a GarbageFacility component:
    • Reads the facility's current processing rate (component.m_ProcessingRate).
    • Reads prefab data (GarbageFacilityData) to get base garbageCapacity (m_GarbageCapacity), processingCapacity (m_ProcessingSpeed) and flags:
    • m_LongTermStorage → adds "Landfill" tooltip key
    • m_IndustrialWasteOnly → sets loadKey = LoadKey.IndustrialWaste and adds "HazardousWaste" tooltip key
    • If the entity has ResourceProducer → adds "RecyclingCenter" tooltip key
    • If the entity has ElectricityProducer → adds "Incinerator" tooltip key
    • If the selected entity has a resources buffer, uses EconomyUtils.GetResources(Resource.Garbage, buffer) to read stored garbage.
  • Iterates linked SubArea buffers on the selected entity:

    • For each linked area, if it has a Storage component and a StorageAreaData prefab, adds that area's calculated capacity (via AreaUtils.CalculateStorageCapacity) to garbageCapacity and sums area storage amounts into garbage. This method combines facility + area storage and capacity so the UI shows totals for the building and its associated storage areas.
  • public override void OnWriteProperties(IJsonWriter writer)
    Serializes current values to JSON for the UI. Writes properties:

  • "garbage" — int
  • "garbageCapacity" — int
  • "processingSpeed" — int
  • "processingCapacity" — int
  • "loadKey" — string representation of the LoadKey enum name (Enum.GetName)

Usage Example

[Preserve]
protected override void OnUpdate()
{
    // Ensure the section is only visible for garbage facilities
    base.visible = Visible();
}

protected override void OnProcess()
{
    // Example: OnProcess pools data from the GarbageFacility component and linked storage areas
    // (See source for full implementation — it populates garbage, garbageCapacity, processingSpeed, processingCapacity, loadKey)
}

Notes / Implementation details: - The section relies on ECS components (EntityManager, TryGetComponent, TryGetBuffer, GetComponentData) and on prefab data types such as GarbageFacilityData and StorageAreaData. - Tooltip keys collected (Landfill, RecyclingCenter, Incinerator, HazardousWaste) are added to base.tooltipKeys and used elsewhere by UI code to show icons/descriptions. - loadKey is written as the enum name string; UI may use that string to select localized labels or icons for "Garbage" vs "IndustrialWaste". - This class is marked [CompilerGenerated] in the source file header; however it behaves like a regular InfoSection implementation and is preserved via [Preserve] on relevant methods/ctor.