Skip to content

Game.Prefabs.WindPoweredData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
Represents compact data for wind-powered prefabs (for example wind turbines) used by the game's ECS-based systems. Holds a maximum wind threshold and an integer production value. Provides combination semantics (used when multiple instances are merged or aggregated) and implements custom binary serialization/deserialization for persistence or network transfer. The combination logic ensures the aggregated maximum wind is the minimum of contributors when there is existing production, while production values are summed.


Fields

  • public float m_MaximumWind
    Holds the maximum wind value relevant to this component (used as a threshold/limit for production). When combining multiple WindPoweredData instances, this field is set to the minimum of the existing and incoming maximum wind if production is already present; otherwise it adopts the incoming value. Uses Unity.Mathematics.math for numeric operations.

  • public int m_Production
    Integer production value (e.g., amount of power produced or production-related count). When combining, production values are added together.

Properties

  • This type defines no properties.

Constructors

  • public WindPoweredData()
    Default value-type constructor (implicitly provided). Default field values are 0 for m_MaximumWind and 0 for m_Production unless initialized explicitly.

Methods

  • public void Combine(WindPoweredData otherData)
    Aggregates another WindPoweredData into this instance. Behavior:
  • If this.m_Production > 0, sets this.m_MaximumWind = math.min(this.m_MaximumWind, otherData.m_MaximumWind).
  • Otherwise sets this.m_MaximumWind = otherData.m_MaximumWind.
  • Adds otherData.m_Production into this.m_Production. This is useful when merging multiple component instances (e.g., when combining LOD or aggregated entity data).

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the struct fields to a writer in order:

  • m_MaximumWind (float)
  • m_Production (int) This is used for persistence or transmission with the game's custom serialization framework (Colossal.Serialization.Entities).

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads fields from a reader into this instance in the same order as serialization:

  • m_MaximumWind (float)
  • m_Production (int) Uses ref locals when reading to assign directly into the struct fields.

Usage Example

// Create two wind-powered data instances (e.g., from two sources or LODs)
var a = new WindPoweredData { m_MaximumWind = 12f, m_Production = 5 };
var b = new WindPoweredData { m_MaximumWind = 10f, m_Production = 3 };

// Combine b into a:
// - a.m_MaximumWind becomes math.min(12f, 10f) == 10f (since a.m_Production > 0)
// - a.m_Production becomes 8
a.Combine(b);

// Serialization example (pseudo-usage — depends on actual IWriter implementation)
IWriter writer = /* obtain writer */;
a.Serialize(writer);

// Deserialization example (pseudo-usage)
IReader reader = /* obtain reader */;
var recovered = new WindPoweredData();
recovered.Deserialize(reader);