public static List <ushort> getAllBuildingsFromCity(ref ServiceSystemDefinition ssd, int?districtId = null, bool strict = false, bool mustAllowSpawn = false) { var saida = new List <ushort>(); BuildingManager bm = Singleton <BuildingManager> .instance; FastList <ushort> buildings; IVMCDistrictExtension ext = ssd.GetDistrictExtension(); if (ssd.outsideConnection) { buildings = bm.GetOutsideConnections(); } else { buildings = bm.GetServiceBuildings(ssd.service); } LogUtils.DoLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size); foreach (ushort i in buildings) { ref Building building = ref bm.m_buildings.m_buffer[i]; if (ssd.isFromSystem(building.Info)) { if (districtId != null && ssd.AllowRestrictions) { byte buildingDistrict = DistrictManager.instance.GetDistrict(bm.m_buildings.m_buffer[i].m_position); if (districtId != buildingDistrict && (strict || (!ext.GetAllowServeOtherDistricts(buildingDistrict) ?? VehiclesMasterControlMod.allowServeOtherDistrictsAsDefault))) { continue; } } if (mustAllowSpawn) { int max = GetMaxVehiclesBuilding(ref building, ssd.vehicleType, ssd.level); int count = 0; int cargo = 0; int capacity = 0; int inbound = 0; int outbound = 0; VMCBuildingUtils.CalculateOwnVehicles(ref bm.m_buildings.m_buffer[i], ref count, ref cargo, ref capacity, ref inbound, ref outbound); if (count >= max) { continue; } } saida.Add(i); } }
private void Awake() { VMCTabPanel.eventOnDistrictSelectionChanged += onDistrictChanged; mainPanel = GetComponentInChildren <UIScrollablePanel>(); mainPanel.autoLayout = false; m_uiHelper = new UIHelperExtension(mainPanel); KlyteMonoUtils.CreateUIElement(out UILabel lbl, mainPanel.transform, "DistrictColorLabel", new Vector4(5, 5, 250, 40)); allowColorChange = SingletonLite <T> .instance.GetSSD().AllowColorChanging(); if (allowColorChange) { KlyteMonoUtils.LimitWidth(lbl, 250); lbl.autoSize = true; lbl.localeID = "K45_VMC_DISTRICT_COLOR_LABEL"; m_districtColor = KlyteMonoUtils.CreateColorField(mainPanel); m_districtColor.eventSelectedColorChanged += onChangeDistrictColor; KlyteMonoUtils.CreateUIElement(out UIButton resetColor, mainPanel.transform, "DistrictColorReset", new Vector4(290, 0, 0, 0)); KlyteMonoUtils.InitButton(resetColor, false, "ButtonMenu"); KlyteMonoUtils.LimitWidth(resetColor, 200); resetColor.textPadding = new RectOffset(5, 5, 5, 2); resetColor.autoSize = true; resetColor.localeID = "K45_VMC_RESET_COLOR"; resetColor.eventClick += onResetColor; } ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD(); IVMCDistrictExtension extension = SingletonLite <T> .instance.GetExtensionDistrict(); KlyteMonoUtils.CreateElement(out m_assetSelectorWindow, mainPanel.transform); m_assetSelectorWindow.setTabContent(this); }
private void OnBuildingChange(ushort buildingId) { LogUtils.DoLog("EventOnBuildingSelChanged"); m_isLoading = true; IEnumerable <ServiceSystemDefinition> ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info); if (!ssds.Contains(SingletonLite <T> .instance.GetSSD())) { m_mainPanel.isVisible = false; return; } m_mainPanel.isVisible = true; ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD(); IVMCBuildingExtension ext = ssd.GetBuildingExtension(); bool isCustomConfig = ext.GetIgnoreDistrict(buildingId); LogUtils.DoLog("ssd = {0}", ssd); List <string> selectedAssets; Color selectedColor; if (isCustomConfig) { selectedAssets = ext.GetAssetList(buildingId); selectedColor = ext.GetColor(buildingId); } else { ushort districtId = BuildingUtils.GetBuildingDistrict(buildingId); IVMCDistrictExtension distExt = ssd.GetDistrictExtension(); selectedAssets = distExt.GetAssetList(districtId); selectedColor = distExt.GetColor(districtId); } foreach (string i in m_checkboxes.Keys) { m_checkboxes[i].isChecked = selectedAssets?.Contains(i) ?? false; } if (m_color != null) { m_color.selectedColor = selectedColor; } if (isCustomConfig) { m_title.text = string.Format(Locale.Get("K45_VMC_ASSET_SELECT_WINDOW_TITLE"), Singleton <BuildingManager> .instance.GetBuildingName(buildingId, default), ssd.NameForServiceSystem); } else { ushort districtId = BuildingUtils.GetBuildingDistrict(buildingId); if (districtId > 0) { m_title.text = string.Format(Locale.Get("K45_VMC_ASSET_SELECT_WINDOW_TITLE_DISTRICT"), Singleton <DistrictManager> .instance.GetDistrictName(districtId), ssd.NameForServiceSystem); } else { m_title.text = string.Format(Locale.Get("K45_VMC_ASSET_SELECT_WINDOW_TITLE_CITY"), ssd.NameForServiceSystem); } } m_isLoading = false; m_previewPanel.isVisible = false; }