public static void FullUpdateAllRoadJunctions() { Log.Called(); for (ushort nodeID = 0; nodeID < NetManager.MAX_NODE_COUNT; ++nodeID) { if (!NetUtil.IsNodeValid(nodeID)) { continue; } if (!nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction)) { continue; } if (!nodeID.ToNode().Info.IsRoad()) { continue; } NetManager.instance.UpdateNode(nodeID); } }
public static void UpdateAllNetworkRenderers() { Log.Called(); for (ushort nodeID = 0; nodeID < NetManager.MAX_NODE_COUNT; ++nodeID) { if (!NetUtil.IsNodeValid(nodeID)) { continue; } if (!nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction)) { continue; } NetManager.instance.UpdateNodeRenderer(nodeID, true); foreach (ushort segmentID in NetUtil.IterateNodeSegments(nodeID)) { NetManager.instance.UpdateSegmentRenderer(segmentID, true); } } }
public static void UpdateAllNodes() { Log.Called(); for (ushort nodeID = 0; nodeID < NetManager.MAX_NODE_COUNT; ++nodeID) { if (!NetUtil.IsNodeValid(nodeID)) { continue; } if (!nodeID.ToNode().Info.m_requireDirectRenderers) { continue; } if (!nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction)) { continue; } NetManager.instance.UpdateNodeRenderer(nodeID, true); } }
/// <summary> /// Determines if there is any lane connection from source lane to target segment. /// </summary> public static bool IsLaneConnectedToSegment(LaneData sourceLane, ushort targetSegmentID) { ushort sourceSegmentID = sourceLane.SegmentID; ushort nodeID = sourceSegmentID.ToSegment().GetSharedNode(targetSegmentID); bool sourceStartNode = NetUtil.IsStartNode(sourceSegmentID, nodeID); bool targetStartNode = NetUtil.IsStartNode(targetSegmentID, nodeID); var targetLanes = NetUtil.IterateLanes( targetSegmentID, !targetStartNode,// going away from start node. LaneConnectionManager.LANE_TYPES, LaneConnectionManager.VEHICLE_TYPES); foreach (LaneData targetLane in targetLanes) { if (LaneConnectionManager.Instance.AreLanesConnected(sourceLane.LaneID, targetLane.LaneID, sourceStartNode)) { return(true); } } return(false); }
public static void UpdateAllNodeRenderers() { try { Log.Called(); for (ushort nodeID = 0; nodeID < NetManager.MAX_NODE_COUNT; ++nodeID) { if (!NetUtil.IsNodeValid(nodeID)) { continue; } if (!nodeID.ToNode().Info.IsRoad()) { continue; } if (!nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction)) { continue; } NetManager.instance.UpdateNodeRenderer(nodeID, true); } } catch (Exception ex) { ex.Log(); } }
/// <summary> /// Determines if any lane from source segment goes to the target segment /// based on lane arrows and lane connections. public static bool DoesSegmentGoToSegment(ushort sourceSegmentID, ushort targetSegmentID, ushort nodeID) { bool startNode = NetUtil.IsStartNode(sourceSegmentID, nodeID); if (sourceSegmentID == targetSegmentID) { return(TMPE.JunctionRestrictionsManager.IsUturnAllowed(sourceSegmentID, startNode)); } ArrowDirection arrowDir = TMPE.ExtSegmentEndManager.GetDirection(sourceSegmentID, targetSegmentID, nodeID); LaneArrows arrow = ArrowDir2LaneArrows(arrowDir); var sourceLanes = new LaneDataIterator( sourceSegmentID, startNode, TMPE.LaneArrowManager.LaneTypes, TMPE.LaneArrowManager.VehicleTypes); //Log.Debug("DoesSegmentGoToSegment: sourceLanes=" + sourceLanes.ToSTR()); foreach (LaneData sourceLane in sourceLanes) { bool connected; if (TMPE.LaneConnectionManager.HasConnections(sourceLane.LaneID, startNode)) { connected = IsLaneConnectedToSegment(sourceLane.LaneID, targetSegmentID); //Log.Debug($"IsLaneConnectedToSegment({sourceLane},{targetSegmentID}) = {connected}"); } else { LaneArrows arrows = TMPE.LaneArrowManager.GetFinalLaneArrows(sourceLane.LaneID); connected = (arrows & arrow) != 0; } if (connected) { return(true); } } return(false); }
/// <summary> /// Determines if there is any lane connection from source lane to target segment. /// </summary> public static bool IsLaneConnectedToSegment(uint sourceLaneId, ushort targetSegmentID) { ushort sourceSegmentID = sourceLaneId.ToLane().m_segment; ushort nodeID = sourceSegmentID.ToSegment().GetSharedNode(targetSegmentID); bool sourceStartNode = NetUtil.IsStartNode(sourceSegmentID, nodeID); bool targetStartNode = NetUtil.IsStartNode(targetSegmentID, nodeID); var targetLanes = new LaneDataIterator( targetSegmentID, !targetStartNode,// going away from start node. TMPE.LaneConnectionManager.LaneTypes, TMPE.LaneConnectionManager.VehicleTypes); foreach (LaneData targetLane in targetLanes) { if (TMPE.LaneConnectionManager.AreLanesConnected(sourceLaneId, targetLane.LaneID, sourceStartNode)) { return(true); } } return(false); }
/// <summary> /// Determines if any lane from source segment goes to the target segment /// based on lane arrows and lane connections. public static bool DoesSegmentGoToSegment(ushort sourceSegmentID, ushort targetSegmentID, ushort nodeID) { bool startNode = NetUtil.IsStartNode(sourceSegmentID, nodeID); if (sourceSegmentID == targetSegmentID) { return(JunctionRestrictionsManager.Instance.IsUturnAllowed(sourceSegmentID, startNode)); } ArrowDirection arrowDir = ExtSegmentEndManager.Instance.GetDirection(sourceSegmentID, targetSegmentID, nodeID); LaneArrows arrow = ArrowDir2LaneArrows(arrowDir); var sourceLanes = NetUtil.IterateLanes( sourceSegmentID, startNode, LaneArrowManager.LANE_TYPES, LaneArrowManager.VEHICLE_TYPES); foreach (LaneData sourceLane in sourceLanes) { bool connected; if (LaneConnectionManager.Instance.HasConnections(sourceLane.LaneID, startNode)) { connected = IsLaneConnectedToSegment(sourceLane, targetSegmentID); //Log.Debug($"IsLaneConnectedToSegment({sourceLane},{targetSegmentID}) = {connected}"); } else { LaneArrows arrows = LaneArrowManager.Instance.GetFinalLaneArrows(sourceLane.LaneID); connected = arrows.IsFlagSet(arrow); } if (connected) { return(true); } } return(false); }