示例#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);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        private void ShowNetwork(string name, string desc, GeneratedScrollPanel panel, int constructionCost, int maintenanceCost, string prefixIcon)
        {
            UIButton button = panel.Find <UIButton>(name);

            if (button != null && button.name == name)
            {
                GameObject.DestroyImmediate(button);
            }

            NetInfo netInfo = PrefabCollection <NetInfo> .FindLoaded(name);

            if (netInfo == null)
            {
                DebugUtils.Warning("Couldn't find NetInfo named '" + name + "'");
                return;
            }

            //DebugUtils.Log("NetInfo named '" + name + "' found.");

            PlayerNetAI netAI = netInfo.m_netAI as PlayerNetAI;

            // Adding cost
            netAI.m_constructionCost = constructionCost;
            netAI.m_maintenanceCost  = maintenanceCost;

            // Making the prefab valid
            netInfo.m_availableIn    = ItemClass.Availability.All;
            netInfo.m_placementStyle = ItemClass.Placement.Manual;
            typeof(NetInfo).GetField("m_UICategory", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(netInfo, "PublicTransportPlane");

            // Adding icons
            netInfo.m_Atlas     = m_atlas;
            netInfo.m_Thumbnail = prefixIcon;

            // Adding missing locale
            Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(SingletonLite <LocaleManager> .instance);

            Locale.Key key = new Locale.Key()
            {
                m_Identifier = "NET_TITLE", m_Key = name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, name);
            }
            key = new Locale.Key()
            {
                m_Identifier = "NET_DESC", m_Key = name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, desc);
            }

            typeof(GeneratedScrollPanel).GetMethod("CreateAssetItem", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(panel, new object[] { netInfo });
        }
示例#3
0
 private static void RevertBuilding(ref BuildingInfo info)
 {
     if (m_CpmNetDict != null)
     {
         for (int j = 0; j < info.m_paths.Count(); j++)
         {
             NetInfo ninfo = info.m_paths[j].m_netInfo;
             if (m_CpmNetDict.ContainsKey(ninfo.name))
             {
                 if (ninfo.m_netAI != null)
                 {
                     PlayerNetAI pnai = ninfo.GetComponent <PlayerNetAI>();
                     if (pnai != null)
                     {
                         pnai.m_createPassMilestone = m_CpmNetDict[ninfo.name];
                     }
                 }
             }
         }
     }
     if (m_CpmBuildingDict != null)
     {
         if (m_CpmBuildingDict.ContainsKey(info.name))
         {
             PlayerBuildingAI pbai = info.GetComponent <PlayerBuildingAI>();
             if (pbai != null)
             {
                 pbai.m_createPassMilestone  = m_CpmBuildingDict[info.name][0];
                 pbai.m_createPassMilestone2 = m_CpmBuildingDict[info.name][1];
                 pbai.m_createPassMilestone3 = m_CpmBuildingDict[info.name][2];
                 info.m_buildingAI           = pbai;
                 if (info.m_subBuildings != null && info.m_subBuildings.Count() > 0)
                 {
                     foreach (BuildingInfo.SubInfo subBuilding in info.m_subBuildings)
                     {
                         if (subBuilding.m_buildingInfo != null)
                         {
                             RevertBuilding(ref subBuilding.m_buildingInfo);
                         }
                     }
                 }
             }
         }
     }
 }
示例#4
0
        private static void RemoveCreatePassMileStone(NetInfo info)
        {
            PlayerNetAI pnai = info.GetComponent <PlayerNetAI>();

            if (pnai != null)
            {
                if (pnai.m_createPassMilestone != null)
                {
                    if (m_CpmNetDict == null)
                    {
                        m_CpmNetDict = new Dictionary <string, ManualMilestone>();
                    }
                    if (m_CpmNetDict.ContainsKey(info.name) == false)
                    {
                        m_CpmNetDict.Add(info.name, pnai.m_createPassMilestone);
                    }
                    pnai.m_createPassMilestone = null;
                }
            }
        }
示例#5
0
        /// <summary>
        /// Set up access to airport roads. Modified from SamsamTS's Airport Roads mod
        /// </summary>
        public void SetAirplaneRoads(PrefabInfo prefab)
        {
            int    constructionCost = 0;
            int    maintenanceCost  = 0;
            string thumbnail        = "";

            if (prefab.name == "Airplane Runway")
            {
                constructionCost = 7000;
                maintenanceCost  = 600;
                thumbnail        = "Runway";
            }
            else if (prefab.name == "Aviation Club Runway")
            {
                constructionCost     = 7000;
                maintenanceCost      = 600;
                thumbnail            = "Runway";
                prefab.m_dlcRequired = SteamHelper.DLC_BitMask.UrbanDLC; // Sunset Harbor
            }
            else if (prefab.name == "Airplane Taxiway")
            {
                constructionCost = 4000;
                maintenanceCost  = 200;
                thumbnail        = "Taxiway";
            }

            // Adding cost
            NetInfo netInfo = prefab as NetInfo;

            if (netInfo == null)
            {
                return;
            }
            PlayerNetAI netAI = netInfo.m_netAI as PlayerNetAI;

            netAI.m_constructionCost = constructionCost;
            netAI.m_maintenanceCost  = maintenanceCost;

            // Making the prefab valid
            netInfo.m_availableIn    = ItemClass.Availability.All;
            netInfo.m_placementStyle = ItemClass.Placement.Manual;
            typeof(NetInfo).GetField("m_UICategory", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(netInfo, "PublicTransportPlane");

            // Adding icons
            netInfo.m_Atlas            = SamsamTS.UIUtils.GetAtlas("FindItAtlas");
            netInfo.m_Thumbnail        = thumbnail;
            netInfo.m_InfoTooltipAtlas = SamsamTS.UIUtils.GetAtlas("FindItAtlas");

            // Adding missing locale
            Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(SingletonLite <LocaleManager> .instance);

            Locale.Key key = new Locale.Key()
            {
                m_Identifier = "NET_TITLE", m_Key = prefab.name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, prefab.name);
            }
            key = new Locale.Key()
            {
                m_Identifier = "NET_DESC", m_Key = prefab.name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, thumbnail);
            }
        }