public bool UpdateSegmentEnd(ushort segmentId, bool startNode) { SegmentGeometry segGeo = SegmentGeometry.Get(segmentId); if (segGeo == null) { #if DEBUGGEO Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Segment {segmentId} is invalid. Removing all segment ends."); #endif RemoveSegmentEnds(segmentId); return(false); } SegmentEndGeometry endGeo = segGeo.GetEnd(startNode); if (endGeo == null) { Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Segment end {segmentId} @ {startNode} is invalid. Removing segment end."); RemoveSegmentEnd(segmentId, startNode); return(false); } if (TrafficPriorityManager.Instance.HasSegmentPrioritySign(segmentId, startNode) || TrafficLightSimulationManager.Instance.HasTimedSimulation(endGeo.NodeId())) { Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Segment {segmentId} @ {startNode} has timed light or priority sign. Adding segment end {segmentId} @ {startNode}"); ISegmentEnd end = GetOrAddSegmentEnd(segmentId, startNode); if (end == null) { Log.Warning($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Failed to add segment end."); return(false); } else { Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Added segment end. Updating now."); end.Update(); Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Update of segment end finished."); return(true); } } else { #if DEBUGGEO Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Segment {segmentId} @ {startNode} neither has timed light nor priority sign. Removing segment end {segmentId} @ {startNode}"); #endif RemoveSegmentEnd(segmentId, startNode); return(false); } }
public bool UpdateSegmentEnd(ushort segmentId, bool startNode) { #if DEBUG bool logPriority = DebugSwitch.PriorityRules.Get() && (DebugSettings.SegmentId <= 0 || segmentId == DebugSettings.SegmentId); #else const bool logPriority = false; #endif if (!Services.NetService.IsSegmentValid(segmentId)) { if (logPriority) { Log._Debug( $"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): Segment " + $"{segmentId} is invalid. Removing all segment ends."); } RemoveSegmentEnds(segmentId); return(false); } if (TrafficPriorityManager.Instance.HasSegmentPrioritySign(segmentId, startNode) || TrafficLightSimulationManager.Instance.HasTimedSimulation( Services.NetService.GetSegmentNodeId( segmentId, startNode))) { if (logPriority) { Log._DebugFormat( "SegmentEndManager.UpdateSegmentEnd({0}, {1}): Segment {2} @ {3} has timed " + "light or priority sign. Adding segment end {4} @ {5}", segmentId, startNode, segmentId, startNode, segmentId, startNode); } ISegmentEnd end = GetOrAddSegmentEnd(segmentId, startNode); if (end == null) { Log.Warning($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): " + "Failed to add segment end."); return(false); } if (logPriority) { Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): " + "Added segment end. Updating now."); } end.Update(); if (logPriority) { Log._Debug($"SegmentEndManager.UpdateSegmentEnd({segmentId}, {startNode}): " + "Update of segment end finished."); } return(true); } else { if (logPriority) { Log._DebugFormat( "SegmentEndManager.UpdateSegmentEnd({0}, {1}): Segment {2} @ {3} neither has " + "timed light nor priority sign. Removing segment end {4} @ {5}", segmentId, startNode, segmentId, startNode, segmentId, startNode); } RemoveSegmentEnd(segmentId, startNode); return(false); } }