예제 #1
0
        public void UpdateCatenary()
        {
            int probability = reduceCatenary.value ? 0 : 100;

            for (uint i = 0; i < PrefabCollection <NetInfo> .PrefabCount(); i++)
            {
                NetInfo info = PrefabCollection <NetInfo> .GetPrefab(i);

                if (info == null)
                {
                    continue;
                }

                for (int j = 0; j < info.m_lanes.Length; j++)
                {
                    if (info.m_lanes[j] != null && info.m_lanes[j].m_laneProps != null)
                    {
                        NetLaneProps.Prop[] props = info.m_lanes[j].m_laneProps.m_props;
                        if (props == null)
                        {
                            continue;
                        }

                        for (int k = 0; k < props.Length; k++)
                        {
                            if (props[k] != null && props[k].m_prop != null && props[k].m_segmentOffset != 1f && props[k].m_prop.name.ToLower().Contains("powerline"))
                            {
                                props[k].m_probability = probability;
                            }
                        }
                    }
                }
            }
        }
        public void UpdateDisasterProperties(bool isSet)
        {
            int prefabsCount = PrefabCollection <DisasterInfo> .PrefabCount();

            for (uint i = 0; i < prefabsCount; i++)
            {
                DisasterInfo di = PrefabCollection <DisasterInfo> .GetPrefab(i);

                if (di == null)
                {
                    continue;
                }

                if (di.m_disasterAI as EarthquakeAI != null)
                {
                    if (isSet && NoCracks)
                    {
                        ((EarthquakeAI)di.m_disasterAI).m_crackLength = 0;
                        ((EarthquakeAI)di.m_disasterAI).m_crackWidth  = 0;
                    }
                    else
                    {
                        ((EarthquakeAI)di.m_disasterAI).m_crackLength = 1000;
                        ((EarthquakeAI)di.m_disasterAI).m_crackWidth  = 100;
                    }
                }
            }
        }
예제 #3
0
 private IEnumerable <NetInfo> EnumeratePrefabs()
 {
     for (uint c = 0; c < PrefabCollection <NetInfo> .PrefabCount(); c++)
     {
         yield return(PrefabCollection <NetInfo> .GetPrefab(c));
     }
 }
예제 #4
0
        private void CreateNewVehicleAI <TPrefab, TAI>(Action <TAI> runner) where TPrefab : VehicleInfo where TAI : VehicleAI
        {
            if (runner == null)
            {
                return;
            }

            var prefabCount = PrefabCollection <TPrefab> .PrefabCount();

            for (uint i = 0; i < prefabCount; i++)
            {
                var prefab = PrefabCollection <TPrefab> .GetPrefab(i);

                var ai = prefab.GetAI();
                if (ai is TAI)
                {
                    // Remove the "old" AI
                    // And create a new one (literally the same AI type)
                    // Then run the "runner" on it which can do things like updating capacities
                    // And ticket prices.
                    Object.Destroy(prefab.GetComponent <TAI>());
                    var newAi = prefab.gameObject.GetComponent <TAI>();

                    runner(newAi);

                    prefab.m_vehicleAI = newAi;
                    newAi.InitializeAI();
                }
            }
        }
예제 #5
0
        private void LoadTrackedPrefabs()
        {
            for (uint i = 0; i < PrefabCollection <CitizenInfo> .PrefabCount(); i++)
            {
                CitizenInfo prefab = PrefabCollection <CitizenInfo> .GetPrefab(i);

                if (prefab == null)
                {
                    continue;
                }

                string name = prefab.GetLocalizedTitle();

                if (String.IsNullOrEmpty(name))
                {
                    continue;
                }

                if (!_settings.Animals.Contains(name))
                {
                    continue;
                }

                if (_prefabs.ContainsKey(name))
                {
                    continue;
                }

                _prefabs.Add(name, (int)i);
            }
        }
		private static void UpdateData(TreeManager tm, SimulationManager.UpdateMode mode)
		{
			Singleton<LoadingManager>.instance.m_loadingProfilerSimulation.BeginLoading("TreeManager.UpdateData");
            if (TreeUnlimiter.Mod.DEBUG_LOG_ON == true) { Debug.Log("[TreeUnlimiter::LimitTreeManager::UpdateData()] calling Ensure Init"); }
            LimitTreeManager.Helper.EnsureInit(3);
			for (int i = 1; i < LimitTreeManager.Helper.TreeLimit; i++)
			{
				if (tm.m_trees.m_buffer[i].m_flags != 0 && tm.m_trees.m_buffer[i].Info == null)
				{
					tm.ReleaseTree((uint)i);
				}
			}
			int num = PrefabCollection<TreeInfo>.PrefabCount();
			int num1 = 1;
			while (num1 * num1 < num)
			{
				num1++;
			}
			for (int j = 0; j < num; j++)
			{
				TreeInfo prefab = PrefabCollection<TreeInfo>.GetPrefab((uint)j);
				if (prefab != null)
				{
					prefab.SetRenderParameters(j, num1);
				}
			}
			ColossalFramework.Threading.ThreadHelper.dispatcher.Dispatch(() => {
				tm.GetType().GetField("m_lastShadowRotation", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(tm, new Quaternion());
				tm.GetType().GetField("m_lastCameraRotation", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(tm, new Quaternion());
			});
			tm.m_infoCount = num;
			Singleton<LoadingManager>.instance.m_loadingProfilerSimulation.EndLoading();
		}
예제 #7
0
        public static IEnumerable <NetInfo> IterateRoadPrefabs()
        {
            int prefabCount = PrefabCollection <NetInfo> .PrefabCount();

            int loadedCount = PrefabCollection <NetInfo> .LoadedCount();

            //Log.Debug($"IterateRoadPrefabs: prefabCount={prefabCount} LoadedCount={loadedCount}",false);
            for (uint i = 0; i < loadedCount; ++i)
            {
                NetInfo info = PrefabCollection <NetInfo> .GetLoaded(i);

                if (!info)
                {
                    Log.Warning("Skipping Bad prefab with null info");
                    continue;
                }
                else if (info.m_netAI == null)
                {
                    Log.Warning("Skipping Bad prefab with null info.m_NetAI");
                    continue;
                }
                if (!(info.m_netAI is RoadBaseAI))
                {
                    continue;
                }
                yield return(info);
            } // end for
        }
예제 #8
0
        private List <BuildingItem> GetBuildingItemList(Configuration.Theme theme)
        {
            List <BuildingItem> list = new List <BuildingItem>();

            // List of all growables prefabs
            Dictionary <string, BuildingItem> buildingDictionary = new Dictionary <string, BuildingItem>();

            for (uint i = 0; i < PrefabCollection <BuildingInfo> .PrefabCount(); i++)
            {
                BuildingInfo prefab = PrefabCollection <BuildingInfo> .GetPrefab(i);

                if (prefab != null && prefab.m_placementStyle == ItemClass.Placement.Automatic)
                {
                    BuildingItem item = new BuildingItem();
                    item.prefab = PrefabCollection <BuildingInfo> .GetPrefab(i);

                    buildingDictionary.Add(item.name, item);

                    if (!BuildingVariationManager.instance.IsVariation(item.name))
                    {
                        list.Add(item);
                    }
                }
            }

            // Combine growables with buildings in configuration
            Configuration.Building[] buildings = theme.buildings.ToArray();
            for (int i = 0; i < buildings.Length; i++)
            {
                if (buildingDictionary.ContainsKey(buildings[i].name))
                {
                    // Associate building with prefab
                    BuildingItem item = buildingDictionary[buildings[i].name];
                    item.building = buildings[i];

                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
                else
                {
                    // Prefab not found, adding building without prefab

                    if (buildings[i].dlc != null && !Steam.IsDlcInstalled(Convert.ToUInt32(buildings[i].dlc)))
                    {
                        continue;
                    }

                    BuildingItem item = new BuildingItem();
                    item.building = buildings[i];
                    list.Add(item);
                }
            }

            // Sorting
            list.Sort(BuildingCompare);
            return(list);
        }
예제 #9
0
        private void FindAllPrefabs()
        {
            List <PrefabData> prefabDataList1 = new List <PrefabData>();
            List <PrefabData> prefabDataList2 = new List <PrefabData>();
            List <PrefabData> prefabDataList3 = new List <PrefabData>();
            List <PrefabData> prefabDataList4 = new List <PrefabData>();
            List <PrefabData> prefabDataList5 = new List <PrefabData>();
            List <PrefabData> prefabDataList6 = new List <PrefabData>();
            List <PrefabData> prefabDataList7 = new List <PrefabData>();

            for (int index = 0; index < PrefabCollection <VehicleInfo> .PrefabCount(); ++index)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab((uint)index);

                if ((Object)prefab != (Object)null && !VehiclePrefabs.IsTrailer(prefab) && (prefab.m_class.m_service == ItemClass.Service.PublicTransport && prefab.m_class.m_level == ItemClass.Level.Level1))
                {
                    switch (prefab.m_class.m_subService)
                    {
                    case ItemClass.SubService.PublicTransportBus:
                        prefabDataList1.Add(new PrefabData(prefab));
                        continue;

                    case ItemClass.SubService.PublicTransportMetro:
                        prefabDataList2.Add(new PrefabData(prefab));
                        continue;

                    case ItemClass.SubService.PublicTransportTrain:
                        prefabDataList3.Add(new PrefabData(prefab));
                        continue;

                    case ItemClass.SubService.PublicTransportShip:
                        prefabDataList4.Add(new PrefabData(prefab));
                        continue;

                    case ItemClass.SubService.PublicTransportPlane:
                        prefabDataList5.Add(new PrefabData(prefab));
                        continue;

                    case ItemClass.SubService.PublicTransportTaxi:
                        prefabDataList6.Add(new PrefabData(prefab));
                        continue;

                    case ItemClass.SubService.PublicTransportTram:
                        prefabDataList7.Add(new PrefabData(prefab));
                        continue;

                    default:
                        continue;
                    }
                }
            }
            this._busPrefabData   = prefabDataList1.ToArray();
            this._metroPrefabData = prefabDataList2.ToArray();
            this._trainPrefabData = prefabDataList3.ToArray();
            this._shipPrefabData  = prefabDataList4.ToArray();
            this._planePrefabData = prefabDataList5.ToArray();
            this._taxiPrefabData  = prefabDataList6.ToArray();
            this._tramPrefabData  = prefabDataList7.ToArray();
        }
예제 #10
0
        private void DebugOutput()
        {
            for (uint i = 0; i < PrefabCollection <RadioChannelInfo> .PrefabCount(); ++i)
            {
                String message = "";

                RadioChannelInfo info = PrefabCollection <RadioChannelInfo> .GetPrefab(i);

                if (info == null)
                {
                    continue;
                }

                message += "[ChannelInfo] " + info + "\n";
                message += "Schedule:\n";

                if (info.m_stateChain != null)
                {
                    foreach (RadioChannelInfo.State s in info.m_stateChain)
                    {
                        message += "\t" + s.m_contentType + " " + s.m_minCount + " - " + s.m_maxCount + "\n";
                    }
                }

                message += "Content:\n";

                for (uint j = 0; j < PrefabCollection <RadioContentInfo> .PrefabCount(); ++j)
                {
                    RadioContentInfo content = PrefabCollection <RadioContentInfo> .GetPrefab(j);

                    if (content == null)
                    {
                        continue;
                    }
                    if (content.m_radioChannels != null)
                    {
                        if (content.m_radioChannels.Contains(info))
                        {
                            message += "\t[ContentInfo] " + content + " " + content.m_fileName + "\n";
                        }
                    }
                }

                CSLMusicMod.Log(message);
            }

            for (uint i = 0; i < PrefabCollection <DisasterInfo> .PrefabCount(); ++i)
            {
                DisasterInfo info = PrefabCollection <DisasterInfo> .GetPrefab(i);

                if (info == null)
                {
                    continue;
                }

                CSLMusicMod.Log("[DisasterContext] Disaster name: " + info.name);
            }
        }
예제 #11
0
        public static void StoreAll()
        {
            DefaultOptions.Clear();
            for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++)
            {
                DefaultOptions.Store(PrefabCollection <VehicleInfo> .GetPrefab(i));
            }

            DebugUtils.Log("Default values stored");
        }
		private static void EndRenderingImpl(TreeManager tm, RenderManager.CameraInfo cameraInfo)
		{
			unsafe
			{
				if (Input.GetKeyDown(KeyCode.F5) && Event.current.control)
				{
					DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, string.Format("TreeLimit: TreeCount={0}, TreeLimit={1}, CanPlaceMoreTrees={2}", tm.m_treeCount, LimitTreeManager.Helper.TreeLimit, tm.CheckLimits()));
					Array32<TreeInstance> mTrees = tm.m_trees;
					DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, string.Format("TreeLimit: ArraySize={0}, ItemCount={1}, UnusedCount={2}", mTrees.m_size, mTrees.ItemCount(), mTrees.GetType().GetField("m_unusedCount", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(mTrees)));
				}
				FastList<RenderGroup> mRenderedGroups = Singleton<RenderManager>.instance.m_renderedGroups;
				for (int i = 0; i < mRenderedGroups.m_size; i++)
				{
					RenderGroup mBuffer = mRenderedGroups.m_buffer[i];
					if ((mBuffer.m_instanceMask & 1 << (tm.m_treeLayer & 31)) != 0)
					{
						int mX = mBuffer.m_x * 540 / 45;
						int mZ = mBuffer.m_z * 540 / 45;
						int num = (mBuffer.m_x + 1) * 540 / 45 - 1;
						int mZ1 = (mBuffer.m_z + 1) * 540 / 45 - 1;
						for (int j = mZ; j <= mZ1; j++)
						{
							for (int k = mX; k <= num; k++)
							{
								uint mTreeGrid = tm.m_treeGrid[j * 540 + k];
								int num1 = 0;
								while (mTreeGrid != 0)
								{
									tm.m_trees.m_buffer[mTreeGrid].RenderInstance(cameraInfo, mTreeGrid, mBuffer.m_instanceMask);
									mTreeGrid = tm.m_trees.m_buffer[mTreeGrid].m_nextGridTree;
									int num2 = num1 + 1;
									num1 = num2;
									if (num2 < LimitTreeManager.Helper.TreeLimit)
									{
										continue;
									}
									CODebugBase<LogChannel>.Error(LogChannel.Core, string.Concat("Invalid list detected!\n", Environment.StackTrace));
									break;
								}
							}
						}
					}
				}
				int num3 = PrefabCollection<TreeInfo>.PrefabCount();
				for (int l = 0; l < num3; l++)
				{
					TreeInfo prefab = PrefabCollection<TreeInfo>.GetPrefab((uint)l);
					if (prefab != null && prefab.m_lodCount != 0)
					{
						TreeInstance.RenderLod(cameraInfo, prefab);
					}
				}
			}
		}
예제 #13
0
            public static void MaterialCache()
            {
                Log.Info("BENCHMARK> MaterialCache started ... ");
                materialList = new List <Material>();
                int count = PrefabCollection <NetInfo> .PrefabCount();

                int loadedCount = PrefabCollection <NetInfo> .LoadedCount();

                for (uint i = 0; i < loadedCount; ++i)
                {
                    NetInfo info = PrefabCollection <NetInfo> .GetLoaded(i);

                    if (info?.m_netAI != null && NetInfoExt.GetCanHideCrossings(info))
                    {
                        foreach (var nodeInfo in info.m_nodes)
                        {
                            if (nodeInfo?.m_nodeMaterial == null || nodeInfo.m_directConnect)
                            {
                                continue;
                            }
                            var nodeMaterial = nodeInfo.m_nodeMaterial;

                            // processed and cache material
                            var material2 = MaterialUtils.HideCrossings(nodeMaterial, null, info);

                            // add to cached material list.
                            materialList.Add(nodeMaterial);
                        }
                    }
                } // end for

                int totalCollisions = 0;

                foreach (var material in materialList)
                {
                    totalCollisions += CountCollisions(material);
                }
                float averageCollisions = totalCollisions / (float)materialList.Count;

                Log.Info($"BENCHMARK> totalCollisions={totalCollisions} averageCollisions={averageCollisions}");

                Log.Info($"BENCHMARK> peforming cache speed benchmark:");
                for (int i = 0; i < 1000; ++i)
                {
                    foreach (var material in materialList)
                    {
                        // its possible for some arguments to be null only if the material is cached already.
                        var material2 = MaterialUtils.HideCrossings(material, null, null);
                    }
                }
                Log.Info($"BENCHMARK> Done peforming cache speed benchmark {1000 * materialList.Count} times ");
            }
예제 #14
0
 private void readVehicles(bool global, bool force = false)
 {
     if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
     {
         TLMUtils.doLog("PrefabCount: {0} ({1})", PrefabCollection <VehicleInfo> .PrefabCount(), PrefabCollection <VehicleInfo> .LoadedCount());
     }
     if (PrefabCollection <VehicleInfo> .LoadedCount() == 0)
     {
         TLMUtils.doErrorLog("Prefabs not loaded!");
         return;
     }
     loadPrefixConfigList(global);
 }
예제 #15
0
        public static void Postfix(ref RenderManager.CameraInfo cameraInfo)
        {
            ItemClass.Availability availability = ToolManager.instance.m_properties.m_mode;
            FastList <RenderGroup> fastList     = RenderManager.instance.m_renderedGroups;
            int num1 = 1 << LayerMask.NameToLayer("Props") | 1 << RenderManager.instance.lightSystem.m_lightLayer;

            for (int index1 = 0; index1 < fastList.m_size; ++index1)
            {
                RenderGroup renderGroup = fastList.m_buffer[index1];
                if ((renderGroup.m_instanceMask & num1) != 0)
                {
                    int minX = renderGroup.m_x * 270 / 45;
                    int minZ = renderGroup.m_z * 270 / 45;
                    int maxX = (renderGroup.m_x + 1) * 270 / 45 - 1;
                    int maxZ = (renderGroup.m_z + 1) * 270 / 45 - 1;
                    for (int index2 = minZ; index2 <= maxZ; ++index2)
                    {
                        for (int index3 = minX; index3 <= maxX; ++index3)
                        {
                            int gridKey = index2 * 270 + index3;
                            List <PropContainer> list = PropUnlimiterManager.instance.GetPropsInGrid(gridKey);

                            if (list != null)
                            {
                                foreach (PropContainer instance in list)
                                {
                                    if (instance.extras.ContainsKey("accx") && instance.extras.ContainsKey("accy") && instance.extras.ContainsKey("accz"))
                                    {
                                        RenderProp(cameraInfo, instance);
                                    }
                                    else
                                    {
                                        instance.propInstance.RenderInstance(cameraInfo, 0, renderGroup.m_instanceMask);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            for (int index = 0; index < PrefabCollection <PropInfo> .PrefabCount(); ++index)
            {
                PropInfo prefab = PrefabCollection <PropInfo> .GetPrefab((uint)index);

                if (prefab != null && prefab.m_lodCount != 0)
                {
                    PropInstance.RenderLod(cameraInfo, prefab);
                }
            }
        }
        /* Load road netinfos */
        public void Populate(bool keepSelection = false)
        {
            NetInfo lastSelection = null;

            if (keepSelection)
            {
                try
                {
                    lastSelection = Value;
                }
                catch { keepSelection = false; }
            }

            var count = PrefabCollection <NetInfo> .PrefabCount();

            m_dictionary = new SortedDictionary <StringWithLaneCount, NetInfo>();
            bool freeCursor = UIWindow2.instance?.toolOnUI is FreeCursorTool;

            for (uint i = 0; i < count; i++)
            {
                var prefab = PrefabCollection <NetInfo> .GetPrefab(i);

                if (prefab != null)
                {
                    //Debug.Log($"Prefab {prefab.GetUncheckedLocalizedTitle()}, fl {prefab.m_hasBackwardVehicleLanes}, bl {prefab.m_hasForwardVehicleLanes}, car flag {(prefab.m_vehicleTypes & VehicleInfo.VehicleType.Car) != 0}");
                    if (IsEligible(prefab, freeCursor))
                    {
                        StringWithLaneCount slc = new StringWithLaneCount(prefab);
                        //beautified = (prefab.m_forwardVehicleLaneCount + prefab.m_backwardVehicleLaneCount) + "_" + beautified;
                        if (m_dictionary.ContainsKey(slc))
                        {
                            slc.Name += " [" + i + "]";
                        }
                        m_dictionary[slc] = prefab;
                        //Debug.Log("Loaded prefab: " + slc.Name + " ,underground: " + prefab.m_netAI.IsUnderground() + " ,overground: " + prefab.m_netAI.IsOverground());
                    }
                }
            }

            UpdateListWithPrefab(null);

            /* It seems that this code is there twice. (In this method and in the UpdateListWithPrefab method.) Yes, basically it is... :( */
            if (keepSelection)
            {
                int i = Array.IndexOf(m_netInfos, lastSelection);
                if (i > -1 && i < m_netInfos.Length)
                {
                    selectedIndex = i;
                }
            }
        }
        public static void BuildVehicleInfoDictionary()
        {
            m_prefabs.Clear();

            for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(i);

                if (prefab != null)
                {
                    m_prefabs[prefab.name] = prefab;
                }
            }
        }
예제 #18
0
        void itemsDropdown_eventSelectedIndexChanged(UIComponent component, int value)
        {
            for (uint i = 0; i <= PrefabCollection <BuildingInfo> .PrefabCount(); i++)
            {
                var prefab = PrefabCollection <BuildingInfo> .GetPrefab(i);

                if (prefab.name == itemsDropdown.selectedValue)
                {
                    GameObject.FindObjectOfType <BuildingTool>().m_prefab = prefab;
                    GameObject.FindObjectOfType <BuildingTool>().enabled  = true;
                    modesDropdown.selectedValue = prefab.m_placementMode.ToString();
                }
            }
        }
예제 #19
0
        void propToolDropdown_eventSelectedIndexChanged(UIComponent component, int value)
        {
            for (uint i = 0; i < PrefabCollection <PropInfo> .PrefabCount(); i++)
            {
                var prefab = PrefabCollection <PropInfo> .GetPrefab(i);

                if ((prefab != null) && prefab.name == propToolDropdown.selectedValue)
                {
                    var netTool = GameObject.FindObjectOfType <PropTool>();
                    netTool.m_prefab = prefab;
                    netTool.enabled  = true;
                }
            }
        }
예제 #20
0
        /// <summary>
        /// Collects prefabs of the specified prefab type.
        /// </summary>
        /// <typeparam name="TPrefab">The type of the prefab.</typeparam>
        /// <returns>
        /// A sequence of assets of the specified type.
        /// </returns>
        public static IEnumerable <PrefabInfo> Collect <TPrefab>() where TPrefab : PrefabInfo
        {
            int count = PrefabCollection <TPrefab> .PrefabCount();

            for (uint i = 0; i < count; i++)
            {
                PrefabInfo prefab = PrefabCollection <TPrefab> .GetPrefab(i);

                if ((UnityEngine.Object)prefab != (UnityEngine.Object)null)
                {
                    yield return(prefab);
                }
            }
        }
예제 #21
0
        public static void PatchEveryBuildingAI()
        {
            prefabCount = PrefabCollection <BuildingInfo> .PrefabCount();

            for (int i = 0; i < prefabCount; ++i)
            {
                prefab = PrefabCollection <BuildingInfo> .GetPrefab((uint)i);

                if (prefab != null)
                {
                    component = prefab.GetComponent <BuildingAI>();

                    if (component != null)
                    {
                        Type currentAiType = component.GetType();
                        Type newAiType     = null;

                        if (currentAiType == typeof(ResidentialBuildingAI))
                        {
                            newAiType = typeof(MyResidentialBuildingAI);
                        }
                        else if (currentAiType == typeof(CommercialBuildingAI))
                        {
                            newAiType = typeof(MyCommercialBuildingAI);
                        }
                        else if (currentAiType == typeof(IndustrialBuildingAI))
                        {
                            newAiType = typeof(MyIndustrialBuildingAI);
                        }
                        else if (currentAiType == typeof(IndustrialExtractorAI))
                        {
                            newAiType = typeof(MyIndustrialExtractorAI);
                        }
                        else if (currentAiType == typeof(OfficeBuildingAI))
                        {
                            newAiType = typeof(MyOfficeBuildingAI);
                        }

                        if (newAiType != null)
                        {
                            BuildingAI buildingAI = (BuildingAI)prefab.gameObject.AddComponent(newAiType);

                            buildingAI.m_info   = prefab;
                            prefab.m_buildingAI = buildingAI;
                            buildingAI.InitializePrefab();
                        }
                    }
                }
            }
        }
예제 #22
0
        internal static List <string> LoadBasicAssets(CitizenWealthDefinition definition)
        {
            var basicAssetsList = new List <string>();

            for (uint num = 0u; num < (ulong)PrefabCollection <VehicleInfo> .PrefabCount(); num += 1u)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(num);

                if (!(prefab == null) && definition.isFromSystem(prefab) && !VehicleUtils.IsTrailer(prefab))
                {
                    basicAssetsList.Add(prefab.name);
                }
            }
            return(basicAssetsList);
        }
예제 #23
0
        private void RemoveUnsupportedContent()
        {
            // Apply filtering after loading
            for (uint i = 0; i < PrefabCollection <RadioChannelInfo> .PrefabCount(); ++i)
            {
                RadioChannelInfo info = PrefabCollection <RadioChannelInfo> .GetPrefab(i);

                if (info == null)
                {
                    continue;
                }

                RemoveUnsupportedContent(info);
            }
        }
예제 #24
0
        internal static List <string> LoadBasicAssets(ServiceSystemDefinition definition)
        {
            List <string> basicAssetsList = new List <string>();

            for (uint num = 0u; (ulong)num < (ulong)((long)PrefabCollection <VehicleInfo> .PrefabCount()); num += 1u)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(num);

                if (!(prefab == null) && definition.isFromSystem(prefab) && !IsTrailer(prefab))
                {
                    basicAssetsList.Add(prefab.name);
                }
            }
            return(basicAssetsList);
        }
예제 #25
0
        internal static List <string> LoadBasicAssets(ref TransportSystemDefinition definition)
        {
            var basicAssetsList = new List <string>();

            TLMUtils.doLog("LoadBasicAssets: pre prefab read");
            for (uint num = 0u; num < (ulong)PrefabCollection <VehicleInfo> .PrefabCount(); num += 1u)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(num);

                if (!(prefab == null) && definition.IsFromSystem(prefab) && !VehicleUtils.IsTrailer(prefab))
                {
                    basicAssetsList.Add(prefab.name);
                }
            }
            return(basicAssetsList);
        }
        public static IEnumerable <DisasterInfo> GetDisasterInfos()
        {
            var numPrefabs = PrefabCollection <DisasterInfo> .PrefabCount();

            for (var i = 0; i < numPrefabs; i++)
            {
                var disasterInfo = PrefabCollection <DisasterInfo> .GetPrefab((uint)i);

                if (disasterInfo == null || disasterInfo.name == DisasterInfoNames.GenericFlood)
                {
                    continue;
                }

                yield return(disasterInfo);
            }
        }
            private IEnumerator Store()
            {
                while (PrefabCollection <VehicleInfo> .GetPrefab(0) == null)
                {
                    yield return(null);
                }

                DefaultOptions.Clear();
                for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++)
                {
                    DefaultOptions.Store(PrefabCollection <VehicleInfo> .GetPrefab(i));
                }

                DebugUtils.Log("Default values stored");
                Destroy(gameObject);
            }
예제 #28
0
        /// <summary>
        /// Looks up the custom assets placed in the city.
        /// </summary>
        void LookupSimulationAssets <P>(HashSet <string> packages, HashSet <string> assets) where P : PrefabInfo
        {
            try
            {
                int n = PrefabCollection <P> .PrefabCount();

                for (int i = 0; i < n; i++)
                {
                    Add(PrefabCollection <P> .PrefabName((uint)i), packages, assets);
                }
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
        }
예제 #29
0
        private List <T> GetInfos()
        {
            var  list = new List <T>();
            uint num  = 0u;

            while (num < (ulong)PrefabCollection <T> .PrefabCount())
            {
                T prefabInfo = PrefabCollection <T> .GetPrefab(num);

                if (prefabInfo != null)
                {
                    list.Add(prefabInfo);
                }
                num += 1u;
            }
            return(list);
        }
        public static void StoreAllModded()
        {
            if (m_modded.Count > 0)
            {
                return;
            }

            for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(i);

                if (prefab != null && !m_modded.ContainsKey(prefab.name))
                {
                    m_modded.Add(prefab.name, new DefaultOptions(prefab));
                }
            }
        }