コード例 #1
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);

            if (enabled == true)
            {
                if (m_seg1 != 0)
                {
                    NetSegment hoveredSegment = GetSegment(m_seg1);
                    NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, scolor, new Color(1f, 0f, 0f, 1f));
                }

                if (m_seg2 != 0)
                {
                    NetSegment hoveredSegment = GetSegment(m_seg2);
                    NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, scolor, new Color(1f, 0f, 0f, 1f));
                }
                if (m_hover != 0)
                {
                    NetSegment hoveredSegment = GetSegment(m_hover);
                    NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, m_errors ? Color.Lerp(hcolor, new Color(1f, 0f, 0f, 1f), (float)Mathf.Sin(pulsating / 5) / 2 + 0.5f) : hcolor, new Color(1f, 0f, 0f, 1f));
                    if (m_snapFakeNode != Vector3.zero)
                    {
                        RenderManager.instance.OverlayEffect.DrawCircle(cameraInfo, hcolor, m_snapFakeNode, 10f, m_snapFakeNode.y - 1f, m_snapFakeNode.y + 1f, true, true);
                    }
                }
                //if(true) { // @TODO find circle place???
                //    Singleton<RenderManager>.instance.OverlayEffect.DrawCircle(cameraInfo, new Color(), new Vector3(), 5f)
                //}
            }
        }
コード例 #2
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);
            if (!enabled)
            {
                return;
            }

            if (np_hoveredObject.NetSegment != 0)
            {
                NetSegment hoveredSegment = np_hoveredObject.NetSegment.S();
                NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, _hovc, new Color(1f, 0f, 0f, 1f));
            }
            else if (np_hoveredObject.NetNode != 0 && np_hoveredObject.NetNode < 32768)
            {
                NetNode hoveredNode = np_hoveredObject.NetNode.N();
                RenderManager.instance.OverlayEffect.DrawCircle(cameraInfo, _hovc, hoveredNode.m_position, Mathf.Max(6f, hoveredNode.Info.m_halfWidth * 2f), -1f, 1280f, false, true);
            }
            else if (np_hoveredObject.Building != 0)
            {
                Building hoveredBuilding = np_hoveredObject.Building.B();
                BuildingTool.RenderOverlay(cameraInfo, ref hoveredBuilding, _hovc, _hovc);
            }
            else if (np_hoveredObject.Tree != 0)
            {
                TreeInstance hoveredTree = np_hoveredObject.Tree.T();
                TreeTool.RenderOverlay(cameraInfo, hoveredTree.Info, hoveredTree.Position, hoveredTree.Info.m_minScale, _hovc);
            }
            else if (np_hoveredObject.Prop != 0)
            {
                PropInstance hoveredTree = np_hoveredObject.Prop.P();
                PropTool.RenderOverlay(cameraInfo, hoveredTree.Info, hoveredTree.Position, hoveredTree.Info.m_minScale, hoveredTree.Angle, _hovc);
            }
        }
コード例 #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));
            }
        }
コード例 #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));
        }
コード例 #5
0
 public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
 {
     base.RenderOverlay(cameraInfo);
     if (enabled == true)
     {
         if (m_hover != 0)
         {
             NetSegment hoveredSegment = GetSegment(m_hover);
             NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, hcolor, new Color(1f, 0f, 0f, 1f));
         }
     }
 }
コード例 #6
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo, Color toolColor, Color despawnColor)
        {
            if (!isValid)
            {
                return;
            }
            if (MoveItTool.m_isLowSensitivity)
            {
                return;
            }

            ushort       building     = id.Building;
            BuildingInfo buildingInfo = buildingBuffer[building].Info;

            if (WillBuildingDespawn(building))
            {
                toolColor = despawnColor;
            }

            float alpha = 1f;

            BuildingTool.CheckOverlayAlpha(buildingInfo, ref alpha);
            toolColor.a *= alpha;

            int length = buildingBuffer[building].Length;

            BuildingTool.RenderOverlay(cameraInfo, buildingInfo, length, OverlayPosition, OverlayAngle, toolColor, false);

            foreach (Instance subInstance in subInstances)
            {
                if (subInstance is MoveableNode mn)
                {
                    ushort node = mn.id.NetNode;
                    for (int k = 0; k < 8; k++)
                    {
                        ushort segment = netManager.m_nodes.m_buffer[node].GetSegment(k);
                        if (segment != 0 && netManager.m_segments.m_buffer[segment].m_startNode == node && (netManager.m_segments.m_buffer[segment].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                        {
                            NetTool.RenderOverlay(cameraInfo, ref netManager.m_segments.m_buffer[segment], toolColor, toolColor);
                        }
                    }
                }
                else if (subInstance is MoveableBuilding mb)
                {
                    Building b = buildingBuffer[mb.id.Building];
                    BuildingTool.RenderOverlay(cameraInfo, (BuildingInfo)mb.Info.Prefab, b.Length, mb.OverlayPosition, mb.OverlayAngle, toolColor, false);
                }
            }
        }
コード例 #7
0
 public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
 {
     if (currentSegment != 0)
     {
         NetTool.RenderOverlay(RenderManager.instance.CurrentCameraInfo, ref NetManager.instance.m_segments.m_buffer[currentSegment], new Color(0.0f, 0.0f, 0.5f, 0.6f), new Color(0f, 0.0f, 0.5f, 0.9f));
         LaneChangerPathManager pathManager = (LaneChangerPathManager)PathManager.instance;
         NetManager             netManager  = NetManager.instance;
         if (pathManager.laneChangerSegments[currentSegment] != null)
         {
             RenderOverlayForSegments(cameraInfo, netManager.m_nodes.m_buffer[netManager.m_segments.m_buffer[currentSegment].m_startNode]);
             RenderOverlayForSegments(cameraInfo, netManager.m_nodes.m_buffer[netManager.m_segments.m_buffer[currentSegment].m_endNode]);
         }
     }
     base.RenderOverlay(cameraInfo);
 }
コード例 #8
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);

            if (isHoveringSegment)
            {
                bool  warning = toolError == ToolError.AlreadyBuilt;
                bool  error   = toolError != ToolError.None && toolError != ToolError.AlreadyBuilt;
                Color color   = GetToolColor(warning, error);
                NetTool.RenderOverlay(cameraInfo, ref segment, color, color);

                Color color2 = GetToolColor(true, false);
                m_toolController.RenderColliding(cameraInfo, color, color2, color, color2, (ushort)segmentIndex, 0);
            }
        }
コード例 #9
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);
            if (HoveredSegmentId == 0 || HoveredNodeId == 0)
            {
                return;
            }
            NetNode.Flags nodeFlags = HoveredNodeId.ToNode().m_flags;
            Color         color     = GetToolColor(Input.GetMouseButton(0), false);

            NetTool.RenderOverlay(
                cameraInfo,
                ref HoveredSegmentId.ToSegment(),
                color,
                color);
        }
コード例 #10
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            // ModDebug.LogClassAndMethodName(this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name);
            base.RenderOverlay(cameraInfo);

            if (isHoveringSegment)
            {
                bool  warning = toolError == ToolError.AlreadyBuilt;
                bool  error   = toolError != ToolError.None && toolError != ToolError.AlreadyBuilt;
                Color color   = GetToolColor(warning, error);
                NetTool.RenderOverlay(cameraInfo, ref segment, color, color);

                Color color2 = GetToolColor(true, false);
                m_toolController.RenderColliding(cameraInfo, color, color2, color, color2, (ushort)segmentIndex, 0);
            }
        }
コード例 #11
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (HoveredSegmentId != 0)
            {
                ushort     segment    = HoveredSegmentId;
                NetManager netManager = NetManager.instance;
                Color      color      = GetToolColor(false, false);
                float      alpha      = 1.0f;
                NetTool.CheckOverlayAlpha(ref netManager.m_segments.m_buffer[HoveredSegmentId], ref alpha);
                color.a *= alpha;

                NetTool.RenderOverlay(
                    cameraInfo,
                    ref netManager.m_segments.m_buffer[HoveredSegmentId],
                    color,
                    color);
            }
            base.RenderOverlay(cameraInfo);
        }
コード例 #12
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (!MouseRayValid)
            {
                base.RenderOverlay(cameraInfo);
                return;
            }

            switch (HoverInstance.Type)
            {
            case InstanceType.NetSegment: {
                ushort     segment    = HoverInstance.NetSegment;
                ushort     segment2   = HoverInstance2.NetSegment;
                NetManager netManager = NetManager.instance;
                Color      color      = GetToolColor(false, false);
                float      alpha      = 1.0f;
                NetTool.CheckOverlayAlpha(ref netManager.m_segments.m_buffer[segment], ref alpha);
                if (segment2 != 0)
                {
                    NetTool.CheckOverlayAlpha(ref netManager.m_segments.m_buffer[segment2], ref alpha);
                }
                color.a *= alpha;

                if (netManager.NetAdjust != null)
                {
                    if (netManager.NetAdjust.RenderOverlay(cameraInfo, segment, color, SubHoverIndex))
                    {
                        break;
                    }
                }

                NetTool.RenderOverlay(cameraInfo, ref netManager.m_segments.m_buffer[segment], color, color);
                if (segment2 != 0)
                {
                    NetTool.RenderOverlay(cameraInfo, ref netManager.m_segments.m_buffer[segment2], color, color);
                }

                break;
            }
            }
            base.RenderOverlay(cameraInfo);
        }
コード例 #13
0
        void RenderOverlayForSegments(RenderManager.CameraInfo cameraInfo, NetNode node)
        {
            LaneChangerPathManager pathManager = (LaneChangerPathManager)PathManager.instance;

            for (int i = 0; i < node.CountSegments(); i++)
            {
                ushort segId = node.GetSegment(i);
                if (segId != currentSegment)
                {
                    if (pathManager.laneChangerSegments[currentSegment].PermittedConnectionTo(segId))
                    {
                        NetTool.RenderOverlay(RenderManager.instance.CurrentCameraInfo, ref NetManager.instance.m_segments.m_buffer[segId], new Color(0.0f, 1f, 0.0f, 0.6f), new Color(0f, 1f, 0f, 0.9f));
                    }
                    else
                    {
                        NetTool.RenderOverlay(RenderManager.instance.CurrentCameraInfo, ref NetManager.instance.m_segments.m_buffer[segId], new Color(1f, 0.0f, 0.0f, 0.6f), new Color(1f, 0f, 0f, 0.9f));
                    }
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Called by game when overlay is to be rendered.
        /// </summary>
        /// <param name="cameraInfo">Current camera instance</param>
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            // Colors for rendering.
            Color segmentColor = GetToolColor(false, false);

            // Local references.
            ToolManager toolManager = Singleton <ToolManager> .instance;

            NetSegment[] segmentBuffer = Singleton <NetManager> .instance.m_segments.m_buffer;

            base.RenderOverlay(cameraInfo);

            if (ReplacerPanel.Panel?.selectedSegments != null)
            {
                foreach (ushort segmentID in ReplacerPanel.Panel.selectedSegments)
                {
                    toolManager.m_drawCallData.m_overlayCalls++;
                    NetTool.RenderOverlay(cameraInfo, ref segmentBuffer[segmentID], segmentColor, segmentColor);
                }
            }
        }
コード例 #15
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));
        }
コード例 #16
0
ファイル: Tool.cs プロジェクト: doctorvargaz/Picker
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);
            if (!enabled)
            {
                return;
            }

            if (hoveredId.NetSegment != 0)
            {
                NetSegment hoveredSegment = hoveredId.NetSegment.S();
                NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, hoverColor, hoverColor);
            }
            //else if (hoveredObject.NetNode != 0 && hoveredObject.NetNode < 32768)
            //{
            //    NetNode hoveredNode = hoveredObject.NetNode.N();
            //    RenderManager.instance.OverlayEffect.DrawCircle(cameraInfo, hoverColor, hoveredNode.m_position, Mathf.Max(6f, hoveredNode.Info.m_halfWidth * 2f), -1f, 1280f, false, true);
            //}
            else if (hoveredId.Building != 0)
            {
                Building hoveredBuilding = hoveredId.Building.B();
                BuildingTool.RenderOverlay(cameraInfo, ref hoveredBuilding, hoverColor, hoverColor);

                while (hoveredBuilding.m_subBuilding > 0)
                {
                    hoveredBuilding = BuildingManager.instance.m_buildings.m_buffer[hoveredBuilding.m_subBuilding];
                    BuildingTool.RenderOverlay(cameraInfo, ref hoveredBuilding, hoverColor, hoverColor);
                }
            }
            else if (hoveredId.Tree != 0)
            {
                TreeInstance hoveredTree = hoveredId.Tree.T();
                TreeTool.RenderOverlay(cameraInfo, hoveredTree.Info, hoveredTree.Position, hoveredTree.Info.m_minScale, hoverColor);
            }
            else if (hoveredId.Prop != 0)
            {
                PropInstance hoveredProp = hoveredId.Prop.P();
                PropTool.RenderOverlay(cameraInfo, hoveredProp.Info, hoveredProp.Position, hoveredProp.Info.m_minScale, hoveredProp.Angle, hoverColor);
            }
        }
コード例 #17
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));
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
ファイル: PrioritySignsTool.cs プロジェクト: sirusmonkey/TMPE
        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;
            }
コード例 #20
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;
        }
コード例 #21
0
ファイル: PrioritySignsTool.cs プロジェクト: s2500111/TMPE
        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;
                }
            }
コード例 #22
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo, Color toolColor, Color despawnColor)
        {
            if (!isValid)
            {
                return;
            }

            ushort       building     = id.Building;
            BuildingInfo buildingInfo = buildingBuffer[building].Info;

            if (WillBuildingDespawn(building))
            {
                toolColor = despawnColor;
            }

            float alpha = 1f;

            BuildingTool.CheckOverlayAlpha(buildingInfo, ref alpha);
            toolColor.a *= alpha;

            int     length   = buildingBuffer[building].Length;
            Vector3 position = buildingBuffer[building].m_position;
            float   angle    = buildingBuffer[building].m_angle;

            BuildingTool.RenderOverlay(cameraInfo, buildingInfo, length, position, angle, toolColor, false);

            ushort node  = buildingBuffer[building].m_netNode;
            int    count = 0;

            while (node != 0)
            {
                for (int k = 0; k < 8; k++)
                {
                    ushort segment2 = netManager.m_nodes.m_buffer[node].GetSegment(k);
                    if (segment2 != 0 && netManager.m_segments.m_buffer[segment2].m_startNode == node && (netManager.m_segments.m_buffer[segment2].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                    {
                        NetTool.RenderOverlay(cameraInfo, ref netManager.m_segments.m_buffer[segment2], toolColor, toolColor);
                    }
                }
                node = netManager.m_nodes.m_buffer[node].m_nextBuildingNode;

                if (++count > 32768)
                {
                    CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                    break;
                }
            }
            ushort subBuilding = buildingBuffer[building].m_subBuilding;

            count = 0;
            while (subBuilding != 0)
            {
                BuildingInfo subBuildingInfo = buildingBuffer[subBuilding].Info;
                int          subLength       = buildingBuffer[subBuilding].Length;
                Vector3      subPosition     = buildingBuffer[subBuilding].m_position;
                float        subAngle        = buildingBuffer[subBuilding].m_angle;
                BuildingTool.RenderOverlay(cameraInfo, subBuildingInfo, subLength, subPosition, subAngle, toolColor, false);
                subBuilding = buildingBuffer[subBuilding].m_subBuilding;

                if (++count > 49152)
                {
                    CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                    break;
                }
            }
        }
コード例 #23
0
ファイル: UniqueTool.cs プロジェクト: TPBCS/UniqueInstances
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (this.m_toolController.IsInsideUI || !Cursor.visible)
            {
                base.RenderOverlay(cameraInfo);
                return;
            }
            switch (HoverInstance.Type)
            {
            case InstanceType.Building:
            {
                ushort          building   = HoverInstance.Building;
                NetManager      instance   = Singleton <NetManager> .instance;
                BuildingManager instance2  = Singleton <BuildingManager> .instance;
                BuildingInfo    info5      = instance2.m_buildings.m_buffer[(int)building].Info;
                Color           toolColor6 = GetOverlayColor();
                float           num        = 1f;
                BuildingTool.CheckOverlayAlpha(info5, ref num);
                ushort num2 = instance2.m_buildings.m_buffer[(int)building].m_netNode;
                int    num3 = 0;
                while (num2 != 0)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        ushort segment = instance.m_nodes.m_buffer[(int)num2].GetSegment(j);
                        if (segment != 0 && instance.m_segments.m_buffer[(int)segment].m_startNode == num2 && (instance.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                        {
                            NetTool.CheckOverlayAlpha(ref instance.m_segments.m_buffer[(int)segment], ref num);
                        }
                    }
                    num2 = instance.m_nodes.m_buffer[(int)num2].m_nextBuildingNode;
                    if (++num3 > 32768)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                ushort subBuilding = instance2.m_buildings.m_buffer[(int)building].m_subBuilding;
                num3 = 0;
                while (subBuilding != 0)
                {
                    BuildingTool.CheckOverlayAlpha(instance2.m_buildings.m_buffer[(int)subBuilding].Info, ref num);
                    subBuilding = instance2.m_buildings.m_buffer[(int)subBuilding].m_subBuilding;
                    if (++num3 > 49152)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                toolColor6.a *= num;
                int     length    = instance2.m_buildings.m_buffer[(int)building].Length;
                Vector3 position2 = instance2.m_buildings.m_buffer[(int)building].m_position;
                float   angle2    = instance2.m_buildings.m_buffer[(int)building].m_angle;
                BuildingTool.RenderOverlay(cameraInfo, info5, length, position2, angle2, toolColor6, false);
                num2 = instance2.m_buildings.m_buffer[(int)building].m_netNode;
                num3 = 0;
                while (num2 != 0)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        ushort segment2 = instance.m_nodes.m_buffer[(int)num2].GetSegment(k);
                        if (segment2 != 0 && instance.m_segments.m_buffer[(int)segment2].m_startNode == num2 && (instance.m_segments.m_buffer[(int)segment2].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                        {
                            NetTool.RenderOverlay(cameraInfo, ref instance.m_segments.m_buffer[(int)segment2], toolColor6, toolColor6);
                        }
                    }
                    num2 = instance.m_nodes.m_buffer[(int)num2].m_nextBuildingNode;
                    if (++num3 > 32768)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                subBuilding = instance2.m_buildings.m_buffer[(int)building].m_subBuilding;
                num3        = 0;
                while (subBuilding != 0)
                {
                    BuildingInfo info6     = instance2.m_buildings.m_buffer[(int)subBuilding].Info;
                    int          length2   = instance2.m_buildings.m_buffer[(int)subBuilding].Length;
                    Vector3      position3 = instance2.m_buildings.m_buffer[(int)subBuilding].m_position;
                    float        angle3    = instance2.m_buildings.m_buffer[(int)subBuilding].m_angle;
                    BuildingTool.RenderOverlay(cameraInfo, info6, length2, position3, angle3, toolColor6, false);
                    subBuilding = instance2.m_buildings.m_buffer[(int)subBuilding].m_subBuilding;
                    if (++num3 > 49152)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                break;
            }

            case InstanceType.Tree:
            {
                uint        tree        = HoverInstance.Tree;
                TreeManager instance11  = Singleton <TreeManager> .instance;
                TreeInfo    info9       = instance11.m_trees.m_buffer[(int)((UIntPtr)tree)].Info;
                Vector3     position6   = instance11.m_trees.m_buffer[(int)((UIntPtr)tree)].Position;
                Randomizer  randomizer4 = new Randomizer(tree);
                float       scale4      = info9.m_minScale + (float)randomizer4.Int32(10000u) * (info9.m_maxScale - info9.m_minScale) * 0.0001f;
                Color       toolColor13 = GetOverlayColor();
                float       num13       = 1f;
                TreeTool.CheckOverlayAlpha(info9, scale4, ref num13);
                toolColor13.a *= num13;
                TreeTool.RenderOverlay(cameraInfo, info9, position6, scale4, toolColor13);
                break;
            }
            }
            base.RenderOverlay(cameraInfo);
        }