protected override void OnPrimaryMouseClicked() { if (!HoverValid) { return; } Log.Info($"OnPrimaryMouseClicked: segment {HoveredSegmentId} node {HoveredNodeId}"); if (RoundaboutUtil.Instance_Click.TraverseLoop(HoveredSegmentId, out var segList)) { Singleton <SimulationManager> .instance.AddAction(delegate() { RaboutWraper.Create(RoundaboutUtil.Instance_Click); }); } else if (IsSuitableRoadForRoadBridge()) { Singleton <SimulationManager> .instance.AddAction(delegate() { RoadBridgeWrapper.Create(HoveredSegmentId, HitPos); }); } else if (IsSuitableJunction()) { Singleton <SimulationManager> .instance.AddAction(delegate() { JunctionWrapper.Create(HoveredNodeId); }); } else { Singleton <SimulationManager> .instance.AddAction(delegate() { PathConnectWrapper.Create(HoveredNodeId, HoveredSegmentId); }); } }
public override void RenderOverlay(RenderManager.CameraInfo cameraInfo) { base.RenderOverlay(cameraInfo); if (!HoverValid) { return; } //Log.Debug($"HoveredSegmentId={HoveredSegmentId} HoveredNodeId={HoveredNodeId} HitPos={HitPos}"); //if (Input.GetKey(KeyCode.LeftAlt)) { // var b = HoveredSegmentId.ToSegment().CalculateSegmentBezier3(); // float hw = HoveredSegmentId.ToSegment().Info.m_halfWidth; // var b2d = b.ToCSBezier2(); // var b1 = b2d.CalculateParallelBezier(hw * 2, false).TOCSBezier3(); // var b2 = b2d.CalculateParallelBezier(hw * 2, true).TOCSBezier3(); // b = b2d.TOCSBezier3(); // b.Render(cameraInfo, Color.green, hw); // b1.Render(cameraInfo, Color.blue, hw); // b2.Render(cameraInfo, Color.blue, hw); // DrawOverlayCircle(cameraInfo, Color.red, HitPos, 1, true); // return; //} Color color = Color.yellow;// GetToolColor(Input.GetMouseButton(0), false); if (RoundaboutUtil.Instance_render.TraverseLoop(HoveredSegmentId, out var segList)) { foreach (var segmentID in segList) { NetTool.RenderOverlay(cameraInfo, ref segmentID.ToSegment(), color, color); } } else if (IsSuitableRoadForRoadBridge()) { RoadBridgeWrapper.RenderOverlay(cameraInfo, color, HoveredSegmentId, HitPos); } else if (IsSuitableJunction()) { foreach (var segmentID in NetUtil.GetCCSegList(HoveredNodeId)) { NetTool.RenderOverlay(cameraInfo, ref segmentID.ToSegment(), color, color); } } else { bool cached = _cachedPathConnectWrapper != null && _cachedPathConnectWrapper?.endSegmentID == HoveredSegmentId && _cachedPathConnectWrapper?.endNodeID == HoveredNodeId; _cachedPathConnectWrapper = cached ? _cachedPathConnectWrapper : new PathConnectWrapper(HoveredNodeId, HoveredSegmentId); _cachedPathConnectWrapper?.RenderOverlay(cameraInfo); } DrawOverlayCircle(cameraInfo, Color.red, HitPos, 1, true); if (Input.GetKey(KeyCode.LeftAlt)) { RenderGrids(cameraInfo, m_mousePosition, Color.black); } }