/// <summary> /// Populates the given parent dictionaries with parent/child network info. /// </summary> /// <param name="parentDict"></param> internal static void GetParents(Dictionary <NetInfo, NetInfo> slopeParents, Dictionary <NetInfo, NetInfo> elevatedParents, Dictionary <NetInfo, NetInfo> bridgeParents, Dictionary <NetInfo, NetInfo> tunnelParents) { // Iterate through all loaded net prefabs. for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i) { NetInfo prefab = PrefabCollection <NetInfo> .GetLoaded(i); if (prefab.GetAI() is RoadAI roadAI) { // Road networks. RecordParent(slopeParents, roadAI.m_slopeInfo, prefab); RecordParent(elevatedParents, roadAI.m_elevatedInfo, prefab); RecordParent(bridgeParents, roadAI.m_bridgeInfo, prefab); RecordParent(tunnelParents, roadAI.m_tunnelInfo, prefab); } else if (prefab.GetAI() is TrainTrackAI railAI) { // Rail networks. RecordParent(slopeParents, railAI.m_slopeInfo, prefab); RecordParent(elevatedParents, railAI.m_elevatedInfo, prefab); RecordParent(bridgeParents, railAI.m_bridgeInfo, prefab); RecordParent(tunnelParents, railAI.m_tunnelInfo, prefab); } else if (prefab.GetAI() is PedestrianPathAI pathAI) { // Rail networks. RecordParent(slopeParents, pathAI.m_slopeInfo, prefab); RecordParent(elevatedParents, pathAI.m_elevatedInfo, prefab); RecordParent(bridgeParents, pathAI.m_bridgeInfo, prefab); RecordParent(tunnelParents, pathAI.m_tunnelInfo, prefab); } } }
public static NetInfo GetGroundInfo(this NetInfo info) { if (info.m_netAI is RoadAI) { return(info); } int n = PrefabCollection <NetInfo> .LoadedCount(); for (uint i = 0; i < n; ++i) { NetInfo info2 = PrefabCollection <NetInfo> .GetLoaded(i); if (IsNormalGroundRoad(info2)) { RoadAI ai = info2.m_netAI as RoadAI; bool b; b = ai.m_elevatedInfo == info; b |= ai.m_bridgeInfo == info; b |= ai.m_tunnelInfo == info; b |= ai.m_slopeInfo == info; if (b) { return(info2); } } } return(null);//in case of failure. }
private static void UpdateStats() { var count = PrefabCollection <BuildingInfo> .LoadedCount(); for (uint i = 0; i < count; i++) { var info = PrefabCollection <BuildingInfo> .GetLoaded(i); if (info?.m_buildingAI == null || info.m_buildingAI is SnowDumpAI || (info.m_buildingAI is LandfillSiteAI && ((LandfillSiteAI)info.m_buildingAI).m_electricityProduction == 0)) { continue; } var type = info.m_buildingAI.GetType(); var fieldInfo = type.GetField("m_pollutionRadius"); if (fieldInfo != null && fieldInfo.FieldType == typeof(float)) { var newValue = (float)fieldInfo.GetValue(info.m_buildingAI) * OriginalFactor; if (Math.Abs(newValue - 60) < 0.1) { newValue += 1; //to prevent multiplying twice } fieldInfo.SetValue(info.m_buildingAI, newValue); } } }
public static void Dumps() { for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i) { NetInfo info = PrefabCollection <NetInfo> .GetLoaded(i); if (info?.m_netAI is RoadAI) { string name = info.GetUncheckedLocalizedTitle().Trim(); bool b = false; b |= name == "Six-Lane Road"; //b |= name == "Six-Lane Road with Median"; //b |= name == "Eight-Lane Road"; //b |= name == "Four-Lane Road"; //b |= name == "Four-Lane Road with Median"; //b |= name.ToLower().Contains("suburb"); b |= name.ToLower().Contains("2+3"); b |= name.ToLower().Contains("2+4"); //b = info.category == "RoadsLarge"; if (b) { Extensions.Log("found " + name); info = (info.m_netAI as RoadAI).m_elevatedInfo; DumpDebugTextures(info); } } } }
// Call this to output values for PavementTextureDict and RoadTextureDict and insert them into this file! // That way HasPavementTexture and HasRoadTexture are fast for vanilla prefabs! public static void DisplayNetTextureDicts() { PavementTextureDict.Clear(); RoadTextureDict.Clear(); var pavementTexture = new StringBuilder(); var roadTexture = new StringBuilder(); for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { var prefab = PrefabCollection <NetInfo> .GetLoaded(i); if (prefab == null) { continue; } pavementTexture.Append($"{{ \"{prefab.name}\", {HasPavementTexture(prefab).ToString().ToLower()} }},\n"); roadTexture.Append($"{{ \"{prefab.name}\", {HasRoadTexture(prefab).ToString().ToLower()} }},\n"); } Debug.Log("PavementTextureDict"); Debug.Log(pavementTexture.ToString()); Debug.Log("RoadTextureDict"); Debug.Log(roadTexture.ToString()); }
public static void UnlockCableCarsButton() { UnlockManager.instance.m_properties.m_SubServiceMilestones[(int)ItemClass.SubService.PublicTransportCableCar] = null; for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++) { BuildingInfo buildInfo = PrefabCollection <BuildingInfo> .GetLoaded(i); if (buildInfo != null) { if (buildInfo.m_class.m_subService == ItemClass.SubService.PublicTransportCableCar) { buildInfo.m_UnlockMilestone = null; } } } for (uint x = 0; x < PrefabCollection <TransportInfo> .LoadedCount(); x++) { TransportInfo transportInfo = PrefabCollection <TransportInfo> .GetLoaded(x); if (transportInfo != null) { if (transportInfo.m_class.m_subService == ItemClass.SubService.PublicTransportCableCar) { transportInfo.m_UnlockMilestone = null; } } } }
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 }
private void SetProp(PropInfo replacementProp, int type) { currentProps[type] = replacementProp; for (uint i = 0; i < PrefabCollection<NetInfo>.LoadedCount(); i++) { var prefab = PrefabCollection<NetInfo>.GetLoaded(i); if (prefab == null) continue; if (prefab.m_lanes != null) { foreach (var lane in prefab.m_lanes) { if (lane.m_laneProps != null) { if (lane.m_laneProps.m_props != null) foreach (var LaneProp in lane.m_laneProps.m_props) { if (LaneProp.m_prop != null) { if (LaneProp.m_prop.name == defaultProps[type]) { LaneProp.m_finalProp = replacementProp; } } } } } } } }
/// <summary> /// Scans building assets, adding any using the shader to the list. /// </summary> private static void Add_Buildings(List <ManagedAsset> list) { int count = PrefabCollection <BuildingInfo> .LoadedCount(); ItemsScanned += count; for (uint index = 0; index < count; index++) { try { var building = PrefabCollection <BuildingInfo> .GetLoaded(index); if (building && building.m_isCustomContent) { if (building.m_mesh && HasShaderToken(building.m_mesh.name)) { list.Add(new ManagedAsset(building)); } if (building.m_props != null && ContainsShaderProps(building)) { list.Add(new ManagedAsset(building, true)); } } } catch (Exception error) { Debug.LogError($"[AdditiveShader] BuildingInfo error: \n{error}"); } } }
internal void LoadTrees() { Trees = new Dictionary <string, TreeInfo>(); TreesMeshData = new Dictionary <string, TreeMeshData>(); var treeCount = PrefabCollection <TreeInfo> .LoadedCount(); for (uint i = 0; i < treeCount; i++) { var tree = PrefabCollection <TreeInfo> .GetLoaded(i); if (tree == null || tree == Container || (UserMod.Settings != null && UserMod.Settings.IgnoreVanillaTrees && !tree.m_isCustomContent)) { continue; } if (tree.m_availableIn != ItemClass.Availability.All) { tree.m_availableIn = ItemClass.Availability.All; } if (tree.m_Atlas == null || string.IsNullOrEmpty(tree.m_Thumbnail) || tree.m_Thumbnail.IsNullOrWhiteSpace()) { ImageUtils.CreateThumbnailAtlas(GetName(tree), tree); } Trees.Add(tree.name, tree); TreesMeshData.Add(tree.name, new TreeMeshData(tree)); } }
public void OnLevelLoaded(LoadMode mode) { for (uint index = 0; index < PrefabCollection <BuildingInfo> .LoadedCount(); index++) { BuildingInfo prefab = PrefabCollection <BuildingInfo> .GetLoaded(index); if (prefab == null || prefab.m_props == null) { continue; } for (int propIndex = 0; propIndex < prefab.m_props.Length; propIndex++) { BuildingInfo.Prop propItem = prefab.m_props[propIndex]; if (propItem.m_prop == null) { continue; } string propName = propItem.m_prop.name; if (propName == "Billboard_big_variation" || propName == "Billboard_big_variation_01" || propName == "Billboard_big_variation_02" || propName == "Billboard_big_variation_04" || propName == "neon-yakisoba-noodles" || propName == "neon-burned-bean-coffee" || propName == "neon-morellos") { propItem.m_probability = 0; } } } }
public void RemovePillar() { for (uint num = 0u; num < PrefabCollection <NetInfo> .LoadedCount(); num++) { NetInfo loaded = PrefabCollection <NetInfo> .GetLoaded(num); if (loaded != null) { if (CSURUtil.IsCSUROffset(loaded)) { var roadAI = loaded.m_netAI as RoadAI; RoadBridgeAI elevatedAI = null; if ((loaded.m_netAI is RoadBridgeAI) && (Regex.Match(loaded.name, "Elevated", RegexOptions.IgnoreCase)).Success) { elevatedAI = loaded.m_netAI as RoadBridgeAI; } else { continue; } elevatedAI.m_bridgePillarInfo = null;// PrefabCollection<BuildingInfo>.FindLoaded("CSUR 2DC.Ama S-1_Data"); Debug.Log("Remove pilla for " + loaded.name.ToString()); } } } }
private static void UpdateTrainTracks() { var vanillaTracksNames = new[] { "Train Track", "Train Track Elevated", "Train Track Bridge", "Train Track Slope", "Train Track Tunnel" }; //var vanillaTracksCosts = vanillaTracksNames.ToDictionary(Initializer.DetectVersion, GetTrackCost); //var toGroundMultipliers = vanillaTracksCosts.ToDictionary(keyValue => keyValue.Key, // keyValue => keyValue.Value == vanillaTracksCosts[NetInfoVersion.Ground] ? 1f : keyValue.Value / (float)vanillaTracksCosts[NetInfoVersion.Ground]); //var baseMultiplier = 1;// GetTrackCost("Metro Track Ground") / (float)GetTrackCost("Train Track"); for (ushort i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { var netInfo = PrefabCollection <NetInfo> .GetLoaded(i); var ai = netInfo?.m_netAI as PlayerNetAI; if (ai == null || netInfo.m_class.m_service != ItemClass.Service.PublicTransport || netInfo.m_class.m_subService != ItemClass.SubService.PublicTransportTrain) { continue; } var version = Initializer.DetectVersion(netInfo.name); //var wasCost = GetTrackCost(netInfo); //var wasMaintCost = GetTrackMaintCost(netInfo); //if (wasCost == 0) //{ // continue; //} //var newCost = wasCost / toGroundMultipliers[version] * // Initializer.GetCostMultiplier(version) * GetAdditionalCostMultiplier(version) * baseMultiplier; #if DEBUG //UnityEngine.Debug.Log($"Updating asset {netInfo.name} cost. Was cost: {wasCost}. New cost: {newCost}"); #endif ai.m_constructionCost = (int)GetTrackCost(version); ai.m_maintenanceCost = (int)GetTrackMaintCost(version); } }
public void Setup() { #if DEBUG Debug.Log("Looking up cargo station prefabs..."); #endif cargoStations.Clear(); for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++) { var prefab = PrefabCollection <BuildingInfo> .GetLoaded(i); if (prefab == null) { Debug.LogWarningFormat("Uninitialized building prefab #{0}! (this should not happen)", i); continue; } if (prefab.m_buildingAI is CargoStationAI) { #if DEBUG Debug.LogFormat("Cargo station prefab found: {0}", prefab.name); #endif cargoStations.Add(prefab.m_prefabDataIndex); } } #if DEBUG Debug.LogFormat("Found {0} cargo station prefabs", cargoStations.Count); #endif for (ushort i = 0; i < BuildingManager.instance.m_buildings.m_size; i++) { AddBuilding(i); } BuildingManager.instance.EventBuildingCreated += AddBuilding; BuildingManager.instance.EventBuildingReleased += RemoveBuilding; }
public override void OnLoadData() { base.OnLoadData(); if (!UserMod.Settings.SavePerCity) { return; } var data = serializableDataManager.LoadData(m_dataID); if (data == null || data.Length == 0) { return; } var binaryFormatter = new BinaryFormatter(); using (var memoryStream = new MemoryStream(data)) { CustomBuildingDataList = binaryFormatter.Deserialize(memoryStream) as List <CustomizablePropertiesEntry>; } SimulationManager.instance.AddAction(() => { for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++) { Loading.LoadCustomData(PrefabCollection <BuildingInfo> .GetLoaded(i)); } }); }
public void Initialize() { if (_isInitialized) { return; } AddPanelButton(); for (uint x = 0; x < PrefabCollection <VehicleInfo> .LoadedCount(); x++) { var vehicleInfo = PrefabCollection <VehicleInfo> .GetLoaded(x); if (vehicleInfo == null) { continue; } var vehicleName = vehicleInfo.name; if (CustomVehicleNames.TryGetValue(vehicleInfo.name, out var props) && props.DefaultName) { vehicleName = props.CustomName; } if (AllLoadedVehicles.TryGetValue(vehicleName, out var _)) { continue; } AllLoadedVehicles.Add(vehicleName, vehicleInfo); } _isInitialized = true; }
public void OnSettingsUI(UIHelperBase helper) { helper.AddSpace(10); Instance.SavePerCityCheckBox = (UICheckBox)helper.AddCheckbox(Instance.CheckboxText, Settings.SavePerCity, (b) => { Settings.SavePerCity = b; Settings.Save(); }); Instance.SavePerCityCheckBox.parent.Find <UILabel>("Label").disabledTextColor = Color.gray; helper.AddSpace(10); Instance.ResetAllButton = (UIButton)helper.AddButton(Instance.ButtonText, () => { SimulationManager.instance.AddAction(() => { for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++) { var building = PrefabCollection <BuildingInfo> .GetLoaded(i); if (building == null || building.m_buildingAI == null || !(building.m_buildingAI.GetType().IsSubclassOf(typeof(PlayerBuildingAI)))) { continue; } CustomizeIt.instance.ResetBuilding(building); } }); }); Instance.ToggleOptionPanelControls(false); }
public static void UVTest() { NetInfo info1 = null, info2 = null; for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i) { NetInfo info = PrefabCollection <NetInfo> .GetLoaded(i); if (info.IsNormalGroundRoad()) { string name = info.GetUncheckedLocalizedTitle().Trim(); bool b1 = name == "Six-Lane Road"; bool b2 = name.Contains("Six-Lane Road") && name.ToLower().Contains("grass"); if (b1) { info1 = info; } if (b2) { info2 = info; } if (info1 != null && info2 != null) { DumpUtils.LogUVs(info1, info2); break; } } } }
public static List <BuildingInfo> GetMetroOverhaulPillars() { var pillars = new List <BuildingInfo>(); var prefabCount = PrefabCollection <BuildingInfo> .LoadedCount(); // support for custom pillars for (uint prefabIndex = 0; prefabIndex < prefabCount; prefabIndex++) { var prefab = PrefabCollection <BuildingInfo> .GetLoaded(prefabIndex); if (prefab == null) { continue; } // only accept buildings with a basic AI if (prefab.m_buildingAI.GetType() != typeof(BuildingAI)) { continue; } if (prefab.name.StartsWith(MetroOverhaulPackageName)) { pillars.Add(prefab); } } return(pillars); }
public static void NameTest() { for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i) { NetInfo info = PrefabCollection <NetInfo> .GetLoaded(i); if (info?.m_netAI is RoadAI) { string name = info.GetUncheckedLocalizedTitle(); bool b; //b = name.ToLower().Contains("asym"); b = true; if (b) { string m = name; RoadAI ai = info.m_netAI as RoadAI; //m += "|" + ai?.m_elevatedInfo?.name; //m += "|" + ai?.m_bridgeInfo?.name; //m += "|" + ai?.m_slopeInfo?.name; //m += "|" + ai?.m_tunnelInfo?.name; m += "|| level:" + info.GetClassLevel(); m += " class:" + info.m_class; m += " category:" + info.category; Extensions.Log(m); } } } Extensions.Log(Extensions.BIG("DONE PRITING NAMES!")); }
private BuildingInfo findEducationBuildingInfo() { // First check for the known Medical Clinic BuildingInfo educationBuildingInfo = PrefabCollection <BuildingInfo> .FindLoaded(COLLEGE_NAME); if (educationBuildingInfo != null) { return(educationBuildingInfo); } // Try 5 times to search for the Medical Clinic before giving up if (++this.numTimesSearchedForMedicalClinic < 5) { return(null); } // Attempt to find a suitable medical building that can be used as a template Logger.logInfo(LOG_INITIALIZER, "DormitoryInitializer.findMedicalBuildingInfo -- Couldn't find the Medical Clinic asset after {0} tries, attempting to search for any Building with a HospitalAi", this.numTimesSearchedForMedicalClinic); for (uint i = 0; (long)PrefabCollection <BuildingInfo> .LoadedCount() > (long)i; ++i) { BuildingInfo buildingInfo = PrefabCollection <BuildingInfo> .GetLoaded(i); if (buildingInfo != null && buildingInfo.GetService() == ItemClass.Service.Education && !buildingInfo.m_buildingAI.IsWonder() && buildingInfo.m_buildingAI is HospitalAI) { Logger.logInfo(LOG_INITIALIZER, "DormitoryInitializer.findMedicalBuildingInfo -- Using the {0} as a template instead of the Medical Clinic", buildingInfo); return(buildingInfo); } } // Return null to try again next time return(null); }
/// <summary> /// Applies a thinner size to electrial wires (networks using Custom/Net/Electricity shader). /// </summary> internal void ApplyThinnerWires() { // Use Railway Replacer figure for thinner wires. Vector2 thinnerWireScale = new Vector2(3.5f, 1f); /// Target shader name. string shaderName = "Custom/Net/Electricity"; Logging.Message("thinning electrical wires"); // Iterate thorugh each loaded net prefab. for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i) { NetInfo netPrefab = PrefabCollection <NetInfo> .GetLoaded(i); if (netPrefab?.m_segments != null) { // Iterate through each segment in prefab. foreach (NetInfo.Segment segment in netPrefab.m_segments) { // Check for electricity shader. Shader shader = segment?.m_material?.shader; if (shader != null && shader.name == shaderName) { // Using electricity shader - record original values (if we haven't already). if (!segmentWires.ContainsKey(segment)) { segmentWires.Add(segment, new WireThickness(segment.m_material.mainTextureScale, segment.m_segmentMaterial.mainTextureScale)); } // Rescale materials. segment.m_material.mainTextureScale = thinnerWireScale; segment.m_segmentMaterial.mainTextureScale = thinnerWireScale; } } // Iterate through each node in prefab. foreach (NetInfo.Node node in netPrefab.m_nodes) { // Check for electricity shader. Shader shader = node?.m_material?.shader; if (shader != null && shader.name == shaderName) { // Using electricity shader - record original values (if we haven't already). if (!nodeWires.ContainsKey(node)) { nodeWires.Add(node, new WireThickness(node.m_material.mainTextureScale, node.m_nodeMaterial.mainTextureScale)); } // Rescale materials. node.m_material.mainTextureScale = thinnerWireScale; node.m_nodeMaterial.mainTextureScale = thinnerWireScale; } } } } }
public static void ReplaceLaneProp(string original, string replacement) { for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { var netInfo = PrefabCollection <NetInfo> .GetLoaded(i); if (netInfo == null) { Log.Info("SSE: The name '" + netInfo + "'does not belong to a loaded net!"); return; } if (!netInfo.m_hasPedestrianLanes) { continue; } var replacementProp = PrefabCollection <PropInfo> .FindLoaded(replacement); if (replacementProp == null) { Log.Info("SSE:The name '" + replacement + "'does not belong to a loaded prop!"); return; } if (netInfo.m_lanes != null) { foreach (var lane in netInfo.m_lanes) { if (lane != null && lane.m_laneProps != null && lane.m_laneProps.m_props != null) { foreach (var laneProp in lane.m_laneProps.m_props) { if (laneProp != null && laneProp.m_prop != null && laneProp.m_prop.name == original) { laneProp.m_prop = replacementProp; laneProp.m_finalProp = replacementProp; switch (lane.m_laneProps.name) { case "Props - Gravel Left": laneProp.m_angle = -90; break; case "Props - Gravel Right": laneProp.m_angle = 90; break; case "Props - Basic Right": laneProp.m_angle = 180; break; } } } } } } } }
public void OnLevelLoaded(LoadMode mode) { // Don't load if it's not a game if (!NetworkSkinsMod.CheckLoadMode(mode)) { return; } // Save defaults for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { var prefab = PrefabCollection <NetInfo> .GetLoaded(i); if (prefab == null) { continue; } SaveDefaults(prefab); } availablePillars.Add(null); // no pillar = null; // support for custom pillars for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++) { var prefab = PrefabCollection <BuildingInfo> .GetLoaded(i); if (prefab == null) { continue; } // only accept buildings with a basic AI if (prefab.m_buildingAI.GetType() != typeof(BuildingAI)) { continue; } var asset = PackageManager.FindAssetByName(prefab.name); var crpPath = asset?.package?.packagePath; if (crpPath == null) { continue; } var pillarConfigPath = Path.Combine(Path.GetDirectoryName(crpPath), "Pillar.xml"); // TODO parse the config file if (File.Exists(pillarConfigPath)) { availablePillars.Add(prefab); } } }
// called when level is loaded public void OnLevelLoaded(LoadMode mode) { // loads texture container if (!Utils.LoadTextures()) { ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel", true); panel.SetMessage("CSUR Loader", "Road texture not found. This indicates that " + $"the asset containing textures for CSUR roads are not loaded into the game. " + $"Please check if the file CSURTextureContainer.crp is present in the workshop" + $"folder for CSUR Loader.", true); return; } OptionUI.LoadSetting(); for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { NetInfo asset = PrefabCollection <NetInfo> .GetLoaded(i); if (Utils.IsCSUR(asset)) { Utils.ApplyTexture(asset); Utils.SetOutsideConnection(asset); Utils.ApplyGeneralSkins(asset); if (Utils.IsTwoWayCSUR(asset)) { Utils.ApplyIntersectionSkins(asset); } Utils.SetColor(asset, RoadSkins.roadColor); if (Utils.IsCSURDerivative(asset)) { Utils.LinkDerivative(asset); } else { Utils.LinkBridgeMode(asset); } } else if (asset != null && OptionUI.changeAllRoadColor) { if (asset.m_netAI is RoadAI) { //Debug.Log("Process color change for " + asset.name.ToString()); Utils.SetColor(asset, RoadSkins.roadColor); } } } RoadSkins.SetSidewalkPillars(); //Change All color RoadSkins.ChangeBuiltRoadColor(); //Refresh networks to apply skin change RoadSkins.RefreshNetworks(); if (Utils.LOAD_LOD) { NetManager.instance.RebuildLods(); } OptionUI.levelLoaded = true; }
public void Lock() { for (int index = 0; index < PrefabCollection <TransportInfo> .LoadedCount(); ++index) { TransportInfo loaded = PrefabCollection <TransportInfo> .GetLoaded((uint)index); loaded.m_UnlockMilestone = GetDefaultMilestone(loaded.GetSubService()); } }
public void ReplaceAllBuildingTextures() { var prefabCount = PrefabCollection <BuildingInfo> .LoadedCount(); for (var i = 0u; i < prefabCount; i++) { ReplaceBuildingTextures(PrefabCollection <BuildingInfo> .GetLoaded(i)); } }
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); } } } } } }
private void DumpButtonClick(UIComponent component, UIMouseEventParameter eventParam) { using (StreamWriter writer = new StreamWriter(@"D:\Downloads\prefabs.txt", false)) { for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { writer.WriteLine($"nr: {i} => {PrefabCollection<NetInfo>.GetLoaded(i).name}"); } } }
/// <summary> /// Builds the lists of loaded trees props. Must be called before use. /// </summary> internal static void BuildLists() { // Initialise lists. List <PropInfo> props = new List <PropInfo>(); List <TreeInfo> trees = new List <TreeInfo>(); // Iterate through all loaded props. for (uint i = 0u; i < PrefabCollection <PropInfo> .LoadedCount(); ++i) { // Get prop and add to our list, if it isn't null. PropInfo prop = PrefabCollection <PropInfo> .GetLoaded(i); if (prop?.name != null) { props.Add(prop); // Try to find random prop template if it isn't already there. if (RandomPropTemplate == null) { if (prop.name.EndsWith("BOBRandomPropTemplate_Data")) { RandomPropTemplate = prop; } } } } // Iterate through all loaded trees. for (uint i = 0u; i < PrefabCollection <TreeInfo> .LoadedCount(); ++i) { // Get tree and add to our list, if it isn't null. TreeInfo tree = PrefabCollection <TreeInfo> .GetLoaded(i); if (tree?.name != null) { trees.Add(tree); // Try to find random tree template if it isn't already there. if (RandomTreeTemplate == null) { if (tree.name.EndsWith("BOBRandomTreeTemplate_Data")) { RandomTreeTemplate = tree; } } } } // Order lists by name. LoadedProps = props.OrderBy(prop => GetDisplayName(prop)).ToList().ToArray(); LoadedTrees = trees.OrderBy(tree => GetDisplayName(tree)).ToList().ToArray(); // Populate creators dictionary. GetCreators(); }