Game.Pathfind.LaneDataUnknownEscalateSystem
Assembly: Assembly-CSharp (game code)
Namespace: Game.Pathfind
Type: public class
Base: GameSystemBase
Summary:
LaneDataUnknownEscalateSystem is a compiler-generated ECS system used by the pathfinding code to escalate "unknown" / updated lane information to related sub-lanes. It finds entities that match the lane query (lanes marked PathfindUpdated) and, using a parallel job, walks their SubLane buffers to add PathfindUpdated to related sub-lane entities when certain conditions are met:
- For car lanes: when a sub-lane's CarLane component has the same carriageway group as the lane being processed.
- For slave/master relations: when a sub-lane is part of the same master/slave group and the master lane matches the slave's group.
- For parking lanes: when a sub-lane's start node equals the middle node of a found lane, it also marks parking sub-lanes as updated.
The system schedules a parallel IJobChunk (LaneDataUnknownEscalateJob) and writes component additions through a ModificationBarrier5 EntityCommandBuffer. It uses ComponentTypeHandle/ComponentLookup/BufferLookup for safe parallel reads.
Fields
-
private ModificationBarrier5 m_ModificationBarrier
Holds the system that provides an EntityCommandBuffer (modification barrier) used to add components (PathfindUpdated) safely from worker jobs. The command buffer is converted to a ParallelWriter and passed into the job. -
private EntityQuery m_LaneQuery
EntityQuery built in OnCreate to select lanes that should be processed. The query requires PathfindUpdated, Lane and Owner (and optionally CarLane), and excludes Updated, Deleted and Temp. The system uses RequireForUpdate(m_LaneQuery) so the system only runs when matching entities exist. -
private TypeHandle __TypeHandle
Container of ComponentTypeHandle/ComponentLookup/BufferLookup instances used to access component data inside the scheduled job. It is initialized in OnCreateForCompiler by calling __AssignHandles on the stored SystemState (CheckedStateRef).
Properties
- None.
This system does not expose public properties.
Constructors
public LaneDataUnknownEscalateSystem()
Default public constructor (annotated with [Preserve]). No custom construction logic beyond what the base GameSystemBase performs; important initialization is done in OnCreate / OnCreateForCompiler.
Methods
-
protected override void OnCreate()
Sets up the ModificationBarrier5 reference and constructs the EntityQuery (m_LaneQuery) used to find lanes to process. Calls RequireForUpdate(m_LaneQuery) so the system only runs when relevant entities exist. -
protected override void OnUpdate()
Creates and schedules a parallel LaneDataUnknownEscalateJob using JobChunkExtensions.ScheduleParallel and the previously prepared TypeHandles / lookups. It passes a ParallelWriter from the modification barrier to the job, adds the job handle to the barrier (m_ModificationBarrier.AddJobHandleForProducer), and sets base.Dependency to the returned job handle. -
protected override void OnCreateForCompiler()
Called by generated/compiled code paths to initialize query assignments and component handles for the system's internal state. It calls __AssignQueries and __TypeHandle.__AssignHandles to prepare lookups used by the job. -
private void __AssignQueries(ref SystemState state)
An internal helper used by OnCreateForCompiler. In this compiled variant it constructs (and disposes) an EntityQueryBuilder placeholder; real query setup occurs in OnCreate. Present for compiler compatibility. -
private struct TypeHandle { ... }
A nested struct holding read-only ComponentTypeHandle, ComponentLookup , and BufferLookup instances for: - Lane, SlaveLane, CarLane, Owner
- ComponentLookup for Lane, MasterLane, ParkingLane, CarLane
-
BufferLookup for SubLane
It exposes __AssignHandles(ref SystemState) that acquires the appropriate handles from the SystemState (GetComponentTypeHandle/GetComponentLookup/GetBufferLookup) with isReadOnly = true. These are later converted to runtime handles via InternalCompilerInterface in OnUpdate. -
private struct LaneDataUnknownEscalateJob : IJobChunk
The worker job executed in parallel over matching archetype chunks. Key behavior: - Reads NativeArray
, SlaveLane, CarLane, Owner (via ComponentTypeHandle) from the chunk. - Uses ComponentLookup<...> to read Lane, MasterLane, ParkingLane, CarLane for arbitrary entities referenced in buffers.
- Uses BufferLookup
to iterate per-lane sub-lanes (DynamicBuffer ). - Adds PathfindUpdated to sub-lanes via the supplied EntityCommandBuffer.ParallelWriter when:
- the sub-lane has a CarLane and its carriagewayGroup matches the current lane's carriagewayGroup, or
- the sub-lane's Lane start node equals the processed lane's middle node and the sub-lane has a ParkingLane.
- In the slave-lane path, it first searches for the matching master sub-lane with the same master group to obtain a reference middle node, then marks related parking sub-lanes.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// mirror of system OnCreate: acquire modification barrier and build query
m_ModificationBarrier = World.GetOrCreateSystemManaged<ModificationBarrier5>();
m_LaneQuery = GetEntityQuery(new EntityQueryDesc
{
All = new ComponentType[]
{
ComponentType.ReadOnly<PathfindUpdated>(),
ComponentType.ReadOnly<Lane>(),
ComponentType.ReadOnly<Owner>()
},
Any = new ComponentType[] { ComponentType.ReadOnly<CarLane>() },
None = new ComponentType[]
{
ComponentType.ReadOnly<Updated>(),
ComponentType.ReadOnly<Deleted>(),
ComponentType.ReadOnly<Temp>()
}
});
RequireForUpdate(m_LaneQuery);
}
[Preserve]
protected override void OnUpdate()
{
// scheduling is handled inside the system; this demonstrates intent:
var job = new LaneDataUnknownEscalateJob
{
m_LaneType = InternalCompilerInterface.GetComponentTypeHandle(ref __TypeHandle.__Game_Net_Lane_RO_ComponentTypeHandle, ref CheckedStateRef),
// ... assign other handles/lookups and the command buffer
m_CommandBuffer = m_ModificationBarrier.CreateCommandBuffer().AsParallelWriter()
};
JobHandle handle = JobChunkExtensions.ScheduleParallel(job, m_LaneQuery, Dependency);
m_ModificationBarrier.AddJobHandleForProducer(handle);
Dependency = handle;
}
Notes: - This system is read-only for lane-related component data and performs structural changes (adds PathfindUpdated) via the ModificationBarrier5 command buffer. - Because it uses parallel ECB writing, chunk index (unfilteredChunkIndex) is used when adding components inside the job.