Game.Vehicles.AircraftNavigation
Assembly: Assembly-CSharp
Namespace: Game.Vehicles
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
AircraftNavigation is an ECS component used to store navigation-related parameters for aircraft in Cities: Skylines 2. It holds the target world position and direction, maximum speed, and a minimum climb angle. The struct implements ISerializable for version-aware save/load behavior and can be used as a query parameter (IQueryTypeParameter) in Unity DOTS systems.
Fields
-
public float3 m_TargetPosition
This is the world-space target position the aircraft is navigating toward (Unity.Mathematics.float3). -
public float3 m_TargetDirection
A direction vector representing the aircraft's heading or desired approach direction (float3). It is typically normalized before use. -
public float m_MaxSpeed
The maximum speed the aircraft should use while navigating toward the target (float). -
public float m_MinClimbAngle
Minimum climb angle for the aircraft (float). This field is conditionally read from save data depending on serialization version (see Deserialize notes below).
Properties
- This struct does not define any C# properties. Its data is exposed via public fields and used directly when setting/getting component data.
Constructors
public AircraftNavigation()
As a value type (struct), AircraftNavigation has an implicit parameterless constructor that zero-initializes all fields. Initialize explicit values when creating instances to avoid default-zero semantics.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component fields to the provided writer in the following order: m_TargetPosition, m_TargetDirection, m_MaxSpeed, m_MinClimbAngle. This ordering must be preserved for compatibility. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the provided reader. The method reads m_TargetPosition, m_TargetDirection and m_MaxSpeed unconditionally. m_MinClimbAngle is only read if reader.context.version >= Version.aircraftNavigation — this provides backward compatibility with older save formats where minClimbAngle did not exist.
Notes: - The generic constraints require writer/reader types that implement IWriter / IReader. - The version check relies on a Version enum (or similar) available on the reader.context; mods should not change read order or semantics for older versions to maintain compatibility. - Because this is a DOTS component (IComponentData), it is intended to be attached to entities and used inside ECS systems.
Usage Example
// Create and initialize an AircraftNavigation component instance
var nav = new AircraftNavigation {
m_TargetPosition = new float3(1000f, 500f, 2000f),
m_TargetDirection = math.normalize(new float3(0.0f, 0.1f, 1.0f)),
m_MaxSpeed = 220f,
m_MinClimbAngle = 5f
};
// Assign to an entity (EntityManager usage)
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity aircraftEntity = /* obtain or create an Entity representing the aircraft */;
entityManager.SetComponentData(aircraftEntity, nav);
// Serialization example (writer must implement IWriter)
nav.Serialize(writer);
// Deserialization example (reader must implement IReader)
AircraftNavigation loadedNav = new AircraftNavigation();
loadedNav.Deserialize(reader);
Additional notes: - Normalize m_TargetDirection before use to ensure consistent steering calculations. - When modifying this component or its serialization, keep field write/read order stable and update the Version enum appropriately to avoid breaking saved games.