Skip to content

Game.Simulation.HealthcarePathfindSetup

Assembly: Assembly-CSharp (game)
Namespace: Game.Simulation

Type: struct

Base: System.ValueType

Summary:
HealthcarePathfindSetup is a helper/worker struct used by the PathfindSetupSystem to prepare pathfinding targets related to health services. It creates and schedules several Burst-compiled IJobChunk jobs that locate and enqueue path targets for ambulances, hospitals, hearses (deathcare), and active healthcare requests. The struct builds and caches EntityQuery and ComponentType/Lookup handles, interacts with the city and area search systems, and returns JobHandle values so the caller can chain or synchronize work. Internally it defines the following private job types (Burst-compiled): - SetupAmbulancesJob — finds targets for hospital entities and ambulance vehicles. - SetupHospitalsJob — finds appropriate hospitals for patients (considering health, treatment capabilities and room availability). - SetupHearsesJob — finds targets for deathcare facilities and hearses. - HealthcareRequestsJob — handles active healthcare requests (matching request type and district constraints) and special handling for flying (helicopter) lanes. - DistrictIterator (nested) — helper INativeQuadTreeIterator used by HealthcareRequestsJob to map a world position to a district.

This struct is intended to be used from PathfindSetupSystem (or similar systems) to schedule setup jobs using the provided SetupData. It is not a public API in the sense of being used directly by content (prefab) scripts; rather it is part of the internal ECS job orchestration for the game's pathfinding setup phase.

Fields

  • private EntityQuery m_AmbulanceQuery
    Stores the EntityQuery used to find entities that are hospitals or ambulances when scheduling the ambulance-related setup job.

  • private EntityQuery m_HospitalQuery
    EntityQuery used to iterate hospitals (used by SetupHospitalsJob).

  • private EntityQuery m_HearseQuery
    EntityQuery used to find deathcare facilities and hearses for the hearse-related setup.

  • private EntityQuery m_HealthcareRequestQuery
    EntityQuery for active healthcare requests (not dispatched, no PathInformation) used by the healthcare-request job.

  • private EntityTypeHandle m_EntityType
    Cached EntityTypeHandle used by the jobs to obtain entity arrays from chunks.

  • private ComponentTypeHandle<Owner> m_OwnerType
    Handle for read-only Owner components (cached & updated before scheduling).

  • private ComponentTypeHandle<PathOwner> m_PathOwnerType
    Handle for read-only PathOwner components.

  • private ComponentTypeHandle<ServiceRequest> m_ServiceRequestType
    Handle for ServiceRequest components for healthcare request processing.

  • private ComponentTypeHandle<HealthcareRequest> m_HealthcareRequestType
    Handle for HealthcareRequest components.

  • private ComponentTypeHandle<Hospital> m_HospitalType
    Handle for Hospital components.

  • private ComponentTypeHandle<DeathcareFacility> m_DeathcareFacilityType
    Handle for DeathcareFacility components.

  • private ComponentTypeHandle<Hearse> m_HearseType
    Handle for Hearse components.

  • private ComponentTypeHandle<Ambulance> m_AmbulanceType
    Handle for Ambulance components.

  • private ComponentLookup<HealthcareRequest> m_HealthcareRequestData
    Lookup to access HealthcareRequest components by Entity.

  • private ComponentLookup<CurrentDistrict> m_CurrentDistrictData
    Lookup to access CurrentDistrict components (used to map citizen/building to a district).

  • private ComponentLookup<District> m_DistrictData
    Lookup to read District components.

  • private ComponentLookup<Citizen> m_CitizenData
    Lookup for Citizen component data (e.g., health).

  • private ComponentLookup<HealthProblem> m_HealthProblemData
    Lookup for HealthProblem components (injured/sick flags).

  • private ComponentLookup<Vehicle> m_VehicleData
    Lookup for Vehicle components to detect when a citizen is actually a vehicle entity.

  • private ComponentLookup<Ambulance> m_AmbulanceData
    Lookup for Ambulance components (used to find ambulance targets / patient references).

  • private BufferLookup<ServiceDistrict> m_ServiceDistricts
    BufferLookup for ServiceDistrict buffers — used for service-district checks (which services/districts entities belong to).

  • private ComponentLookup<Game.City.City> m_CityData
    Lookup for city-level options/settings (used when ignoring outside connections if import of outside services is disabled).

  • private Game.Areas.SearchSystem m_AreaSearchSystem
    Cached reference to the game's Area search system (for mapping positions to areas/districts with a QuadTree).

  • private CitySystem m_CitySystem
    Reference to the CitySystem used to access the current city Entity.

Properties

  • None (no public properties)

Constructors

  • public HealthcarePathfindSetup(PathfindSetupSystem system)
    Initializes the HealthcarePathfindSetup instance. Builds and caches the EntityQueries and ComponentType/Lookup/BufferLookup handles by calling PathfindSetupSystem helper methods and System.World methods. Also caches references to the Area search system and CitySystem. This prepares the struct for scheduling the various setup jobs.

Methods

  • public JobHandle SetupAmbulances(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupAmbulancesJob (Burst IJobChunk) over m_AmbulanceQuery. Updates the relevant TypeHandles and Lookups before scheduling. The job:
  • For hospital archetypes: checks available ambulance/helicopter capability, service district membership, and enqueues hospital entities as targets for matching seeker entries in setupData (applying road/flying type filtering and a cost factor).
  • For ambulance vehicle archetypes: enqueues ambulance entities as targets for seekers when the ambulance is returning/available (or not disabled). Returns a JobHandle representing the scheduled job; callers should combine or complete as needed.

  • public JobHandle SetupHospitals(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupHospitalsJob (Burst IJobChunk) over m_HospitalQuery. The job:

  • Iterates configured seekers (setupData) and for each checks the patient's current health and health problems (via Citizen and HealthProblem component data and possible ambulance target).
  • Evaluates each hospital for treatment compatibility (can cure disease/injury) and health-range constraints, adjusts path method availability by service-district membership, computes a cost value based on hospital treatment bonus, distance to current owner, room availability, etc., and asks the seeker to FindTargets for the hospital with the computed cost. Returns a JobHandle.

  • public JobHandle SetupHearses(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupHearsesJob (Burst IJobChunk) over m_HearseQuery. The job:

  • For deathcare facility archetypes: enqueues facilities that have available hearses and room for bodies, respecting service-districts and applying a cost.
  • For hearse vehicle archetypes: enqueues returning/available hearses as targets for seekers. Returns a JobHandle.

  • public JobHandle SetupHealthcareRequest(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the HealthcareRequestsJob (Burst IJobChunk) over m_HealthcareRequestQuery. This job:

  • Iterates active healthcare requests and matches them against seekers in setupData for the same request type.
  • Resolves the "service" entity for the request (handles vehicle-backed citizens vs prefabs).
  • Determines the district for the requesting citizen either via their current building's CurrentDistrict or by using the Area search system (QuadTree) to find which district polygon the transport position lies in.
  • Checks service-district membership and enqueues appropriate path targets for the request. Special-case handling for flying methods (helicopter lanes): the job finds the nearest helicopter lane and enqueues a target lane instead of a building. This method reads the Area search tree (m_AreaSearchSystem.GetSearchTree(...)) and registers the returned JobHandle dependency with the area system (AddSearchTreeReader). Returns the JobHandle of the scheduled job.

Notes: - All scheduling methods update cached TypeHandles/Lookups before job scheduling — callers should pass a valid PathfindSetupSystem reference and proper SetupData (PathfindSetupSystem.SetupData). - Jobs are scheduled with ScheduleParallel using the respective EntityQuery. The returned JobHandles should be combined with other work when appropriate.

Usage Example

// Example usage inside PathfindSetupSystem (or similar system) when preparing pathfind targets.
// Assume `this` is a PathfindSetupSystem and `setupData` is a PathfindSetupSystem.SetupData instance.

private HealthcarePathfindSetup m_HealthcareSetup;

// In system initialization:
m_HealthcareSetup = new HealthcarePathfindSetup(this);

// When scheduling setup jobs (typical flow):
JobHandle deps = default;
deps = m_HealthcareSetup.SetupAmbulances(this, setupData, deps);
deps = m_HealthcareSetup.SetupHospitals(this, setupData, deps);
deps = m_HealthcareSetup.SetupHearses(this, setupData, deps);
deps = m_HealthcareSetup.SetupHealthcareRequest(this, setupData, deps);

// Now deps is a JobHandle representing all scheduled healthcare-related setup jobs.
// You can return it to the caller or combine it with other JobHandles.

If you need doc for any specific nested job type (fields/behaviour of SetupAmbulancesJob, SetupHospitalsJob, SetupHearsesJob, HealthcareRequestsJob or DistrictIterator), tell me which one and I can expand with detailed per-field and per-step descriptions.