Game.AircraftLaneSpeedIterator
Assembly: Assembly-CSharp
Namespace: Game.Simulation
Type: struct AircraftLaneSpeedIterator
Base: System.ValueType
Summary:
Helper iterator used by aircraft simulation to walk along lane curves (and overlapping lanes) ahead of an aircraft and compute the maximum allowed travel speed given lane geometry, lane objects (other vehicles/objects), lane reservations, and braking distances. The iterator accumulates traveled distance, evaluates lane and overlap lane objects, and updates m_MaxSpeed, m_Blocker and m_BlockerType to indicate the limiting object (if any) and the reason for the speed limit. Intended for ground/low-level aircraft movement (taxiing, runway/ground interactions) and used by systems that simulate aircraft movement along lanes.
Fields
-
public ComponentLookup<Transform> m_TransformData
Component lookup to get world Transform for arbitrary Entities (used to compute distances to objects). -
public ComponentLookup<Moving> m_MovingData
Component lookup for Moving components (velocity data) used to determine object forward speed along the lane curve. -
public ComponentLookup<Aircraft> m_AircraftData
Component lookup for Aircraft components (used to detect other aircraft lane objects and apply special priority logic). -
public ComponentLookup<LaneReservation> m_LaneReservationData
Component lookup for lane reservations (priority/offset info used when evaluating overlapping lanes). -
public ComponentLookup<Curve> m_CurveData
Component lookup for curve data for a lane Entity (Bezier curve and length). -
public ComponentLookup<Game.Net.CarLane> m_CarLaneData
Component lookup for car-lane-specific data (used to derive drive speed limits for the type of lane). -
public ComponentLookup<PrefabRef> m_PrefabRefData
Component lookup to find the PrefabRef for an object Entity (used to obtain object prefab data). -
public ComponentLookup<ObjectGeometryData> m_PrefabObjectGeometryData
Component lookup for object geometry per prefab (bounds used to compute offsets and collision distances). -
public ComponentLookup<AircraftData> m_PrefabAircraftData
Component lookup for AircraftData of prefabs (used to compare braking/ground-braking characteristics of other aircraft/vehicles). -
public BufferLookup<LaneOverlap> m_LaneOverlapData
Buffer lookup of LaneOverlap buffers for lanes; used to find overlapping lanes and their overlap ranges/flags. -
public BufferLookup<LaneObject> m_LaneObjectData
Buffer lookup of LaneObject buffers for lanes; used to inspect objects present on a lane. -
public Entity m_Entity
The querying entity (the aircraft lane object doing the iteration). Used to ignore self when checking lane objects. -
public Entity m_Ignore
An entity to ignore in addition to m_Entity (commonly used to exclude another object from blocking checks). -
public int m_Priority
Priority value of the querying aircraft (used when comparing against other vehicles/overlaps/reservations). -
public float m_TimeStep
Simulation timestep used for dynamic calculations (e.g., braking when object speeds are considered). -
public float m_SafeTimeStep
A conservative timestep used to compute safe braking distances. -
public AircraftData m_PrefabAircraft
AircraftData of the querying aircraft prefab (braking, ground-braking and other aircraft-specific parameters used in VehicleUtils). -
public ObjectGeometryData m_PrefabObjectGeometry
Geometry data for the querying aircraft's prefab (bounds used for offsets). -
public Bounds1 m_SpeedRange
Allowed speed range [min, max] for clamping computed speeds. -
public float m_MaxSpeed
Current maximum allowed speed found by the iterator (it is updated downward when restrictions are found). -
public float m_CanChangeLane
Flag/value indicating lane change ability (present in struct but usage depends on calling code). -
public float3 m_CurrentPosition
Current world position along the curve being iterated (updated as the iterator advances). -
public float m_Distance
Accumulated distance traveled along the iterated path (used to compute braking distances). -
public Entity m_Blocker
Entity that currently limits speed (set by UpdateMaxSpeed when an object imposes a lower speed). -
public BlockerType m_BlockerType
Type of blocking (None, Limit, Continuing, Crossing, etc.) that describes the limiting reason. -
private Entity m_Lane
The lane Entity currently being inspected (private internal state). -
private Curve m_Curve
The Curve value for m_Lane (cached to avoid repeated ComponentLookup reads). -
private float2 m_CurveOffset
Cached offsets (start/end offset) along the curve for the current lane overlap/check context. -
private float3 m_PrevPosition
Previous saved position used to compute relative distances when objects move or for special distance adjustments. -
private float m_PrevDistance
Previous saved distance when m_PrevPosition was recorded.
Properties
- (none)
This struct exposes no managed properties; it uses public fields for setup and result retrieval.
Constructors
public AircraftLaneSpeedIterator()
Default (compiler-generated) value-type constructor. Typical usage is to instantiate, then fill the ComponentLookup/BufferLookup and parameter fields before iterating lanes.
Methods
-
public bool IterateFirstLane(Entity lane, float3 curveOffset)
Starts iteration on the given lane using a 3-component curveOffset (x = start offset, y = mid or check offset, z = end offset). Updates m_CurrentPosition and m_Distance from the lane's curve, evaluates the lane's car-lane speed limit and lane objects, and checks overlapping lanes. Updates m_MaxSpeed, m_Blocker and m_BlockerType as necessary. Returns true when iteration can stop early: either the accumulated distance exceeds the required braking distance (with a 20-unit margin) or m_MaxSpeed is already at the minimum speed in m_SpeedRange. -
public bool IterateNextLane(Entity lane, float2 curveOffset, float minOffset)
Continue iteration onto the next lane segment given a 2-component curveOffset and the minimum offset to consider. Evaluates car-lane speed limits, lane objects, and overlaps for the given lane. Advances m_CurrentPosition and m_Distance similarly to IterateFirstLane. Returns the same stop condition as IterateFirstLane (braking threshold reached or minimum speed reached). -
public void IterateTarget(float3 targetPosition)
Called when the iterator reaches a target position (e.g., end of path). Computes distance to the target, updates accumulated distance, and updates m_MaxSpeed (and blocker info) based on braking calculations toward that fixed target position. -
private void CheckCurrentLane(float distance, float2 minOffset)
Inspects the LaneObject buffer of the current lane (m_Lane) and checks lane objects that meet offset thresholds. For each relevant lane object it obtains object speed via GetObjectSpeed and calls UpdateMaxSpeed to potentially reduce m_MaxSpeed and set a blocker. -
private void CheckOverlappingLanes(float origDistance, float origMinOffset)
Iterates overlapping lanes (from m_Lane's LaneOverlap buffer). For each overlap it evaluates: - lane reservation offsets/priorities and applies braking constraints if a reservation or higher-priority reservation disallows passage,
- objects on the overlapping lane (m_LaneObjectData) and adjusts their perceived offset/position based on parallelism, priorities and object speed,
-
calls UpdateMaxSpeed for overlapping objects that may limit the querying aircraft. This method contains most of the complex logic handling merges, crossing, priority deltas, and how other vehicles influence braking requirements.
-
private float GetObjectSpeed(Entity obj, float curveOffset)
If the object has a Moving component, projects the object's velocity onto the tangent of the current curve at curveOffset to derive forward speed along the lane. Returns 0 if the object is not moving or has no Moving component. -
private void UpdateMaxSpeed(Entity obj, BlockerType blockerType, float objectSpeed, float laneOffset, float distanceFactor, float distanceOffset)
Core routine that computes the effective braking constraint imposed by a particular lane object (obj). Steps: - obtain the object prefab and geometry (bound offset),
- reject objects that are physically beyond the relevant z-bound offset,
- compute an effective distance (num2) from the querying aircraft to the object, adjusting for prior saved positions and perpendicular geometry,
- incorporate objectSpeed and the object's AircraftData (if any) to determine additional braking distance influence,
- compute the maximum braking speed the querying aircraft must adopt to avoid collision given the computed approach distance and safe timestep,
- clamp the computed speed to m_SpeedRange and, if it's lower than the current m_MaxSpeed, update m_MaxSpeed, m_Blocker and m_BlockerType appropriately. This method is where object motion, ground-braking comparisons, and different braking formulas are used to determine the limiting speed.
Usage Example
// Example (simplified): prepare iterator, set lookup fields and parameters, then iterate lanes
AircraftLaneSpeedIterator iter = new AircraftLaneSpeedIterator
{
m_TransformData = transformLookup, // ComponentLookup<Transform>
m_MovingData = movingLookup, // ComponentLookup<Moving>
m_AircraftData = aircraftLookup, // ComponentLookup<Aircraft>
m_LaneReservationData = reservationLookup, // ComponentLookup<LaneReservation>
m_CurveData = curveLookup, // ComponentLookup<Curve>
m_CarLaneData = carLaneLookup, // ComponentLookup<Game.Net.CarLane>
m_PrefabRefData = prefabRefLookup, // ComponentLookup<PrefabRef>
m_PrefabObjectGeometryData = geomLookup, // ComponentLookup<ObjectGeometryData>
m_PrefabAircraftData = prefabAircraftLookup, // ComponentLookup<AircraftData>
m_LaneOverlapData = overlapBufferLookup, // BufferLookup<LaneOverlap>
m_LaneObjectData = laneObjectBufferLookup, // BufferLookup<LaneObject>
m_Entity = myAircraftEntity,
m_Ignore = Entity.Null,
m_Priority = myPriority,
m_TimeStep = deltaTime,
m_SafeTimeStep = safeDeltaTime,
m_PrefabAircraft = myPrefabAircraftData,
m_PrefabObjectGeometry = myObjectGeometryData,
m_SpeedRange = new Bounds1(minSpeed, maxSpeed),
m_MaxSpeed = maxSpeed,
m_CurrentPosition = startPos,
m_Distance = 0f
};
// Start on first lane (example call)
if (iter.IterateFirstLane(firstLaneEntity, new float3(startOffset, midOffset, endOffset)))
{
// iteration indicates early stop condition (braking distance reached or min speed)
}
// Continue onto subsequent lanes using IterateNextLane(...) until route completed or Iterate* returns true
Notes and tips: - This iterator mutates its public fields (m_MaxSpeed, m_Blocker, m_BlockerType, m_CurrentPosition and m_Distance) as it runs; after iteration you should read those to determine the allowed speed and any blocking entity. - The struct expects ComponentLookup and BufferLookup instances prepared for the current system context (read permissions and safety; when used inside jobs ensure correct access mode). - BlockerType, LaneOverlap flags (OverlapFlags) and physics utilities (VehicleUtils, MathUtils) are external types used heavily by the iterator; refer to their docs for details on semantics (merge flags, priority semantics, braking formulas).