Skip to content

Game.Prefabs.CoverageData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents coverage parameters for a service used by a prefab/entity. This struct stores which CoverageService the prefab provides and numeric parameters describing its effect: range, capacity, and magnitude. It implements Unity.Entities.IComponentData so it can be attached to ECS entities, IQueryTypeParameter (used by the query system), and Colossal.Serialization.Entities.ISerializable so it can be written to/read from the game's serialization streams (e.g., for network/prefab saving and loading). The Serialize/Deserialize methods write/read the float fields in a fixed order and store the service enum as a single byte.


Fields

  • public CoverageService m_Service
    Holds the type of service this coverage represents (e.g., power, water, health — defined by the CoverageService enum). Serialized as a single byte.

  • public float m_Range
    Radius or range of the coverage effect. Written first in serialization.

  • public float m_Capacity
    Capacity value associated with the service (semantic depends on service). Written second in serialization.

  • public float m_Magnitude
    Magnitude/strength of the effect. Written third in serialization.

Properties

  • This type defines no properties.

Constructors

  • public CoverageData()
    No explicit constructors are defined in the source — the default parameterless struct constructor is used. Initialize fields directly when creating an instance.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes this struct's data into the provided writer in the following order: m_Range (float), m_Capacity (float), m_Magnitude (float), and m_Service (as a single byte cast from the enum). Ensure the reader used to deserialize reads the same order and types.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads values from the provided reader and assigns them to the struct fields in the order they were written: m_Range, m_Capacity, m_Magnitude, then a byte that is cast to CoverageService for m_Service. The method uses ref locals to read directly into the struct fields.

Usage Example

// Create and populate a CoverageData instance
var coverage = new CoverageData
{
    m_Service = CoverageService.Power,
    m_Range = 50f,
    m_Capacity = 1000f,
    m_Magnitude = 1.5f
};

// Serialize using an IWriter implementation (pseudocode)
IWriter writer = GetWriter();
coverage.Serialize(writer);

// Deserialize (pseudocode)
IReader reader = GetReader();
var readCoverage = new CoverageData();
readCoverage.Deserialize(reader);
// readCoverage now has the values written earlier

Notes: - The exact meanings of range/capacity/magnitude depend on the specific CoverageService and how systems consume this component. - CoverageService is an enum defined elsewhere; serialization stores it as a single byte, so enum values should fit in one byte.