Skip to content

Game.IconElementSystem

Assembly: Assembly-CSharp
Namespace: Game.Serialization

Type: class

Base: Game.Common.GameSystemBase

Summary:
IconElementSystem is a compiler-generated ECS system that collects Icon entities and appends IconElement entries to the IconElement buffer of the corresponding Owner entity. It schedules a Burst-compiled IJobChunk (WarningElementJob) that reads each chunk's Entity, Owner and (optionally) Animation components. If an Animation is present and its AnimationType indicates a marker-disappear state, that Icon is skipped. The system uses EntityQuery to require Icon entities (and Owner) and uses BufferLookup to write into owner buffers. It contains a generated TypeHandle struct to hold the various Entity/Component type handles required for job scheduling.


Fields

  • private EntityQuery m_Query
    This EntityQuery filters entities that have an Icon component and (optionally) an Owner component. It's created in OnCreate and used to schedule the WarningElementJob. The query is also passed to RequireForUpdate so the system only runs when relevant entities exist.

  • private TypeHandle __TypeHandle
    Holds generated type-handle fields and a helper method to assign them from a SystemState. It contains:

  • EntityTypeHandle
  • ComponentTypeHandle (read-only)
  • ComponentTypeHandle (read-only)
  • BufferLookup (read/write) This struct's __AssignHandles(ref SystemState) is invoked in OnCreateForCompiler to initialize handles.

Properties

  • None (no public properties defined on this system)

Constructors

  • public IconElementSystem()
    Default, [Preserve]-attributed constructor. No custom initialization beyond what the base constructor performs; system initialization occurs in OnCreate / OnCreateForCompiler.

Methods

  • protected override void OnCreate()
    Creates the m_Query for entities with an Icon component (and an Owner in the Any clause) and calls RequireForUpdate(m_Query). This ensures the system only updates when matching entities exist.

  • protected override void OnUpdate()
    Builds a WarningElementJob instance, initializing its EntityTypeHandle, ComponentTypeHandles and BufferLookup via InternalCompilerInterface.Get* methods (using the stored __TypeHandle). Schedules the job with JobChunkExtensions.Schedule(jobData, m_Query, base.Dependency) and assigns the returned JobHandle to base.Dependency.

  • private void __AssignQueries(ref SystemState state)
    A small compiler-generated helper that constructs (and immediately disposes) an EntityQueryBuilder with Allocator.Temp. Present for compiler bookkeeping / generated patterns.

  • protected override void OnCreateForCompiler()
    Called by the compiler/init flow: calls __AssignQueries and __TypeHandle.__AssignHandles(ref state) to initialize query and type handles ahead of use.

  • Nested: private struct WarningElementJob : IJobChunk

  • Attributes: [BurstCompile] on the struct in the source.
  • Fields: EntityTypeHandle m_EntityType (read-only), ComponentTypeHandle m_OwnerType (read-only), ComponentTypeHandle m_AnimationType (read-only), BufferLookup m_IconElements (RW).
  • Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask): iterates the chunk's arrays:
    • Reads Entity[] and Owner[] (and Animation[] if present).
    • If an Animation exists for the entity and its AnimationType indicates marker-disappear, the icon is skipped.
    • Otherwise, attempts to get the IconElement buffer for the owner entity via m_IconElements.TryGetBuffer(owner.m_Owner, out bufferData). If found, adds a new IconElement for the icon Entity.
  • Implements IJobChunk.Execute by forwarding to the strongly-typed Execute method.

  • Nested: private struct TypeHandle

  • Contains the typed handles described above and provides __AssignHandles(ref SystemState state) with AggressiveInlining to populate them from the SystemState.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_Query = GetEntityQuery(new EntityQueryDesc
    {
        All = new ComponentType[1] { ComponentType.ReadOnly<Icon>() },
        Any = new ComponentType[1] { ComponentType.ReadOnly<Owner>() }
    });
    RequireForUpdate(m_Query);
}

Notes for modders: - This system is compiler-generated and uses the ECS low-level type handles + InternalCompilerInterface; altering it manually is possible but requires understanding of the Entities package job scheduling patterns. - The job is Burst-compiled and uses BufferLookup to mutate owner buffers; ensure buffer layouts and IconElement struct definitions match expected formats when adding/modifying behavior. - Animation filtering logic: the job checks Animation.m_Type and skips icons when the animation corresponds to marker-disappear; adjust that logic if you need different filtering.