Skip to content

Game.Buildings.WaterPowered

Assembly: Assembly-CSharp (Cities: Skylines 2 / mod)
Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
A small ECS component that represents water-powered building parameters. It stores three single-precision floating-point properties (length, height and an estimate value) and implements Colossal.Serialization.Entities.ISerializable so it can be written/read by the game's serialization system. The component is intended to be attached to building entities (or used in queries) within the Unity Entities (DOTS) world.


Fields

  • public float m_Length
    This field represents the length parameter for the water-powered building. Units are floating-point values as used by the game (typically world units/meters). It is the first value written by Serialize and the first value read by Deserialize.

  • public float m_Height
    This field represents the height parameter for the water-powered building. It is the second value written and read during serialization.

  • public float m_Estimate
    An estimate value associated with the water-powered building (purpose depends on caller logic — e.g., estimated output, efficiency, or other metric). It is the third value written and read during serialization.

Properties

  • This struct does not declare any C# properties. It exposes three public fields (m_Length, m_Height, m_Estimate) and no get/set properties.

Constructors

  • public WaterPowered() (implicit default)
    As a value type (struct), WaterPowered has the implicit parameterless constructor which zero-initializes the three float fields. No explicit constructors are declared in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the component to the provided writer. Writes the three float fields in the following order: m_Length, m_Height, m_Estimate. The method captures local floats and calls writer.Write for each value.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the component from the provided reader. Reads three float values (in the same order as Serialize) and assigns them to the component's fields. Uses ref locals to assign directly into the struct fields.

Notes: - The Serialize/Deserialize generic constraints use IWriter/IReader from Colossal.Serialization.Entities; when implementing or calling these you must supply a compatible writer/reader used by the game serialization system. - Order must be preserved between Serialize and Deserialize to ensure correct reconstruction.

Usage Example

// Creating and attaching the component to an entity (EntityManager API)
var water = new Game.Buildings.WaterPowered {
    m_Length = 12.5f,
    m_Height = 6.0f,
    m_Estimate = 42.0f
};
entityManager.AddComponentData(buildingEntity, water);

// Example pseudo-usage for serialization (using the game's IWriter / IReader):
// Note: IWriter/IReader implementations are provided by the game's serialization system.
// This is illustrative; real calls happen inside the game's save/load pipeline.
void SaveComponent<TWriter>(TWriter writer, Game.Buildings.WaterPowered component) where TWriter : Colossal.Serialization.Entities.IWriter
{
    component.Serialize(writer);
}

void LoadComponent<TReader>(TReader reader, out Game.Buildings.WaterPowered component) where TReader : Colossal.Serialization.Entities.IReader
{
    component = new Game.Buildings.WaterPowered();
    component.Deserialize(reader);
}

Additional tips: - When adding this component as part of a saved game, ensure serialization/deserialization are invoked by the appropriate game systems; manual calls are only necessary for custom serialization flows. - Keep Serialize/Deserialize order in sync if you extend the struct with new fields (append new fields at the end and handle versioning if needed).