Skip to content

Game.Prefabs.GarbageFacilityData

Assembly: Assembly-CSharp (game main assembly)
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
Represents configuration/state data for a garbage facility prefab in the ECS world. Holds capacity and behavior flags used by the game's systems to control how much garbage the facility can store, how many vehicles it can host, transport throughput, and whether it accepts only industrial waste or supports long-term storage. Implements combining semantics for aggregating multiple data sources and (de)serialization for save/load or network operations.


Fields

  • public int m_GarbageCapacity
    Stores the facility's garbage storage capacity (units of garbage). Used to determine how much waste the facility can hold before it is considered full.

  • public int m_VehicleCapacity
    Maximum number of vehicles the facility can accommodate (e.g., garbage trucks). Affects how many transport units can be assigned to this facility.

  • public int m_TransportCapacity
    Throughput capacity for transport (amount that can be moved per unit time). Used to calculate how much waste can be transported away from/into the facility.

  • public int m_ProcessingSpeed
    Processing rate of the facility (how fast garbage is processed). Typically used to reduce stored garbage over time.

  • public bool m_IndustrialWasteOnly
    If true, the facility accepts only industrial waste; false means it accepts all waste types.

  • public bool m_LongTermStorage
    If true, facility operates as long-term storage (affects how systems prioritize processing vs. storing).

Properties

  • This type exposes no properties. All data members are public fields and behavior is provided via methods and interface implementations.

Constructors

  • public GarbageFacilityData()
    Default (implicit) constructor. All numeric fields default to 0 and booleans default to false. Instances are typically populated by prefab loading, serialization/deserialization, or by code that sets specific values. Combine(...) can be used to aggregate multiple instances.

Methods

  • public void Combine(GarbageFacilityData otherData)
    Merges another GarbageFacilityData into this instance. Numeric capacities/speeds are added together. Boolean flags are combined with logical OR so that if either instance supports a behavior (e.g., industrial-only or long-term), the resulting instance preserves that behavior. Use this when aggregating data from multiple sources (for example, stacked prefabs or multiple modifiers).

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the fields to the provided writer in the following order: m_GarbageCapacity, m_VehicleCapacity, m_TransportCapacity, m_ProcessingSpeed, m_IndustrialWasteOnly, m_LongTermStorage. This ordering must match Deserialize to ensure correct round-trip serialization.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads fields from the provided reader into this instance, using the same ordering used by Serialize. The implementation uses ref locals to directly populate the struct fields.

Notes: - The struct is an ECS component (IComponentData) and can be attached to entities. It also implements IQueryTypeParameter to be usable in ECS queries. - The (de)serialization methods rely on the game's Colossal.Serialization interfaces and are required for saving/loading and network sync of prefab data.

Usage Example

// Create and initialize data for a small facility
GarbageFacilityData small = new GarbageFacilityData
{
    m_GarbageCapacity = 1000,
    m_VehicleCapacity = 2,
    m_TransportCapacity = 200,
    m_ProcessingSpeed = 50,
    m_IndustrialWasteOnly = false,
    m_LongTermStorage = false
};

// Create another data instance, e.g., from an upgrade or modifier
GarbageFacilityData addon = new GarbageFacilityData
{
    m_GarbageCapacity = 500,
    m_VehicleCapacity = 1,
    m_ProcessingCapacity = 25,
    m_IndustrialWasteOnly = true,
    m_LongTermStorage = true
};

// Combine them (sums numeric values, ORs booleans)
small.Combine(addon);

// small now reflects the aggregated capacities and flags
// Serialization example (pseudo-usage; TWriter is provided by the game's serialization system)
void Save<TWriter>(ref GarbageFacilityData data, TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
{
    data.Serialize(writer);
}