Skip to content

Game.Vehicles.Aircraft

Assembly:
Assembly-CSharp (game assembly containing runtime types)
{{ This struct is defined in the game's runtime assembly (commonly Assembly-CSharp). If you are creating a mod project, reference the Assembly-CSharp (or the game's provided assemblies) so this type is available to your code. }}

Namespace: Game.Vehicles
{{ The Aircraft type lives in the Game.Vehicles namespace. Import this namespace or use the fully qualified name when referencing the type. }}

Type:
public struct Aircraft : IComponentData, IQueryTypeParameter, ISerializable
{{ Aircraft is a public value type (struct) used with Unity's ECS. It implements IComponentData so it can be attached to Entities, IQueryTypeParameter so it can be used in ECS query parameters, and ISerializable to support the game's custom binary serialization. }}

Base:
System.ValueType (struct)
{{ As a C# struct, Aircraft derives from System.ValueType. It does not inherit from other user types. }}

Summary:
Represents aircraft-specific component data for an entity. The struct stores aircraft flags and implements the game's serialization interface to persist those flags.
{{ This component is small and intended to be attached to ECS entities representing aircraft. The component's state consists solely of an AircraftFlags value which is serialized as a 32-bit unsigned integer. }}


Fields

  • public AircraftFlags m_Flags
    {{ Flags describing state/behavior of the aircraft. The underlying storage used for persistence is cast to/from a uint. The actual enum AircraftFlags is defined elsewhere in the codebase; consult that enum for available flag values (for example: grounded, flying, landing, etc.). Because this is a public field in a struct, modifying it directly modifies the component value — when working with ECS, read/modify/write the entire component via the EntityManager or an IComponentData accessor. }}

Properties

  • (none)
    {{ There are no properties defined on this struct. Access is via the public field m_Flags. }}

Constructors

  • public Aircraft(AircraftFlags flags)
    {{ Initializes a new Aircraft component with the provided flags. Use this constructor when creating and adding the component to an entity or when constructing temporary values. Example: new Aircraft(AircraftFlags.None) or new Aircraft(AircraftFlags.SomeFlag). }}

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    {{ Serializes the component to the provided writer. Implementation writes the AircraftFlags value cast to a uint: writer.Write((uint)m_Flags). This produces a compact 32-bit representation suitable for the game's binary save format or network serialization. The generic constraint requires a writer implementing IWriter. }}

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    {{ Deserializes the component from the provided reader. Implementation reads a uint and casts it back to AircraftFlags: reader.Read(out uint value); m_Flags = (AircraftFlags)value. Ensure the reader's data matches the expected format (a 32-bit unsigned integer). }}

Usage Example

// Adding the Aircraft component to an entity (EntityManager example)
using Unity.Entities;
using Game.Vehicles;

// create component with specific flags
var aircraftComponent = new Aircraft(AircraftFlags.None);

// add component to an existing entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(entity, aircraftComponent);

// Reading and modifying component
var aircraft = entityManager.GetComponentData<Aircraft>(entity);
aircraft.m_Flags |= AircraftFlags.SomeFlag; // set a flag (bitwise)
entityManager.SetComponentData(entity, aircraft);

// Example of (de)serialization usage is internal to the save/load system:
// writer.Write((uint)aircraft.m_Flags);
// reader.Read(out uint value); aircraft.m_Flags = (AircraftFlags)value;

{{ Notes and tips: - Because m_Flags is an enum stored as a uint during serialization, be careful when changing the AircraftFlags enum (adding, removing, or reordering flags) as that can affect save compatibility. - When manipulating components in ECS, avoid directly mutating fields on structs retrieved by reference-like patterns unless using the correct APIs (use EntityManager or System APIs to get/set component data). - Implementations of IWriter and IReader used by the game provide the actual binary stream handling; for custom serialization utilities in mods, ensure they match the game's expectations. }}