Game.Prefabs.WaterPoweredData
Assembly: Assembly-CSharp (typical game assembly)
Namespace: Game.Prefabs
Type: struct (public)
Base: IComponentData, IQueryTypeParameter, ICombineData
Summary:
Component data used by the game's ECS to represent multipliers for "water-powered" prefabs. It stores separate production and capacity factors, supports combining (aggregation) of multiple sources, and implements simple binary-style serialization/deserialization for save/load or network transfer. The order of serialization is productionFactor followed by capacityFactor.
Fields
-
public System.Single m_ProductionFactor
Multiplier applied to production output for a water-powered prefab (e.g., resource generation). Values are additive when combined via Combine. -
public System.Single m_CapacityFactor
Multiplier applied to capacity/throughput for a water-powered prefab (e.g., storage or service capacity). Values are additive when combined via Combine.
Properties
- None (no properties are declared on this struct).
Constructors
public WaterPoweredData()
Implicit/default constructor provided by the struct. Both fields default to 0.0f. Instances are typically created by value initialization or by assigning to fields directly.
Methods
-
public void Combine(WaterPoweredData otherData)
Adds the otherData's m_ProductionFactor and m_CapacityFactor to this instance. Used to aggregate contributions from multiple sources (e.g., multiple modifiers affecting the same entity). -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the two float fields to the provided writer in the order: - m_ProductionFactor
-
m_CapacityFactor
This deterministic order must be preserved by any matching Deserialize implementation. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the two float fields from the provided reader in the same order as Serialize. The method reads into the struct fields directly (using ref locals in the implementation).
Usage Example
// Create two data instances and combine them
var baseData = new WaterPoweredData { m_ProductionFactor = 1.0f, m_CapacityFactor = 0.5f };
var modifier = new WaterPoweredData { m_ProductionFactor = 0.2f, m_CapacityFactor = 0.1f };
baseData.Combine(modifier);
// baseData.m_ProductionFactor == 1.2f
// baseData.m_CapacityFactor == 0.6f
// Serialize example (pseudo-code; depends on concrete IWriter implementation)
using (var writer = /* obtain an IWriter instance */)
{
baseData.Serialize(writer);
}
// Deserialize example (pseudo-code; depends on concrete IReader implementation)
var loaded = new WaterPoweredData();
using (var reader = /* obtain an IReader instance */)
{
loaded.Deserialize(reader);
}