Skip to content

Game.Prefabs.WaterPumpingStation

Assembly:
Assembly-CSharp (typical Unity/Colossal Order mod assembly)

Namespace:
Game.Prefabs

Type:
class

Base:
ComponentBase, IServiceUpgrade

Summary:
Prefab component that defines configuration and entity conversion for a water pumping station building. Exposes editable fields used by the prefab (capacity, purification, allowed water types), registers runtime ECS components required by the building, and initializes the entity's WaterPumpingStationData when the prefab is instantiated. The class is annotated with a ComponentMenu attribute so it appears under "Buildings/CityServices/" in the editor and is associated with BuildingPrefab and BuildingExtensionPrefab types.


Fields

  • public int m_Capacity = 75
    Capacity of the pumping station expressed in units used by the game (default 75). Used to initialize WaterPumpingStationData.m_Capacity.

  • public float m_Purification
    Purification rate / factor for the water pumping station. Mapped to WaterPumpingStationData.m_Purification during entity initialization.

  • public AllowedWaterTypes m_AllowedWaterTypes
    Enum-flag field that indicates which water types this pumping station is allowed to use. Stored in WaterPumpingStationData.m_Types. The EnumFlag attribute means multiple options can be combined (bitmask).

Properties

  • (none declared)
    This class does not declare C# properties. It uses public fields and implements IServiceUpgrade via method GetUpgradeComponents.

Constructors

  • public WaterPumpingStation()
    No explicit constructor is defined in the source; a default parameterless constructor is provided by the compiler. Initialization of instance values is done via field initializers (e.g., m_Capacity = 75) and via the Unity/prefab lifecycle methods.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the runtime component type required to store the prefab-specific data on the entity:
  • Adds ComponentType.ReadWrite() so the entity will have a WaterPumpingStationData component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Configures additional components to include in the archetype depending on other components present on the prefab:

  • If the prefab does NOT include a ServiceUpgrade component, it adds ComponentType.ReadWrite().
  • If the prefab also includes CityServiceBuilding, it adds ComponentType.ReadWrite().
  • In short: this method conditionally includes the building logic and efficiency components for non-upgrade variants.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Part of the IServiceUpgrade contract. Adds ComponentType.ReadWrite() for upgrade entities so the underlying building component exists on upgrade instances.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is converted into an ECS entity. Sets the WaterPumpingStationData component on the entity using the prefab field values:

  • m_Capacity => WaterPumpingStationData.m_Capacity
  • m_AllowedWaterTypes => WaterPumpingStationData.m_Types
  • m_Purification => WaterPumpingStationData.m_Purification

Usage Example

// This example demonstrates how the prefab's Initialize method stores prefab values into the entity.
// Typically you don't call Initialize yourself; the prefab conversion pipeline calls it when creating the entity.

public class CustomWaterPumpingStationPrefab : WaterPumpingStation
{
    // You can override prefab defaults in a subclass or set them in the inspector.
    public CustomWaterPumpingStationPrefab()
    {
        m_Capacity = 120;
        m_Purification = 0.85f;
        m_AllowedWaterTypes = AllowedWaterTypes.Fresh | AllowedWaterTypes.Recycled;
    }

    public override void GetPrefabComponents(HashSet<ComponentType> components)
    {
        base.GetPrefabComponents(components);
        // add additional component types if needed
    }
}

// Example of how Initialize maps fields into the entity (similar to the real implementation)
protected void ExampleInitialize(EntityManager entityManager, Entity entity, WaterPumpingStation prefab)
{
    entityManager.SetComponentData(entity, new WaterPumpingStationData
    {
        m_Capacity = prefab.m_Capacity,
        m_Types = prefab.m_AllowedWaterTypes,
        m_Purification = prefab.m_Purification
    });
}

Notes: - The ComponentMenu attribute places this prefab under "Buildings/CityServices/" in the editor and ties it to BuildingPrefab and BuildingExtensionPrefab types. - The presence (or absence) of ServiceUpgrade and CityServiceBuilding components on the prefab affects which ECS components are included in the archetype (see GetArchetypeComponents). This allows the same prefab class to be used for standard buildings and for upgrade variants.