Game.Simulation.PolicePathfindSetup
Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Simulation
Type: struct
Base: System.ValueType
Summary:
PolicePathfindSetup is a DOTS-based helper used by the game's pathfinding setup system to enqueue and prepare police-related pathfinding targets. It schedules several IJobChunk jobs that collect targets and requests for police patrol cars, police stations, prisoner transport, crime producers and police emergency/patrol requests. The struct holds EntityQuery definitions, Component/Buffer type handles and ComponentLookup/BufferLookup references required by the jobs, and exposes high-level Setup* methods that schedule the corresponding jobs and return JobHandles. This is intended for internal use by the PathfindSetupSystem to build pathfinding targets before pathfinding work runs.
Fields
-
private EntityQuery m_PolicePatrolQuery
Contains the entity query selecting police stations and police cars (used to set up patrol targets). -
private EntityQuery m_CrimeProducerQuery
Query for entities that produce crime (used to enqueue crime-influenced path targets). -
private EntityQuery m_PrisonerTransportQuery
Query for prisons and public transport vehicles involved in prisoner transport. -
private EntityQuery m_PrisonerTransportRequestQuery
Query selecting prisoner transport requests that are not yet dispatched and have no PathInformation. -
private EntityQuery m_PoliceRequestQuery
Query selecting police patrol/emergency requests that are not dispatched and have no PathInformation. -
private EntityTypeHandle m_EntityType
Cached entity type handle used by the IJobChunk jobs. -
private ComponentTypeHandle<PathOwner> m_PathOwnerType
Cached component type handle for PathOwner (read-only). -
private ComponentTypeHandle<Owner> m_OwnerType
Cached component type handle for Owner (read-only). -
private ComponentTypeHandle<ServiceRequest> m_ServiceRequestType
Cached component type handle for ServiceRequest (read-only). -
private ComponentTypeHandle<PrisonerTransportRequest> m_PrisonerTransportRequestType
Cached component type handle for PrisonerTransportRequest (read-only). -
private ComponentTypeHandle<PolicePatrolRequest> m_PolicePatrolRequestType
Cached component type handle for PolicePatrolRequest (read-only). -
private ComponentTypeHandle<PoliceEmergencyRequest> m_PoliceEmergencyRequestType
Cached component type handle for PoliceEmergencyRequest (read-only). -
private ComponentTypeHandle<Game.Buildings.PoliceStation> m_PoliceStationType
Cached component type handle for PoliceStation (read-only). -
private ComponentTypeHandle<CrimeProducer> m_CrimeProducerType
Cached component type handle for CrimeProducer (read-only). -
private ComponentTypeHandle<Game.Buildings.Prison> m_PrisonType
Cached component type handle for Prison (read-only). -
private ComponentTypeHandle<Game.Vehicles.PoliceCar> m_PoliceCarType
Cached component type handle for PoliceCar (read-only). -
private ComponentTypeHandle<Helicopter> m_HelicopterType
Cached component type handle for Helicopter presence (read-only). -
private ComponentTypeHandle<Game.Vehicles.PublicTransport> m_PublicTransportType
Cached component type handle for PublicTransport (read-only). -
private BufferTypeHandle<PathElement> m_PathElementType
Cached buffer handle for PathElement buffers (read-only). -
private BufferTypeHandle<ServiceDispatch> m_ServiceDispatchType
Cached buffer handle for ServiceDispatch buffers (read-only). -
private BufferTypeHandle<Passenger> m_PassengerType
Cached buffer handle for Passenger buffers (read-only). -
private BufferTypeHandle<Renter> m_RenterType
Cached buffer handle for Renter buffers (read-only, used by crime producer setup). -
private BufferTypeHandle<Employee> m_EmployeeType
Cached buffer handle for Employee buffers (read-only, used by crime producer setup). -
private ComponentLookup<PathInformation> m_PathInformationData
Lookup for PathInformation components (read-only). -
private ComponentLookup<PolicePatrolRequest> m_PolicePatrolRequestData
Lookup for PolicePatrolRequest (read-only). -
private ComponentLookup<PoliceEmergencyRequest> m_PoliceEmergencyRequestData
Lookup for PoliceEmergencyRequest (read-only). -
private ComponentLookup<PrisonerTransportRequest> m_PrisonerTransportRequestData
Lookup for PrisonerTransportRequest (read-only). -
private ComponentLookup<Game.Objects.OutsideConnection> m_OutsideConnections
Lookup to test for outside connections (affects whether outside services are considered). -
private ComponentLookup<Composition> m_CompositionData
Lookup for composition data (used when finding nearby targets or net composition checks). -
private ComponentLookup<CurrentDistrict> m_CurrentDistrictData
Lookup for current district info for entities. -
private ComponentLookup<District> m_DistrictData
Lookup used when resolving district by area triangle. -
private ComponentLookup<Game.Buildings.PoliceStation> m_PoliceStationData
Lookup for police station components (read-only). -
private ComponentLookup<Creature> m_CreatureData
Lookup for creature components (used to avoid certain accident handling logic). -
private ComponentLookup<Vehicle> m_VehicleData
Lookup for vehicle components (used in accident handling). -
private ComponentLookup<Game.Vehicles.PoliceCar> m_PoliceCarData
Lookup for PoliceCar components (read-only, used when handling police requests). -
private ComponentLookup<Game.Vehicles.PublicTransport> m_PublicTransportData
Lookup for PublicTransport components (used by prisoner transport request handling). -
private ComponentLookup<AccidentSite> m_AccidentSiteData
Lookup for AccidentSite components (used for emergency target expansion). -
private ComponentLookup<NetCompositionData> m_NetCompositionData
Lookup for net composition used by certain target iterators. -
private ComponentLookup<Game.City.City> m_CityData
Lookup for city-level options/data (e.g., whether outside services are imported). -
private BufferLookup<PathElement> m_PathElements
BufferLookup for PathElement buffers of arbitrary entities. -
private BufferLookup<ServiceDistrict> m_ServiceDistricts
BufferLookup for service district bindings (used to check whether a service covers a district). -
private BufferLookup<TargetElement> m_TargetElements
BufferLookup referencing target elements for events/accident sites. -
private Game.Areas.SearchSystem m_AreaSearchSystem
Reference to area search system used to resolve which district contains a position. -
private Game.Net.SearchSystem m_NetSearchSystem
Reference to net search system used for net target iteration. -
private CitySystem m_CitySystem
Reference to the city system (used to get the City entity).
Properties
- No public properties.
This struct exposes only methods; internal state is held in private fields and used to schedule jobs.
Constructors
public PolicePathfindSetup(PathfindSetupSystem system)
Initializes queries, component/buffer type handles, component lookups, and cached systems (AreaSearchSystem, NetSearchSystem, CitySystem). This constructor must be called with the PathfindSetupSystem instance that owns the World and Scheduling context before calling any Setup* methods.
Methods
-
public JobHandle SetupPolicePatrols(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
Schedules the SetupPolicePatrolsJob (IJobChunk) which scans police stations and police cars to enqueue patrol/response targets based on purpose masks, available vehicles/helicopters, service districts and existing service dispatches. Returns a JobHandle for the scheduled job. -
public JobHandle SetupCrimeProducer(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
Schedules the SetupCrimeProducersJob which enqueues targets based on CrimeProducer components (buildings producing crime). It uses randomization per chunk to vary costs slightly. -
public JobHandle SetupPrisonerTransport(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
Schedules the SetupPrisonerTransportJob to find targets from prisons and public transport vehicles (prisoner vans and transport vehicles) for prisoner movement. -
public JobHandle SetupPrisonerTransportRequest(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
Schedules the PrisonerTransportRequestsJob which handles prisoner transport requests, matching requests against available prisoner transport services and enqueuing targets accordingly. -
public JobHandle SetupPoliceRequest(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
Schedules the PoliceRequestsJob which processes PolicePatrolRequest and PoliceEmergencyRequest entities. This job uses area and net search trees to determine districts and nearby net targets, handles special logic for accident sites (expanding target entities), restricts methods/road types for emergency responses, and enqueues targets for police vehicles or stations. It also adds the scheduled job as a reader to area and net search systems.
Notes on nested job structs: - SetupPolicePatrolsJob: handles both station->target and vehicle->target logic depending on the chunk contents. Applies filters such as station purpose masks, vehicle state (e.g., Returning, Disabled), service district checks, and makes use of PathOwner/path buffers to estimate costs or target endpoints. - SetupCrimeProducersJob: simple job to add crime-based targets using building crime and random variation. - SetupPrisonerTransportJob & PrisonerTransportRequestsJob: handle prisoner transport vehicles and requests; they take into account request reversals, path buffers, and public transport identification. - PoliceRequestsJob: complex job implementing district lookup (via a DistrictIterator over an area quadtree), accident-site expansion (CheckTarget), and special handling for helicopter landing lanes if flying methods are enabled.
Usage Example
// Typical usage inside the PathfindSetupSystem or similar initialization code:
// assuming `system` is your PathfindSetupSystem and `setupData` is the SetupData provided by it,
// and `inputDeps` is the current JobHandle dependency chain:
var policeSetup = new Game.Simulation.PolicePathfindSetup(system);
// Schedule jobs to populate police-related pathfinding targets:
JobHandle h1 = policeSetup.SetupPolicePatrols(system, setupData, inputDeps);
JobHandle h2 = policeSetup.SetupCrimeProducer(system, setupData, h1);
JobHandle h3 = policeSetup.SetupPrisonerTransport(system, setupData, h2);
JobHandle h4 = policeSetup.SetupPrisonerTransportRequest(system, setupData, h3);
JobHandle h5 = policeSetup.SetupPoliceRequest(system, setupData, h4);
// `h5` now represents the dependency that includes all police pathfind setup work.
If you need reference for a specific job's inputs/behaviour (for modding or hooking), tell me which area (patrols, crime producers, prisoner transport, or police requests) and I can expand that job's responsibilities, the exact component dependencies, and how targets are enqueued.