Game.UI.Tooltip.TempNotificationTooltipSystem
Assembly: Assembly-CSharp.dll (game assembly; actual assembly name may vary)
Namespace: Game.UI.Tooltip
Type: class
Base: TooltipSystemBase
Summary:
TempNotificationTooltipSystem is an ECS-managed UI tooltip system that gathers temporary notification icons (Temp + Icon + PrefabRef) present in the world, groups them by notification prefab, selects the highest IconPriority per prefab, sorts notifications by priority, and constructs a small list of StringTooltip entries to display as temporary notification tooltips. It skips marker-cluster icons, notifications owned by another entity that already has an equal-or-higher-priority icon of the same prefab, and entities currently selected (TempFlags.Select) or being dragged. The system uses PrefabSystem to resolve notification prefab data (icon and localized title) and reuses allocated Native collections for performance.
Fields
-
private PrefabSystem m_PrefabSystem
Reference to the game's PrefabSystem used to resolve NotificationIconPrefab instances for each notification prefab entity. -
private EntityQuery m_TempQuery
EntityQuery used to select entities that have Temp, Owner (optional), Icon and PrefabRef components, excluding Deleted entities. -
private NativeParallelHashMap<Entity, IconPriority> m_Priorities
Persistent native hash map mapping notification prefab Entity -> highest observed IconPriority for that prefab during the current update. Used to deduplicate by prefab and keep only the top priority per prefab. -
private NativeList<ItemInfo> m_Items
Persistent native list of ItemInfo (prefab + priority) created from m_Priorities and sorted by priority descending for ordered tooltip generation. -
private List<StringTooltip> m_Tooltips
Managed list of StringTooltip objects reused across updates to populate and add mouse tooltips for each top notification. -
private TypeHandle __TypeHandle
Compiler-generated struct that stores ComponentTypeHandleinstances (Temp, Owner, Icon, PrefabRef) and provides an __AssignHandles method to initialize them against a SystemState. -
private struct ItemInfo
Nested struct holding a prefab Entity and its IconPriority, implements IComparableto sort items by priority descending: public Entity m_Prefab
-
public IconPriority m_Priority
-
private struct TypeHandle
Nested struct containing read-only ComponentTypeHandle fields: ComponentTypeHandle<Temp> __Game_Tools_Temp_RO_ComponentTypeHandle
ComponentTypeHandle<Owner> __Game_Common_Owner_RO_ComponentTypeHandle
ComponentTypeHandle<Icon> __Game_Notifications_Icon_RO_ComponentTypeHandle
ComponentTypeHandle<PrefabRef> __Game_Prefabs_PrefabRef_RO_ComponentTypeHandle
and a method __AssignHandles(ref SystemState) to obtain handles from a SystemState.
Properties
- None (no public properties exposed by this system)
Constructors
public TempNotificationTooltipSystem()
Default constructor (the system is initialized by the ECS world; most initialization happens in OnCreate).
Methods
-
protected override void OnCreate()
Initializes the system: obtains PrefabSystem, creates the EntityQuery that reads Temp, Owner, Icon, PrefabRef and excludes Deleted, and allocates persistent native collections (m_Priorities and m_Items) as well as the managed m_Tooltips list. -
protected override void OnDestroy()
Disposes persistent native collections (m_Priorities and m_Items) and calls base.OnDestroy to clean up. -
protected override void OnUpdate()
Main update loop: - Completes any outstanding dependencies.
- Clears the m_Priorities map and m_Items list.
- Iterates over matching archetype chunks for the query, obtains component arrays via ComponentTypeHandle
and for each entity: - Skips icons with IconClusterLayer.Marker.
- If an Owner component exists, checks the owner entity to see whether it already has an icon for the same prefab with equal or higher priority (via HasIcon) and skips if so.
- Skips if the Temp flags indicate the entity is selected (and not dragging).
- Records or updates the highest priority for the notification prefab in m_Priorities.
-
Converts the m_Priorities entries to m_Items, sorts them by priority descending, and then for each item:
- Resolves the NotificationIconPrefab using m_PrefabSystem.GetPrefab
. - Ensures a StringTooltip exists in m_Tooltips for this index and sets its fields: icon (from UIObject.m_Icon if present), value (localized notification title using LocalizedString.Id with prefab.name), and color (NotificationTooltip.GetColor based on priority).
- Calls AddMouseTooltip to add the tooltip to the UI tooltips collection.
- Resolves the NotificationIconPrefab using m_PrefabSystem.GetPrefab
-
private bool HasIcon(Entity entity, Entity prefab, IconPriority minPriority)
Checks whether the specified entity (owner) has a DynamicBufferand whether any icon buffer entry references an icon entity whose PrefabRef matches the given prefab and whose Icon priority is >= minPriority. Returns true if such an icon is present, otherwise false. Used to avoid showing a notification tooltip for a child temp when the owner already shows an equal-or-higher priority icon. -
[MethodImpl(MethodImplOptions.AggressiveInlining)] private void __AssignQueries(ref SystemState state)
A small compiler helper that builds (and currently disposes) an EntityQueryBuilder; used by the compiler-generated OnCreateForCompiler path to ensure queries are assigned. -
protected override void OnCreateForCompiler()
Compiler-assist initialization that calls __AssignQueries and sets up component type handles via the internal __TypeHandle.__AssignHandles method.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// The TempNotificationTooltipSystem initializes its own collections and query.
// No extra setup is normally required from a mod author; the system will
// gather temp notifications each frame and add appropriate StringTooltips.
}
Notes and implementation details: - The system uses persistent Native containers (Allocator.Persistent) allocated in OnCreate and disposed in OnDestroy to avoid per-frame GC and allocations. - The entity query excludes Deleted entities to avoid processing removed objects. - The prioritization logic ensures only one tooltip per notification prefab is shown, using the highest observed IconPriority among temps of that prefab. - Localization of the tooltip title uses LocalizedString.Id("Notifications.TITLE[" + prefab.name + "]"), matching in-game localization keys. - The system is marked CompilerGenerated and uses several [Preserve] attributes to survive code stripping and to integrate with the game's ECS/compilation patterns.