Skip to content

Game.Rendering.UtilityLodUpdateSystem

Assembly:
Namespace: Game.Rendering

Type: class UtilityLodUpdateSystem
Base: GameSystemBase

Summary:
UtilityLodUpdateSystem is a systems-layer class used by the rendering pipeline to update level-of-detail (LOD) related data for utility lanes (and related culling information). It coordinates with several other systems (ToolSystem, UndergroundViewSystem, Net Search, Rendering, PreCulling and Terrain) to: - update the lane search tree used for utility lane spatial queries, - initialize and update culling information for rendering, - schedule and combine Jobs for those updates, - add or mark entity components (e.g., BatchesUpdated) so downstream systems know which entities need processing.

The system relies heavily on ECS ComponentTypeHandles, ComponentLookup and SharedComponentTypeHandle packed into an internal TypeHandle struct to access components safely inside Jobs. It schedules two main jobs each frame: an UpdateLaneSearchTree job (writing to the search tree) and an InitializeCullingJob (initializing/updating culling data). The system also registers the job handles with the NetSearchSystem, PreCullingSystem and TerrainSystem so they can coordinate CPU/GPU and job dependencies.


Fields

  • private ToolSystem m_ToolSystem
    Reference to the ToolSystem; used to query editor/editor-mode state (for example, to detect editor action mode).

  • private UndergroundViewSystem m_UndergroundViewSystem
    Reference to the UndergroundViewSystem; used to obtain utility type dilation / settings relevant for underground/utility rendering.

  • private Game.Net.SearchSystem m_NetSearchSystem
    Reference to the Net search system that provides lane search tree access and writers. The system obtains a search tree writer and registers produced JobHandles with it.

  • private RenderingSystem m_RenderingSystem
    Reference to the RenderingSystem; used to check properties such as whether unspawned objects are visible.

  • private PreCullingSystem m_PreCullingSystem
    Reference to the PreCullingSystem; used to obtain and write culling data and to register job writers for culling data.

  • private TerrainSystem m_TerrainSystem
    Reference to the TerrainSystem; used to obtain terrain height data and to register CPU height readers for dependency chaining.

  • private EntityQuery m_TreeUpdateQuery
    EntityQuery selecting utility lanes that need search-tree updates. Built in OnCreate with filters: ReadOnly, ReadOnly, Exclude, Exclude, Exclude.

  • private EntityQuery m_CullingUpdateQuery
    EntityQuery selecting utility lanes requiring culling updates. Built in OnCreate with filters: ReadOnly, ReadOnly, Exclude, Exclude.

  • private EntityQuery m_BatchUpdateQuery
    EntityQuery selecting utility lanes requiring mesh batch updates. Built in OnCreate with filters: ReadOnly, ReadOnly, Exclude, Exclude, Exclude.

  • private bool m_Loaded
    A boolean flag present on the system. In the shown code it's defined but not used beyond being available for potential initialization logic.

  • private TypeHandle __TypeHandle
    Internal CompilerGenerated struct instance containing ComponentTypeHandle, BufferTypeHandle, SharedComponentTypeHandle and ComponentLookup fields required by Jobs. The nested TypeHandle packs read-only and read-write handles for many components used in the jobs (e.g., Entity, Curve, Created, Deleted, Overridden, Owner, UtilityLane, PrefabRef, Net/Geometry data, UpdateFrame shared component, Updated, BatchesUpdated, Transform, Stack, Node/Edge/Geometry components, CullingInfo (RW), and multiple Prefab lookups). Its __AssignHandles method binds these handles to a SystemState at OnCreateForCompiler time.


Properties

  • (none)
    This system does not define public properties. All state is stored in private fields and internal TypeHandle.

Constructors

  • public UtilityLodUpdateSystem()
    Default parameterless constructor (CompilerGenerated attribute present). The ECS framework / World creates instances; no custom construction logic beyond what the base class provides.

Methods

  • [Preserve] protected override void OnCreate() : System.Void
    Initializes the system: retrieves references to dependent managed systems via World.GetOrCreateSystemManaged<...>(), sets up the three EntityQuery instances (m_TreeUpdateQuery, m_CullingUpdateQuery, m_BatchUpdateQuery). Marked with Preserve to avoid stripping. This is the normal ECS OnCreate lifecycle entry.

  • [Preserve] protected override void OnUpdate() : System.Void
    Main per-frame update method. High-level behavior:

  • Retrieve utility type dilation from UndergroundViewSystem.
  • Add BatchesUpdated component to entities matching m_BatchUpdateQuery (so downstream processors can handle mesh batch updates).
  • Prepare and schedule a Game.Net.SearchSystem.UpdateLaneSearchTreeJob to update lane search trees. That job uses many component type handles and writes to the lane search tree obtained from m_NetSearchSystem.
  • Prepare and schedule a PreCullingSystem.InitializeCullingJob to initialize culling info for utility lanes. That job uses many component handles and reads/writes to culling data obtained from PreCullingSystem and terrain height data from TerrainSystem.
  • Schedules the two jobs (one via JobChunkExtensions.Schedule, the other via ScheduleParallel), registers the job handles with NetSearchSystem / PreCullingSystem / TerrainSystem, and combines them into base.Dependency for correct dependency chaining.
  • Calls PreCullingSystem.ResetCulling() at the end of OnUpdate to reset culling state for the frame.

  • [MethodImpl(MethodImplOptions.AggressiveInlining)] private void __AssignQueries(ref SystemState state) : System.Void
    Compiler-generated helper used during OnCreateForCompiler. In this decompiled listing it simply creates and disposes an EntityQueryBuilder(Allocator.Temp) — used by the compiler-generated boilerplate to ensure queries are declared/registered.

  • protected override void OnCreateForCompiler() : System.Void
    Compiler-time helper that calls __AssignQueries and the TypeHandle.__AssignHandles to bind type handles to the system's checked SystemState. This is part of the generated ECS boilerplate in converted/compiled systems.

  • private struct TypeHandle
    A nested CompilerGenerated struct packing all ComponentTypeHandles, BufferTypeHandles, SharedComponentTypeHandle and ComponentLookup instances used by the jobs. It exposes a Method:

  • [MethodImpl(MethodImplOptions.AggressiveInlining)] public void __AssignHandles(ref SystemState state)
    Binds each handle field to the given SystemState using state.GetComponentTypeHandle(isReadOnly), state.GetBufferTypeHandle, state.GetSharedComponentTypeHandle, and state.GetComponentLookup(isReadOnly). This is required to get valid handles for use inside Jobs and job structs.

Notes about Jobs and dependencies: - UpdateLaneSearchTreeJob uses the NetSearchSystem.GetLaneSearchTree(readOnly: false, out dependencies) to obtain a writer and returns an initial requirement JobHandle (dependencies) that is combined when scheduling. - PreCullingSystem.InitializeCullingJob obtains culling data via PreCullingSystem.GetCullingData(readOnly: false, out dependencies2) and uses TerrainSystem.GetHeightData() for terrain heights. It is scheduled parallel and its writer JobHandle is registered with the PreCullingSystem and TerrainSystem for correct dependency propagation. - The system explicitly adds a BatchesUpdated component to the m_BatchUpdateQuery (base.EntityManager.AddComponent(m_BatchUpdateQuery)) every update.

Usage Example

// This system is created and executed by the ECS World automatically.
// Example: typical override to initialize local data in a derived/custom system.
// (UtilityLodUpdateSystem itself uses OnCreate to retrieve other systems and setup queries.)

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_ToolSystem = World.GetOrCreateSystemManaged<ToolSystem>();
    m_UndergroundViewSystem = World.GetOrCreateSystemManaged<UndergroundViewSystem>();
    // ... set up EntityQueries similar to the system's implementation
}

If you are writing a mod that needs to interact with this system: - Do not call OnUpdate manually — let the World schedule the system. - If you need to know when culling/search data has been updated, consider registering or reading the same systems (PreCullingSystem, Game.Net.SearchSystem, TerrainSystem) or observing the BatchesUpdated/Updated components on entities. - To change behavior, prefer creating an additional system that runs in the appropriate system group (before/after this one) and uses the same component queries or registers job dependencies via the provided system APIs (e.g., AddLaneSearchTreeWriter / AddCullingDataWriter) to coordinate safely with the scheduled jobs.