public void RefreshData() { if (Singleton <BuildingManager> .exists && transform.parent.gameObject.GetComponent <UIComponent>().isVisible) { GetComponent <UIComponent>().isVisible = true; Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID]; this.m_buildingName.text = Singleton <BuildingManager> .instance.GetBuildingName(this.m_buildingID, default(InstanceID)); byte districtID = Singleton <DistrictManager> .instance.GetDistrict(b.m_position); string districtName = districtID == 0 ? Locale.Get("SVM_DISTRICT_NONE") : Singleton <DistrictManager> .instance.GetDistrictName(districtID); this.m_districtName.text = districtName; int count = 0; int cargo = 0; int capacity = 0; int inbound = 0; int outbound = 0; var extstr = SVMBuildingAIOverrideUtils.getBuildingOverrideExtensionStrict(b.Info); var defLevel = b.Info.m_class.m_level; SVMBuildingUtils.CalculateOwnVehicles(buildingId, ref b, extstr.GetManagedReasons(b.Info).Where(x => (x.Value.vehicleLevel ?? defLevel) == sysDef.level).Select(x => x.Key), ref count, ref cargo, ref capacity, ref inbound, ref outbound); int maxCount = SVMBuildingUtils.GetMaxVehiclesBuilding(buildingId, sysDef.vehicleType, sysDef.level); m_totalVehicles.prefix = count.ToString(); m_totalVehicles.suffix = maxCount > 0x3FFF ? "∞" : maxCount.ToString(); if (Singleton <T> .instance.GetSSD().outsideConnection) { float angle = Vector2.zero.GetAngleToPoint(VectorUtils.XZ(b.m_position)); m_directionLabel.prefix = $"{angle:n1}°"; m_directionLabel.text = " - "; m_directionLabel.suffix = CardinalPoint.getCardinalPoint(angle).ToString(); } } }
public void Update() { if (!this.m_buildingInfoPanel.isVisible) { return; } Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building]; if (!(b.Info.GetAI() is BuildingAI basicAI)) { closeBuildingInfo(null, null); return; } var ssds = ServiceSystemDefinition.from(b.Info); List <string> textVehicles = new List <string>(); foreach (var ssd in ssds) { int count = 0; int cargo = 0; int capacity = 0; int inbound = 0; int outbound = 0; var ext = SVMBuildingAIOverrideUtils.getBuildingOverrideExtension(b.Info); SVMBuildingUtils.CalculateOwnVehicles(m_buildingIdSelecionado.Building, ref b, ext.GetManagedReasons(b.Info).Keys, ref count, ref cargo, ref capacity, ref inbound, ref outbound); var maxField = ext.GetVehicleMaxCountField(ssd.vehicleType); int maxVehicles = (SVMUtils.GetPrivateField <int>(b.Info.GetAI(), maxField) * SVMBuildingUtils.GetProductionRate(ref b) / 100); string maxVehiclesStr = maxField == null || maxVehicles > 0x3FFF ? "∞" : maxVehicles.ToString(); textVehicles.Add($"{count}/{maxVehiclesStr} ({Locale.Get("SVM_VEHICLE_TYPE", ssd.vehicleType.ToString())})"); } vehiclesInUseLabel.text = string.Join(" | ", textVehicles.ToArray()); upkeepCost.text = LocaleFormatter.FormatUpkeep(basicAI.GetResourceRate(m_buildingIdSelecionado.Building, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)m_buildingIdSelecionado.Building], EconomyManager.Resource.Maintenance), false); uint num = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].m_citizenUnits; int num2 = 0; int num3 = 0; int unskill = 0; int oneSchool = 0; int twoSchool = 0; int threeSchool = 0; CitizenManager instance = Singleton <CitizenManager> .instance; while (num != 0u) { uint nextUnit = instance.m_units.m_buffer[(int)((UIntPtr)num)].m_nextUnit; if ((ushort)(instance.m_units.m_buffer[(int)((UIntPtr)num)].m_flags & CitizenUnit.Flags.Work) != 0) { for (int i = 0; i < 5; i++) { uint citizen = instance.m_units.m_buffer[(int)((UIntPtr)num)].GetCitizen(i); if (citizen != 0u && !instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].Dead && (instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].m_flags & Citizen.Flags.MovingIn) == Citizen.Flags.None) { num3++; switch (instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].EducationLevel) { case Citizen.Education.Uneducated: unskill++; break; case Citizen.Education.OneSchool: oneSchool++; break; case Citizen.Education.TwoSchools: twoSchool++; break; case Citizen.Education.ThreeSchools: threeSchool++; break; } } } } num = nextUnit; if (++num2 > 524288) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } workerChart.SetValues(new int[] { unskill, oneSchool, twoSchool, threeSchool }, new int[] { SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount0"), SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount1"), SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount2"), SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount3") }); }