Game.Objects.ResetOverriddenSystem
Assembly: Assembly-CSharp (game runtime assembly)
Namespace: Game.Objects
Type: class ResetOverriddenSystem
Base: GameSystemBase
Summary:
ResetOverriddenSystem is a compiler-generated ECS system that finds entities with the Overridden and Updated tags and a Tree component, and resets certain runtime state on those Tree components. It clears several TreeState flags (Teen, Adult, Elderly, Dead, Stump) and sets the growth value to 0. The work is performed in a Burst-compiled IJobChunk (ResetOverriddenJob) scheduled in parallel for matching chunks. The system also uses EntityQuery filtering to exclude Deleted and Temp-tagged entities and calls RequireForUpdate so it only runs when matching entities exist.
Fields
-
private EntityQuery m_OverriddenQuery
Stores the query used to find entities that have the Updated and Overridden tags and a Tree component, excluding Deleted and Temp-tagged entities. This query is created in OnCreate and passed to Job scheduling in OnUpdate. -
private TypeHandle __TypeHandle
Helper struct instance that contains ComponentTypeHandleused when scheduling the IJobChunk. It is initialized for the SystemState in OnCreateForCompiler by calling __AssignHandles. -
private struct TypeHandle.__Game_Objects_Tree_RW_ComponentTypeHandle
(inside TypeHandle)
The actual ComponentTypeHandleused for reading/writing Tree components in the job. Assigned via state.GetComponentTypeHandle (). -
private struct ResetOverriddenJob
(nested)
The Burst-compiled IJobChunk that performs the per-chunk processing. Contains a ComponentTypeHandle(m_TreeType) and an Execute method that iterates the chunk's Tree array and resets flags and growth.
Properties
- This type exposes no public properties.
Constructors
public ResetOverriddenSystem()
Default parameterless constructor. Marked with [Preserve] in source to avoid stripping by codegen/IL2CPP. The constructor does not perform initialization beyond base class construction; real initialization happens in OnCreate and OnCreateForCompiler.
Methods
-
protected override void OnCreate() : System.Void
Creates and configures the EntityQuery (m_OverriddenQuery) to select entities with Updated, Overridden and Tree (read/write), and excludes Deleted and Temp. Calls RequireForUpdate(m_OverriddenQuery) so this system only updates when there are matching entities. -
protected override void OnUpdate() : System.Void
Schedules ResetOverriddenJob in parallel over m_OverriddenQuery. The job's m_TreeType ComponentTypeHandle is obtained by calling InternalCompilerInterface.GetComponentTypeHandle with the cached TypeHandle and the system's CheckedStateRef. The returned JobHandle is assigned to base.Dependency so the job is tracked by the system's dependency chain. -
private void __AssignQueries(ref SystemState state)
Compiler-generated helper used during OnCreateForCompiler. In this source it creates and immediately disposes an EntityQueryBuilder(Allocator.Temp) — effectively a placeholder for generated query assignments. Marked MethodImplOptions.AggressiveInlining. -
protected override void OnCreateForCompiler() : System.Void
Compiler initialization entry called to assign generated query references and to initialize TypeHandle component type handles via __TypeHandle.__AssignHandles(ref base.CheckedStateRef). -
private struct ResetOverriddenJob.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) : System.Void
The job Execute implementation obtains a NativeArrayfrom the chunk using m_TreeType, loops over each Tree, clears the flags TreeState.Teen, TreeState.Adult, TreeState.Elderly, TreeState.Dead, TreeState.Stump from m_State, sets m_Growth to 0, and writes the element back to the array. The job is Burst-compiled and scheduled with ScheduleParallel.
Notes:
- The job uses ComponentTypeHandle
Usage Example
// The ResetOverriddenSystem runs automatically as part of the DOTS system group.
// Example: mark a tree entity as Overridden and Updated to have it reset on next frame.
// Example Tree component (simplified)
public struct Tree : IComponentData
{
public TreeState m_State;
public int m_Growth;
}
// Somewhere in game code when you want to reset a specific tree entity:
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity treeEntity = /* obtain entity */;
entityManager.AddComponentData(treeEntity, new Overridden()); // tag component
entityManager.AddComponentData(treeEntity, new Updated()); // tag component
// On the next frame (when systems run), ResetOverriddenSystem will find this entity
// and ResetOverriddenJob will clear the state flags and set m_Growth = 0 for that tree.
Additional implementation notes: - Because the job uses Burst and schedules in parallel, ensure Tree is a blittable struct and any memory layout assumptions are valid for Burst compilation. - If you need to customize which flags are cleared or add additional reset behavior, modify ResetOverriddenJob.Execute accordingly (taking care to preserve Burst compatibility).