Game.AircraftNavigationLane
Assembly: Game
Namespace: Game.Vehicles
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable
Summary:
Represents a single navigation lane entry for aircraft in ECS. This struct is a buffer element (InternalBufferCapacity(8)) that stores a reference to a lane entity, a 2D curve position along that lane, and lane flags. It implements the game's ISerializable interface to read/write its data for save/load.
Fields
-
public Unity.Entities.Entity m_Lane
The entity that identifies the linked aircraft lane. Serialized/deserialized as an Entity. -
public Unity.Mathematics.float2 m_CurvePosition
A 2D position on the lane's curve (likely X/Z or curve parameterization). Serialized/deserialized as a float2. -
public AircraftLaneFlags m_Flags
Flags describing lane properties (uses the AircraftLaneFlags enum). When serialized, flags are written/read as a uint and cast to/from the enum.
Properties
- (none)
This struct exposes no C# properties; all data members are public fields.
Constructors
public AircraftNavigationLane()
(implicit default)
The struct uses the implicit parameterless constructor — fields will be default-initialized. No explicit constructors are defined in the source.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the data in the following order to the writer: m_Lane (Entity), m_CurvePosition (float2), and m_Flags (written as uint). The method copies fields to local variables before writing. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads data from the reader into this instance in the same order: m_Lane, m_CurvePosition, then a uint value which is cast back to AircraftLaneFlags and stored in m_Flags. Uses out/ref reads to populate fields.
Additional notes: - The struct is decorated with [InternalBufferCapacity(8)], which sets an initial internal buffer capacity of 8 elements for dynamic buffers of this type on entities. - Serialization uses integer casting for the flags field; ensure compatibility if the AircraftLaneFlags enum changes.
Usage Example
// Example: adding navigation lane entries to an entity's dynamic buffer inside a SystemBase
using Unity.Entities;
using Unity.Mathematics;
using Game.Vehicles;
public partial class ExampleSystem : SystemBase
{
protected override void OnUpdate()
{
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
// Suppose 'airportEntity' exists and 'laneEntity' is a lane entity we want to reference.
Entity airportEntity = /* obtain airport entity */;
Entity laneEntity = /* obtain lane entity */;
// Ensure the buffer exists
if (!em.HasComponent<DynamicBuffer<AircraftNavigationLane>>(airportEntity))
{
em.AddBuffer<AircraftNavigationLane>(airportEntity);
}
DynamicBuffer<AircraftNavigationLane> buffer = em.GetBuffer<AircraftNavigationLane>(airportEntity);
buffer.Add(new AircraftNavigationLane {
m_Lane = laneEntity,
m_CurvePosition = new float2(0.5f, 0.0f), // example curve position
m_Flags = AircraftLaneFlags.None // set appropriate flags
});
}
}