Skip to content

Game.Simulation.CitizenPathfindSetup

Assembly: Assembly-CSharp.dll
Namespace: Game.Simulation

Type: struct

Base: System.ValueType

Summary:
CitizenPathfindSetup is an ECS helper used by the PathfindSetupSystem to prepare citizen pathfinding targets. It contains EntityQueries, ComponentTypeHandles, ComponentLookup/BufferLookup references and a set of job definitions (Burst-compiled IJobChunk implementations) that scan building/service/provider entities and fill PathfindSetupSystem.SetupData with candidate targets for different citizen types and needs (leisure, tourist lodging, school placement, job seeking, homeless shelters, home finding, attractions, etc.). Each public Setup* method updates handle/lookups, schedules the corresponding job over the appropriate query and returns a JobHandle that can be combined with other work. This type is optimized for the Unity DOTS/ECS pipeline and uses Burst and parallel chunk scheduling.


Fields

  • private EntityQuery m_LeisureProviderQuery
    Used to query leisure provider buildings (leisure services) to schedule SetupLeisureTargetJob.

  • private EntityQuery m_TouristTargetQuery
    Query for buildings that can be tourist targets (lodging or attractiveness providers).

  • private EntityQuery m_SchoolQuery
    Query used when setting up school seeker targets (schools).

  • private EntityQuery m_FreeWorkplaceQuery
    Query for free workplaces used by job seeker setup.

  • private EntityQuery m_AttractionQuery
    Query for attraction providers used by the attraction setup job.

  • private EntityQuery m_HomelessShelterQuery
    Query for homeless shelters (parks or abandoned/converted buildings) for homeless setup.

  • private EntityQuery m_FindHomeQuery
    Query used to find residential properties on the market (used by SetupFindHome).

  • private GroundPollutionSystem m_GroundPollutionSystem
    Reference to the ground pollution system (used to read pollution maps for property scoring).

  • private AirPollutionSystem m_AirPollutionSystem
    Reference to the air pollution system (used to read air pollution maps).

  • private NoisePollutionSystem m_NoisePollutionSystem
    Reference to the noise pollution system (used to read noise maps).

  • private TelecomCoverageSystem m_TelecomCoverageSystem
    Reference to telecom coverage system (used to read telecom coverage data).

  • private CitySystem m_CitySystem
    Reference to the CitySystem (used to obtain city entity and modifiers).

  • private ResourceSystem m_ResourceSystem
    Reference to the ResourceSystem, used to obtain resource prefabs and register readers.

  • private LeisureSystem m_LeisureSystem
    Reference to the leisure system (used to read leisure update interval).

  • private TaxSystem m_TaxSystem
    Reference to tax system (used to obtain tax rates for household income calculations).

  • private EntityQuery m_EconomyParameterQuery

  • private EntityQuery m_HealthcareParameterQuery
  • private EntityQuery m_ParkParameterQuery
  • private EntityQuery m_EducationParameterQuery
  • private EntityQuery m_TelecomParameterQuery
  • private EntityQuery m_GarbageParameterQuery
  • private EntityQuery m_PoliceParameterQuery
  • private EntityQuery m_CitizenHappinessParameterQuery
  • private EntityQuery m_ServiceFeeParameterQuery
    Queries to fetch various game parameter singletons used by SetupFindHome and other jobs.

  • private EntityTypeHandle m_EntityType
    Component/Entity type handle used to read Entity arrays inside jobs; updated before scheduling.

  • private ComponentTypeHandle<ServiceAvailable> m_ServiceAvailableType
    Component type handle used by leisure job to access service availability per building.

  • private ComponentTypeHandle<FreeWorkplaces> m_FreeWorkplaceType
    Handle to read FreeWorkplaces buffer/component for job seeker logic.

  • private ComponentTypeHandle<WorkProvider> m_WorkProviderType
    Handle to read work provider info (max workers etc.).

  • private ComponentTypeHandle<CityServiceUpkeep> m_CityServiceType
    Used to check if a building is a city service and adjust scoring.

  • private ComponentTypeHandle<Building> m_BuildingType
    Handle to read Building components for many jobs.

  • private ComponentTypeHandle<PrefabRef> m_PrefabRefType
    Handle to read associated prefab entity for a building.

  • private BufferTypeHandle<Renter> m_RenterType
    Buffer handle for renter lists used when evaluating housing capacity and homeless shelters.

  • private BufferTypeHandle<Game.Buildings.Student> m_StudentType
    Buffer handle for students attached to schools used by school seeker setup.

  • private BufferTypeHandle<InstalledUpgrade> m_UpgradeType
    Buffer handle for installed upgrades (service upgrades) used to combine stats.

  • private ComponentLookup<Game.Objects.OutsideConnection> m_OutsideConnections
    Lookup used to identify outside connections (imports/exports) for job seeker scoring.

  • private ComponentLookup<ServiceCompanyData> m_ServiceDatas
    Lookup for service company data used by leisure/commercial logic.

  • private ComponentLookup<Building> m_Buildings
    Component lookup for building instances (used in complex property evaluation).

  • private ComponentLookup<Household> m_Households
    Lookup for household data used by home finding.

  • private ComponentLookup<HomelessHousehold> m_HomelessHouseholds
    Lookup for homeless-specific household state.

  • private ComponentLookup<Worker> m_Workers
    Lookup for worker data to compute household incomes, etc.

  • private ComponentLookup<Game.Citizens.Student> m_Students
    Lookup for citizen student component.

  • private ComponentLookup<Citizen> m_Citizens
    Lookup for general citizen components.

  • private ComponentLookup<HealthProblem> m_HealthProblems
    Lookup used to influence household income/needs.

  • private ComponentLookup<TouristHousehold> m_TouristHouseholds
    Lookup to identify tourist households and check lodging state.

  • private BufferLookup<HouseholdCitizen> m_HouseholdCitizens
    Buffer lookup for household membership (used by SetupFindHome).

  • private ComponentLookup<Game.Objects.Transform> m_Transforms
    Lookup for object transforms (used in property scoring).

  • private ComponentLookup<Building> m_BuildingDatas
    Prefab building data lookup.

  • private BufferLookup<Efficiency> m_Efficiencies
    Buffer lookup for building efficiencies (influences capacities like schools).

  • private ComponentLookup<LodgingProvider> m_LodgingProviders
    Lookup for lodging providers (hotels etc) used by tourist targeting.

  • private ComponentLookup<AttractivenessProvider> m_AttractivenessProviders
    Lookup for attractiveness providers used by tourists and attraction setup.

  • private ComponentLookup<PropertyOnMarket> m_PropertiesOnMarket
    Lookup for property market data (asking rent) used in find-home logic.

  • private ComponentLookup<PropertyRenter> m_PropertyRenters
    Lookup to resolve property owner relationships (used for lodging provider → property).

  • private ComponentLookup<CrimeProducer> m_Crimes
    Lookup used in property scoring.

  • private ComponentLookup<Game.Buildings.Park> m_Parks
    Lookup used to identify parks (homeless shelter logic, property scoring).

  • private ComponentLookup<Abandoned> m_Abandoneds
    Lookup for abandoned buildings (can be used as shelters etc).

  • private ComponentLookup<ElectricityConsumer> m_ElectricityConsumers

  • private ComponentLookup<WaterConsumer> m_WaterConsumers
  • private ComponentLookup<GarbageProducer> m_GarbageProducers
  • private ComponentLookup<MailProducer> m_MailProducers
    Lookups used in property scoring (availability of utilities and services).

  • private ComponentLookup<PathInformation> m_PathInfos
    Used when evaluating properties / routing contexts.

  • private ComponentLookup<PrefabRef> m_Prefabs
    Lookup for prefab references (prefab definitions for buildings).

  • private ComponentLookup<IndustrialProcessData> m_IndustrialProcessDatas
    Used by leisure/commercial logic to give preference to resource-producing establishments.

  • private ComponentLookup<LeisureProviderData> m_LeisureProviderDatas
    Lookup for leisure provider definitions for scoring.

  • private ComponentLookup<ResourceData> m_ResourceDatas
    Lookup used to get market prices for resources.

  • private ComponentLookup<SchoolData> m_SchoolDatas
    Lookup for school prefab data (capacity, education level).

  • private ComponentLookup<BuildingData> m_PrefabBuildingDatas
    Lookup for building prefab attributes.

  • private ComponentLookup<BuildingPropertyData> m_BuildingProperties
    Lookup for additional building property data (e.g., housing sizes, shelter capacity).

  • private ComponentLookup<SpawnableBuildingData> m_SpawnableDatas
    Lookup for spawnable building settings used by property scoring.

  • private ComponentLookup<Locked> m_Lockeds
    Lookup used to exclude locked buildings/properties.

  • private BufferLookup<Game.Economy.Resources> m_Resources
    Buffer lookup for economy resource buffers attached to households (money etc).

  • private BufferLookup<ServiceDistrict> m_ServiceDistricts
    Buffer lookup used when checking district service boundaries for school/service distribution.

  • private BufferLookup<ResourceAvailability> m_Availabilities
    Per-road-edge resource availability buffers (used for attractiveness/availability scoring).

  • private BufferLookup<Game.Net.ServiceCoverage> m_ServiceCoverages
    Buffer lookup for net service coverages used by homeless and property scoring.

  • private BufferLookup<Renter> m_Renters
    Buffer lookup for renters on a building (used for capacity checks).

  • private BufferLookup<CityModifier> m_CityModifiers
    City modifier buffers used when computing property scores.

  • private BufferLookup<OwnedVehicle> m_OwnedVehicles
    Lookup used by household evaluation for access to vehicles.

(Fields above reflect the private fields used to configure and schedule the various Setup jobs. They are updated via Update(...) calls before each job schedule.)

Properties

  • (None public)
    This struct does not expose public properties. It stores internal ECS query/handle/state used to schedule jobs.

Constructors

  • public CitizenPathfindSetup(PathfindSetupSystem system)
    Initializes a new CitizenPathfindSetup tied to the provided PathfindSetupSystem. The constructor:
  • Creates and caches EntityQuery objects for the different target groups (leisure providers, tourist targets, schools, free workplaces, attractions, homeless shelters, find-home targets).
  • Fetches and caches references to various game systems (pollution, telecom, city, resources, leisure, tax) and parameter queries.
  • Initializes all ComponentTypeHandle, ComponentLookup, and BufferLookup fields (but they must be Updated against a specific SystemState/System before scheduling).
  • Prepares the object to be used by the public Setup* scheduling methods.

Methods

  • public JobHandle SetupLeisureTarget(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupLeisureTargetJob over m_LeisureProviderQuery. Updates required ComponentTypeHandles/lookups, constructs the job with references (including resource prefabs and leisure update interval), and schedules it parallel. Registers the job as a reader with ResourceSystem. Returns the job handle.

  • public JobHandle SetupTouristTarget(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupTouristTargetJob over m_TouristTargetQuery. Updates entity/lookup handles and schedules the job which considers lodging providers, property renters, building data and attractiveness to find lodging/attraction targets for tourist households.

  • public JobHandle SetupSchoolSeekerTo(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupSchoolSeekerToJob over m_SchoolQuery. It finds school buildings that match seeker education level, computes effective capacity (considering upgrades and efficiencies) and pushes targets for students.

  • public JobHandle SetupJobSeekerTo(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupJobSeekerToJob over m_FreeWorkplaceQuery. This job ranks workplaces for job seekers, taking into account free workplace counts, outside connections, randomness from seeker seed, and whether building is city service.

  • public JobHandle SetupHomeless(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupHomelessJob over m_HomelessShelterQuery. Finds shelter-capable buildings (parks, abandoned, shelters), computes service coverage and capacity ratios and produces targets for homeless seeker entities.

  • public JobHandle SetupFindHome(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupFindHomeJob over m_FindHomeQuery. This is the most complex job: it combines many lookups and singleton parameter data (healthcare, park, education, economy, telecom, garbage, police, citizen happiness, service fees) and several pollution/telecom maps (read-only). It evaluates on-market residential properties with PropertyUtils.GetPropertyScore and ranks properties for households, taking into account household income, rent, support needs, utilities, crime, pollution, coverage, etc. It gathers dependency JobHandles for fetching the pollution/telecom maps and combines them with inputDeps.

  • public JobHandle SetupAttraction(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupAttractionJob over m_AttractionQuery. This job uses AttractivenessProvider values and each seeker's random seed to produce attraction-based target scores.

Private nested job structs (Burst-compiled IJobChunk implementations) - private struct SetupTouristTargetJob : IJobChunk
Iterates tourist-relevant chunks and evaluates lodging and attractiveness providers, adjusting scores for price, free rooms, and resource attractiveness availability; invokes targetSeeker.FindTargets for candidate buildings.

  • private struct SetupLeisureTargetJob : IJobChunk
    Evaluates leisure providers and computes a score influenced by leisure seeker weights, provider efficiency, service availability and resource market price (for commercial/meals types), then calls targetSeeker.FindTargets.

  • private struct SetupSchoolSeekerToJob : IJobChunk
    Checks service district membership, combines upgrade stats, computes effective student capacity, and schedules schools with available spots.

  • private struct SetupJobSeekerToJob : IJobChunk
    Scores workplaces for job seekers using free workplace counts, best/lowest slots, outside-connection penalties/bonuses, and randomness.

  • private struct SetupAttractionJob : IJobChunk
    Adds attraction-based scoring using AttractivenessProvider.m_Attractiveness modulated by a random factor.

  • private struct SetupHomelessJob : IJobChunk
    Scores shelter buildings based on police coverage, shelter capacity and current occupancy.

  • private struct SetupFindHomeJob : IJobChunk
    Performs property scoring across many factors (rent, asking rent, household income/resources, utilities, pollution, telecom coverage, city modifiers, service coverage, crime, locked state, ownership/household compatibility), and schedules the best property targets for households. Uses many read-only lookups and maps and therefore sets up several read-only dependencies.

Notes on scheduling & handles: - Before calling any Setup method you must pass the same PathfindSetupSystem instance the constructor received (or ensure the system parameter is the currently running PathfindSetupSystem). Each Setup call calls Update(...) on the handles it needs; these must be called from the same system scheduling the jobs. - Several methods obtain read-only maps from other systems (pollution/telecom). They expose dependency JobHandles which are combined when scheduling SetupFindHome: the method calls GetMap/GetData providing out JobHandles which are then combined into the scheduled job using JobUtils.CombineDependencies.

Usage Example

// Typical usage inside PathfindSetupSystem (pseudo-code)
public void BuildCitizenTargets(PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
{
    var citizenSetup = new CitizenPathfindSetup(this); // 'this' is PathfindSetupSystem

    // Schedule leisure target setup
    JobHandle h1 = citizenSetup.SetupLeisureTarget(this, setupData, inputDeps);

    // Schedule tourist target setup in parallel
    JobHandle h2 = citizenSetup.SetupTouristTarget(this, setupData, h1);

    // Schedule school seekers
    JobHandle h3 = citizenSetup.SetupSchoolSeekerTo(this, setupData, h2);

    // Combine handles and continue scheduling other setup jobs...
    JobHandle combined = JobHandle.CombineDependencies(h1, h2, h3);

    // When finished, ensure the combined handle is returned/synchronized with the caller
    // so the rest of the simulation waits for these target-setup jobs.
}

Notes: - All Setup* methods return a JobHandle. You should combine these handles appropriately to maintain correct dependencies. - The struct is tightly coupled to PathfindSetupSystem and the game's ECS components; modifying or reusing it outside the intended system requires replicating the required ECS context and lookups.