public static void RemoveAllUnwantedVehicles() { VehicleManager vm = Singleton <VehicleManager> .instance; for (ushort lineId = 1; lineId < Singleton <TransportManager> .instance.m_lines.m_size; lineId++) { if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None) { IBasicExtension extension = TLMLineUtils.GetEffectiveExtensionForLine(lineId); ref TransportLine tl = ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineId]; List <string> modelList = extension.GetAssetListForLine(lineId); if (TransportLinesManagerMod.DebugMode) { LogUtils.DoLog("removeAllUnwantedVehicles: models found: {0}", modelList == null ? "?!?" : modelList.Count.ToString()); } if (modelList.Count > 0) { var vehiclesToRemove = new Dictionary <ushort, VehicleInfo>(); for (int i = 0; i < tl.CountVehicles(lineId); i++) { ushort vehicle = tl.GetVehicle(i); if (vehicle != 0) { VehicleInfo info2 = vm.m_vehicles.m_buffer[vehicle].Info; if (!modelList.Contains(info2.name)) { vehiclesToRemove[vehicle] = info2; } } } foreach (KeyValuePair <ushort, VehicleInfo> item in vehiclesToRemove) { if (item.Value.m_vehicleAI is BusAI) { VehicleUtils.ReplaceVehicleModel(item.Key, extension.GetAModel(lineId)); } else { item.Value.m_vehicleAI.SetTransportLine(item.Key, ref vm.m_vehicles.m_buffer[item.Key], 0); } } } } }
private static void addToArrayWithName(string[] input, List <string> saida, TLMCW.ConfigIndex nameReferenceSystem) { if (nameReferenceSystem == TLMCW.ConfigIndex.NIL) { saida.AddRange(input); } else { for (uint i = 0; i < input.Length; i++) { string item = input[i]; string prefixName = TLMLineUtils.getTransportSystemPrefixName(nameReferenceSystem, i + 1); if (string.IsNullOrEmpty(prefixName)) { saida.Add(item); } else { saida.Add(item + " - " + prefixName); } } } }
internal static string[] getStringOptionsForPrefix(ModoNomenclatura m, bool showUnprefixed = false, TLMCW.ConfigIndex nameReferenceSystem = TLMCW.ConfigIndex.NIL, bool noneOption = true) { List <string> saida = new List <string>(new string[noneOption ? 1 : 0]); if (showUnprefixed) { string unprefixedName = Locale.Get("TLM_UNPREFIXED"); if (nameReferenceSystem != TLMCW.ConfigIndex.NIL) { string prefixName = TLMLineUtils.getTransportSystemPrefixName(nameReferenceSystem, 0); if (!string.IsNullOrEmpty(prefixName)) { unprefixedName += " - " + prefixName; } } saida.Add(unprefixedName); } if (m == ModoNomenclatura.Nenhum) { return(saida.ToArray()); } switch (m) { case ModoNomenclatura.GregoMaiusculo: case ModoNomenclatura.GregoMaiusculoNumero: addToArrayWithName(gregoMaiusculo, saida, nameReferenceSystem); break; case ModoNomenclatura.GregoMinusculo: case ModoNomenclatura.GregoMinusculoNumero: addToArrayWithName(gregoMinusculo, saida, nameReferenceSystem); break; case ModoNomenclatura.CirilicoMaiusculo: case ModoNomenclatura.CirilicoMaiusculoNumero: addToArrayWithName(cirilicoMaiusculo, saida, nameReferenceSystem); break; case ModoNomenclatura.CirilicoMinusculo: case ModoNomenclatura.CirilicoMinusculoNumero: addToArrayWithName(cirilicoMinusculo, saida, nameReferenceSystem); break; case ModoNomenclatura.LatinoMaiusculo: case ModoNomenclatura.LatinoMaiusculoNumero: addToArrayWithName(latinoMaiusculo, saida, nameReferenceSystem); break; case ModoNomenclatura.LatinoMinusculo: case ModoNomenclatura.LatinoMinusculoNumero: addToArrayWithName(latinoMinusculo, saida, nameReferenceSystem); break; case ModoNomenclatura.Numero: string[] temp = new string[64]; for (int i = 1; i <= 64; i++) { temp[i - 1] = i.ToString(); } addToArrayWithName(temp, saida, nameReferenceSystem); break; case ModoNomenclatura.Romano: string[] tempR = new string[64]; for (ushort i = 1; i <= 64; i++) { tempR[i - 1] = ToRomanNumeral(i); } addToArrayWithName(tempR, saida, nameReferenceSystem); break; } if (TLMLineUtils.nomenclaturasComNumeros.Contains(m)) { addToArrayWithName(numeros, saida, nameReferenceSystem); } return(saida.ToArray()); }