Game.Vehicles.AircraftCurrentLane
Assembly: Assembly-CSharp
Namespace: Game.Vehicles
Type: struct
Base: System.ValueType (implements IComponentData, IQueryTypeParameter, ISerializable)
Summary:
Represents the current lane information for an aircraft in the ECS (Entity Component System). This struct is used as a component to store which lane/entity the aircraft is currently following, the local curve position on that lane, lane-related flags, and simple movement metrics (duration, distance, position). It is serializable for save/load and compatible with Unity.Entities queries via IQueryTypeParameter.
Fields
-
public Entity m_Lane
Holds the Entity reference of the lane or path target the aircraft is currently on. This is the primary identifier linking the aircraft to a path/segment in the pathfinding/traffic system. -
public float3 m_CurvePosition
A float3 representing the curve/local position on the lane. Typically stores a local offset or positional delta used when sampling the lane geometry for rendering or movement. -
public AircraftLaneFlags m_LaneFlags
Bitflags (enum) describing lane-specific state (e.g., whether the aircraft is on the left/right side, special lane behavior, or other aircraft-specific lane metadata). Serialized as a uint. -
public float m_Duration
Accumulated time spent on this lane (seconds). Useful for timing-based logic or smoothing. -
public float m_Distance
Accumulated distance traveled on this lane (world units). Useful for distance-based logic and calculations. -
public float m_LanePosition
A value representing the position along the lane. Could be a normalized 0..1 value or absolute offset depending on the consuming systems; used for interpolation/sampling along the lane.
Properties
- (none)
This struct exposes only public fields and does not declare C# properties.
Constructors
-
public AircraftCurrentLane(ParkedCar parkedCar, AircraftLaneFlags flags)
Constructs the component from a ParkedCar snapshot. Copies lane Entity and curve position from the parked car and sets provided lane flags. Movement metrics (m_Duration, m_Distance, m_LanePosition) are initialized to 0. -
public AircraftCurrentLane(PathElement pathElement, AircraftLaneFlags laneFlags)
Constructs the component from a PathElement (typically used when following a path). The lane Entity is set from pathElement.m_Target and the curve position is set from pathElement.m_TargetDelta.xxx (x component replicated into a float3). Movement metrics are initialized to 0.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes component data to a serializer in a fixed order: m_Lane (Entity), m_CurvePosition (float3), m_LaneFlags (written as uint), m_Duration (float), m_Distance (float), m_LanePosition (float). Order must be preserved for correct deserialization. Use this when saving game state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from a deserializer in the same order used by Serialize. After reading primitive fields, m_LaneFlags is reconstructed from the read uint. This method restores the component state during load.
Notes: - The generic writer/reader constraints require types that implement IWriter/IReader from Colossal.Serialization.Entities. - The serialization is explicit and non-versioned here; if fields change in future versions, compatibility wrappers will be needed.
Usage Example
// Create from a path element and add to an entity with an EntityManager:
PathElement pathElement = ...;
AircraftLaneFlags flags = AircraftLaneFlags.None;
var aircraftLane = new AircraftCurrentLane(pathElement, flags);
entityManager.AddComponentData(aircraftEntity, aircraftLane);
// Example: update component values in a system
var acl = entityManager.GetComponentData<AircraftCurrentLane>(aircraftEntity);
acl.m_Duration += deltaTime;
acl.m_Distance += travelledThisFrame;
entityManager.SetComponentData(aircraftEntity, acl);
// Example: serialization is handled by the game's save system, but custom usage:
using(var writer = new BinaryWriterAdapter(stream))
{
aircraftLane.Serialize(writer);
}