Пример #1
0
        public void OnGUI()
        {
            if (!(Loader.is1637663252 | Loader.is583429740 | Loader.is1806963141))
            {
                return;
            }

            if ((laterLeftClick == 8) && needLaterLeftClick)
            {
                laterLeftClick = 0;
                MouseSimulater.LeftClick();
                needLaterLeftClick = false;
            }
            else if (needLaterLeftClick)
            {
                laterLeftClick++;
            }

            var e = Event.current;

            // Checking key presses
            if (OptionsKeymappingFunction.m_stayinlane.IsPressed(e))
            {
                Assembly TMPE               = Assembly.Load("TrafficManager");
                var      selectedNodeId     = TMPE.GetType("TrafficManager.UI.TrafficManagerTool").GetProperty("SelectedNodeId");
                var      TrafficManagerTool = TMPE.CreateInstance("TrafficManager.UI.TrafficManagerTool");
                ushort   node               = (ushort)selectedNodeId.GetValue(TrafficManagerTool, null);
                DebugLog.LogToFileOnly("TMPE select node = " + node.ToString());
                NetInfo asset = Singleton <NetManager> .instance.m_nodes.m_buffer[node].Info;
                if (CSURUtil.IsCSUR(asset))
                {
                    bool IsCSURRLane  = false;
                    bool IsCSURDual   = false;
                    bool IsCSURSingle = false;
                    for (int j = 0; j < 8; j++)
                    {
                        ushort segmentID = Singleton <NetManager> .instance.m_nodes.m_buffer[node].GetSegment(j);
                        if (segmentID != 0)
                        {
                            var segment = Singleton <NetManager> .instance.m_segments.m_buffer[segmentID];
                            if (CSURUtil.IsCSUR(segment.Info))
                            {
                                if (CSURUtil.IsCSURDual(segment.Info))
                                {
                                    IsCSURDual = true;
                                }
                                else
                                {
                                    if (CSURUtil.IsCSURRLaneOffset(segment.Info))
                                    {
                                        IsCSURRLane = true;
                                        break;
                                    }
                                    IsCSURSingle = true;
                                }
                            }
                        }
                    }
                    if (IsCSURRLane || (IsCSURDual && IsCSURSingle))
                    {
                        AddLaneConnectionForCSUR(node, TMPE);
                        //refresh
                        MouseSimulater.RightClick();
                        needLaterLeftClick = true;
                    }
                }
            }

            if (OptionsKeymappingFunction.m_stayinlaneAll.IsPressed(e))
            {
                Assembly TMPE = Assembly.Load("TrafficManager");
                for (ushort i = 0; i < Singleton <NetManager> .instance.m_nodes.m_size; i++)
                {
                    bool IsCSURRLane  = false;
                    bool IsCSURDual   = false;
                    bool IsCSURSingle = false;
                    for (int j = 0; j < 8; j++)
                    {
                        ushort segmentID = Singleton <NetManager> .instance.m_nodes.m_buffer[i].GetSegment(j);
                        if (segmentID != 0)
                        {
                            var segment = Singleton <NetManager> .instance.m_segments.m_buffer[segmentID];
                            if (CSURUtil.IsCSUR(segment.Info))
                            {
                                if (CSURUtil.IsCSURDual(segment.Info))
                                {
                                    IsCSURDual = true;
                                }
                                else
                                {
                                    if (CSURUtil.IsCSURRLaneOffset(segment.Info))
                                    {
                                        IsCSURRLane = true;
                                        break;
                                    }
                                    IsCSURSingle = true;
                                }
                            }
                        }
                    }
                    if (IsCSURRLane || (IsCSURDual && IsCSURSingle))
                    {
                        AddLaneConnectionForCSUR(i, TMPE);
                    }
                }
            }
        }