private void BuildNonDefault(ModConfigModel config) { ModSettingModel modSetting = JsonHelper.FromJsonFile <ModSettingModel>(CustomMilestonesMod.modSettingFilePath) ?? new ModSettingModel(); if (modSetting.BuildAllAssets) { CustomAssets assets = new CustomAssets(); for (uint index = 0; index < PrefabCollection <NetInfo> .LoadedCount(); index++) { NetInfo net = PrefabCollection <NetInfo> .GetLoaded(index); if (net.GetUnlockMilestone().GetLevel() > 0 && !config.RoadIncludes.Contains(config.Renames.GetRename(net.name)) && !config.RoadGroups.Any(m => m.Value.Contains(net.name))) { assets.Roads.Add(new ItemModel() { Name = net.name, LocalizedName = net.GetLocalizedTitle(), Expansions = net.m_class.m_service.ToString() + "|" + net.m_class.m_subService.ToString() + "|" + net.category }); } } for (uint index = 0; index < PrefabCollection <BuildingInfo> .LoadedCount(); index++) { BuildingInfo building = PrefabCollection <BuildingInfo> .GetLoaded(index); if (building.GetUnlockMilestone().GetLevel() > 0 && !config.BuildingIncludes.Contains(config.Renames.GetRename(building.name)) && !config.BuildingGroups.Any(m => m.Value.Contains(building.name))) { if (building.category == "RoadsIntersection") { assets.Roads.Add(new ItemModel() { Name = building.name, LocalizedName = building.GetLocalizedTitle() }); } else { assets.Buildings.Add(new ItemModel() { Name = building.name, LocalizedName = building.GetLocalizedTitle() }); } } } modSetting.BuildAllAssets = false; JsonHelper.ToJsonFile(modSetting, CustomMilestonesMod.modSettingFilePath); XmlHelper.ToXmlFile(assets, DataLocation.executableDirectory + "\\CustomMilestone-Non-Default.xml"); } }
public string GetShowName() { if (infoType == "PROP") { return(propPrefab.GetLocalizedTitle() + (isBasicShape ? " (Basic)" : string.Empty)); } else // if (infoType == "BUILDING") { return(buildingPrefab.GetLocalizedTitle() + (isBasicShape ? " (Basic)" : string.Empty)); } }
private void GetServiceBuildings(BuildingManager buildingManager, DistrictManager districtManager, ItemClass.Service service, string filter) { var m_size = buildingManager.GetServiceBuildings(service); for (ushort i = 0; i < m_size.m_size; i++) { Building building = buildingManager.m_buildings.m_buffer[m_size[i]]; if (EnumExtensions.IsFlagSet(building.m_flags, Building.Flags.Created)) { BuildingInfo info = building.Info; string name = EnumExtensions.IsFlagSet(building.m_flags, Building.Flags.CustomName) ? buildingManager.GetBuildingName(m_size[i], info.m_instanceID) : info.GetLocalizedTitle(); if (!String.IsNullOrEmpty(filter) && name.ToLower().Contains(filter.ToLower())) { continue; } InstanceID instanceID = InstanceID.Empty; instanceID.Building = m_size[i]; byte districtID = districtManager.GetDistrict(building.m_position); byte parkID = districtManager.GetPark(building.m_position); buildings.Add(new XMLBuilding { instanceID = instanceID, name = name, district = parkID != 0 ? districtManager.GetParkName(parkID) : districtID == 0 ? Singleton <SimulationManager> .instance.m_metaData.m_CityName : districtManager.GetDistrictName(districtID), position = building.m_position, service = service, stats = info.m_buildingAI.GetLocalizedStats(m_size[i], ref building).Replace(Environment.NewLine, "; "), status = info.m_buildingAI.GetLocalizedStatus(m_size[i], ref building), tooltip = info.GetLocalizedTooltip(), upkeep = info.m_buildingAI.GetResourceRate(m_size[i], ref building, EconomyManager.Resource.Maintenance) }); buildingMap.Add(m_size[i]); } } }
public void RefreshMilestones(ModConfigModel config) { CustomMilestoneModel customMilestone = XmlHelper.FromXmlFile <CustomMilestoneModel>(_xmlFilePath); if (customMilestone.Rebuild) { customMilestone.Rebuild = false; //读取默认道路信息 for (uint index = 0; index < PrefabCollection <NetInfo> .LoadedCount(); index++) { NetInfo net = PrefabCollection <NetInfo> .GetLoaded(index); if (config.RoadIncludes.Contains(config.Renames.GetRename(net.name)) && !customMilestone.Exists(config.Renames.GetRename(net.name))) { if (config.BuildingExistsRoads.Contains(config.Renames.GetRename(net.name))) { customMilestone.Milestones[net.GetUnlockMilestone().GetLevel()].Buildings.Add(new ItemModel() { Name = config.Renames.GetRename(net.name), LocalizedName = net.GetLocalizedTitle(), Expansions = net.m_class.m_service.ToString() + "|" + net.m_class.m_subService.ToString() + "|" + net.category }); } else { customMilestone.Milestones[net.GetUnlockMilestone().GetLevel()].Roads.Add(new ItemModel() { Name = config.Renames.GetRename(net.name), LocalizedName = net.GetLocalizedTitle(), Expansions = net.m_class.m_service.ToString() + "|" + net.m_class.m_subService.ToString() + "|" + net.category }); } } } //读取默认建筑信息 for (uint index = 0; index < PrefabCollection <BuildingInfo> .LoadedCount(); index++) { BuildingInfo building = PrefabCollection <BuildingInfo> .GetLoaded(index); if (config.BuildingIncludes.Contains(config.Renames.GetRename(building.name)) && !customMilestone.Exists(config.Renames.GetRename(building.name))) { if (config.RoadExistsBuildings.Contains(config.Renames.GetRename(building.name))) { customMilestone.Milestones[building.GetUnlockMilestone().GetLevel()].Roads.Add(new ItemModel() { Name = config.Renames.GetRename(building.name), LocalizedName = building.GetLocalizedTitle(), Expansions = building.m_class.m_service.ToString() + "|" + building.m_class.m_subService.ToString() + "|" + building.category }); } else { customMilestone.Milestones[building.GetUnlockMilestone().GetLevel()].Buildings.Add(new ItemModel() { Name = config.Renames.GetRename(building.name), LocalizedName = building.GetLocalizedTitle(), Expansions = building.m_class.m_service.ToString() + "|" + building.m_class.m_subService.ToString() + "|" + building.category }); } } } //读取默认功能信息 foreach (var featureEnum in Utils.GetOrderedEnumData <UnlockManager.Feature>()) { if (config.Features.Contains(featureEnum.enumName) && !customMilestone.Exists(featureEnum.enumName, "Feature")) { var level = Singleton <UnlockManager> .instance.m_properties.m_FeatureMilestones[(int)featureEnum.enumValue].GetLevel(); if (config.ServiceExistsFeatures.Contains(featureEnum.enumName)) { customMilestone.Milestones[level].Services.Add(new ItemModel() { Name = featureEnum.enumName, LocalizedName = featureEnum.GetLocalizedName(), }); } else { customMilestone.Milestones[level].Features.Add(new ItemModel() { Name = featureEnum.enumName, LocalizedName = featureEnum.GetLocalizedName(), }); } } } //读取默认服务信息 foreach (var serviceEnum in Utils.GetOrderedEnumData <ItemClass.Service>()) { if (config.Services.Contains(serviceEnum.enumName) && !customMilestone.Exists(serviceEnum.enumName, "Service")) { var level = Singleton <UnlockManager> .instance.m_properties.m_ServiceMilestones[(int)serviceEnum.enumValue].GetLevel(); customMilestone.Milestones[level].Services.Add(new ItemModel() { Name = serviceEnum.enumName, LocalizedName = serviceEnum.GetLocalizedName(), }); } } //读取默认服务政策信息 foreach (var policyEnum in Utils.GetOrderedEnumData <DistrictPolicies.Policies>("Services")) { var index = (int)(policyEnum.enumValue & (DistrictPolicies.Policies) 31); var level = Singleton <UnlockManager> .instance.m_properties.m_ServicePolicyMilestones[index].GetLevel(); customMilestone.Milestones[level].Policies.Add(new ItemModel() { Name = policyEnum.enumName, LocalizedName = policyEnum.GetLocalizedName(), Expansions = policyEnum.enumCategory }); } //读取默认税收政策信息 foreach (var policyEnum in Utils.GetOrderedEnumData <DistrictPolicies.Policies>("Taxation")) { var index = (int)(policyEnum.enumValue & (DistrictPolicies.Policies) 31); var level = Singleton <UnlockManager> .instance.m_properties.m_TaxationPolicyMilestones[index].GetLevel(); customMilestone.Milestones[level].Policies.Add(new ItemModel() { Name = policyEnum.enumName, LocalizedName = policyEnum.GetLocalizedName(), Expansions = policyEnum.enumCategory }); } //读取默认城市规划政策信息 foreach (var policyEnum in Utils.GetOrderedEnumData <DistrictPolicies.Policies>("CityPlanning")) { var index = (int)(policyEnum.enumValue & (DistrictPolicies.Policies) 31); var level = Singleton <UnlockManager> .instance.m_properties.m_CityPlanningPolicyMilestones[index].GetLevel(); customMilestone.Milestones[level].Policies.Add(new ItemModel() { Name = policyEnum.enumName, LocalizedName = policyEnum.GetLocalizedName(), Expansions = policyEnum.enumCategory }); } //读取默认信息面板信息 foreach (var infoMode in Utils.GetOrderedEnumData <InfoManager.InfoMode>()) { var level = Singleton <UnlockManager> .instance.m_properties.m_InfoModeMilestones[(int)infoMode.enumValue].GetLevel(); customMilestone.Milestones[level].InfoViews.Add(new ItemModel() { Name = infoMode.enumName, LocalizedName = Locale.Get("INFOVIEWS", infoMode.enumName) }); } XmlHelper.ToXmlFile(customMilestone, _xmlFilePath); } else { MilestoneInfo[] progressionMilestones = Singleton <UnlockManager> .instance.m_properties.m_progressionMilestones; //根据配置文件刷新里程碑信息 foreach (MilestoneModel milestoneModel in customMilestone.Milestones) { MilestoneInfo milestoneInfo = milestoneModel.Level > 0 ? progressionMilestones[milestoneModel.Level - 1] : null; //刷新里程碑奖金、地块 var count = (milestoneModel.Level == 0 && milestoneModel.PurchaseAreasCount == 0) ? 1 : milestoneModel.PurchaseAreasCount; var total = customMilestone.Milestones.Take(Array.IndexOf(customMilestone.Milestones, milestoneModel)).Sum(m => m.PurchaseAreasCount); for (int i = total; i < total + count && i < 9; i++) { Singleton <UnlockManager> .instance.m_properties.m_AreaMilestones[i] = milestoneInfo; } if (milestoneInfo != null) { milestoneInfo.m_rewardCash = milestoneModel.RewardCash.Value; } //刷新道路 foreach (var roadModel in milestoneModel.Roads) { if (config.RoadIncludes.Contains(roadModel.Name) || config.RoadExistsBuildings.Contains(roadModel.Name)) { RefreshRoadMilestone(roadModel.Name, milestoneInfo, config); } } //刷新建筑 foreach (var buildingModel in milestoneModel.Buildings) { if (config.BuildingIncludes.Contains(buildingModel.Name) || config.BuildingExistsRoads.Contains(buildingModel.Name)) { RefreshBuildingMilestone(buildingModel.Name, milestoneInfo, config); } } //刷新功能 foreach (var featureModel in milestoneModel.Features) { if (config.Features.Contains(featureModel.Name)) { RefreshFeatureMilestones(featureModel.Name, milestoneInfo, config); } } //刷新服务 foreach (var serviceModel in milestoneModel.Services) { if (config.Services.Contains(serviceModel.Name) || config.ServiceExistsFeatures.Contains(serviceModel.Name)) { RefreshServiceMilestones(serviceModel.Name, milestoneInfo, config); } } //刷新政策 foreach (var policyModel in milestoneModel.Policies) { RefreshPolicyMilestones(policyModel.Name, milestoneInfo); } } } }
private void Window(int id) { GUI.DragWindow(new Rect(0, 0, 375, 24)); GUI.Label(new Rect(5, 18, 365, 23), "Choose station tracks to use on \"" + selectedPrefab.GetLocalizedTitle() + "\""); ushort h = 43; foreach (STType type in prefabNetTypes) { GUI.Label(new Rect(35, 2 + h, 330, 20), type.ToString()); var expanded = expandedTypes.ContainsKey(type); ushort toIncrease = 28; if (GUI.Button(new Rect(5, h, 25, 25), expanded ? "▼" : "►")) { if (expanded) { expandedTypes.Remove(type); expanded = false; } else { expandedTypes.Add(type, Vector2.zero); expanded = true; } winheight = 48 + (28 * prefabNetTypes.Count) + (expandedTypes.Count * 100); } if (expanded) { var t = tracks[type]; if (t.Count > 10) { toIncrease = 304; GUI.Box(new Rect(5, 27 + h, 365, 272), string.Empty); expandedTypes[type] = GUI.BeginScrollView(new Rect(7, 29 + h, 361, 268), expandedTypes[type], new Rect(0, 0, 342, t.Count * 27 + 4)); DrawButtons(t, type, true); GUI.EndScrollView(); } else { toIncrease = (ushort)(34 + 27 * t.Count); GUI.Box(new Rect(5, 27 + h, 365, 27 * t.Count + 4), string.Empty); GUI.BeginGroup(new Rect(new Rect(7, 29 + h, 361, 27 * t.Count))); DrawButtons(t, type, false); GUI.EndGroup(); } } h += toIncrease; } winheight = h + 2; }