Skip to content

Game.UI.Tooltip.TempZoningEvaluationTooltipSystem

Assembly: Assembly-CSharp
Namespace: Game.UI.Tooltip

Type: class

Base: TooltipSystemBase

Summary:
TempZoningEvaluationTooltipSystem is a UI tooltip system that displays temporary zoning evaluation tooltips based on evaluation results provided by the game's zoning info system. On each update it reads a NativeList of ZoneEvaluationUtils.ZoningEvaluationResult from the ZoningInfoSystem, creates or reuses ZoningEvaluationTooltip instances (one per evaluation up to maxCount), filters results by scoreThreshold, populates the tooltip (factor, score, path) and registers it with the base class via AddMouseTooltip so it appears near the mouse. The system obtains its IZoningInfoSystem implementation from the World and pre-allocates a List to maxCount capacity during creation. Methods and the constructor are preserved for runtime linking.


Fields

  • private IZoningInfoSystem m_ZoningInfoSystem
    Holds a reference to the zoning information system (ZoningInfoSystem) obtained from the World. Used to access the evaluationResults NativeList each frame.

  • private List<ZoningEvaluationTooltip> m_Tooltips
    A reusable pool/list of ZoningEvaluationTooltip objects. The list is pre-sized to maxCount on creation and expanded as needed up to maxCount. Each entry is given a unique path like "zoningEvaluation0", "zoningEvaluation1", etc.

Properties

  • public Unity.Jobs.JobHandle producerHandle { get; private set }
    NOTE: This property is not present in this class. (The template included it — for this class, the public configurable properties are below.)

  • public int maxCount { get; set; } = 5
    Maximum number of zoning evaluation tooltips to consider/display each update. Defaults to 5. The update loop will process at most min(evaluationResults.Length, maxCount) entries.

  • public float scoreThreshold { get; set; } = 10f
    Minimum absolute score required for a zoning evaluation result to produce a tooltip. Results with Mathf.Abs(m_Score) <= scoreThreshold are ignored. Defaults to 10.0.

Constructors

  • public TempZoningEvaluationTooltipSystem()
    Default constructor. Marked with [Preserve] in source to prevent stripping. No custom initialization is performed here — initialization happens in OnCreate.

Methods

  • protected override void OnCreate() : System.Void
    Called when the system is created. Implementation:
  • Calls base.OnCreate().
  • Acquires the ZoningInfoSystem from the world via base.World.GetOrCreateSystemManaged() and stores it in m_ZoningInfoSystem.
  • Initializes m_Tooltips as a new List with capacity set to maxCount.
  • Marked with [Preserve] in source.

  • protected override void OnUpdate() : System.Void
    Called every update tick. Implementation:

  • Reads evaluationResults (NativeList) from m_ZoningInfoSystem.
  • Iterates i from 0 to math.min(evaluationResults.Length, maxCount) - 1.
  • Ensures m_Tooltips has an element at index i; if not, adds a new ZoningEvaluationTooltip with path set to $"zoningEvaluation{i}".
  • For each evaluation result, checks Mathf.Abs(zoningEvaluationResult.m_Score) > scoreThreshold.
  • If the check passes, sets the matching tooltip's factor and score from the result and calls AddMouseTooltip(zoningEvaluationTooltip) to display it.
  • Marked with [Preserve] in source.

Additional notes: - The class depends on these types: IZoningInfoSystem / ZoningInfoSystem (provides evaluationResults), ZoneEvaluationUtils.ZoningEvaluationResult (fields m_Factor, m_Score), ZoningEvaluationTooltip (fields factor, score, path), and the base TooltipSystemBase method AddMouseTooltip. - Uses Unity.Collections.NativeList and Unity.Mathematics.math for bounds; uses UnityEngine.Mathf for absolute value and comparison. - The class reads a NativeList from another system — it does not attempt to modify or dispose it.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();

    // Example: adjust how many tooltips to display and lower threshold
    // This can be done immediately after creation or by another controller.
    var tooltipSystem = this; // when inside the system subclass or resolved from the World
    tooltipSystem.maxCount = 8;
    tooltipSystem.scoreThreshold = 5f;

    // The base OnCreate of TempZoningEvaluationTooltipSystem will still be called
    // and will initialize m_ZoningInfoSystem and m_Tooltips as usual.
}