Game.Serialization.ResetUnlockRequirementSystem
Assembly: Game
Namespace: Game.Serialization
Type: public class
Base: GameSystemBase
Summary:
ResetUnlockRequirementSystem is a small ECS system (compiler-generated class) that resets unlock progress for all entities that have an UnlockRequirementData component. Each frame (when any matching entities exist) it schedules a Burst-compiled IJobChunk (ResetUnlockRequirementJob) to iterate chunks containing UnlockRequirementData and set the m_Progress field to 0. The system uses a generated TypeHandle to cache the ComponentTypeHandle
Fields
-
private EntityQuery m_RequirementQuery
This query selects entities that have an UnlockRequirementData component (read-only in the query). It is created in OnCreate and passed to the job scheduler in OnUpdate. -
private TypeHandle __TypeHandle
A private nested helper struct instance used to hold and assign a ComponentTypeHandle. Populated via __AssignHandles when the system is created for the compiler. -
private struct ResetUnlockRequirementJob
(nested)
Burst-compiled IJobChunk implementation used to reset UnlockRequirementData.m_Progress to 0 for all component instances in each processed chunk. Contains a ComponentTypeHandlefield named m_UnlockRequirementDataType and an Execute method that iterates the chunk's NativeArray . -
private struct TypeHandle
(nested)
Holds ComponentTypeHandle(__Game_Prefabs_UnlockRequirementData_RW_ComponentTypeHandle) and provides an __AssignHandles(ref SystemState state) method which calls state.GetComponentTypeHandle () to initialize the handle.
Properties
- This type exposes no public properties. (All relevant handles and query fields are private.)
Constructors
public ResetUnlockRequirementSystem()
Default constructor marked with [Preserve]. It does no custom initialization beyond what the generated base/system wiring performs.
Methods
-
protected override void OnCreate()
Creates the entity query for UnlockRequirementData and calls RequireForUpdate(m_RequirementQuery) so the system only updates when matching entities exist. Marked with [Preserve]. -
protected override void OnUpdate()
Builds a ResetUnlockRequirementJob and sets its m_UnlockRequirementDataType by calling InternalCompilerInterface.GetComponentTypeHandle with the cached TypeHandle and the system state reference. Schedules the job with JobChunkExtensions.ScheduleParallel(jobData, m_RequirementQuery, base.Dependency) and assigns the returned JobHandle to base.Dependency so the system's dependency chain remains correct. -
protected override void OnCreateForCompiler()
Called as part of the compiler-generated lifecycle to wire up queries and type handles. Calls __AssignQueries(ref base.CheckedStateRef) and __TypeHandle.__AssignHandles(ref base.CheckedStateRef). -
private void __AssignQueries(ref SystemState state)
Generated helper invoked during OnCreateForCompiler. In this implementation it constructs and disposes a new EntityQueryBuilder(Allocator.Temp) (placeholder — wiring is handled by the generated code). -
private void __AssignHandles(ref SystemState state)
(in TypeHandle)
Initializes the stored ComponentTypeHandlefrom the provided SystemState. -
ResetUnlockRequirementJob.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
For each chunk it obtains the NativeArrayvia chunk.GetNativeArray(ref m_UnlockRequirementDataType) and iterates through it, setting each element's m_Progress to 0 and writing it back. The job is [BurstCompile] and implements IJobChunk (also provides the explicit interface implementation calling the same Execute).
Usage Example
// No extra setup is required for the system: it registers itself and will run
// whenever entities with UnlockRequirementData exist. After a world update,
// each entity's UnlockRequirementData.m_Progress will be 0.
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// Example: read the component after the system has run
var req = entityManager.GetComponentData<UnlockRequirementData>(someEntity);
// req.m_Progress == 0 (reset by ResetUnlockRequirementSystem)
Notes: - The reset is performed on worker threads using a Burst-compiled chunk job and scheduled in parallel. - The system uses generated/inner plumbing (TypeHandle, __AssignQueries, OnCreateForCompiler) that is typical for compiler-emitted ECS systems to cache handles and minimize per-frame allocations.