Skip to content

Game.UI.Tooltip.RaycastNotificationTooltipSystem

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

Type: class

Base: TooltipSystemBase

Summary:
RaycastNotificationTooltipSystem is an ECS UI system that displays a notification tooltip when the player mouses over notification icons in the world. The system queries a configuration singleton (IconConfigurationData), listens to the tool raycast results (ToolRaycastSystem) and, when the active tool is the default tool and the raycast hit belongs to a notification icon prefab, it constructs a NotificationTooltip (name and color) and invokes AddMouseTooltip to show it. The system also skips special marker prefabs (selected/followed markers) defined in the configuration.


Fields

  • private ToolSystem m_ToolSystem
    Used to check the currently active tool. The system compares m_ToolSystem.activeTool against m_DefaultTool to ensure tool-state is appropriate for showing tooltips.

  • private DefaultToolSystem m_DefaultTool
    Reference to the game's default tool system; used to validate that the default tool is active before showing notification tooltips.

  • private PrefabSystem m_PrefabSystem
    Used to resolve prefabs and obtain display names: attempts to get a NotificationIconPrefab to read its name, falling back to an obsolete ID -> GetName() lookup.

  • private NameSystem m_NameSystem
    Present for potential name lookups (acquired in OnCreate). Not actively used in the provided OnUpdate implementation, but kept as a dependency.

  • private ImageSystem m_ImageSystem
    Present for potential icon/image lookups. Not actively used in the provided OnUpdate implementation, but kept as a dependency.

  • private ToolRaycastSystem m_ToolRaycastSystem
    Used to perform/get the last tool raycast result. The system calls GetRaycastResult(out result) to obtain the entity hit by the raycast.

  • private EntityQuery m_ConfigurationQuery
    EntityQuery targeting IconConfigurationData singleton. The system Requires this query for update and reads the singleton to access configured selected/followed marker prefabs.

  • private NotificationTooltip m_Tooltip
    A reusable NotificationTooltip instance configured in OnCreate (path = "raycastNotification", verbose = true). Filled with name and color before being passed to AddMouseTooltip.

Properties

  • (none)

Constructors

  • public RaycastNotificationTooltipSystem()
    Default parameterless constructor. Marked with [Preserve] in source; standard ECS system construction—no custom constructor logic beyond attribute presence.

Methods

  • protected override void OnCreate() : System.Void
    Initializes system dependencies and resources:
  • Calls base.OnCreate().
  • Caches systems: ToolSystem, DefaultToolSystem, NameSystem, ImageSystem, PrefabSystem, ToolRaycastSystem using World.GetOrCreateSystemManaged().
  • Creates an EntityQuery for IconConfigurationData and calls RequireForUpdate(m_ConfigurationQuery) so the system only updates when configuration exists.
  • Constructs and configures the NotificationTooltip instance (path = "raycastNotification", verbose = true).

  • protected override void OnUpdate() : System.Void
    Core runtime logic executed each tick:

  • Checks that the active tool equals the default tool.
  • Asks ToolRaycastSystem for the current raycast result. If a hit exists and the hit entity has both Icon and PrefabRef components, proceeds.
  • Reads IconConfigurationData singleton to obtain special marker prefab references.
  • Skips showing a tooltip if the hit prefab equals the configured SelectedMarker or FollowedMarker.
  • Attempts to resolve a NotificationIconPrefab from PrefabRef; if found uses prefab.name, otherwise obtains a fallback name via PrefabSystem.GetObsoleteID(...).GetName().
  • Sets m_Tooltip.name and m_Tooltip.color (color determined by NotificationTooltip.GetColor(component.m_Priority)) and calls AddMouseTooltip(m_Tooltip) to display the tooltip.

Notes: - The system depends on the presence of IconConfigurationData singleton; without it the system will not run. - Some cached subsystems (NameSystem, ImageSystem) are not used in the current OnUpdate but are prepared for potential future use. - Tooltip text & color are derived from the notification prefab and its priority.

Usage Example

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

    // Example: mimic the system's initialization to configure a tooltip instance.
    m_ToolSystem = World.GetOrCreateSystemManaged<ToolSystem>();
    m_DefaultTool = World.GetOrCreateSystemManaged<DefaultToolSystem>();
    m_ToolRaycastSystem = World.GetOrCreateSystemManaged<ToolRaycastSystem>();
    m_ConfigurationQuery = GetEntityQuery(ComponentType.ReadOnly<IconConfigurationData>());
    RequireForUpdate(m_ConfigurationQuery);

    m_Tooltip = new NotificationTooltip
    {
        path = "raycastNotification",
        verbose = true
    };
}