Skip to content

Game.Tools.InfoviewUtils

Assembly: Assembly-CSharp (game code)
Namespace: Game.Tools

Type: public static class

Base: N/A (static utility class)

Summary:
Utility helper methods used by the infoview system to convert various game metrics into normalized color values (0..1). The class provides several overloaded GetColor methods for different Infoview data types (coverage, availability, net/building/object status). The methods typically normalize an input metric against a configured min/max range or compute a score using zone evaluation utilities and then clamp the result to the 0..1 interval using math.saturate. These helpers are intended for use in UI/mod systems that display infoview overlays.


Fields

  • This static utility class declares no fields.
    (All state is local to method calls; inputs often include DynamicBuffer/NativeArray/NativeList/ComponentLookup references.)

Properties

  • This class defines no properties.

Constructors

  • This class has no public constructors (static class, implicit static constructor if needed).

Methods

  • public static float GetColor(InfoviewCoverageData data, float coverage)
    Returns a normalized color value (0..1) by mapping a coverage value into the configured range on the supplied InfoviewCoverageData. Implementation: (coverage - range.min) / (range.max - range.min), then clamped with math.saturate. If the range is degenerate, callers should ensure they do not pass equal min/max to avoid divide-by-zero semantics in custom code (the game code expects reasonable ranges).

  • public static float GetColor(InfoviewAvailabilityData data, DynamicBuffer<ResourceAvailability> availabilityBuffer, float curvePosition, ref ZonePreferenceData preferences, NativeArray<int> industrialDemands, NativeArray<int> storageDemands, float pollution, float landValue, DynamicBuffer<ProcessEstimate> estimates, NativeList<IndustrialProcessData> processes, ResourcePrefabs resourcePrefabs, ComponentLookup<ResourceData> resourceDatas)
    Computes a normalized availability color for a zone/area using the zone evaluation pipeline. Behavior summary:

  • Constructs a BuildingPropertyData that allows all resources (calls EconomyUtils.GetAllResources()) and sets residential properties to 1.
  • Calls ZoneEvaluationUtils.GetScore(...) with storage = false to compute a base score, then divides that score by 256f to scale it to ~0..1.
  • If the data indicates an Industrial area and not an office, the method reduces the base score by multiplying by 0.875 and additionally adds a storage-based score (ZoneEvaluationUtils.GetScore with storage = true) divided by 2048f (a small contribution).
  • Finally clamps the result with math.saturate and returns it. Notes/requirements:
  • This overload is the most complex — it depends on DynamicBuffer, NativeArray, NativeList, ProcessEstimate and ComponentLookup types. It must be called in a context where these data structures are valid (e.g., inside a System or code that has access to ECS buffers/arrays).
  • The method reads and passes resourceDatas by reference to the evaluator. Ensure appropriate read/write access and lifetimes.
  • Inputs such as industrialDemands/storageDemands, pollution, landValue and estimates influence the computed score via ZoneEvaluationUtils.GetScore.

  • public static float GetColor(InfoviewNetStatusData data, float status)
    Normalizes a network status value against the configured min/max in InfoviewNetStatusData and clamps to 0..1 using math.saturate. Same mapping approach as coverage/status helpers.

  • public static float GetColor(InfoviewBuildingStatusData data, float status)
    Normalizes a building status metric against data.m_Range and clamps to 0..1.

  • public static float GetColor(InfoviewObjectStatusData data, float status)
    Normalizes an object status metric against data.m_Range and clamps to 0..1.

Usage Example

// Simple coverage example
InfoviewCoverageData covData = /* obtain from infoview config */;
float coverageValue = 0.65f; // e.g., measured coverage for the cell
float color = InfoviewUtils.GetColor(covData, coverageValue); // normalized 0..1

// Basic status example
InfoviewNetStatusData netData = /* obtain from infoview config */;
float netStatus = 12f;
float netColor = InfoviewUtils.GetColor(netData, netStatus);

// More complex availability example (called from a System where buffers/arrays are valid)
protected void SomeSystemMethod(
    DynamicBuffer<ResourceAvailability> availabilityBuffer,
    ref ZonePreferenceData zonePrefs,
    DynamicBuffer<ProcessEstimate> estimates,
    ComponentLookup<ResourceData> resourceDatas)
{
    InfoviewAvailabilityData availData = /* obtain from infoview config */;
    NativeArray<int> industrialDemands = /* prepared native array */;
    NativeArray<int> storageDemands = /* prepared native array */;
    NativeList<IndustrialProcessData> processes = /* prepared native list */;
    ResourcePrefabs resourcePrefabs = /* resource prefabs instance */;
    float curvePos = 0.5f;
    float pollution = 0.1f;
    float landValue = 0.3f;

    float availColor = InfoviewUtils.GetColor(
        availData,
        availabilityBuffer,
        curvePos,
        ref zonePrefs,
        industrialDemands,
        storageDemands,
        pollution,
        landValue,
        estimates,
        processes,
        resourcePrefabs,
        resourceDatas);
    // use availColor for overlay tinting or UI
}

Notes and tips: - All returned float values are clamped to [0,1]; they are intended to be fed directly into UI color gradients or overlay shaders. - The availability overload relies on internal game scoring functions (ZoneEvaluationUtils). When calling from mods, ensure you have the required ECS context and correct read/write access to buffers and native collections. - If you need to debug the score composition, consider computing the individual ZoneEvaluationUtils.GetScore calls separately before combining them to see their contributions.