コード例 #1
0
        public override void OnPrimaryClickOverlay()
        {
            if (IsCursorInPanel())
            {
                return;
            }

            if (HoveredNodeId == 0)
            {
                return;
            }

            ToggleTrafficLight(HoveredNodeId, ref HoveredNodeId.ToNode());
        }
コード例 #2
0
        bool IsSuitableJunction()
        {
            if (HoveredNodeId == 0)
            {
                return(false);
            }
            NetNode node = HoveredNodeId.ToNode();

            if (node.CountSegments() < 2)
            {
                return(false);
            }

            return(true);
        }
コード例 #3
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);
        }
コード例 #4
0
        bool IsSuitableRoadForRoadBridge()
        {
            if (!HoveredSegmentId.ToSegment().CanConnectPath())
            {
                return(false);
            }
            float minDistance = 1 * NetUtil.MPU + NetUtil.MaxNodeHW(HoveredNodeId);

            if (HoveredNodeId.ToNode().m_flags.IsFlagSet(NetNode.Flags.Middle))
            {
                return(true);
            }
            var   diff  = HitPos - HoveredNodeId.ToNode().m_position;
            float diff2 = diff.sqrMagnitude;

            return(diff2 > minDistance * minDistance);
        }
コード例 #5
0
        bool IsSuitableJunction()
        {
            if (HoveredNodeId == 0)
            {
                return(false);
            }
            NetNode node = HoveredNodeId.ToNode();

            if (node.CountSegments() < 3)
            {
                return(false);
            }

            if (!node.Info.CanConnectPath())
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        internal ushort GetSegmentFromNode()
        {
            bool   considerSegmentLenght = true;
            ushort minSegId = 0;

            if (HoveredNodeId != 0)
            {
                NetNode node      = HoveredNodeId.ToNode();
                Vector3 dir0      = node.m_position - m_mousePosition;
                float   min_angle = float.MaxValue;
                for (int i = 0; i < 8; ++i)
                {
                    ushort segmentId = node.GetSegment(i);
                    if (segmentId == 0)
                    {
                        continue;
                    }
                    NetSegment segment = segmentId.ToSegment();
                    Vector3    dir;
                    if (segment.m_startNode == HoveredNodeId)
                    {
                        dir = segment.m_startDirection;
                    }
                    else
                    {
                        dir = segment.m_endDirection;
                    }
                    float angle = GetAgnele(-dir, dir0);
                    if (considerSegmentLenght)
                    {
                        angle *= segment.m_averageLength;
                    }
                    if (angle < min_angle)
                    {
                        min_angle = angle;
                        minSegId  = segmentId;
                    }
                }
            }
            return(minSegId);
        }