Skip to content

Game.Rendering.NotificationIconBufferSystem

Assembly: Assembly-CSharp
Namespace: Game.Rendering

Type: class

Base: GameSystemBase

Summary:
NotificationIconBufferSystem collects and prepares notification icon instance data for rendering. It queries entities with Icon components, integrates icon clustering (IconClusterSystem), applies animations and per-prefab display parameters (NotificationIconDisplayData), handles temporary icons, hidden/original icon mapping, and computes bounding volumes for all icons. Work is performed using Burst-compiled jobs (NotificationIconBufferJob and NotificationIconSortJob) and Native containers to minimize main-thread work and allow multithreaded sorting and instance accumulation. The system exposes an IconData structure that provides the prepared instance array and overall bounds for downstream rendering systems.


Fields

  • private EntityQuery m_IconQuery
    Holds the query used to find Icon entities (includes optional DisallowCluster / Animation; excludes Deleted and Hidden).

  • private EntityQuery m_ConfigurationQuery
    Query used to locate the singleton IconConfigurationData entity required for icon configuration.

  • private IconClusterSystem m_IconClusterSystem
    Reference to the IconClusterSystem used to obtain cluster data and to register writers for cluster updates.

  • private ToolSystem m_ToolSystem
    Reference to the ToolSystem (used to check active infoview and its notification mask).

  • private PrefabSystem m_PrefabSystem
    Reference to the PrefabSystem used to read infoview/prefab component data.

  • private NativeList<InstanceData> m_InstanceData
    Persistent native list that accumulates InstanceData for all icons each frame (created lazily on first update).

  • private NativeValue<Bounds3> m_IconBounds
    Persistent native value storing the aggregated Bounds3 for the icons computed during the buffer job.

  • private JobHandle m_InstanceDataDeps
    JobHandle tracking dependencies for jobs that operate on m_InstanceData (ensures completion before access).

  • private TypeHandle __TypeHandle
    Internal container of ComponentTypeHandle/ComponentLookup/BufferLookup used to map ECS component handles (assigned in OnCreateForCompiler).

Properties

  • None (the system exposes data via GetIconData()).

Constructors

  • public NotificationIconBufferSystem()
    Default ctor. The system is created by the World; most initialization is done in OnCreate.

Methods

  • protected override void OnCreate()
    Initializes system references and entity queries:
  • Retrieves IconClusterSystem, ToolSystem, PrefabSystem.
  • Prepares m_IconQuery to select Icon entities (with optional DisallowCluster/Animation, excluding Deleted/Hidden).
  • Prepares m_ConfigurationQuery to find IconConfigurationData singleton.

  • protected override void OnDestroy()
    Disposes native containers if created (waits for outstanding jobs via m_InstanceDataDeps.Complete(), then disposes m_InstanceData and m_IconBounds).

  • protected override void OnUpdate()
    Main scheduling point:

  • Ensures Camera.main exists and configuration is present.
  • Lazily creates m_InstanceData and m_IconBounds (Allocator.Persistent).
  • Computes category mask from active infoview (if any).
  • Obtains archetype chunks matching m_IconQuery asynchronously.
  • Builds and schedules NotificationIconBufferJob (reads chunk list, cluster data, lookups, camera transforms) to fill m_InstanceData and compute bounds.
  • Schedules NotificationIconSortJob to sort instances by distance.
  • Registers cluster writer with IconClusterSystem and stores job dependencies so GetIconData can safely wait.

  • public IconData GetIconData()
    Waits for instance data jobs to complete, resets m_InstanceDataDeps, and returns an IconData containing:

  • m_InstanceData: a NativeArray view of the accumulated instances.
  • m_IconBounds: the NativeValue computed by the last job.
    If no instance data exists, returns default(IconData).

  • protected override void OnCreateForCompiler()
    Compiler-time initialization helper that assigns query and type handles (calls __AssignQueries and __TypeHandle.__AssignHandles). Used by the generated/compiled system wiring.

  • private void __AssignQueries(ref SystemState state)
    Internal; invoked by OnCreateForCompiler. No runtime query assignment beyond the existing OnCreate usage.

Nested / Job types (brief):

  • IconData (struct)
  • m_InstanceData: NativeArray
  • m_IconBounds: NativeValue
  • Returned by GetIconData for rendering consumption.

  • InstanceData (struct, IComparable)

  • m_Position: float3
  • m_Params: float4 (x/y: size params, z/w: other per-instance params; w often used for category/visibility)
  • m_Icon: float (icon index)
  • m_Distance: float (distance from camera used for sorting)
  • CompareTo sorts by descending distance (used by NotificationIconSortJob).

  • NotificationIconBufferJob : IJob (BurstCompile)

  • Core job that inspects clusters and entity chunks, handles:

    • Icon clusters traversal (keeps or expands cluster nodes, places clustered icons, and handles hidden originals for temp icons).
    • Per-entity processing for both Temp and non-Temp icons:
    • Reads PrefabRef -> NotificationIconDisplayData to blend min/max params based on priority.
    • Applies animations (Animate helper) using IconAnimationElement buffers for animated offset/scale.
    • Computes icon radii (IconClusterSystem.IconCluster.CalculateRadius) and updates m_InstanceData and bounds.
    • Uses NativeParallelHashMap for mapping hidden/original icons' temporary positions when clustering.
    • Writes computed overall Bounds3 to m_IconBounds.
  • Private helper Animate(ref float3 location, ref float4 iconParams, float radius, Game.Notifications.Animation animation, DynamicBuffer iconAnimations)

    • Evaluates animation curve and adjusts iconParams (scale) and location (vertical offset relative to camera up).
  • NotificationIconSortJob : IJob (BurstCompile)

  • Sorts m_InstanceData by distance if length >= 2.

  • TypeHandle (struct)

  • Holds ComponentTypeHandle and ComponentLookup/BufferLookup instances used to build job data.
  • __AssignHandles(ref SystemState state) maps handles from the SystemState (called in OnCreateForCompiler).

Usage Example

// Typical usage inside a rendering system that depends on NotificationIconBufferSystem:
var iconBufferSystem = World.GetOrCreateSystemManaged<NotificationIconBufferSystem>();
var iconData = iconBufferSystem.GetIconData(); // This blocks until the internal jobs are complete

if (iconData.m_InstanceData.IsCreated)
{
    var instances = iconData.m_InstanceData; // NativeArray<InstanceData>
    var bounds = iconData.m_IconBounds.value; // Bounds3 for culling/visibility
    // Iterate instances for rendering:
    for (int i = 0; i < instances.Length; i++)
    {
        var inst = instances[i];
        // inst.m_Position, inst.m_Params, inst.m_Icon, inst.m_Distance
        // Submit per-instance data to GPU or batching renderer.
    }
}

Notes and implementation details: - The system is optimized for multi-threaded data preparation using Burst jobs and native containers; avoid accessing m_InstanceData on the main thread without calling GetIconData (which completes job dependencies). - Clustering logic uses IconClusterSystem to reduce icon clutter; temporary icons (Temp) may be reassigned positions when clustered to avoid overlap and optionally animate based on original entity animations. - NotificationIconDisplayData drives per-prefab min/max params and category masks; the system respects component enable/disable state for display data. - The system registers with IconClusterSystem to coordinate cluster writers and reads cluster data via GetIconClusterData, which returns a JobHandle dependency included in scheduling.