Ejemplo n.º 1
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (MainTool.GetToolController().IsInsideUI || !Cursor.visible)
            {
                return;
            }

            if (HoveredNodeId == 0)
            {
                return;
            }

            if (!Flags.mayHaveTrafficLight(HoveredNodeId))
            {
                return;
            }

            var segment = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_segment0];

            Bezier3 bezier;

            bezier.a = Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_position;
            bezier.d = Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_position;

            var color = MainTool.GetToolColor(Input.GetMouseButton(0), false);

            NetSegment.CalculateMiddlePoints(bezier.a, segment.m_startDirection, bezier.d,
                                             segment.m_endDirection,
                                             false, false, out bezier.b, out bezier.c);

            MainTool.DrawOverlayBezier(cameraInfo, bezier, color);
        }
Ejemplo n.º 2
0
        private int RenderSegmentSideOverlay(
            RenderManager.CameraInfo cameraInfo,
            ushort segmentId,
            NetInfo.Direction finalDirection)
        {
            int   count   = 0;
            bool  pressed = Input.GetMouseButton(0);
            Color color   = MainTool.GetToolColor(pressed, false);

            netService.IterateSegmentLanes(
                segmentId,
                (uint laneId,
                 ref NetLane lane,
                 NetInfo.Lane laneInfo,
                 ushort _,
                 ref NetSegment segment,
                 byte laneIndex) => {
                bool render = (laneInfo.m_laneType & SpeedLimitManager.LANE_TYPES) != 0;
                render     &= (laneInfo.m_vehicleType & SpeedLimitManager.VEHICLE_TYPES) != 0;
                render     &= laneInfo.m_finalDirection == finalDirection;
                if (render)
                {
                    RenderLaneOverlay(cameraInfo, laneId);
                    count++;
                }
                return(true);
            });
            return(count);
        }
Ejemplo n.º 3
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            // Log._Debug($"Restrictions overlay {_cursorInSecondaryPanel} {HoveredNodeId} {SelectedNodeId} {HoveredSegmentId} {SelectedSegmentId}");

            if (SelectedSegmentId != 0)
            {
                NetTool.RenderOverlay(
                    cameraInfo,
                    ref Singleton <NetManager> .instance.m_segments.m_buffer[SelectedSegmentId],
                    MainTool.GetToolColor(true, false),
                    MainTool.GetToolColor(true, false));
            }

            if (cursorInSecondaryPanel)
            {
                return;
            }

            if (HoveredSegmentId != 0 && HoveredSegmentId != SelectedSegmentId &&
                !overlayHandleHovered)
            {
                NetTool.RenderOverlay(
                    cameraInfo,
                    ref Singleton <NetManager> .instance.m_segments.m_buffer[HoveredSegmentId],
                    MainTool.GetToolColor(false, false),
                    MainTool.GetToolColor(false, false));
            }
        }
Ejemplo n.º 4
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (MainTool.GetToolController().IsInsideUI || !Cursor.visible)
            {
                return;
            }

            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                // draw hovered segments
                if (HoveredSegmentId != 0)
                {
                    Color color = MainTool.GetToolColor(Input.GetMouseButton(0), false);
                    SegmentTraverser.Traverse(
                        HoveredSegmentId,
                        TraverseDirection.AnyDirection,
                        TraverseSide.Straight,
                        SegmentStopCriterion.None,
                        data => {
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref Singleton <NetManager> .instance.m_segments.m_buffer[
                                data.CurSeg.segmentId],
                            color,
                            color);
                        return(true);
                    });
                }
                else
                {
                    massEditMode = PrioritySignsMassEditMode.MainYield;
                }

                return;
            }

            massEditMode = PrioritySignsMassEditMode.MainYield;

            if (HoveredNodeId == SelectedNodeId)
            {
                return;
            }

            // no highlight for existing priority node in sign mode
            if (TrafficPriorityManager.Instance.HasNodePrioritySign(HoveredNodeId))
            {
                // Log._Debug($"PrioritySignsTool.RenderOverlay: HasNodePrioritySign({HoveredNodeId})=true");
                return;
            }

            if (!TrafficPriorityManager.Instance.MayNodeHavePrioritySigns(HoveredNodeId))
            {
                // Log._Debug($"PrioritySignsTool.RenderOverlay: MayNodeHavePrioritySigns({HoveredNodeId})=false");
                return;
            }

            MainTool.DrawNodeCircle(cameraInfo, HoveredNodeId, Input.GetMouseButton(0));
        }
Ejemplo n.º 5
0
        private void RenderLaneOverlay(RenderManager.CameraInfo cameraInfo, uint laneId)
        {
            var   marker  = new SegmentLaneMarker(laneBuffer[laneId].m_bezier);
            bool  pressed = Input.GetMouseButton(0);
            Color color   = MainTool.GetToolColor(pressed, false);

            if (!ShowLimitsPerLane)
            {
                marker.Size = 3f; // lump the lanes together.
            }
            marker.RenderOverlay(cameraInfo, color, pressed);
        }
Ejemplo n.º 6
0
        private void RenderRoadParkings(RenderManager.CameraInfo cameraInfo)
        {
            NetLane[] laneBuffer = NetManager.instance.m_lanes.m_buffer;
            bool LaneVisitor(SegmentLaneVisitData data)
            {
                ushort segmentId = data.SegVisitData.CurSeg.segmentId;
                int    laneIndex = data.CurLanePos.laneIndex;

                NetInfo.Lane laneInfo = segmentId.ToSegment().Info.m_lanes[laneIndex];

                NetInfo.Direction finalDirection = laneInfo.m_finalDirection;

                if (!data.SegVisitData.Initial)
                {
                    bool reverse =
                        data.SegVisitData.ViaStartNode ==
                        data.SegVisitData.ViaInitialStartNode;

                    bool invert1 = segmentId.ToSegment().m_flags.IsFlagSet(NetSegment.Flags.Invert);
                    bool invert2 = renderInfo_.SegmentId.ToSegment().m_flags.IsFlagSet(NetSegment.Flags.Invert);
                    bool invert  = invert1 != invert2;

                    if (reverse ^ invert)
                    {
                        finalDirection = NetInfo.InvertDirection(finalDirection);
                    }
                }
                if (finalDirection == renderInfo_.FinalDirection)
                {
                    bool  pressed     = Input.GetMouseButton(0);
                    Color color       = MainTool.GetToolColor(pressed, false);
                    uint  otherLaneId = data.CurLanePos.laneId;
                    var   laneMarker  = new SegmentLaneMarker(laneBuffer[otherLaneId].m_bezier);
                    laneMarker.RenderOverlay(cameraInfo, color, enlarge: pressed);
                }

                return(true);
            }

            SegmentLaneTraverser.Traverse(
                renderInfo_.SegmentId,
                SegmentTraverser.TraverseDirection.AnyDirection,
                SegmentTraverser.TraverseSide.AnySide,
                SegmentLaneTraverser.LaneStopCriterion.LaneCount,
                SegmentTraverser.SegmentStopCriterion.Junction,
                ParkingRestrictionsManager.LANE_TYPES,
                ParkingRestrictionsManager.VEHICLE_TYPES,
                LaneVisitor);
        }
        private void RenderManualSelectionOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (HoveredNodeId == 0)
            {
                return;
            }
            var segment = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_segment0];

            //if ((node.m_flags & NetNode.Flags.TrafficLights) == NetNode.Flags.None) return;
            Bezier3 bezier;

            bezier.a = Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_position;
            bezier.d = Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_position;

            var color = MainTool.GetToolColor(false, false);

            NetSegment.CalculateMiddlePoints(bezier.a, segment.m_startDirection, bezier.d,
                                             segment.m_endDirection, false, false, out bezier.b, out bezier.c);
            MainTool.DrawOverlayBezier(cameraInfo, bezier, color);
        }
Ejemplo n.º 8
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            //Log._Debug($"LaneArrow Overlay: {HoveredNodeId} {HoveredSegmentId} {SelectedNodeId} {SelectedSegmentId}");
            if (!_cursorInSecondaryPanel && HoveredSegmentId != 0 && HoveredNodeId != 0 && (HoveredSegmentId != SelectedSegmentId || HoveredNodeId != SelectedNodeId))
            {
                var netFlags = Singleton <NetManager> .instance.m_nodes.m_buffer[HoveredNodeId].m_flags;

                if ((netFlags & NetNode.Flags.Junction) != NetNode.Flags.None)
                {
                    NetTool.RenderOverlay(cameraInfo, ref Singleton <NetManager> .instance.m_segments.m_buffer[HoveredSegmentId], MainTool.GetToolColor(false, false),
                                          MainTool.GetToolColor(false, false));
                }
            }

            if (SelectedSegmentId == 0)
            {
                return;
            }

            NetTool.RenderOverlay(cameraInfo, ref Singleton <NetManager> .instance.m_segments.m_buffer[SelectedSegmentId], MainTool.GetToolColor(true, false), MainTool.GetToolColor(true, false));
        }
Ejemplo n.º 9
0
        private void RenderSegmentParkings(RenderManager.CameraInfo cameraInfo)
        {
            bool  allowed = parkingManager.IsParkingAllowed(renderInfo_.SegmentId, renderInfo_.FinalDirection);
            bool  pressed = Input.GetMouseButton(0);
            Color color;

            if (pressed)
            {
                color = MainTool.GetToolColor(true, false);
            }
            else if (allowed)
            {
                color = Color.green;
            }
            else
            {
                color = Color.red;
            }

            Bezier3        bezier  = default;
            ref NetSegment segment = ref renderInfo_.SegmentId.ToSegment();
Ejemplo n.º 10
0
        private void RenderSegmentParkings(RenderManager.CameraInfo cameraInfo)
        {
            bool  allowed = parkingManager.IsParkingAllowed(renderInfo_.SegmentId, renderInfo_.FinalDirection);
            bool  pressed = Input.GetMouseButton(0);
            Color color;

            if (pressed)
            {
                color = MainTool.GetToolColor(true, false);
            }
            else if (allowed)
            {
                color = Color.green;
            }
            else
            {
                color = Color.red;
            }

            Bezier3 bezier = default;

            netService.IterateSegmentLanes(
                renderInfo_.SegmentId,
                (uint laneId,
                 ref NetLane lane,
                 NetInfo.Lane laneInfo,
                 ushort _,
                 ref NetSegment segment,
                 byte laneIndex) => {
                bool isParking = laneInfo.m_laneType.IsFlagSet(NetInfo.LaneType.Parking);
                if (isParking && laneInfo.m_finalDirection == renderInfo_.FinalDirection)
                {
                    bezier      = lane.m_bezier;
                    laneMarker_ = new SegmentLaneMarker(bezier);
                    laneMarker_.RenderOverlay(cameraInfo, color, enlarge: pressed);
                }
                return(true);
            });
        }
Ejemplo n.º 11
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            // Log._Debug($"Restrictions overlay {_cursorInSecondaryPanel} {HoveredNodeId} {SelectedNodeId} {HoveredSegmentId} {SelectedSegmentId}");
            if (SelectedSegmentId != 0)
            {
                Color color = MainTool.GetToolColor(true, false);
                // continues lane highlight requires lane alphaBlend == false.
                // for such lane highlight to be on the top of segment highlight,
                // the alphaBlend of segment highlight needs to be true.
                TrafficManagerTool.DrawSegmentOverlay(cameraInfo, SelectedSegmentId, color, true);

                if (overlayHandleHovered)
                {
                    if (RoadMode)
                    {
                        RenderRoadLane(cameraInfo);
                    }
                    else
                    {
                        RenderLaneOverlay(cameraInfo, renderData_.laneId);
                    }
                }
            }

            if (cursorInSecondaryPanel)
            {
                return;
            }

            if (HoveredSegmentId != 0 && HoveredSegmentId != SelectedSegmentId &&
                !overlayHandleHovered)
            {
                NetTool.RenderOverlay(
                    cameraInfo,
                    ref Singleton <NetManager> .instance.m_segments.m_buffer[HoveredSegmentId],
                    MainTool.GetToolColor(false, false),
                    MainTool.GetToolColor(false, false));
            }
        }
Ejemplo n.º 12
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (MainTool.GetToolController().IsInsideUI || !Cursor.visible)
            {
                return;
            }

            bool ctrlDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
            bool shiftDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

            MassEditOVerlay.Show = ctrlDown;

            if (ctrlDown)
            {
                massEditMode = PrioritySignsMassEditMode.MainYield;
            }

            if (HoveredSegmentId == 0)
            {
                if (shiftDown)
                {
                    massEditMode = PrioritySignsMassEditMode.MainYield;
                }
                return;
            }

            if (shiftDown)
            {
                bool  isRAbout = RoundaboutMassEdit.Instance.TraverseLoop(HoveredSegmentId, out var segmentList);
                Color color    = MainTool.GetToolColor(Input.GetMouseButton(0), false);
                if (isRAbout)
                {
                    foreach (uint segmentId in segmentList)
                    {
                        ref NetSegment seg = ref Singleton <NetManager> .instance.m_segments.m_buffer[segmentId];
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref seg,
                            color,
                            color);
                    } // end foreach
                }
                else
                {
                    SegmentTraverser.Traverse(
                        HoveredSegmentId,
                        TraverseDirection.AnyDirection,
                        TraverseSide.Straight,
                        SegmentStopCriterion.None,
                        data => {
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref Singleton <NetManager> .instance.m_segments.m_buffer[
                                data.CurSeg.segmentId],
                            color,
                            color);
                        return(true);
                    });
                }
                return;
            }
Ejemplo n.º 13
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (MainTool.GetToolController().IsInsideUI || !Cursor.visible)
            {
                return;
            }

            ModifyMode mode = ModifyMode.None;

            MassEditOverlay.Show = ControlIsPressed;

            if (HoveredSegmentId == 0)
            {
                massEditMode = PrioritySignsMassEditMode.Min;
                return;
            }

            if (Shortcuts.ShiftIsPressed)
            {
                bool  isRoundabout = RoundaboutMassEdit.Instance.TraverseLoop(HoveredSegmentId, out var segmentList);
                Color color        = MainTool.GetToolColor(Input.GetMouseButton(0), false);
                if (isRoundabout)
                {
                    foreach (uint segmentId in segmentList)
                    {
                        ref NetSegment seg = ref Singleton <NetManager> .instance.m_segments.m_buffer[segmentId];
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref seg,
                            color,
                            color);
                    } // end foreach
                }
                else
                {
                    SegmentTraverser.Traverse(
                        HoveredSegmentId,
                        TraverseDirection.AnyDirection,
                        TraverseSide.Straight,
                        SegmentStopCriterion.None,
                        data => {
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref Singleton <NetManager> .instance.m_segments.m_buffer[
                                data.CurSeg.segmentId],
                            color,
                            color);
                        return(true);
                    });
                }
                if (!ControlIsPressed)
                {
                    mode = ModifyMode.PriorityRoad;
                }
                else if (!isRoundabout)
                {
                    mode = ModifyMode.HighPriorityRoad;
                }
                else
                {
                    mode = ModifyMode.Roundabout;
                }

                if (mode != PrevHoveredState.Mode || HoveredSegmentId != PrevHoveredState.SegmentId)
                {
                    massEditMode = PrioritySignsMassEditMode.Min;
                }
            }
Ejemplo n.º 14
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (MainTool.GetToolController().IsInsideUI || !Cursor.visible)
            {
                return;
            }

            ModifyMode mode = ModifyMode.None;

            MassEditOverlay.Show = ControlIsPressed;

            if (HoveredSegmentId == 0)
            {
                massEditMode = PrioritySignsMassEditMode.Min;
                return;
            }

            if (Shortcuts.ShiftIsPressed)
            {
                bool  isRoundabout = RoundaboutMassEdit.Instance.TraverseLoop(HoveredSegmentId, out var segmentList);
                Color color        = MainTool.GetToolColor(Input.GetMouseButton(0), false);
                if (isRoundabout)
                {
                    foreach (ushort segmentId in segmentList)
                    {
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref segmentId.ToSegment(),
                            color,
                            color);
                    } // end foreach
                }
                else
                {
                    SegmentTraverser.Traverse(
                        HoveredSegmentId,
                        TraverseDirection.AnyDirection,
                        TraverseSide.Straight,
                        SegmentStopCriterion.None,
                        data => {
                        NetTool.RenderOverlay(
                            cameraInfo,
                            ref data.CurSeg.segmentId.ToSegment(),
                            color,
                            color);
                        return(true);
                    });
                }
                if (!ControlIsPressed)
                {
                    mode = ModifyMode.PriorityRoad;
                }
                else if (!isRoundabout)
                {
                    mode = ModifyMode.HighPriorityRoad;
                }
                else
                {
                    mode = ModifyMode.Roundabout;
                }

                if (mode != PrevHoveredState.Mode || HoveredSegmentId != PrevHoveredState.SegmentId)
                {
                    massEditMode = PrioritySignsMassEditMode.Min;
                }
            }
            else if (ControlIsPressed)
            {
                Highlight.DrawNodeCircle(
                    cameraInfo: cameraInfo,
                    nodeId: HoveredNodeId,
                    warning: Input.GetMouseButton(0));

                mode = ModifyMode.HighPriorityJunction;

                if (mode != PrevHoveredState.Mode || HoveredNodeId != PrevHoveredState.NodeId)
                {
                    massEditMode = PrioritySignsMassEditMode.Min;
                }
            }
            else
            {
                massEditMode = PrioritySignsMassEditMode.Min;

                if (HoveredNodeId == SelectedNodeId)
                {
                    return;
                }

                // no highlight for existing priority node in sign mode
                if (TrafficPriorityManager.Instance.HasNodePrioritySign(HoveredNodeId))
                {
                    // Log._Debug($"PrioritySignsTool.RenderOverlay: HasNodePrioritySign({HoveredNodeId})=true");
                    return;
                }

                if (!TrafficPriorityManager.Instance.MayNodeHavePrioritySigns(HoveredNodeId))
                {
                    // Log._Debug($"PrioritySignsTool.RenderOverlay: MayNodeHavePrioritySigns({HoveredNodeId})=false");
                    return;
                }

                Highlight.DrawNodeCircle(
                    cameraInfo: cameraInfo,
                    nodeId: HoveredNodeId,
                    warning: Input.GetMouseButton(0));
            }

            PrevHoveredState.Mode      = mode;
            PrevHoveredState.SegmentId = HoveredSegmentId;
            PrevHoveredState.NodeId    = HoveredNodeId;
        }