private static string GetDistrictAt(ComparableRoad refer) { string sourceDistrict; NetNode node = NetManager.instance.m_nodes.m_buffer[refer.nodeReference]; LogUtils.DoLog($"[Node {refer.nodeReference}] Flags => " + NetManager.instance.m_nodes.m_buffer[refer.nodeReference].m_flags); if ((NetManager.instance.m_nodes.m_buffer[refer.nodeReference].m_flags & NetNode.Flags.Outside) != 0) { float angle = Vector2.zero.GetAngleToPoint(VectorUtils.XZ(node.m_position)); LogUtils.DoLog($"[Node {refer.nodeReference}] angle => {angle}, pos => {node.m_position} "); sourceDistrict = OutsideConnectionAIOverrides.GetNameBasedInAngle(angle, out _); } else { int districtId = Singleton <DistrictManager> .instance.GetDistrict(node.m_position); if (districtId == 0) { sourceDistrict = SimulationManager.instance.m_metaData.m_CityName; } else { sourceDistrict = DistrictManager.instance.GetDistrictName(districtId); } } return(sourceDistrict); }
public static byte GetCardinalDirection(ComparableRoad startRef, ComparableRoad endRef) { NetNode nodeS = NetManager.instance.m_nodes.m_buffer[startRef.nodeReference]; NetNode nodeE = NetManager.instance.m_nodes.m_buffer[endRef.nodeReference]; byte cardinalDirection = CardinalPoint.GetCardinalPoint(VectorUtils.XZ(nodeS.m_position).GetAngleToPoint(VectorUtils.XZ(nodeE.m_position))).GetCardinalIndex8(); return(cardinalDirection); }
public static IEnumerable <Tuple <ushort, float> > GetSegmentRoadEdges(ushort segmentId, bool requireSameDirection, bool requireSameSizeAndType, bool localAdjust, out ComparableRoad startRef, out ComparableRoad endRef, out ushort[] nodes) { List <ushort> accessSegments = GetSegmentOrderRoad(segmentId, requireSameDirection, requireSameSizeAndType, localAdjust, out bool nodeStartS, out bool nodeStartE, out nodes); if (accessSegments == null) { startRef = default; endRef = default; return(null); } //doLog($"[{segmentId}-> sd {requireSameDirection} rsst {requireSameSizeAndType} la {localAdjust}] segs = [{string.Join(",", accessSegments.Select(x => x.ToString()).ToArray())}]; start={nodeStartS}; end={nodeStartE}"); startRef = new ComparableRoad(accessSegments[0], nodeStartS); endRef = new ComparableRoad(accessSegments[accessSegments.Count - 1], nodeStartE); return(accessSegments.Select(x => Tuple.New(x, NetManager.instance.m_segments.m_buffer[x].m_averageLength))); }
public int CompareTo(ComparableRoad otherRoad) { int result = 0; if (otherRoad.isHighway != isHighway) { result = isHighway ? 1 : -1; } if (otherRoad.isPassing != isPassing) { result = isPassing ? 1 : -1; } if (otherRoad.width != width) { result = otherRoad.width < width ? 1 : -1; } if (otherRoad.lanes != lanes) { result = otherRoad.lanes < lanes ? 1 : -1; } LogUtils.DoLog($"cmp: {this} & {otherRoad} => {result}"); return(result); }
public RoadIdentifier(ComparableRoad start, ComparableRoad end, ushort[] segments) { this.start = start; this.end = end; this.segments = segments; }