Game.Simulation.AircraftNavigationSystem
Assembly:
Namespace: Game.Simulation
Type: class
Base: GameSystemBase
Summary:
AircraftNavigationSystem is an ECS-style game system responsible for updating aircraft (airplanes and helicopters) navigation each simulation frame. It assembles and schedules Burst-compiled jobs that:
- determine the current lane for aircraft,
- build/consume navigation paths (taxiways, runways, airways),
- compute movement targets and speeds (including flying vs. ground logic),
- reserve lanes and apply side-effects (pollution, lane reservation state),
- query spatial search trees and terrain/water data for height and collision checks.
The system batches work into parallel jobs (UpdateNavigationJob, UpdateLaneReservationsJob, ApplyLaneEffectsJob), uses NativeQueues for inter-job communication, and integrates with other world systems (net search, airway, object search, terrain, water). It runs at a fixed update cadence (see GetUpdateInterval/GetUpdateOffset).
Fields
-
private Game.Net.SearchSystem m_NetSearchSystem
Holds a reference to the game's network search system used to get a read-only net search quadtree for lane lookups. -
private AirwaySystem m_AirwaySystem
Reference to the airway system that provides airway data used for airborne routing. -
private Game.Objects.SearchSystem m_ObjectSearchSystem
Used to access the moving-object search quadtree (for collision queries among moving objects such as other aircraft). -
private TerrainSystem m_TerrainSystem
Used to obtain terrain height data for height/altitude calculations. -
private WaterSystem m_WaterSystem
Used to obtain water surface data (sample heights when computing target altitudes). -
private EntityQuery m_VehicleQuery
EntityQuery used to select aircraft entities that this system updates (filters aircraft + required components). -
private LaneObjectUpdater m_LaneObjectUpdater
Utility used to update lane objects buffers; the system obtains a LaneObjectCommandBuffer from this updater for the UpdateNavigationJob. -
private TypeHandle __TypeHandle
Generated helper that stores Entity/Component/Buffer/ComponentLookup handles used to produce Job data (internal compiled handles assigned in OnCreateForCompiler).
Properties
public
None declared in this type.
Constructors
public AircraftNavigationSystem()
Default constructor. The system is marked [Preserve] on lifecycle methods; construction is minimal and most initialization occurs in OnCreate.
Methods
-
public override int GetUpdateInterval(SystemUpdatePhase phase)
Returns 16. Indicates the system's update interval (frames) for the given update phase. -
public override int GetUpdateOffset(SystemUpdatePhase phase)
Returns 10. The update offset used to stagger when within the interval this system runs. -
[Preserve] protected override void OnCreate()
Initializes system references (m_NetSearchSystem, m_AirwaySystem, m_ObjectSearchSystem, m_TerrainSystem, m_WaterSystem), sets up m_VehicleQuery to select aircraft entities and creates a LaneObjectUpdater. Calls RequireForUpdate(m_VehicleQuery) to ensure the system only runs when relevant entities exist. -
[Preserve] protected override void OnUpdate()
Main runtime entry. Creates NativeQueues for lane reservations and lane effects, builds UpdateNavigationJob (populating many ComponentTypeHandle/ComponentLookup/BufferLookup and read-only search trees/height data), schedules: - UpdateNavigationJob (IJobChunk, Burst) in parallel over m_VehicleQuery,
- UpdateLaneReservationsJob (IJob) to consume the lane reservation queue,
-
ApplyLaneEffectsJob (IJob) to consume the lane effects queue. Groups job dependencies, registers read accessors with the search/terrain/water systems, disposes temporary queues with job dependencies, applies lane object updates, and sets base.Dependency to the combined job dependencies. This method contains the scheduling logic and wiring between systems and jobs.
-
protected override void OnCreateForCompiler()
Called to set up query assignment and assign handles in the generated __TypeHandle. Used by the compiled system to initialize ComponentTypeHandles/ComponentLookup/BufferLookup before jobs are constructed. -
private void __AssignQueries(ref SystemState state)
Currently contains a placeholder EntityQueryBuilder and is used during compiler-time setup; no active queries are created there in the decompiled code. -
(Nested)
UpdateNavigationJob : IJobChunk
Burst-compiled job that iterates matching archetype chunks and performs the per-aircraft navigation logic: - Finds/validates current lane,
- Fills navigation lanes from PathElement buffer,
- Computes navigation targets/speeds depending on helicopter vs airplane and flying/ground mode,
- Performs collision checks (GetCollisionHeightTarget),
- Reserves lane ranges by enqueueing lane reservations,
-
Produces lane side-effects that are enqueued for later application. This job uses many read-only ComponentLookup and BufferLookup references and writes to AircraftNavigation, AircraftCurrentLane, PathOwner, Blocker, Odometer, and lane buffers.
-
(Nested)
UpdateLaneReservationsJob : IJob
Consumes the lane reservation queue and writes updates to LaneReservation component data (m_Next offsets and priorities, m_Blocker). Runs after UpdateNavigationJob (consumes its queue). -
(Nested)
ApplyLaneEffectsJob : IJob
Consumes lane effects queue and updates Owner -> Pollution components based on computed side-effects enqueued by the navigation job. -
(Nested)
TypeHandle
struct
Generated container storing all needed EntityTypeHandle, ComponentTypeHandle, BufferTypeHandle and ComponentLookup/BufferLookup instances used when preparing job data. It has an __AssignHandles method that gets handles from a SystemState. -
Other helper/private methods (inside UpdateNavigationJob): lots of domain-specific functions used by the job: UpdateStopped, UpdateNavigationLanes, ClearNavigationLanes, TryFindCurrentLane, FillNavigationPaths, GetTransformTarget, CheckBlocker, UpdateNavigationTarget, GetCollisionHeightTarget, ApplyLanePosition, ApplySideEffects (overloads), ReserveNavigationLanes, UpdateTargetHeight (helicopter/airplane overloads), MoveTarget (overload for entity vs Bezier). These implement the low-level navigation and path consumption logic.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
m_NetSearchSystem = base.World.GetOrCreateSystemManaged<Game.Net.SearchSystem>();
m_AirwaySystem = base.World.GetOrCreateSystemManaged<AirwaySystem>();
m_ObjectSearchSystem = base.World.GetOrCreateSystemManaged<Game.Objects.SearchSystem>();
m_TerrainSystem = base.World.GetOrCreateSystemManaged<TerrainSystem>();
m_WaterSystem = base.World.GetOrCreateSystemManaged<WaterSystem>();
m_VehicleQuery = GetEntityQuery(
ComponentType.ReadOnly<Aircraft>(),
ComponentType.ReadOnly<Game.Objects.Transform>(),
ComponentType.ReadOnly<Target>(),
ComponentType.ReadOnly<PrefabRef>(),
ComponentType.ReadOnly<UpdateFrame>(),
ComponentType.ReadOnly<PathElement>(),
ComponentType.ReadWrite<PathOwner>(),
ComponentType.ReadWrite<AircraftNavigation>(),
ComponentType.Exclude<Deleted>(),
ComponentType.Exclude<Temp>(),
ComponentType.Exclude<TripSource>()
);
m_LaneObjectUpdater = new LaneObjectUpdater(this);
RequireForUpdate(m_VehicleQuery);
}
Notes / Tips for Modders: - The core per-entity logic is inside UpdateNavigationJob; to change navigation behavior you can: - Modify how navigation lanes are filled (FillNavigationPaths), - Adjust target height or braking logic (UpdateTargetHeight / VehicleUtils usage), - Hook into lane reservations / lane effects by intercepting the NativeQueue usage (requires rebuilding job scheduling). - Because this system uses Burst and jobs heavily, changes must respect job safety (no managed references inside jobs) and must update TypeHandle assignment in OnCreateForCompiler when adding new component accesses. - The system registers itself as readers of the game's spatial search trees and terrain/water systems; when modifying what is read you must also register appropriate readers similarly in OnUpdate so these systems know about concurrent access.