Skip to content

Game.Prefabs.EffectInitializeSystem

Assembly: Assembly-CSharp (game code)
Namespace: Game.Prefabs

Type: class

Base: GameSystemBase

Summary:
EffectInitializeSystem is a compiler-generated ECS system that initializes Effect buffers on prefab entities. It finds and stores the bone index for each Effect entry by calling RenderingUtils.FindBoneIndex with the prefab entity, the effect's local position/rotation and the prefab's SubMesh and ProceduralBone buffers. Work is performed in a Burst-compiled IJobChunk (InitializeEffectsJob) and scheduled to run in parallel for all prefabs that contain Created, PrefabData and an Effect buffer. The system uses ECS type handles and buffer lookups to access entity, submesh and procedural bone data efficiently.


Fields

  • private EntityQuery m_PrefabQuery
    Used to select prefab entities that have Created, PrefabData and an Effect buffer. The query is created in OnCreate and passed to the job scheduler in OnUpdate.

  • private TypeHandle __TypeHandle
    Holds ECS type handles (EntityTypeHandle, BufferLookup, BufferLookup, BufferTypeHandle) used by the job. The handles are assigned via __AssignHandles(ref SystemState) during OnCreateForCompiler.

Properties

  • (none)

Constructors

  • public EffectInitializeSystem()
    Default constructor with [Preserve] attribute. No custom initialization is performed here; setup occurs in OnCreate / OnCreateForCompiler.

Methods

  • protected override void OnCreate()
    Creates the entity query: GetEntityQuery(ComponentType.ReadOnly(), ComponentType.ReadOnly(), ComponentType.ReadWrite())
    and calls RequireForUpdate(m_PrefabQuery) so the system runs only when matching entities exist.

  • protected override void OnUpdate()
    Builds and schedules the Burst-compiled InitializeEffectsJob (IJobChunk) using the type handles from __TypeHandle and schedules it across m_PrefabQuery. The resulting JobHandle is assigned to base.Dependency.

  • protected override void OnCreateForCompiler()
    Called for compiler-time setup: assigns queries and calls __TypeHandle.__AssignHandles(ref base.CheckedStateRef) to prepare the type handles.

  • private void __AssignQueries(ref SystemState state)
    Compiler helper for query assignment. In this implementation it creates and disposes an EntityQueryBuilder(Allocator.Temp) placeholder; real query setup happens in OnCreate.

Nested / Job-related methods (internal to the system):

  • InitializeEffectsJob.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
    For each entity in the chunk, gets the Effect dynamic buffer and for each Effect element calls: value.m_BoneIndex = RenderingUtils.FindBoneIndex(prefab, ref value.m_Position, ref value.m_Rotation, value.m_ParentMesh, ref m_SubMeshes, ref m_ProceduralBones); and writes the updated Effect element back into the buffer. The job uses:
  • EntityTypeHandle m_EntityType
  • BufferLookup m_SubMeshes (read-only)
  • BufferLookup m_ProceduralBones (read-only)
  • BufferTypeHandle m_EffectType (read-write)

  • TypeHandle.__AssignHandles(ref SystemState state)
    Initializes the contained ECS handles:

  • state.GetEntityTypeHandle()
  • state.GetBufferLookup(isReadOnly: true)
  • state.GetBufferLookup(isReadOnly: true)
  • state.GetBufferTypeHandle()

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_PrefabQuery = GetEntityQuery(
        ComponentType.ReadOnly<Created>(),
        ComponentType.ReadOnly<PrefabData>(),
        ComponentType.ReadWrite<Effect>()
    );
    RequireForUpdate(m_PrefabQuery);
}

Additional notes: - The InitializeEffectsJob is Burst-compiled and scheduled via JobChunkExtensions.ScheduleParallel, making this system suitable for large numbers of prefabs. - The system depends on RenderingUtils.FindBoneIndex to resolve bone indices; ensure that the relevant rendering buffers (SubMesh, ProceduralBone) are present on the prefab entities. - The class is marked [CompilerGenerated] and several members have [Preserve] attributes to prevent stripping by code stripping tools used in the build.