Game.Simulation.TransportAircraftAISystem
Assembly: Assembly-CSharp.dll
Namespace: Game.Simulation
Type: class
Base: GameSystemBase
Summary:
System responsible for AI and runtime behaviour of transport aircraft (airplanes and helicopters). It updates aircraft entities on a fixed interval (scheduling a Burst-compiled IJobChunk), handling pathfinding setup, boarding/dispatch logic, maintenance/refueling checks, returning to depot, dummy-vehicle resource handling, and lifecycle (spawn/unspawn/delete) decisions. The heavy per-entity work is done inside the nested TransportAircraftTickJob which interacts with pathfinding, route/waypoint buffers, boarding helpers and various component lookups.
Fields
-
private EndFrameBarrier m_EndFrameBarrier
Holds the EndFrameBarrier system used to create a parallel command buffer for structural changes applied by the job (add/remove components, create entities, etc). -
private SimulationSystem m_SimulationSystem
Reference to the simulation system used for accessing the current simulation frame index. -
private PathfindSetupSystem m_PathfindSetupSystem
Reference to the pathfinding setup system used to enqueue pathfind setup requests (m_PathfindQueue). -
private CityStatisticsSystem m_CityStatisticsSystem
Reference used by boarding/boarding results to update city statistics. -
private AchievementTriggerSystem m_AchievementTriggerSystem
Reference used by boarding/boarding results to trigger achievements. -
private EntityQuery m_VehicleQuery
EntityQuery used to select aircraft entities that the system updates (requires AircraftCurrentLane, Owner, PrefabRef, PathOwner, Target and either CargoTransport or PublicTransport). -
private EntityArchetype m_TransportVehicleRequestArchetype
Archetype used by this system for creating transport vehicle request entities. -
private EntityArchetype m_HandleRequestArchetype
Archetype used for request-handling bookkeeping entities. -
private TransportBoardingHelpers.BoardingLookupData m_BoardingLookupData
Lookup data used to accelerate boarding-related operations in the boarding job. -
private TypeHandle __TypeHandle
Generated helper containing component & buffer type handles and component lookups used by the scheduled job.
Properties
- None (no public properties exposed by this system).
Constructors
public TransportAircraftAISystem()
Default constructor. The system is initialized by the framework; real setup happens in OnCreate.
Methods
-
public override int GetUpdateInterval(SystemUpdatePhase phase)
Returns the system update interval in frames. This system updates every 16 frames (returns 16). -
public override int GetUpdateOffset(SystemUpdatePhase phase)
Returns the system update offset. This system uses an offset of 10. -
protected override void OnCreate()
Sets up references to other systems (EndFrameBarrier, SimulationSystem, PathfindSetupSystem, CityStatisticsSystem, AchievementTriggerSystem), creates the boarding lookup data and entity archetypes, builds the m_VehicleQuery and calls RequireForUpdate to ensure the system only runs when vehicles exist. -
protected override void OnUpdate()
Main update entry. Prepares a TransportBoardingHelpers.BoardingData (temporary Job data), updates boarding lookup data, schedules TransportAircraftTickJob as a parallel IJobChunk (Burst compiled) to process aircraft entities, schedules and completes boarding jobs, registers the pathfind queue writer, and registers the job handle with EndFrameBarrier. This method assembles all required type handles, component lookups and buffers and passes them to the job. -
protected override void OnCreateForCompiler()
Compiler-specific setup used by generated code: assigns queries and type handles for the system (internal). -
private void __AssignQueries(ref SystemState state)
Internal helper used by generated code to assign and validate queries (empty in this class except for a placeholder). -
private struct TransportAircraftTickJob : IJobChunk
(nested)
Burst-compiled job that performs per-chunk and per-entity updates for aircraft. Responsibilities include: - Handling unspawned/stopped state and starting vehicles.
- Resetting/clearing paths when needed and adjusting aircraft flags (taxiway / mid-air behavior).
- Checking maintenance/refuel needs via prefab vehicle data and odometer.
- Managing service dispatches and transport vehicle requests (creating request entities when needed).
- Starting/stopping boarding via TransportBoardingHelpers.BoardingData (begins/ends boarding, manages passengers).
- Selecting next dispatch/route and appending path elements when available.
- Returning vehicle to depot when route/target invalid or stuck.
- Finding and requesting new paths when VehicleUtils.RequireNewPath indicates.
- Handling dummy traffic resources (loading Resources for cargo dummy vehicles).
- Many small utility routines: FindNextLane, CheckNavigationLanes, SetNextWaypointTarget, GetTransportStationFromStop, GetStorageCompanyFromStop, GetNextStorageCompany, etc.
The job uses many ComponentLookup and BufferLookup references (read-only and read-write) to operate without main-thread structural changes, and writes structural changes through a parallel EntityCommandBuffer.
private void __AssignHandles(ref SystemState state)
(in TypeHandle)
Generated method that caches component type handles and buffer lookups required by the job. This is invoked during system initialization (OnCreateForCompiler).
Usage Example
// Typical way to get the system instance from your mod code:
var transportAircraftSystem = World.DefaultGameObjectInjectionWorld
.GetOrCreateSystemManaged<Game.Simulation.TransportAircraftAISystem>();
// You can read its update interval and offset:
int interval = transportAircraftSystem.GetUpdateInterval(SystemUpdatePhase.Simulation);
int offset = transportAircraftSystem.GetUpdateOffset(SystemUpdatePhase.Simulation);
// Note: The system manages aircraft automatically; to influence behaviour you typically
// add/remove components like CurrentRoute, ServiceRequest or TransportVehicleRequest
// to entities (via ECS) so this system responds on its next scheduled update.
(If you want detail on the nested TransportAircraftTickJob's per-entity logic or any specific helper functions like StartBoarding/StopBoarding/FindPathIfNeeded, tell me which function and I can produce a focused breakdown with parameter/return semantics and relevant components used.)