Skip to content

Game.Simulation.FirePathfindSetup

Assembly: Assembly-CSharp
Namespace: Game.Simulation

Type: struct

Base: ValueType (struct)

Summary:
FirePathfindSetup is a helper struct used by the PathfindSetupSystem to prepare pathfinding targets related to fire & evacuation systems. It contains several Burst-compiled IJobChunk implementations that gather and enqueue path targets for: - fire engines and fire stations, - emergency shelters, - evacuation transport (public transport and shelter vehicles), - evacuation requests, - fire rescue requests (including nearby network targets and helicopter lanes).

The setup uses Unity's ECS chunk iteration, ComponentLookup/BufferLookup, NativeQuadTree searches (area & net), and schedules parallel jobs via JobChunkExtensions.ScheduleParallel. It also interacts with CitySystem, area/net search systems and respects service districts, outside connections, and vehicle/building flags to determine valid targets.


Fields

  • private EntityQuery m_FireEngineQuery
    Internal EntityQuery used to iterate over fire stations and fire engines for fire engine target setup.

  • private EntityQuery m_EmergencyShelterQuery
    EntityQuery for emergency shelter entities with service dispatch buffers (shelter target setup).

  • private EntityQuery m_EvacuationTransportQuery
    EntityQuery for evacuation transport sources: either emergency shelters or public transport vehicles.

  • private EntityQuery m_EvacuationRequestQuery
    EntityQuery for evacuation requests (requests which are not yet dispatched and don't have path info).

  • private EntityQuery m_FireRescueRequestQuery
    EntityQuery for fire rescue requests (not dispatched / without path info).

  • private EntityTypeHandle m_EntityType
    EntityTypeHandle used by jobs to retrieve entities from chunks.

  • private ComponentTypeHandle<PathOwner> m_PathOwnerType
    Read-only handle for PathOwner component (used to estimate progress along paths).

  • private ComponentTypeHandle<Owner> m_OwnerType
    Read-only handle for Owner component (used when checking ownership/service district relations).

  • private ComponentTypeHandle<ServiceRequest> m_ServiceRequestType
    Read-only handle for ServiceRequest component (used in request jobs).

  • private ComponentTypeHandle<FireRescueRequest> m_FireRescueRequestType
    Read-only handle for FireRescueRequest component (used in fire rescue job).

  • private ComponentTypeHandle<EvacuationRequest> m_EvacuationRequestType
    Read-only handle for EvacuationRequest component.

  • private ComponentTypeHandle<Game.Buildings.FireStation> m_FireStationType
    Read-only handle for FireStation component (building-level data/flags).

  • private ComponentTypeHandle<Game.Buildings.EmergencyShelter> m_EmergencyShelterType
    Read-only handle for EmergencyShelter component.

  • private ComponentTypeHandle<Game.Vehicles.FireEngine> m_FireEngineType
    Read-only handle for FireEngine vehicle component (state, path element time, request count, etc).

  • private ComponentTypeHandle<Game.Vehicles.PublicTransport> m_PublicTransportType
    Read-only handle for PublicTransport vehicle component (evacuation vehicles).

  • private BufferTypeHandle<PathElement> m_PathElementType
    Read-only buffer handle for PathElement buffers (per-entity path data).

  • private BufferTypeHandle<ServiceDispatch> m_ServiceDispatchType
    Read-only buffer handle for ServiceDispatch buffers (dispatch/requests queue).

  • private ComponentLookup<PathInformation> m_PathInformationData
    Read-only component lookup for PathInformation (used to estimate queued durations).

  • private ComponentLookup<FireRescueRequest> m_FireRescueRequestData
    Read-only lookup for FireRescueRequest components (per-target).

  • private ComponentLookup<EvacuationRequest> m_EvacuationRequestData
    Read-only lookup for EvacuationRequest components.

  • private ComponentLookup<Game.Objects.OutsideConnection> m_OutsideConnections
    Read-only lookup to determine outside connections (used to add extra travel cost).

  • private ComponentLookup<Composition> m_CompositionData
    Read-only composition lookup (used when searching for suitable network targets).

  • private ComponentLookup<CurrentDistrict> m_CurrentDistrictData
    Read-only lookup for current district membership of entities.

  • private ComponentLookup<District> m_DistrictData
    Read-only lookup for District components (used to resolve district from areas).

  • private ComponentLookup<Game.Buildings.FireStation> m_FireStationData
    Read-only lookup for FireStation (used when request target is a station).

  • private ComponentLookup<Game.Vehicles.FireEngine> m_FireEngineData
    Read-only lookup for FireEngine (used when request target is a vehicle).

  • private ComponentLookup<Game.Vehicles.PublicTransport> m_PublicTransportData
    Read-only lookup for PublicTransport vehicles.

  • private ComponentLookup<NetCompositionData> m_NetCompositionData
    Read-only lookup for net composition (used by network target search).

  • private BufferLookup<PathElement> m_PathElements
    Read-only buffer lookup for PathElement buffers of arbitrary entities (used to find last path element).

  • private BufferLookup<ServiceDistrict> m_ServiceDistricts
    Read-only buffer lookup for service district buffers (districts serviced by a service).

  • private ComponentLookup<Game.City.City> m_CityData
    Read-only lookup for City data (used to check city options like ImportOutsideServices).

  • private Game.Areas.SearchSystem m_AreaSearchSystem
    Reference to the area search system (used to build a search tree for areas/districts).

  • private Game.Net.SearchSystem m_NetSearchSystem
    Reference to the net search system (used for nearby network searches).

  • private CitySystem m_CitySystem
    Reference to the CitySystem to access the current city entity.

Properties

  • (none)
    This struct exposes no public properties. All state is private and updated via Update() calls within each Setup* method.

Constructors

  • public FirePathfindSetup(PathfindSetupSystem system)
    Initializes queries, component/buffer handles, lookups, and references to search systems. The constructor prepares all EntityQuery objects and retrieves references to the area/net search systems and CitySystem from the provided world/system.

Methods

  • public JobHandle SetupFireEngines(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules the SetupFireEnginesJob over m_FireEngineQuery. This job:
  • Iterates over fire stations and fire engines.
  • For fire stations: finds possible targets for fires/disasters if the station has available engines/helicopters and the target/request is in service district (or is the direct target) and passes city option checks.
  • For fire engines: estimates queue cost from current path progress and queued requests, filters by disaster response flags, and either enqueues an existing queued target or calls FindTargets to create new path targets.
  • Uses m_CitySystem.City to check ImportOutsideServices.

  • public JobHandle SetupEmergencyShelters(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupEmergencySheltersJob over m_EmergencyShelterQuery. Enqueues shelters as targets for each seeker if the shelter has space and the service district checks pass.

  • public JobHandle SetupEvacuationTransport(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules SetupEvacuationTransportJob over m_EvacuationTransportQuery. Handles:

  • Shelters offering available vehicles (adds targets to seekers in same service district).
  • Evacuating public transport vehicles: estimates queued travel time from current path and queue, filters out dummy traffic and off-district vehicles, and enqueues last path element or calls FindTargets when necessary.

  • public JobHandle SetupEvacuationRequest(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules EvacuationRequestsJob over m_EvacuationRequestQuery. For seekers that have an EvacuationRequest target it:

  • Determines the correct service (either direct transport entity or the service owner of the target).
  • Iterates over evacuation requests and, if service district matches, calls FindTargets to set up target paths for the request.

  • public JobHandle SetupFireRescueRequest(PathfindSetupSystem system, PathfindSetupSystem.SetupData setupData, JobHandle inputDeps)
    Schedules FireRescueRequestsJob over m_FireRescueRequestQuery. This job is more complex and:

  • Resolves whether the FireRescueRequest target is handled by a fire engine or a station and checks disaster availability flags.
  • Resolves district membership for targets either from CurrentDistrict or by using area search (a DistrictIterator iterates the area quad-tree to find the district containing a world position).
  • If service district check passes, calls FindTargets for the request. Additionally:
    • If seeker supports flying methods and passenger helicopters are available, attempts to find nearest helicopter lane and enqueue it.
    • Searches the nearby net tree (within 30m) for network-based targets using CommonPathfindSetup.TargetIterator to find suitable road/net targets.
  • This method obtains read-only area and net search trees (m_AreaSearchSystem.GetSearchTree / m_NetSearchSystem.GetNetSearchTree) and registers the scheduled job as readers (AddSearchTreeReader / AddNetSearchTreeReader). The returned JobHandle already combines the required search-tree dependencies.

Notes about the private nested job structs: - SetupFireEnginesJob, SetupEmergencySheltersJob, SetupEvacuationTransportJob, EvacuationRequestsJob and FireRescueRequestsJob are all private nested Burst-compiled IJobChunk implementations inside this struct. They perform the per-chunk iteration described above and make use of the handles/lookups prepared by the constructor.

Usage Example

// Example usage from a PathfindSetupSystem-like context
public class MyPathfindSetupSystem : SystemBase
{
    private FirePathfindSetup m_FireSetup;
    private PathfindSetupSystem.SetupData m_SetupData;

    protected override void OnCreate()
    {
        var pathfindSetupSystem = /* obtain PathfindSetupSystem reference */;
        m_FireSetup = new FirePathfindSetup(pathfindSetupSystem);
        // m_SetupData would be prepared by PathfindSetupSystem before scheduling setup jobs
    }

    protected override void OnUpdate()
    {
        JobHandle deps = default;
        // schedule various setup steps (example)
        deps = m_FireSetup.SetupFireEngines(/* system */ null, m_SetupData, deps);
        deps = m_FireSetup.SetupEmergencyShelters(/* system */ null, m_SetupData, deps);
        deps = m_FireSetup.SetupEvacuationTransport(/* system */ null, m_SetupData, deps);
        deps = m_FireSetup.SetupEvacuationRequest(/* system */ null, m_SetupData, deps);
        deps = m_FireSetup.SetupFireRescueRequest(/* system */ null, m_SetupData, deps);

        // ensure jobs complete or pass deps to next stage as appropriate
        deps.Complete();
    }
}

Notes: - The real PathfindSetupSystem provides the required handles, SetupData and is the correct context to create this struct. The example shows intended usage flow: construct with the setup system and call the Setup* methods during the setup phase, chaining JobHandles as needed. - The scheduled jobs use Burst and parallel chunk scheduling; ensure proper dependencies are respected when integrating with other systems (especially the area/net search systems).