public static IEnumerable <LaneData> IterateSegmentLanes(SegmentData segData) { int idx = 0; if (segData.Segment.Info == null) { Log.Error("null info: potentially caused by missing assets"); yield break; } int n = segData.Segment.Info.m_lanes.Length; for (uint laneID = segData.Segment.m_lanes; laneID != 0 && idx < n; laneID = laneID.ToLane().m_nextLane, idx++) { var ret = new LaneData(segData.SegmentID) { LaneID = laneID, Index = idx, Position = segData.SegmentID.ToSegment().Info.m_lanes[idx].m_position, Width = segData.SegmentID.ToSegment().Info.m_lanes[idx].m_width, }; yield return(ret); } }
internal static SegmentData GetSegmentData(ushort segmentID) { if (segmentID == 0) { return(new SegmentData { Lanes = { }, }); } var seg = new SegmentData { SegmentID = segmentID, StartNode = (segmentID.ToSegment().Info.m_lanes[0].m_finalDirection == NetInfo.Direction.Forward), Lanes = new List <LaneData> { }, }; foreach (var laneData in IterateSegmentLanes(seg)) { seg.Lanes.Add(laneData); } return(seg); throw new Exception("Unreachable code"); }