Skip to content

Game.Prefabs.AircraftPrefab

Assembly:
Assembly-CSharp (game code / modding assembly)

Namespace:
Game.Prefabs

Type:
abstract class

Base:
VehiclePrefab

Summary:
Abstract base prefab for aircraft-type vehicles. Provides default ground movement parameters (speed, acceleration, braking, turning), and registers/initializes the ECS components required for aircraft entities (AircraftData, UpdateFrameData and, depending on archetype flags, navigation/pathfinding and parked/moving state components). Initialize converts public editor-friendly values (km/h and degrees) into runtime values used by systems (m/s and radians) and assigns an UpdateFrameData interval.


Fields

  • public SizeClass m_SizeClass
    Defines the size classification of the aircraft (enum). Used to populate the AircraftData component.

  • public float m_GroundMaxSpeed = 100f
    Maximum ground speed in km/h as edited in the prefab. In Initialize this value is converted to m/s (divided by 3.6) and stored in AircraftData.m_GroundMaxSpeed.

  • public float m_GroundAcceleration = 3f
    Ground acceleration value used by aircraft movement logic. Passed through to AircraftData.m_GroundAcceleration.

  • public float m_GroundBraking = 5f
    Ground braking value used by aircraft movement logic. Passed through to AircraftData.m_GroundBraking.

  • public float2 m_GroundTurning = new float2(90f, 15f)
    Two-component float vector representing turning-related parameters in degrees (editor-friendly). In Initialize it is converted to radians via math.radians(...) and stored in AircraftData.m_GroundTurning.

Properties

  • None declared on this class. (All configurable members are public fields.)

Constructors

  • public AircraftPrefab()
    Default parameterless constructor (compiler-generated). The class is abstract, so it is intended to be subclassed by concrete aircraft prefabs.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component requirements used by the prefab when creating entities. Calls base.GetPrefabComponents then adds:
  • ComponentType.ReadWrite()
  • ComponentType.ReadWrite()

Use: ensures the prefab entity will have AircraftData and an update tick interval component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds additional archetype components depending on other component flags and base behavior. Calls base.GetArchetypeComponents then:
  • Always adds ComponentType.ReadWrite().
  • If the archetype contains Stopped => also adds ParkedCar.
  • If the archetype contains Moving => adds navigation/pathfinding related components:
    • AircraftNavigation
    • AircraftNavigationLane
    • AircraftCurrentLane
    • PathOwner
    • PathElement
    • Target
    • Blocker

Use: configures entity archetypes so moving aircraft have the pathfinding and lane components necessary for routing.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Initializes component data on the created entity. Calls base.Initialize and then sets:
  • AircraftData with:
    • m_SizeClass = m_SizeClass
    • m_GroundMaxSpeed = m_GroundMaxSpeed / 3.6f (convert km/h to m/s)
    • m_GroundAcceleration = m_GroundAcceleration
    • m_GroundBraking = m_GroundBraking
    • m_GroundTurning = math.radians(m_GroundTurning) (convert degrees to radians)
  • UpdateFrameData(10) — sets an update frame interval value of 10

Use: transfers prefab editable values into runtime component data in appropriate units and formats.

Usage Example

// Example of a concrete aircraft prefab deriving from AircraftPrefab
public class SmallPlanePrefab : AircraftPrefab
{
    public SmallPlanePrefab()
    {
        m_SizeClass = SizeClass.Small;
        m_GroundMaxSpeed = 120f;         // km/h in editor
        m_GroundAcceleration = 4f;
        m_GroundBraking = 6f;
        m_GroundTurning = new float2(80f, 20f); // degrees, converted to radians in Initialize
    }

    // Optionally override Initialize to add extra components or tweak entity data:
    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        base.Initialize(entityManager, entity);

        // Example: set some other custom component or tweak UpdateFrameData
        // var uf = entityManager.GetComponentData<UpdateFrameData>(entity);
        // uf.UpdateInterval = 8;
        // entityManager.SetComponentData(entity, uf);
    }
}

Notes: - This prefab is abstract and intended to be subclassed for specific aircraft types. - Public fields are editor-facing; Initialize converts them to runtime units (m/s and radians) and writes them into AircraftData.