Skip to content

Game.Prefabs.AirplaneData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Component (ECS IComponentData) that contains flight tuning parameters for airplane prefabs. Holds speeds, acceleration/ braking/ turning parameters, climb/pitch/roll tuning values used by the airplane movement/physics systems. The struct implements custom serialization (Colossal.Serialization) so instances are written/read in a fixed field order — useful for saving/loading prefab data and for compatibility between versions.


Fields

  • public Unity.Mathematics.float2 m_FlyingSpeed
    Stores a 2-component speed vector used by the airplane movement system. The exact interpretation (for example forward vs lateral or cruise vs max) is defined by the airplane controller code; consult the airplane movement system if you need the precise semantics for a specific prefab.

  • public float m_FlyingAcceleration
    Forward acceleration (rate of change of speed). Used when increasing velocity while airborne.

  • public float m_FlyingBraking
    Braking/deceleration rate while airborne (for reducing speed).

  • public float m_FlyingTurning
    Tuning factor controlling turning responsiveness (how strongly the airplane changes heading when input/AI requests a turn).

  • public float m_FlyingAngularAcceleration
    Angular acceleration used when changing the airplane's angular velocity (affects responsiveness to roll/pitch/turn inputs).

  • public float m_ClimbAngle
    Nominal climb angle parameter used when the airplane ascends. Interpreted by the flight controller to determine pitch target or climb profile.

  • public float m_SlowPitchAngle
    Pitch angle used when the airplane is slowing (e.g., when approaching landing or reducing speed) to transition pitch more gently.

  • public float m_TurningRollFactor
    Factor applied to roll while turning; affects how much the airplane rolls in response to a turn command.

Properties

  • This type has no public properties.

Constructors

  • public AirplaneData()
    Struct default constructor (value type). All numeric fields default to 0 (m_FlyingSpeed = default(float2)). Initialize fields explicitly before use to avoid unintended zero values.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes each field to the provided writer in the following order: m_FlyingSpeed, m_FlyingAcceleration, m_FlyingBraking, m_FlyingTurning, m_FlyingAngularAcceleration, m_ClimbAngle, m_SlowPitchAngle, m_TurningRollFactor. Maintain this order when reading to preserve compatibility.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads fields from the provided reader into the same fields in the same order as Serialize. Uses ref local variables to populate the struct fields directly.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;

// create an entity with an AirplaneData component and set tuned values
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity airplaneEntity = em.CreateEntity(typeof(AirplaneData));

var airplane = new AirplaneData {
    m_FlyingSpeed = new float2(30f, 10f),    // tune meaning per airplane controller
    m_FlyingAcceleration = 6f,
    m_FlyingBraking = 8f,
    m_FlyingTurning = 1.2f,
    m_FlyingAngularAcceleration = 2.5f,
    m_ClimbAngle = 12f,
    m_SlowPitchAngle = 4f,
    m_TurningRollFactor = 0.9f
};

em.SetComponentData(airplaneEntity, airplane);

Additional notes: - Because this struct implements ISerializable, its serialized layout is fixed — when editing or extending the format, ensure backward compatibility for saved data. - Units and exact semantics (which float corresponds to which maneuver) depend on the airplane controller systems. If you modify values for game balance, iterate and test in-game to confirm expected behavior.