Exemplo n.º 1
0
        public void ChangeDefaultSpeedAndConstructionFee()
        {
            if (OptionUI.tempPatchForSpeedAndPrice)
            {
                for (uint num = 0u; num < PrefabCollection <NetInfo> .LoadedCount(); num++)
                {
                    NetInfo asset = PrefabCollection <NetInfo> .GetLoaded(num);

                    if (asset != null)
                    {
                        if (asset.m_netAI is RoadAI)
                        {
                            if (CSURUtil.IsCSUR(asset))
                            {
                                int laneNum = (int)CSURUtil.CountCSURSVehicleLanes(asset);
                                if (CSURUtil.IsCSURDual(asset))
                                {
                                    if (laneNum <= 6)
                                    {
                                        for (int j = 0; j < asset.m_lanes.Length; j++)
                                        {
                                            asset.m_lanes[j].m_speedLimit = 0.6f + (laneNum >> 1) / 5f;
                                        }
                                    }
                                }
                                else
                                {
                                    if (laneNum <= 3)
                                    {
                                        for (int j = 0; j < asset.m_lanes.Length; j++)
                                        {
                                            asset.m_lanes[j].m_speedLimit = 0.6f + laneNum / 5f;
                                        }
                                    }
                                }
                                laneNum += (int)CSURUtil.CountCSURSOtherLanes(asset, true);

                                float width = 0;
                                if (asset.m_lanes.Length > 0)
                                {
                                    width = asset.m_lanes[asset.m_sortedLanes[0]].m_position - asset.m_lanes[asset.m_sortedLanes[asset.m_lanes.Length - 1]].m_position;
                                }

                                if (width < 0)
                                {
                                    width = -width;
                                }

                                PlayerNetAI AI = asset.m_netAI as PlayerNetAI;
                                AI.m_constructionCost = 400 * laneNum + (int)(width * 100);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void InstallPillar()
        {
            for (uint num = 0u; num < PrefabCollection <NetInfo> .LoadedCount(); num++)
            {
                NetInfo loaded = PrefabCollection <NetInfo> .GetLoaded(num);

                if (CSURUtil.IsCSUR(loaded))
                {
                    RoadBridgeAI elevatedAI = null;
                    if ((loaded.m_netAI is RoadBridgeAI) && (Regex.Match(loaded.name, "Elevated", RegexOptions.IgnoreCase)).Success && (loaded.m_segments.Length != 0))
                    {
                        elevatedAI = loaded.m_netAI as RoadBridgeAI;
                    }
                    else
                    {
                        continue;
                    }

                    //Caculate lane num
                    int laneNum = (int)CSURUtil.CountCSURSVehicleLanes(loaded);

                    if (!CSURUtil.IsCSURDual(loaded))
                    {
                        if (Regex.Match(loaded.name, "CSUR-T", RegexOptions.IgnoreCase).Success)
                        {
                            laneNum = laneNum - 1;
                        }

                        if (laneNum < 0)
                        {
                            laneNum = 0;
                        }

                        switch (laneNum)
                        {
                        case 0:
                        case 1:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = " + laneNum.ToString());
                            DebugLog.LogToFileOnly("Try to Load pillar Ama S-1_Data");
                            elevatedAI.m_bridgePillarOffset = 0.5f;
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama S-1_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama S-1_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama S-1_Data");
                            }
                            break;

                        case 2:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 2");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama S-2_Data");
                            elevatedAI.m_bridgePillarOffset = 1f;
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama S-2_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama S-2_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama S-2_Data");
                            }
                            break;

                        case 3:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 3");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama S-3_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama S-3_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama S-3_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama S-3_Data");
                            }
                            break;

                        case 4:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 4");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama G-3_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama G-3_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama G-3_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama G-3_Data");
                            }
                            break;

                        case 5:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 5");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama G-4_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama G-4_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama G-4_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama G-4_Data");
                            }
                            break;

                        default:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = " + laneNum.ToString());
                            DebugLog.LogToFileOnly("Try to Load pillar Ama G-5_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama G-5_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama G-5_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama G-5_Data");
                            }
                            break;
                        }
                    }
                    else
                    {
                        /*if (Regex.Match(loaded.name, "CSUR-S", RegexOptions.IgnoreCase).Success)
                         *  laneNum = laneNum - 1;
                         * else if (Regex.Match(loaded.name, "CSUR-T", RegexOptions.IgnoreCase).Success)
                         *  laneNum = laneNum - 1;
                         * else if (Regex.Match(loaded.name, "CSUR-R", RegexOptions.IgnoreCase).Success)
                         *  laneNum = laneNum - 1;*/

                        if (laneNum < 0)
                        {
                            laneNum = 0;
                        }

                        //laneNum = laneNum * 2;
                        switch (laneNum)
                        {
                        case 0:
                        case 2:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = " + laneNum.ToString());
                            DebugLog.LogToFileOnly("Try to Load pillar Ama S-2_Data");
                            elevatedAI.m_bridgePillarOffset = 1f;
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama S-2_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama S-2_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama S-2_Data");
                            }
                            break;

                        case 4:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 4");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama M-2_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama M-2_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama M-2_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama M-2_Data");
                            }
                            break;

                        case 6:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 6");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama M-2_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama M-2_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama M-2_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama M-2_Data");
                            }
                            break;

                        case 8:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 8");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama M-4_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama M-4_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama M-4_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama M-4_Data");
                            }
                            break;

                        case 10:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = 10");
                            DebugLog.LogToFileOnly("Try to Load pillar Ama G-8DR_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama G-8DR_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama G-8DR_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama G-8DR_Data");
                            }
                            break;

                        default:
                            DebugLog.LogToFileOnly(loaded.name.ToString() + "lane num = " + laneNum.ToString());
                            DebugLog.LogToFileOnly("Try to Load pillar Ama G-8DR_Data");
                            if (PrefabCollection <BuildingInfo> .FindLoaded("Ama G-8DR_Data") != null)
                            {
                                elevatedAI.m_bridgePillarInfo = PrefabCollection <BuildingInfo> .FindLoaded("Ama G-8DR_Data");
                            }
                            else
                            {
                                DebugLog.LogToFileOnly("Failed Load pillar Ama G-8DR_Data");
                            }
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
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);
                    }
                }
            }
        }