Пример #1
0
        public override void OnPrimaryMouseClicked(Event e)
        {
            if (!IsHoverPoint)
            {
                return;
            }

            if (!IsSelectPoint)
            {
                base.OnPrimaryMouseClicked(e);
            }
            else
            {
                var pointPair = new MarkupPointPair(SelectPoint, HoverPoint);

                if (Tool.Markup.TryGetLine(pointPair, out MarkupLine line))
                {
                    Tool.DeleteItem(line, () =>
                    {
                        Tool.Markup.RemoveLine(line);
                        Panel.UpdatePanel();
                    });
                }
                else
                {
                    var lineType = pointPair.IsStopLine ? NodeMarkupTool.GetStyle(StopLineStyle.StopLineType.Solid) : NodeMarkupTool.GetStyle(RegularLineStyle.RegularLineType.Dashed);
                    var newLine  = Tool.Markup.AddLine(pointPair, lineType);
                    Panel.EditLine(newLine);
                }

                SelectPoint = null;
                SetTarget();
            }
        }
Пример #2
0
        public override void OnPrimaryMouseClicked(Event e)
        {
            if (!IsHoverPoint)
            {
                return;
            }

            if (!IsSelectPoint)
            {
                base.OnPrimaryMouseClicked(e);
            }
            else
            {
                var pointPair = new MarkupPointPair(SelectPoint, HoverPoint);

                if (Tool.Markup.TryGetLine(pointPair, out MarkupLine line))
                {
                    Tool.DeleteItem(line, () =>
                    {
                        Tool.Markup.RemoveLine(line);
                        Panel.UpdatePanel();
                    });
                }
                else
                {
                    var newCrosswalkLine = Tool.Markup.AddLine(pointPair, NodeMarkupTool.GetStyle(CrosswalkStyle.CrosswalkType.Zebra)) as MarkupCrosswalkLine;
                    Panel.EditCrosswalk(newCrosswalkLine?.Crosswalk);
                }

                SelectPoint = null;
                SetTarget();
            }
        }
Пример #3
0
        private void RenderNormalConnectLine(RenderManager.CameraInfo cameraInfo)
        {
            var pointPair = new MarkupPointPair(SelectPoint, HoverPoint);
            var color     = Tool.Markup.ExistLine(pointPair) ? Colors.Red : Colors.Purple;

            var lineBezier = new Bezier3()
            {
                a = SelectPoint.Position,
                b = HoverPoint.Position,
                c = SelectPoint.Position,
                d = HoverPoint.Position,
            };

            NodeMarkupTool.RenderBezier(cameraInfo, lineBezier, color);

            var normal = SelectPoint.Direction.Turn90(false);

            var normalBezier = new Bezier3
            {
                a = SelectPoint.Position + SelectPoint.Direction,
                d = SelectPoint.Position + normal
            };

            normalBezier.b = normalBezier.a + normal / 2;
            normalBezier.c = normalBezier.d + SelectPoint.Direction / 2;
            NodeMarkupTool.RenderBezier(cameraInfo, normalBezier, color, 2f, cut: true);
        }
Пример #4
0
        protected override void Awake()
        {
            Mod.Logger.Debug($"Awake tool");
            base.Awake();

            Instance = this;
            Mod.Logger.Debug($"Tool Created");

            ToolModes = new Dictionary <ToolModeType, BaseToolMode>()
            {
                { ToolModeType.Select, Instance.CreateToolMode <SelectToolMode>() },
                { ToolModeType.MakeLine, Instance.CreateToolMode <MakeLineToolMode>() },
                { ToolModeType.MakeCrosswalk, Instance.CreateToolMode <MakeCrosswalkToolMode>() },
                { ToolModeType.MakeFiller, Instance.CreateToolMode <MakeFillerToolMode>() },
                { ToolModeType.DragPoint, Instance.CreateToolMode <DragPointToolMode>() },
                { ToolModeType.PasteEntersOrder, Instance.CreateToolMode <PasteEntersOrderToolMode>() },
                { ToolModeType.EditEntersOrder, Instance.CreateToolMode <EditEntersOrderToolMode>() },
                { ToolModeType.ApplyIntersectionTemplateOrder, Instance.CreateToolMode <ApplyIntersectionTemplateOrderToolMode>() },
                { ToolModeType.PointsOrder, Instance.CreateToolMode <PointsOrderToolMode>() },
            };

            NodeMarkupPanel.CreatePanel();

            enabled = false;
        }
Пример #5
0
        private void RenderConnectCrosswalkLine(RenderManager.CameraInfo cameraInfo)
        {
            var bezier    = new Line3(SelectPoint.Position, HoverPoint.Position).GetBezier();
            var pointPair = new MarkupPointPair(SelectPoint, HoverPoint);
            var color     = Tool.Markup.ExistLine(pointPair) ? Colors.Red : Colors.Green;

            NodeMarkupTool.RenderBezier(cameraInfo, bezier, color, MarkupCrosswalkPoint.Shift * 2, cut: true);
        }
Пример #6
0
        protected override void Reset(BaseToolMode prevMode)
        {
            NodeMarkupTool.GetCentreAndRadius(Markup, out Vector3 centre, out float radius);
            Centre = centre;
            Radius = radius;

            base.Reset(prevMode);
        }
Пример #7
0
 public static void Remove()
 {
     Mod.Logger.Debug($"Remove tool");
     if (Instance != null)
     {
         Destroy(Instance);
         Instance = null;
         Mod.Logger.Debug($"Tool removed");
     }
 }
Пример #8
0
 public static void Remove()
 {
     Logger.LogDebug($"{nameof(NodeMarkupTool)}.{nameof(Remove)}");
     if (Instance != null)
     {
         Destroy(Instance);
         Instance = null;
         Logger.LogDebug($"Tool removed");
     }
 }
Пример #9
0
        private void RenderNotConnectCrosswalkLine(RenderManager.CameraInfo cameraInfo)
        {
            var dir    = NodeMarkupTool.MouseWorldPosition - SelectPoint.Position;
            var lenght = dir.magnitude;

            dir.Normalize();
            var bezier = new Line3(SelectPoint.Position, SelectPoint.Position + dir * Mathf.Max(lenght, 1f)).GetBezier();

            NodeMarkupTool.RenderBezier(cameraInfo, bezier, Colors.White, MarkupCrosswalkPoint.Shift * 2, cut: true);
        }
Пример #10
0
 private string HoverInfo()
 {
     if (Contour.IsEmpty)
     {
         return(Localize.Tool_InfoFillerClickStart);
     }
     else if (Hover.Equals(Contour.First))
     {
         return(NodeMarkupTool.GetModifierToolTip <FillerStyle.FillerType>(Localize.Tool_InfoFillerClickEnd));
     }
     else
     {
         return(Localize.Tool_InfoFillerClickNext);
     }
 }
Пример #11
0
        private void RenderRegularConnectLine(RenderManager.CameraInfo cameraInfo)
        {
            var bezier = new Bezier3()
            {
                a = SelectPoint.Position,
                b = HoverPoint.Enter == SelectPoint.Enter ? HoverPoint.Position - SelectPoint.Position : SelectPoint.Direction,
                c = HoverPoint.Enter == SelectPoint.Enter ? SelectPoint.Position - HoverPoint.Position : HoverPoint.Direction,
                d = HoverPoint.Position,
            };

            var pointPair = new MarkupPointPair(SelectPoint, HoverPoint);
            var color     = Tool.Markup.ExistLine(pointPair) ? Colors.Red : Colors.Green;

            NetSegment.CalculateMiddlePoints(bezier.a, bezier.b, bezier.d, bezier.c, true, true, out bezier.b, out bezier.c);
            NodeMarkupTool.RenderBezier(cameraInfo, bezier, color);
        }
Пример #12
0
        private void RenderNotConnectLine(RenderManager.CameraInfo cameraInfo)
        {
            var bezier = new Bezier3()
            {
                a = SelectPoint.Position,
                b = SelectPoint.Direction,
                c = SelectPoint.Direction.Turn90(true),
                d = NodeMarkupTool.MouseWorldPosition,
            };

            Line2.Intersect(VectorUtils.XZ(bezier.a), VectorUtils.XZ(bezier.a + bezier.b), VectorUtils.XZ(bezier.d), VectorUtils.XZ(bezier.d + bezier.c), out _, out float v);
            bezier.c = v >= 0 ? bezier.c : -bezier.c;

            NetSegment.CalculateMiddlePoints(bezier.a, bezier.b, bezier.d, bezier.c, true, true, out bezier.b, out bezier.c);
            NodeMarkupTool.RenderBezier(cameraInfo, bezier, Colors.Hover);
        }
Пример #13
0
 public override void OnPrimaryMouseClicked(Event e)
 {
     if (IsHover)
     {
         if (Contour.Add(Hover))
         {
             var filler = new MarkupFiller(Contour, NodeMarkupTool.GetStyle(FillerStyle.FillerType.Stripe));
             Tool.Markup.AddFiller(filler);
             Panel.EditFiller(filler);
             Tool.SetDefaultMode();
             return;
         }
         DisableByAlt = false;
         GetFillerPoints();
     }
 }
Пример #14
0
 public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
 {
     if (IsHoverNode)
     {
         var node = Utilities.GetNode(HoverNodeId);
         NodeMarkupTool.RenderCircle(cameraInfo, node.m_position, Colors.Orange, Mathf.Max(6f, node.Info.m_halfWidth * 2f));
     }
     if (IsHoverSegment)
     {
         var segment = Utilities.GetSegment(HoverSegmentId);
         var bezier  = new Bezier3()
         {
             a = Utilities.GetNode(segment.m_startNode).m_position,
             d = Utilities.GetNode(segment.m_endNode).m_position,
         };
         NetSegment.CalculateMiddlePoints(bezier.a, segment.m_startDirection, bezier.d, segment.m_endDirection, true, true, out bezier.b, out bezier.c);
         NodeMarkupTool.RenderBezier(cameraInfo, bezier, Colors.Orange, segment.Info.m_halfWidth * 2);
     }
 }
Пример #15
0
        private void RenderFillerConnectLine(RenderManager.CameraInfo cameraInfo)
        {
            if (Contour.IsEmpty)
            {
                return;
            }

            if (IsHover)
            {
                var linePart = Contour.GetFillerLine(Contour.Last, Hover);
                if (linePart.GetTrajectory(out ITrajectory trajectory))
                {
                    trajectory.Render(cameraInfo, Colors.Green);
                }
            }
            else
            {
                var bezier = new Line3(Contour.Last.Position, NodeMarkupTool.MouseWorldPosition).GetBezier();
                NodeMarkupTool.RenderBezier(cameraInfo, bezier, Colors.Hover);
            }
        }
Пример #16
0
        public override string GetToolInfo()
        {
            var pointPair = new MarkupPointPair(SelectPoint, HoverPoint);
            var exist     = Tool.Markup.ExistLine(pointPair);

            if (pointPair.IsStopLine)
            {
                return(exist ? Localize.Tool_InfoDeleteStopLine : NodeMarkupTool.GetModifierToolTip <StopLineStyle.StopLineType>(Localize.Tool_InfoCreateStopLine));
            }
            else if (pointPair.IsCrosswalk)
            {
                return(exist ? Localize.Tool_InfoDeleteCrosswalk : NodeMarkupTool.GetModifierToolTip <CrosswalkStyle.CrosswalkType>(Localize.Tool_InfoCreateCrosswalk));
            }
            else if (pointPair.IsNormal)
            {
                return(exist ? Localize.Tool_InfoDeleteNormalLine : NodeMarkupTool.GetModifierToolTip <RegularLineStyle.RegularLineType>(Localize.Tool_InfoCreateNormalLine));
            }
            else
            {
                return(exist ? Localize.Tool_InfoDeleteLine : NodeMarkupTool.GetModifierToolTip <RegularLineStyle.RegularLineType>(Localize.Tool_InfoCreateLine));
            }
        }
Пример #17
0
        public override void OnToolUpdate()
        {
            if (NodeMarkupTool.MouseRayValid)
            {
                RaycastInput input = new RaycastInput(NodeMarkupTool.MouseRay, Camera.main.farClipPlane)
                {
                    m_ignoreTerrain      = true,
                    m_ignoreNodeFlags    = NetNode.Flags.None,
                    m_ignoreSegmentFlags = JustFun ? NetSegment.Flags.None : NetSegment.Flags.All
                };
                input.m_netService.m_itemLayers = (ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels);
                input.m_netService.m_service    = ItemClass.Service.Road;

                if (NodeMarkupTool.RayCast(input, out RaycastOutput output))
                {
                    HoverNodeId    = output.m_netNode;
                    HoverSegmentId = output.m_netSegment;
                    return;
                }
            }

            HoverNodeId    = 0;
            HoverSegmentId = 0;
        }
Пример #18
0
        private bool GetRayCast(ItemClass.Service service, ItemClass.SubService subService = ItemClass.SubService.None)
        {
            RaycastInput input = new RaycastInput(NodeMarkupTool.MouseRay, Camera.main.farClipPlane)
            {
                m_ignoreTerrain      = true,
                m_ignoreNodeFlags    = InputExtension.OnlyShiftIsPressed ? NetNode.Flags.All : NetNode.Flags.None,
                m_ignoreSegmentFlags = NetSegment.Flags.None,
            };

            input.m_netService.m_itemLayers = (ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels);
            input.m_netService.m_service    = service;
            input.m_netService.m_subService = subService;

            if (NodeMarkupTool.RayCast(input, out RaycastOutput output))
            {
                HoverNodeId    = output.m_netNode;
                HoverSegmentId = output.m_netSegment;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #19
0
 protected override void RenderOverlayAfterBaskets(RenderManager.CameraInfo cameraInfo)
 => NodeMarkupTool.RenderCircle(cameraInfo, Centre, width: Radius * 2);