Skip to content

Game.Tools.HeatmapPreviewSystem

Assembly: Assembly-CSharp
Namespace: Game.Tools

Type: class

Base: GameSystemBase

Summary:
HeatmapPreviewSystem is a World/System that monitors the active infomode heatmap settings (InfoviewHeatmapData) and activates the appropriate preview system for rendering that heatmap. It queries for InfomodeActive + InfoviewHeatmapData entities and, based on the requested heatmap type, enables/disables a corresponding preview system (currently TelecomPreviewSystem). The system uses RequireForUpdate on its query so it only runs when heatmap infoview data is present. It also ensures the previously active preview system is properly disabled and updated when changing modes or when the system stops running.


Fields

  • private TelecomPreviewSystem m_TelecomPreviewSystem
    Handles preview rendering for telecom coverage heatmaps. This field is filled in OnCreate via World.GetOrCreateSystemManaged().

  • private EntityQuery m_InfomodeQuery
    EntityQuery that selects entities with InfomodeActive and InfoviewHeatmapData. It is used with RequireForUpdate so the system only runs when infomode heatmap data exists.

  • private ComponentSystemBase m_LastPreviewSystem
    Keeps track of the last preview system that was enabled so the system can disable and update it when switching to another preview system or when stopping.

Properties

  • This class does not expose public properties.

Constructors

  • public HeatmapPreviewSystem()
    Parameterless constructor marked with [Preserve] in the source. No special initialization beyond what the base GameSystemBase constructor performs; actual setup is done in OnCreate.

Methods

  • protected override void OnCreate() : System.Void
    Initializes the system: obtains the TelecomPreviewSystem, constructs the m_InfomodeQuery for InfomodeActive + InfoviewHeatmapData, and calls RequireForUpdate(m_InfomodeQuery) so the system only updates when relevant infomode heatmap data exists. Marked with [Preserve].

  • protected override void OnStopRunning() : System.Void
    If a preview system was active (m_LastPreviewSystem != null), disables it, calls Update on it once more to flush any state, and clears the reference. Calls base.OnStopRunning() afterwards. Marked with [Preserve].

  • private ComponentSystemBase GetPreviewSystem() : ComponentSystemBase
    Determines which preview system should be active by reading all InfoviewHeatmapData components from the query into a NativeArray (Allocator.TempJob). Iterates the array to find a heatmap type match; if it finds HeatmapData.TelecomCoverage it returns the cached TelecomPreviewSystem. Disposes the NativeArray in a finally block to avoid leaks. Returns null if no matching heatmap is found or if the query is empty.

  • protected override void OnUpdate() : System.Void
    Main update loop: calls GetPreviewSystem() to obtain the desired preview system. If it differs from m_LastPreviewSystem, disables and updates the old preview system (if any), stores the new one in m_LastPreviewSystem, and enables it. Finally, it calls Update() on the selected previewSystem (if not null) to drive its behavior. Marked with [Preserve].

Usage Example

// The system is a managed GameSystem; it sets itself up automatically.
// Example: enabling the telecom heatmap by adding an InfoviewHeatmapData component
// to an entity that also has InfomodeActive will make HeatmapPreviewSystem activate
// the TelecomPreviewSystem on the next update.

var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, new InfomodeActive());
entityManager.AddComponentData(entity, new InfoviewHeatmapData { m_Type = HeatmapData.TelecomCoverage });

// HeatmapPreviewSystem will pick up the InfoviewHeatmapData via m_InfomodeQuery,
// enable TelecomPreviewSystem, and call Update() on it each frame until changed.

Notes and implementation details: - The system is decorated with [Preserve] on lifecycle methods to prevent stripping. - Uses RequireForUpdate(m_InfomodeQuery) so the system will not run unless there is matching infomode data. - When switching preview systems, the previous system is disabled and Update() is called once to allow it to clean up any state. - NativeArray created by ToComponentDataArray uses Allocator.TempJob and is disposed in a finally block to avoid memory leaks.