Skip to content

Game.AircraftMoveSystem

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

Type: class

Base: GameSystemBase

Summary:
System responsible for updating movement, rotation and light states of aircraft (airplanes and helicopters). It runs as a parallel IJobChunk (AircraftMoveJob) that iterates over aircraft entities, updates their Moving and Transform components, writes a TransformFrame snapshot into a dynamic buffer, and flags entities with EffectsUpdated when important light/flight state changes occur. Uses prefab data lookups (HelicopterData / AirplaneData), lighting brightness and the simulation frame index to compute transform frames and light behavior.


Fields

  • private SimulationSystem m_SimulationSystem
    Used to read the current simulation frame index (m_TransformFrameIndex calculation) and to coordinate update timing with the simulation.

  • private LightingSystem m_LightingSystem
    Provides lighting state (dayLightBrightness) used to determine which lights should be on/off for aircraft.

  • private EntityQuery m_AircraftQuery
    Query selecting aircraft entities to process. Includes Aircraft, AircraftNavigation, UpdateFrame, Transform, Moving, TransformFrame and excludes Deleted, Temp, TripSource.

  • private EndFrameBarrier m_EndFrameBarrier
    Barrier system used to obtain an EntityCommandBuffer.ParallelWriter to add components (e.g., EffectsUpdated) safely from the job and to register job handles for barrier synchronization.

  • private TypeHandle __TypeHandle
    Internal helper struct that caches Entity/Component type and buffer handles used by the IJobChunk. It contains ComponentTypeHandle/BufferTypeHandle/ComponentLookup fields and an __AssignHandles method to initialize them from a SystemState.

Properties

  • None (no public properties defined on this system).

Constructors

  • public AircraftMoveSystem()
    Default constructor (marked with [Preserve] in the compiled class). No special construction logic beyond base initialization.

Methods

  • public override int GetUpdateInterval(SystemUpdatePhase phase)
    Returns the update interval for this system. Implementation returns 16 (system updates every 16 ticks).

  • public override int GetUpdateOffset(SystemUpdatePhase phase)
    Returns the update offset for this system. Implementation returns 10.

  • protected override void OnCreate()
    Initializes references to other systems and creates the EntityQuery. Specifically:

  • Acquires SimulationSystem, LightingSystem and EndFrameBarrier via World.GetOrCreateSystemManaged.
  • Builds m_AircraftQuery selecting the components required for aircraft movement and excluding deleted/temp/trip-source entities.

  • protected override void OnUpdate()
    Main runtime logic: constructs and schedules the AircraftMoveJob (a Burst-compiled IJobChunk) with parallel scheduling over m_AircraftQuery. Before scheduling the job it fills the job's type handles (via InternalCompilerInterface.GetComponentTypeHandle / GetEntityTypeHandle / GetBufferTypeHandle) and sets:

  • m_TransformFrameIndex = m_SimulationSystem.frameIndex / 16 % 4
  • m_DayLightBrightness = m_LightingSystem.dayLightBrightness
  • m_CommandBuffer = m_EndFrameBarrier.CreateCommandBuffer().AsParallelWriter() After scheduling, the returned JobHandle is registered with m_EndFrameBarrier.AddJobHandleForProducer and assigned to base.Dependency.

  • private void __AssignQueries(ref SystemState state)
    Compiler helper that sets up any queries needed for the generated code path. In the decompiled form it creates and disposes an EntityQueryBuilder; primarily for compiler/IL2CPP compatibility.

  • protected override void OnCreateForCompiler()
    Called by the compiler-generated initialization path: invokes __AssignQueries and calls __TypeHandle.__AssignHandles(ref state) to populate cached type handles.

  • Nested type: private struct AircraftMoveJob : IJobChunk (marked [BurstCompile])
    The job executed for each chunk. Key behaviors:

  • Reads entity, prefab reference, Aircraft, AircraftNavigation, AircraftCurrentLane, PseudoRandomSeed and (optionally) Helicopter marker component.
  • Writes Moving and Transform components and per-frame TransformFrame buffer entries.
  • Distinguishes between helicopter and airplane behavior (chunk.Has(Helicopter) branch). Each path computes velocity, rotation, angular velocity, position and transform flags differently:
    • Flying state: computes target direction (respecting min climb angle), clamps acceleration/rotation, applies sway/rolling/tilt per prefab data, integrates velocity and rotation, and sets flags for InteriorLights, Flying, WarningLights/Landing/TakingOff, MainLights/ExtraLights/WorkLights depending on lane flags, working state and day/night randomization.
    • Non-flying (taxiing/ground) state: simpler steering toward target position with velocity smoothing, sets warning/interior lights and landing/taking-off flags as appropriate.
  • Computes TransformFrame as an interpolated snapshot (often lerp between previous and next position).
  • Compares the transform frame flags at the active frame index across the buffer; if the union of flags across frames changes for relevant light/flight bits, it enqueues an EffectsUpdated component on the entity using the parallel ECB writer.
  • Uses ComponentLookup and ComponentLookup to read prefab-specific parameters (max speeds, accelerations, turning/roll factors, climb/slow angles, etc).
  • Uses PseudoRandomSeed to randomize some light values so aircraft lights flicker or vary slightly.

  • Nested type: private struct TypeHandle
    Contains readonly and read/write ComponentTypeHandle/BufferTypeHandle/ComponentLookup fields for the job. Method __AssignHandles(ref SystemState) initializes all handles from the provided SystemState.

Usage Example

[Preserve]
protected override void OnUpdate()
{
    var job = new AircraftMoveJob
    {
        m_EntityType = InternalCompilerInterface.GetEntityTypeHandle(ref __TypeHandle.__Unity_Entities_Entity_TypeHandle, ref base.CheckedStateRef),
        m_AircraftType = InternalCompilerInterface.GetComponentTypeHandle(ref __TypeHandle.__Game_Vehicles_Aircraft_RO_ComponentTypeHandle, ref base.CheckedStateRef),
        // ... set other handles ...
        m_TransformFrameIndex = m_SimulationSystem.frameIndex / 16 % 4,
        m_DayLightBrightness = m_LightingSystem.dayLightBrightness,
        m_CommandBuffer = m_EndFrameBarrier.CreateCommandBuffer().AsParallelWriter()
    };
    JobHandle jobHandle = JobChunkExtensions.ScheduleParallel(job, m_AircraftQuery, base.Dependency);
    m_EndFrameBarrier.AddJobHandleForProducer(jobHandle);
    base.Dependency = jobHandle;
}

Notes and implementation details: - The system is designed to be burst-compiled and run in parallel over archetype chunks for performance. - Light and motion behavior depends on prefab data (HelicopterData / AirplaneData), lane flags (AircraftLaneFlags), and day/night brightness with small pseudo-random variations. - When transform frame light/flight flags change across frames, the system adds an EffectsUpdated marker component so other systems can react (e.g., visual effect updates).