Skip to content

Game.PowerPlantData

Assembly:
Assembly-CSharp (game/mod assembly)

Namespace:
Game.Prefabs

Type:
struct

Base:
IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
Represents a lightweight ECS component storing the electricity production value for a power plant prefab. This struct is a plain (blittable) value type intended for use with Unity's Entities (ECS) and the game's custom serialization system (Colossal.Serialization). It supports combining (aggregation) of production values and custom binary serialization/deserialization for saving/loading or network transfer.


Fields

  • public System.Int32 m_ElectricityProduction
    Holds the electricity production value (integer) for the power plant. Default is 0 when the struct is default-constructed.

Properties

  • This type exposes no properties.

Constructors

  • public PowerPlantData()
    Implicit default constructor provided by the runtime. Initializes m_ElectricityProduction to 0. No custom constructors are declared in the source.

Methods

  • public void Combine(PowerPlantData otherData) : System.Void
    Adds another PowerPlantData's m_ElectricityProduction into this instance. Useful when aggregating multiple components (for example, combining contributions from multiple sub-entities or tiles).

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter : System.Void
    Writes the m_ElectricityProduction value using the provided writer. This method implements the ISerializable contract used by the game's serialization framework.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader : System.Void
    Reads the m_ElectricityProduction value from the provided reader. This method implements the ISerializable contract used by the game's serialization framework.

Usage Example

// Create two power-plant data instances
var plantA = new PowerPlantData { m_ElectricityProduction = 100 };
var plantB = new PowerPlantData { m_ElectricityProduction = 150 };

// Combine B into A (now A has 250)
plantA.Combine(plantB);

// Serialization example (pseudocode; actual writer/reader depend on the engine framework)
TWriter writer = /* obtain writer */;
plantA.Serialize(writer);

// Deserialization example
TReader reader = /* obtain reader */;
PowerPlantData loaded;
loaded.Deserialize(reader);
// loaded.m_ElectricityProduction now contains the value read from the reader

{{ Additional notes - Intended for use as an ECS component (IComponentData) — keep the struct blittable and simple to maintain performance. - Combine is additive; ensure semantics are correct if using negative values or other rules in your mod. - Serialization uses generic writer/reader interfaces from Colossal.Serialization.Entities; follow existing game conventions for versioning and compatibility if extending the struct. }}