Skip to content

Game.Effects.CompleteEnabledSystem

Assembly:
Assembly-CSharp (game/mod runtime assembly; actual assembly name may vary)

Namespace:
Game.Effects

Type:
public class CompleteEnabledSystem (compiler-generated)

Base:
GameSystemBase

Summary:
CompleteEnabledSystem is a managed game system responsible for finalizing updates to the game's "enabled effects" data each frame. It schedules a Burst-compiled IJob (EffectCleanupJob) that iterates the enabled-effect list, removes disabled entries, fixes up owner buffers and indices when entries are removed/swapped, and enqueues VFX index-move updates when necessary. The system obtains and coordinates with EffectControlSystem and VFXSystem to read/write shared effect data and to ensure proper job dependencies.


Fields

  • private EffectControlSystem m_EffectControlSystem
    The EffectControlSystem instance obtained from the World. Used to get and register access to the NativeList that holds per-enabled-effect runtime records.

  • private VFXSystem m_VFXSystem
    The VFXSystem instance obtained from the World. Used to get the NativeQueue to enqueue updates required by the VFX subsystem and to register writer dependencies.

  • private TypeHandle __TypeHandle
    Internal struct used to cache type/lookups (BufferLookup) required by the job. Populated via __AssignHandles in compiler-time setup.

  • (nested) private struct EffectCleanupJob — fields:

  • public BufferLookup<EnabledEffect> m_EffectOwners
    Buffer lookup providing access to DynamicBuffer for owners (read/write access in the job).
  • public NativeList<EnabledEffectData> m_EnabledData
    The list containing enabled-effect records. The job mutates this list (removes entries and updates indices).
  • public NativeQueue<VFXUpdateInfo> m_VFXUpdateQueue
    Queue used to enqueue VFX update messages (e.g., MoveIndex) when enabled-effect indices change.

  • (nested) private struct TypeHandle — fields:

  • public BufferLookup<EnabledEffect> __Game_Effects_EnabledEffect_RW_BufferLookup
    Cached BufferLookup used to bind the EnabledEffect buffer type for the job.

Properties

  • (none)
    This system does not expose public properties.

Constructors

  • public CompleteEnabledSystem()
    Default constructor. Marked [Preserve] in the source for IL stripping safety.

Methods

  • protected override void OnCreate()
  • Gets or creates EffectControlSystem and VFXSystem instances from the World and stores them in fields. Called when the system is created. Marked with [Preserve] in source.

  • protected override void OnUpdate()

  • Schedules EffectCleanupJob (Burst compiled) using:
    • m_EffectOwners: BufferLookup obtained via InternalCompilerInterface.GetBufferLookup using the cached TypeHandle and the system state.
    • m_EnabledData: obtained from m_EffectControlSystem.GetEnabledData(readOnly: false, out dependencies).
    • m_VFXUpdateQueue: obtained from m_VFXSystem.GetSourceUpdateData().
  • Combines dependencies with base.Dependency and schedules the job, then registers the jobHandle as a writer for the EffectControlSystem and VFXSystem via AddEnabledDataWriter and AddSourceUpdateWriter.
  • Assigns the combined job handle back to base.Dependency to maintain dependency chain.

  • (nested) private struct EffectCleanupJob : IJob

  • public void Execute()
    Burst-compiled function that:

    • Iterates through m_EnabledData by index.
    • Skips entries that don't have either EnabledUpdated or OwnerUpdated flags set.
    • If an entry is now disabled (IsEnabled flag not set):
    • If not Deleted, finds the owner DynamicBuffer and removes the corresponding EnabledEffect entry (matching m_EffectIndex).
    • Removes the enabled-data entry from the list via RemoveAtSwapBack(i).
    • If a swap-back moved a different entry into index i, updates that moved entry's owner buffer to reflect the new m_EnabledIndex.
    • If the moved entry is both IsEnabled and IsVFX, enqueues a VFXUpdateInfo with type MoveIndex and the new/old index info so VFX system can relocate sources.
    • Decrements i to re-evaluate the swapped-in entry (since the loop increments i).
    • Otherwise (still enabled) clears the EnabledUpdated and OwnerUpdated flags on the entry.
  • private void __AssignQueries(ref SystemState state)

  • Compiler-generated startup helper that declares any EntityQuery objects used by the system. The implementation in the decompiled source creates and immediately disposes an empty EntityQueryBuilder; used to satisfy codegen patterns.

  • protected override void OnCreateForCompiler()

  • Compiler-time initialization entry: calls __AssignQueries and __TypeHandle.__AssignHandles to ensure cached lookups are populated for job scheduling.

  • (nested) private struct TypeHandle

  • public void __AssignHandles(ref SystemState state)
    • Initializes the BufferLookup from the provided Entity/System state.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // Acquire systems this system cooperates with:
    m_EffectControlSystem = World.GetOrCreateSystemManaged<EffectControlSystem>();
    m_VFXSystem = World.GetOrCreateSystemManaged<VFXSystem>();
}

// OnUpdate is implemented by the system: it schedules a Burst IJob (EffectCleanupJob)
// which will remove disabled enabled-effects, fix owner buffers and indices, and enqueue
// VFX index-move updates when an enabled-effect index changes.
[Preserve]
protected override void OnUpdate()
{
    JobHandle dependencies;
    var job = new EffectCleanupJob
    {
        m_EffectOwners = InternalCompilerInterface.GetBufferLookup(ref __TypeHandle.__Game_Effects_EnabledEffect_RW_BufferLookup, ref base.CheckedStateRef),
        m_EnabledData = m_EffectControlSystem.GetEnabledData(readOnly: false, out dependencies),
        m_VFXUpdateQueue = m_VFXSystem.GetSourceUpdateData()
    };
    JobHandle jobHandle = IJobExtensions.Schedule(job, JobHandle.CombineDependencies(base.Dependency, dependencies));
    m_EffectControlSystem.AddEnabledDataWriter(jobHandle);
    m_VFXSystem.AddSourceUpdateWriter(jobHandle);
    base.Dependency = jobHandle;
}

Additional notes for modders: - This system runs as part of the game's ECS update flow and coordinates with EffectControlSystem (which holds the NativeList) and VFXSystem (which consumes VFX update messages). Ensure other custom systems that access EnabledEffectData register their reader/writer dependencies similarly to avoid race conditions. - The cleanup is implemented inside a Burst-compiled IJob for performance; types used inside the job must be Burst-compatible and safe for job usage (NativeList/NativeQueue/BufferLookup). - The job uses RemoveAtSwapBack on the enabled-data list; callers should expect that enabled-data indices can change when entries are removed, and the system enqueues VFX MoveIndex updates when that affects VFX sources. - Types referenced here (EnabledEffect, EnabledEffectData, EnabledEffectFlags, VFXUpdateInfo, VFXUpdateType) are part of the effects/VFX subsystem — consult their definitions to understand flag values and queue message semantics.