Skip to content

Game.Simulation.RoadPathfindSetup

Assembly: Assembly-CSharp
Namespace: Game.Simulation

Type: struct

Base: System.ValueType

Summary:
RoadPathfindSetup is an ECS helper used by the PathfindSetupSystem to prepare pathfinding targets for road-related systems in Cities: Skylines 2. It collects and schedules several jobs (Burst-compiled) that scan relevant entity queries and enqueue pathfinding targets for: - maintenance providers (maintenance depots and maintenance vehicles), - random traffic spawners, - outside connections (including special handling for flying vehicles), - maintenance requests (building / network maintenance needs).

The struct wires up EntityQuery and Component/Buffer lookups on construction and exposes methods that schedule the chunk jobs which populate target seekers (PathfindSetupSystem.SetupData). It relies on Unity.Jobs, Unity.Entities and various game-specific search systems (area and net search trees). The nested job structs are Burst-compiled and operate on ArchetypeChunks to run in parallel.


Fields

  • private EntityQuery m_MaintenanceProviderQuery
    Query selecting maintenance depots and maintenance vehicles (excludes deleted/destroyed/temp/service-upgrade).

  • private EntityQuery m_RandomTrafficQuery
    Query selecting traffic spawner buildings (prefab ref present, excludes deleted/destroyed/temp).

  • private EntityQuery m_OutsideConnectionQuery
    Query selecting outside connections (excludes electricity/water outside connection variants, deleted/destroyed/temp).

  • private EntityQuery m_MaintenanceRequestQuery
    Query selecting maintenance requests that are not yet dispatched and don't have PathInformation.

  • private EntityTypeHandle m_EntityType
    Entity type handle, updated before scheduling jobs.

  • private ComponentTypeHandle<PathOwner> m_PathOwnerType
    Component handle for PathOwner (read-only where used).

  • private ComponentTypeHandle<Owner> m_OwnerType
    Component handle for Owner (read-only where used).

  • private ComponentTypeHandle<Game.Objects.OutsideConnection> m_OutsideConnectionType
    Component handle for outside connection component (read-only).

  • private ComponentTypeHandle<ServiceRequest> m_ServiceRequestType
    Component handle for ServiceRequest (read-only).

  • private ComponentTypeHandle<MaintenanceRequest> m_MaintenanceRequestType
    Component handle for MaintenanceRequest (read-only).

  • private ComponentTypeHandle<Game.Buildings.MaintenanceDepot> m_MaintenanceDepotType
    Component handle for maintenance depot (read-only).

  • private ComponentTypeHandle<Game.Vehicles.MaintenanceVehicle> m_MaintenanceVehicleType
    Component handle for maintenance vehicle (read-only).

  • private ComponentTypeHandle<PrefabRef> m_PrefabRefType
    Component handle for PrefabRef (read-only).

  • private BufferTypeHandle<PathElement> m_PathElementType
    Buffer handle for PathElement buffers (read-only).

  • private BufferTypeHandle<ServiceDispatch> m_ServiceDispatchType
    Buffer handle for ServiceDispatch buffers (read-only).

  • private ComponentLookup<PathInformation> m_PathInformationData
    Component lookup for PathInformation used to inspect existing path durations.

  • private ComponentLookup<RandomTrafficRequest> m_RandomTrafficRequestData
    Component lookup for random traffic request settings on owners.

  • private ComponentLookup<MaintenanceRequest> m_MaintenanceRequestData
    Component lookup for maintenance request details.

  • private ComponentLookup<Game.Objects.Surface> m_SurfaceData
    Component lookup for surface information (read-only).

  • private ComponentLookup<Game.Buildings.Park> m_ParkData
    Component lookup for park building data (read-only).

  • private ComponentLookup<Game.Net.Edge> m_EdgeData
    Component lookup for net edge data (read-only).

  • private ComponentLookup<NetCondition> m_NetConditionData
    Component lookup for net condition data (read-only).

  • private ComponentLookup<Composition> m_CompositionData
    Component lookup for composition (used when iterating network targets).

  • private ComponentLookup<CurrentDistrict> m_CurrentDistrictData
    Component lookup to get the current district of an entity.

  • private ComponentLookup<BorderDistrict> m_BorderDistrictData
    Component lookup for border district info.

  • private ComponentLookup<District> m_DistrictData
    Component lookup to test district existence when using area search.

  • private ComponentLookup<Vehicle> m_VehicleData
    Component lookup to detect if a target is a vehicle entity.

  • private ComponentLookup<MaintenanceDepotData> m_PrefabMaintenanceDepotData
    Prefab-level data for maintenance depots.

  • private ComponentLookup<MaintenanceVehicleData> m_PrefabMaintenanceVehicleData
    Prefab-level data for maintenance vehicles.

  • private ComponentLookup<TrafficSpawnerData> m_PrefabTrafficSpawnerData
    Prefab-level data for traffic spawners (road/track types).

  • private ComponentLookup<NetCompositionData> m_NetCompositionData
    Component lookup used for network composition checks when searching targets.

  • private BufferLookup<PathElement> m_PathElements
    Buffer lookup to read path element buffers from other entities.

  • private BufferLookup<ServiceDistrict> m_ServiceDistricts
    Buffer lookup of service districts for service-district checks.

  • private Game.Areas.SearchSystem m_AreaSearchSystem
    Reference to the area search system; used to query area/district search trees.

  • private Game.Net.SearchSystem m_NetSearchSystem
    Reference to the net search system; used to query net lane search trees.

Properties

  • None (this struct exposes no public properties)

Constructors

  • public RoadPathfindSetup(PathfindSetupSystem system)
    Initializes queries and component/buffer lookups used by the setup jobs. It constructs EntityQuery descriptions for maintenance providers, random traffic spawners, outside connections and maintenance requests; and retrieves ComponentTypeHandle/BufferTypeHandle/ComponentLookup/BufferLookup instances from the provided PathfindSetupSystem. It also fetches the area and net search systems from the World.

Methods

  • public JobHandle SetupMaintenanceProviders(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupMaintenanceProvidersJob in parallel over the maintenance-provider query. This job:
  • For maintenance depots: if depot has available vehicles and matches a seeker maintenance type & service district, calls targetSeeker.FindTargets with a computed cost.
  • For maintenance vehicles: inspects vehicle state, request buffers, path owner and queued service dispatches to either enqueue PathTarget entries (with accumulated cost) or call FindTargets to locate targets. Uses prefab maintenance vehicle data to filter by maintenance type.

Returns a JobHandle representing the scheduled work.

  • public JobHandle SetupRandomTraffic(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupRandomTrafficJob in parallel over traffic spawner entities. For each traffic spawner and each seeker, this job tests configured road/track types (from RandomTrafficRequest and prefab TrafficSpawnerData) and enqueues targets using a random cost value to give variety in pathfinding.

  • public JobHandle SetupOutsideConnections(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupOutsideConnectionsJob in parallel over outside connection entities. For each outside connection and seeker:

  • Enqueues the outside connection entity as a pathfinding target (with optional randomized cost).
  • If seeker supports flying PathMethod and the transform for the outside connection is available, attempts to find appropriate airway lanes (helicopter or airplane) using the seeker’s airway maps and enqueues PathTarget entries pointing to the found lane/curve position.

  • public JobHandle SetupMaintenanceRequest(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the MaintenanceRequestsJob in parallel over maintenance request entities. This job:

  • Filters maintenance requests by maintenance type matching the seeker.
  • Determines the associated service entity (either vehicle owner or the target entity itself).
  • Performs district/service-district checks (including area-search fallback to find the district for arbitrary transforms).
  • Calls targetSeeker.FindTargets to set up a path target for the maintenance service and, if the target has a transform, performs a net-tree iteration to locate nearby network edges/lane targets using CommonPathfindSetup.TargetIterator.

This method also fetches read-only area and net search trees, combines their dependency JobHandles, and registers the scheduled job as a reader with the area & net search systems (m_AreaSearchSystem.AddSearchTreeReader and m_NetSearchSystem.AddNetSearchTreeReader). Returns the JobHandle for the scheduled job.

  • Nested private job structs (Burst-compiled) used by the above methods:
  • SetupMaintenanceProvidersJob : IJobChunk
  • SetupRandomTrafficJob : IJobChunk
  • SetupOutsideConnectionsJob : IJobChunk
  • MaintenanceRequestsJob : IJobChunk Each implements Execute on chunks and uses the component/buffer lookups passed in to populate seekers' target queues.

Usage Example

// Typical usage from PathfindSetupSystem (pseudo-code)
public void ScheduleRoadSetup(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
{
    var roadSetup = new Game.Simulation.RoadPathfindSetup(system);

    // schedule the different setup phases, chaining dependencies as required
    JobHandle deps = roadSetup.SetupMaintenanceProviders(system, setupData, inputDeps);
    deps = JobHandle.CombineDependencies(deps, roadSetup.SetupRandomTraffic(system, setupData, inputDeps));
    deps = JobHandle.CombineDependencies(deps, roadSetup.SetupOutsideConnections(system, setupData, inputDeps));
    deps = JobHandle.CombineDependencies(deps, roadSetup.SetupMaintenanceRequest(system, setupData, inputDeps));

    // Now deps represents all scheduled setup jobs for road pathfinding targets.
}

Notes: - All chunk jobs are marked with [BurstCompile] for performance. - The struct assumes the caller updates/maintains the PathfindSetupSystem.SetupData and that target seekers (targetSeeker) expose methods like FindTargets and a buffer/queue for PathTarget entries. - The jobs rely on many game-specific types (ServiceDistrict, PathElement, PathTarget, EdgeFlags, etc.) and on the area and net search trees.