Skip to content

Game.HeatmapInfomodePrefab

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: GradientInfomodeBasePrefab

Summary:
Represents a heatmap infomode prefab used by the game's information overlays (infomodes). Holds which HeatmapData this prefab displays, contributes required ECS components for the infoview, initializes the entity component data, determines which color group the heatmap belongs to, and contains compatibility logic to avoid activating two infomodes that both render arrows on water simultaneously.


Fields

  • public HeatmapData m_Type
    Holds the specific heatmap type this prefab represents (e.g., AirPollution, Wind, WaterFlow, WaterPollution, Fish, etc.). This value is written into the InfoviewHeatmapData component during Initialize so the ECS systems know which heatmap to render.

Properties

  • public override string infomodeTypeLocaleKey => "TerrainColor";
    Returns the localization key used to label this infomode in the UI. In this class it is fixed to "TerrainColor".

Constructors

  • public HeatmapInfomodePrefab()
    Default constructor (no custom initialization in source). Instances are typically configured in editor/prefab data by setting m_Type.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Calls the base implementation and then adds InfoviewHeatmapData (read/write) to the set of ECS components this prefab requires. This informs the prefab-to-entity conversion which components to add.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Calls the base Initialize and sets the InfoviewHeatmapData component on the provided entity to reflect this prefab's m_Type: entityManager.SetComponentData(entity, new InfoviewHeatmapData { m_Type = m_Type });

  • public override int GetColorGroup(out int secondaryGroup)
    Maps the local m_Type to a color group used by the UI/renderer and provides a secondary group value. Mapping implemented in source:

  • AirPollution, Wind, TelecomCoverage, Oil, Noise -> returns primary group 0 and secondaryGroup = 1
  • WaterFlow, WaterPollution, Fish -> returns primary group 1 and secondaryGroup = -1
  • default -> returns primary group 0 and secondaryGroup = -1

  • public override bool CanActivateBoth(InfomodePrefab other)
    Determines whether this infomode may be activated simultaneously with another infomode. If both this and the other are Heatmap infomodes that "have arrows on water" (see HasArrowsOnWater), the method returns false (disallow simultaneous activation). Otherwise it defers to the base implementation.

  • private bool HasArrowsOnWater()
    Returns true for heatmap types that render arrows on water. The code checks (uint)(type - 4) <= 1u, which effectively means two specific HeatmapData enum values (likely WaterFlow and WaterPollution) produce true. Fish (handled elsewhere) does not trigger arrows according to this check.

Usage Example

// Example: configure a prefab for WaterFlow and initialize its entity component
var prefab = new HeatmapInfomodePrefab {
    m_Type = HeatmapData.WaterFlow
};

// When converting prefab to an ECS entity, Initialize will set the InfoviewHeatmapData:
[Preserve]
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    entityManager.SetComponentData(entity, new InfoviewHeatmapData {
        m_Type = prefab.m_Type
    });
}

// Query color group:
int secondary;
int group = prefab.GetColorGroup(out secondary);