Skip to content

Game.Notifications.IconDeletedSystem

Assembly: Assembly-CSharp
Namespace: Game.Notifications

Type: class

Base: GameSystemBase

Summary:
System that detects deleted entities related to notifications (icons) and issues corresponding remove/update commands via the IconCommandSystem. It schedules a Burst-compiled IJobChunk (IconDeletedJob) to iterate over chunks that contain Icon or IconElement data, checks for Deleted components on owners, icons or targets, and uses an IconCommandBuffer to remove icon instances or update owners' icon state. The system requires an EntityQuery that matches entities with Deleted and either Icon or IconElement, ensuring it only runs when relevant deletions occur. It also uses fast ComponentLookup and type handles to access component data inside the job.


Fields

  • private IconCommandSystem m_IconCommandSystem
    Holds a reference to the IconCommandSystem used to create IconCommandBuffer instances. The system uses this to enqueue remove/update icon commands from the job.

  • private EntityQuery m_DeletedQuery
    EntityQuery used to select entities that trigger the system's execution. Constructed to require Deleted plus either Icon or IconElement (and an additional query variant for Updated + IconElement). The system calls RequireForUpdate with this query so it only runs when relevant components change.

  • private TypeHandle __TypeHandle
    Container for the precomputed type and component lookup handles (EntityTypeHandle, ComponentTypeHandle, ComponentTypeHandle, ComponentTypeHandle, ComponentTypeHandle, ComponentTypeHandle, BufferTypeHandle, and several ComponentLookup<> instances). These handles are assigned in OnCreateForCompiler and used to build job data in OnUpdate.

  • (nested) private struct IconDeletedJob
    Burst-compiled IJobChunk that performs the actual per-chunk processing. See Methods for details of its Execute method and the fields it uses.

  • (nested) private struct TypeHandle
    Helper struct that stores the entity/component type handles and component lookups required by the job. Contains an __AssignHandles method to populate those handles from a SystemState.

Properties

  • None (this system exposes no public properties).

Constructors

  • public IconDeletedSystem()
    Default constructor. The system relies on OnCreate to initialize runtime references and queries.

Methods

  • protected override void OnCreate() : System.Void
    Initializes the system: obtains the IconCommandSystem from the World, builds the m_DeletedQuery (requiring Deleted plus Icon or IconElement, and an additional query variant for Updated + IconElement), and calls RequireForUpdate(m_DeletedQuery) so the system only runs when matching entities exist.

  • protected override void OnUpdate() : System.Void
    Builds an IconDeletedJob instance, filling it with type handles and component lookups obtained via InternalCompilerInterface and the internal TypeHandle, and creates an IconCommandBuffer through m_IconCommandSystem.CreateCommandBuffer(). The job is scheduled in parallel over m_DeletedQuery using JobChunkExtensions.ScheduleParallel, and the resulting dependency is passed to m_IconCommandSystem.AddCommandBufferWriter to inform the command system about the writer dependency.

  • protected override void OnCreateForCompiler() : System.Void
    Compiler-time helper that calls __AssignQueries and assigns handles via __TypeHandle.__AssignHandles. Present to support the generated type handle assignment pattern used by the job/system.

  • private void __AssignQueries(ref SystemState state) : System.Void
    Internal helper called from OnCreateForCompiler; in the current implementation it creates and immediately disposes an EntityQueryBuilder (placeholder for possible query assignment by source generators / compiler).

  • (nested) IconDeletedJob.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) : System.Void
    Core chunk processing logic:

  • If the chunk contains Icon components (non-buffered icons):
    • Iterates icons alongside Owner, Target (optional), and PrefabRef components.
    • For each entry, if the owner entity is not marked Deleted, it emits a Remove command via m_WarningCommandBuffer.Remove passing owner, prefab, target (or Entity.Null) and the SecondaryLocation flag extracted from icon.m_Flags.
    • If a chunk uses Target components, it will use the target from the Target component; otherwise target is Entity.Null.
  • If the chunk does not contain Icon components but has IconElement buffers:

    • Iterates each owner entity and its DynamicBuffer.
    • For each icon element, skips if the icon entity itself is Deleted.
    • Reads Icon and PrefabRef for the icon entity and optionally Target.
    • Removes or updates via m_WarningCommandBuffer.Remove, depending on whether the owner or target is Deleted; if the owner chunk is not flagged Deleted, calls m_WarningCommandBuffer.Update(owner) at the end of processing that owner's buffer. The job uses ComponentLookup<> instances (m_DeletedData, m_IconData, m_TargetData, m_PrefabRefData) for random-access reads inside the job and relies on m_IconCommandSystem's IconCommandBuffer to enqueue operations.
  • (explicit) void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
    Explicit interface implementation that forwards to the job's Execute method (required by IJobChunk).

Usage Example

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

    // Initialize/IconCommandSystem and the query as the system does internally.
    m_IconCommandSystem = World.GetOrCreateSystemManaged<IconCommandSystem>();

    m_DeletedQuery = GetEntityQuery(new EntityQueryDesc
    {
        All = new ComponentType[1] { ComponentType.ReadOnly<Deleted>() },
        Any = new ComponentType[2]
        {
            ComponentType.ReadOnly<Icon>(),
            ComponentType.ReadOnly<IconElement>()
        }
    }, new EntityQueryDesc
    {
        All = new ComponentType[2]
        {
            ComponentType.ReadOnly<Updated>(),
            ComponentType.ReadOnly<IconElement>()
        }
    });

    RequireForUpdate(m_DeletedQuery);
}

Notes and tips: - The system is designed to be Burst-compatible and uses ComponentLookup<> to safely read component data by Entity inside jobs. - IconCommandBuffer.Remove and .Update are enqueued from the job; the IconCommandSystem processes those commands later to affect runtime icon state (rendered icons / notifications). - The system handles both per-entity Icon components and owner buffers of IconElement, covering cases where icons are stored directly on entities or in dynamic buffers.