Game.Simulation.TelecomCoverage
Assembly: Game
Namespace: Game.Simulation
Type: struct TelecomCoverage
Base: System.ValueType, IStrideSerializable, ISerializable
Summary:
Represents per-cell telecom coverage information used by the simulation. Stores a compact representation (two bytes) of signal strength and local network load, provides a computed networkQuality value and supports binary serialization (explicit stride of 2). Also includes a static helper to sample a smoothly interpolated network quality at an arbitrary world position from a CellMapData
Fields
-
public byte m_SignalStrength
Stores the raw signal strength for this cell. Range 0–255. Used by networkQuality calculation and sampling. Larger values represent stronger signal. -
public byte m_NetworkLoad
Stores the local network load for this cell. Range 0–255. Higher load reduces effective network quality.
Properties
public int networkQuality { get; }
Computed read-only property that returns an integer quality value derived from m_SignalStrength and m_NetworkLoad using the formula: networkQuality = m_SignalStrength * 510 / (255 + (m_NetworkLoad << 1)) Notes:- The numerator 510 is 2 * 255, so with zero load the value is roughly signalStrength * 2 (range 0–510).
- Increasing m_NetworkLoad increases the denominator and therefore lowers the returned quality.
- The property performs integer arithmetic and returns an integer quality value.
Constructors
public TelecomCoverage()
Implicit default struct constructor. Fields m_SignalStrength and m_NetworkLoad default to 0. No explicit custom constructors are defined in the source.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the two-byte representation in the order: m_SignalStrength, then m_NetworkLoad. Intended for compact persistence via the game's custom writer interface. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads two bytes from reader into m_SignalStrength and m_NetworkLoad (same order as Serialize). Uses by-ref assignment to the struct fields. -
public int GetStride(Context context)
Returns the stride (in bytes) required to serialize this struct. Always returns 2. -
public static float SampleNetworkQuality(CellMapData<TelecomCoverage> coverage, float3 position)
Samples an interpolated network quality at the given world position from a CellMapData grid of TelecomCoverage. Implementation details: - Converts world position to coverage grid / texture coordinates using coverage.m_CellSize and coverage.m_TextureSize.
- Identifies the four neighboring texel/cell indices (floor of coords and +1), clamps them to valid range.
- Loads the four TelecomCoverage cells from coverage.m_Buffer.
- Constructs per-corner signal strength and load values, computes per-corner quality factors as: min(1.0f, signal / (127.5f + load)) (note the float math uses 127.5 instead of half of 255; essentially normalizes and applies load influence).
- Performs bilinear interpolation (math.lerp) between the four corner quality factors based on fractional position inside the cell.
- Returns a single float representing the interpolated network quality (0..1 after the per-corner min, but depending on normalization; consult callers to understand expected scale).
This method is deterministic and does not modify state. Useful for sampling coverage for e.g., service influence, visualizations, or gameplay checks.
Usage Example
// Example: create a TelecomCoverage, check property and sample from a CellMapData grid.
TelecomCoverage cell = new TelecomCoverage();
cell.m_SignalStrength = 200; // 0..255
cell.m_NetworkLoad = 50; // 0..255
int qualityValue = cell.networkQuality; // integer quality derived from the two bytes
// When you have a coverage grid (CellMapData<TelecomCoverage>) and a world position:
float3 worldPos = new float3(100f, 0f, 200f);
float sampledQuality = TelecomCoverage.SampleNetworkQuality(coverageGrid, worldPos);
// Serialization example (pseudo):
// writer.Write(cell.m_SignalStrength);
// writer.Write(cell.m_NetworkLoad);
// or call cell.Serialize(writer) where writer : IWriter
Additional notes: - The struct is deliberately compact (2 bytes) for efficient storage in cell maps / textures. - SampleNetworkQuality performs bilinear interpolation across neighboring cells and includes per-corner clamping to avoid values > 1. Check how calling code expects the scale (some code paths may reinterpret the returned float).