public static int GetMaxVehiclesBuilding(ushort buildingID, VehicleInfo.VehicleType type) { Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID]; var ext = SVMBuildingAIOverrideUtils.getBuildingOverrideExtension(b.Info); var maxField = ext.GetVehicleMaxCountField(type); if (maxField == null) { return(0xFFFFFF); } return(SVMUtils.GetPrivateField <int>(b.Info.GetAI(), maxField) * SVMBuildingUtils.GetProductionRate(ref b) / 100); }
public static List <ushort> getAllBuildingsFromCity(ServiceSystemDefinition ssd, int?districtId = null, bool strict = false, bool mustAllowSpawn = false) { List <ushort> saida = new List <ushort>(); var bm = Singleton <BuildingManager> .instance; FastList <ushort> buildings; var ext = ssd.GetTransportExtension(); if (ssd.outsideConnection) { buildings = bm.GetOutsideConnections(); } else { buildings = bm.GetServiceBuildings(ssd.service); } SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size); foreach (ushort i in buildings) { if (ssd.isFromSystem(bm.m_buildings.m_buffer[i].Info)) { if (districtId != null && ext.GetAllowDistrictServiceRestrictions()) { var buildingDistrict = DistrictManager.instance.GetDistrict(bm.m_buildings.m_buffer[i].m_position); if (districtId != buildingDistrict && (strict || !ext.GetAllowGoOutsideEffective(buildingDistrict))) { continue; } } if (mustAllowSpawn) { int max = GetMaxVehiclesBuilding(i, ssd.vehicleType, ssd.level); int count = 0; int cargo = 0; int capacity = 0; int inbound = 0; int outbound = 0; SVMBuildingUtils.CalculateOwnVehicles(i, ref bm.m_buildings.m_buffer[i], SVMBuildingAIOverrideUtils.getBuildingOverrideExtensionStrict(bm.m_buildings.m_buffer[i].Info).GetManagedReasons(bm.m_buildings.m_buffer[i].Info).Where(x => x.Value.vehicleLevel == null).Select(x => x.Key), ref count, ref cargo, ref capacity, ref inbound, ref outbound); if (count >= max) { continue; } } saida.Add(i); } } SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2}); saida.sz = {3}", ssd, buildings.ToArray(), buildings.m_size, saida.Count); return(saida); }