private void updateCheckboxes() { bool oldIsLoading = isLoading; isLoading = true; DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info.GetAI() as DepotAI; List <string> prefixOptions = TLMUtils.getDepotPrefixesOptions(TLMCW.getConfigIndexForTransportInfo(m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo)); var prefixesServedList = TLMDepotAI.getPrefixesServedByDepot(m_buildingIdSelecionado.Building, m_secondary); for (uint i = 0; i <= 64; i++) { if (i < prefixOptions.Count) { prefixesCheckboxes[i].isVisible = true; prefixesCheckboxes[i].isChecked = prefixesServedList.Contains(i); prefixesCheckboxes[i].text = prefixOptions[(int)i]; } else { prefixesCheckboxes[i].isVisible = false; } } prefixesCheckboxes[65].isChecked = prefixesServedList.Contains(65); isLoading = oldIsLoading; }
public Color AutoColor(ushort i, bool ignoreRandomIfSet = true, bool ignoreAnyIfSet = false) { TransportLine t = tm.m_lines.m_buffer[(int)i]; try { var tsd = TransportSystemDefinition.getDefinitionForLine(i); if (tsd == default(TransportSystemDefinition) || (((t.m_flags & TransportLine.Flags.CustomColor) > 0) && ignoreAnyIfSet)) { return(Color.clear); } TLMCW.ConfigIndex transportType = tsd.toConfigIndex(); Color c = TLMUtils.CalculateAutoColor(t.m_lineNumber, transportType, ((t.m_flags & TransportLine.Flags.CustomColor) > 0) && ignoreRandomIfSet, true); if (c.a == 1) { TLMLineUtils.setLineColor(i, c); } //TLMUtils.doLog("Colocada a cor {0} na linha {1} ({3} {2})", c, i, t.m_lineNumber, t.Info.m_transportType); return(c); } catch (Exception e) { TLMUtils.doErrorLog("ERRO!!!!! " + e.Message); TLMCW.setCurrentConfigBool(TLMCW.ConfigIndex.AUTO_COLOR_ENABLED, false); return(Color.clear); } }
internal static Color CalculateAutoColor(ushort num, TLMCW.ConfigIndex transportType, bool avoidRandom = false, bool allowClear = false) { if (transportType == TLMCW.ConfigIndex.EVAC_BUS_CONFIG) { return(TLMCW.getColorForTransportType(transportType)); } bool prefixBased = TLMCW.getCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_PREFIX_BASED); bool randomOnOverflow = TLMCW.getCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW); string pal = TLMCW.getCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_SUBLINE); if (num >= 1000 && TLMCW.getCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { pal = TLMCW.getCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_MAIN); if (prefixBased) { num /= 1000; } else { num %= 1000; } } Color c; c = TLMAutoColorPalettes.getColor(num, pal, randomOnOverflow, avoidRandom); if (c == Color.clear && !allowClear) { c = TLMCW.getColorForTransportType(transportType); } return(c); }
private void InitPrefixesSelector() { m_prefixSelectorPanel = new UIHelperExtension(m_PrefixEditor); ((UIScrollablePanel)m_prefixSelectorPanel.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)m_prefixSelectorPanel.self).autoLayoutPadding = new RectOffset(5, 5, 0, 0); ((UIScrollablePanel)m_prefixSelectorPanel.self).wrapLayout = true; ((UIScrollablePanel)m_prefixSelectorPanel.self).autoLayout = true; string[] optionList = new string[m_transportTypeOrder.Length + 1]; optionList[0] = "--" + Locale.Get("SELECT") + "--"; for (int i = 1; i < optionList.Length; i++) { optionList[i] = TLMCW.getNameForTransportType(m_transportTypeOrder[i - 1]); } TLMUtils.doLog("INIT m_systemTypeDropDown"); m_systemTypeDropDown = (UIDropDown)m_prefixSelectorPanel.AddDropdown(Locale.Get("TLM_TRANSPORT_SYSTEM"), optionList, 0, loadPrefixes); m_prefixSelection = (UIDropDown)m_prefixSelectorPanel.AddDropdown(Locale.Get("TLM_PREFIX"), new string[] { "" }, 0, selectPrefixAction); foreach (Transform t in m_prefixSelectorPanel.self.transform) { var panel = t.gameObject.GetComponent <UIPanel>(); if (panel) { panel.width = 340; } } }
internal static List <string> getDepotPrefixesOptions(TLMCW.ConfigIndex transportType) { transportType &= TLMConfigWarehouse.ConfigIndex.SYSTEM_PART; var m = (ModoNomenclatura)TLMCW.getCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX); List <string> saida = new List <string>(new string[] { Locale.Get("TLM_UNPREFIXED") }); switch (m) { case ModoNomenclatura.GregoMaiusculo: case ModoNomenclatura.GregoMaiusculoNumero: saida.AddRange(gregoMaiusculo); break; case ModoNomenclatura.GregoMinusculo: case ModoNomenclatura.GregoMinusculoNumero: saida.AddRange(gregoMinusculo); break; case ModoNomenclatura.CirilicoMaiusculo: case ModoNomenclatura.CirilicoMaiusculoNumero: saida.AddRange(cirilicoMaiusculo); break; case ModoNomenclatura.CirilicoMinusculo: case ModoNomenclatura.CirilicoMinusculoNumero: saida.AddRange(cirilicoMinusculo); break; case ModoNomenclatura.LatinoMaiusculo: case ModoNomenclatura.LatinoMaiusculoNumero: saida.AddRange(latinoMaiusculo); break; case ModoNomenclatura.LatinoMinusculo: case ModoNomenclatura.LatinoMinusculoNumero: saida.AddRange(latinoMinusculo); break; case ModoNomenclatura.Numero: for (int i = 1; i <= 64; i++) { saida.Add(i.ToString()); } break; case ModoNomenclatura.Romano: for (ushort i = 1; i <= 64; i++) { saida.Add(ToRomanNumeral(i)); } break; } if (TLMLineUtils.nomenclaturasComNumeros.Contains(m)) { saida.AddRange(numeros.Select(x => x.ToString())); } return(saida); }
public void openDepotInfo(ushort buildingID, bool secondary) { isLoading = true; WorldInfoPanel.HideAllWorldInfoPanels(); m_buildingIdSelecionado = default(InstanceID); m_buildingIdSelecionado.Building = buildingID; DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI; if (depotAI == null) { return; } depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); bool hasPrimary = depotAI.m_transportInfo != null && depotAI.m_maxVehicleCount > 0; bool hasSecondary = depotAI.m_secondaryTransportInfo != null && depotAI.m_maxVehicleCount2 > 0; if (!hasPrimary && !hasSecondary) { closeDepotInfo(null, null); return; } m_secondary = !hasPrimary || (secondary && hasSecondary); TransportInfo currentTransportInfo = m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; TransportInfo otherInfo = !m_secondary && depotAI.m_secondaryTransportInfo != null ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; var tsd = TransportSystemDefinition.from(currentTransportInfo); depotInfoPanel.color = Color.Lerp(TLMCW.getColorForTransportType(tsd.toConfigIndex()), Color.white, 0.5f); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.normalBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.disabledBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.focusedBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.hoveredBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(otherInfo.m_transportType); if (depotAI.m_secondaryTransportInfo != null) { lineTransportIconTypeLabel.tooltip = string.Format(Locale.Get("TLM_SEE_OTHER_DEPOT"), TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(otherInfo).toConfigIndex())); } else { lineTransportIconTypeLabel.tooltip = ""; } Show(); m_controller.defaultListingLinesPanel.Hide(); updateCheckboxes(); isLoading = false; }
private bool isNumeroUsado(int numLinha, ushort lineIdx) { TLMCW.ConfigIndex tipo = TLMCW.getDefinitionForLine(lineIdx).toConfigIndex(); for (ushort i = 0; i < Singleton <TransportManager> .instance.m_lines.m_buffer.Length; i++) { if (i != lineIdx && TLMCW.getDefinitionForLine(i).toConfigIndex() == tipo && Singleton <TransportManager> .instance.m_lines.m_buffer[i].m_lineNumber == numLinha && (Singleton <TransportManager> .instance.m_lines.m_buffer[i].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None) { return(true); } } return(false); }
internal static LineIconSpriteNames GetLineIcon(ushort num, TLMCW.ConfigIndex transportType, ref TransportSystemDefinition tsdRef) { if (num > 0 && TLMCW.GetCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { uint prefix = num / 1000u; ITLMTransportTypeExtension ext = tsdRef.GetTransportExtension(); LineIconSpriteNames format = ext.GetCustomFormat(prefix); if (format != default) { return(format); } } return(TLMCW.getBgIconForIndex(transportType)); }
internal static Color CalculateAutoColor(ushort num, TLMCW.ConfigIndex transportType, ref TransportSystemDefinition tsdRef, bool avoidRandom = false, bool allowClear = false) { if (transportType == TLMCW.ConfigIndex.EVAC_BUS_CONFIG) { return(TLMCW.getColorForTransportType(transportType)); } bool prefixBased = TLMCW.GetCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_PREFIX_BASED); bool randomOnOverflow = TLMCW.GetCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW); var pal = new List <string>(); if (num >= 0 && TLMCW.GetCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { uint prefix = num / 1000u; ITLMTransportTypeExtension ext = tsdRef.GetTransportExtension(); string tempPal = ext.GetCustomPalette(prefix) ?? string.Empty; if (tempPal != string.Empty) { pal.Add(tempPal); num %= 1000; } else { if (prefixBased) { num /= 1000; } else { num %= 1000; } } pal.Add(TLMCW.GetCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_MAIN)); } else { pal.Add(TLMCW.GetCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_MAIN)); } Color c; c = TLMAutoColorPalettes.getColor(num, pal.ToArray(), randomOnOverflow, avoidRandom); if (c == Color.clear && !allowClear) { c = TLMCW.getColorForTransportType(transportType); } return(c); }
public void RefreshData() { if (Singleton <BuildingManager> .exists) { m_prefixesServedList = TLMDepotAI.getPrefixesServedByDepot(m_buildingID); if (m_prefixesServedList == null) { GameObject.Destroy(gameObject); return; } bool isRowVisible; isRowVisible = TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_prefixesServedList); if (!isRowVisible) { GetComponent <UIComponent>().isVisible = false; return; } GetComponent <UIComponent>().isVisible = true; Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID]; this.m_depotName.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("TLM_DISTRICT_NONE") : Singleton <DistrictManager> .instance.GetDistrictName(districtID); this.m_districtName.text = districtName; //prefix this.m_prefixesServed.text = TLMUtils.getPrefixesServedAbstract(this.m_buildingID); List <string> prefixOptions = TLMUtils.getDepotPrefixesOptions(TLMCW.getConfigIndexForTransportInfo((b.Info.GetAI() as DepotAI).m_transportInfo)); prefixOptions.Add(Locale.Get("TLM_REGIONAL")); if (this.m_prefixOptions.items.Length != prefixOptions.Count) { this.m_prefixOptions.items = prefixOptions.ToArray(); onChangePrefixSelected(m_prefixOptions.selectedIndex); } } }
public Color AutoColor(ushort i) { TransportLine t = tm.m_lines.m_buffer[(int)i]; try { TLMCW.ConfigIndex transportType = TLMCW.getDefinitionForLine(i).toConfigIndex(); bool prefixBased = TLMCW.getCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_PREFIX_BASED); bool randomOnOverflow = TLMCW.getCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW); string pal = TLMCW.getCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_SUBLINE); ushort num = t.m_lineNumber; if (num >= 1000 && TLMCW.getCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { pal = TLMCW.getCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_MAIN); if (prefixBased) { num /= 1000; } else { num %= 1000; } } Color c = TLMAutoColorPalettes.getColor(num, pal, randomOnOverflow); TLMUtils.setLineColor(i, c); return(c); } catch (Exception e) { TLMUtils.doErrorLog("ERRO!!!!! " + e.Message); TLMCW.setCurrentConfigBool(TLMCW.ConfigIndex.AUTO_COLOR_ENABLED, false); return(Color.clear); } }
public Color AutoColor(ushort i) { TransportLine t = tm.m_lines.m_buffer[(int)i]; try { var tsd = TLMCW.getDefinitionForLine(i); if (tsd == default(TransportSystemDefinition)) { return(Color.clear); } TLMCW.ConfigIndex transportType = tsd.toConfigIndex(); Color c = TLMUtils.CalculateAutoColor(t.m_lineNumber, transportType); TLMLineUtils.setLineColor(i, c); //TLMUtils.doLog("Colocada a cor {0} na linha {1} ({3} {2})", c, i, t.m_lineNumber, t.Info.m_transportType); return(c); } catch (Exception e) { TLMUtils.doErrorLog("ERRO!!!!! " + e.Message); TLMCW.setCurrentConfigBool(TLMCW.ConfigIndex.AUTO_COLOR_ENABLED, false); return(Color.clear); } }
internal static ModoNomenclatura GetPrefixModoNomenclatura(TLMCW.ConfigIndex transportType) { return((ModoNomenclatura)TLMCW.getCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX)); }
public void openLineInfo(ushort lineID) { if (lineID <= 0) { return; } WorldInfoPanel.HideAllWorldInfoPanels(); linePrefixDropDown.eventSelectedIndexChanged -= saveLineNumber; lineNumberLabel.eventLostFocus -= saveLineNumber; m_lineIdSelecionado = default(InstanceID); m_lineIdSelecionado.TransportLine = lineID; TransportLine t = m_controller.tm.m_lines.m_buffer[(int)lineID]; ushort lineNumber = t.m_lineNumber; TLMCW.ConfigIndex transportType = TLMCW.getDefinitionForLine(lineID).toConfigIndex(); ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMCW.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType); if (mnPrefixo != ModoNomenclatura.Nenhum) { lineNumberLabel.text = (lineNumber % 1000).ToString(); lineNumberLabel.relativePosition = new Vector3(110f, 3f); lineNumberLabel.width = 55; linePrefixDropDown.enabled = false; var temp = TLMUtils.getStringOptionsForPrefix(mnPrefixo); for (uint i = 0; i < temp.Length; i++) { string prefixName = TLMUtils.getTransportSystemPrefixName(transportType, i); if (prefixName != null && prefixName != string.Empty) { temp[(int)i] += " (" + prefixName + ")"; } } linePrefixDropDown.items = temp; linePrefixDropDown.selectedIndex = lineNumber / 1000; linePrefixDropDown.enabled = true; lineNumberLabel.maxLength = 3; } else { lineNumberLabel.text = (lineNumber).ToString(); lineNumberLabel.relativePosition = new Vector3(80f, 3f); lineNumberLabel.width = 75; lineNumberLabel.maxLength = 4; linePrefixDropDown.enabled = false; } lineNumberLabel.color = m_controller.tm.GetLineColor(lineID); lineNameField.text = m_controller.tm.GetLineName(lineID); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.atlas = linePrefixDropDown.atlas; lineTransportIconTypeLabel.backgroundSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(t.Info.m_transportType); lineColorPicker.selectedColor = m_controller.tm.GetLineColor(lineID); bool day, night, zeroed; TLMLineUtils.getLineActive(ref t, out day, out night, out zeroed); if (day && night) { lineTime.selectedIndex = 0; } else if (day) { lineTime.selectedIndex = 1; } else if (night) { lineTime.selectedIndex = 2; } else { lineTime.selectedIndex = 3; } m_linearMap.redrawLine(); Show(); m_controller.defaultListingLinesPanel.Hide(); m_autoNameLabel.text = m_linearMap.autoName; vehicleQuantitySet.text = TLMVehiclesLineManager.instance[this.lineIdSelecionado.TransportLine].ToString(); vehicleQuantitySet.area = new Vector4(150, 150, 50, 20); vehicleQuantitySet.color = Color.gray; linePrefixDropDown.eventSelectedIndexChanged += saveLineNumber; lineNumberLabel.eventLostFocus += saveLineNumber; }
public void closeLineInfo(UIComponent component, UIMouseEventParameter eventParam) { TransportLine t = m_controller.tm.m_lines.m_buffer[(int)m_lineIdSelecionado.TransportLine]; Hide(); m_controller.defaultListingLinesPanel.Show(); TLMPublicTransportDetailPanel.instance.SetActiveTab(Array.IndexOf(TLMPublicTransportDetailPanel.tabSystemOrder, TLMCW.getConfigIndexForTransportInfo(t.Info))); }
public void updateBidings() { ushort lineID = m_lineIdSelecionado.TransportLine; TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID]; TransportInfo info = tl.Info; int turistas = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_touristPassengers.m_averageCount; int residentes = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_residentPassengers.m_averageCount; int residentesPorc = residentes; if (residentesPorc == 0) { residentesPorc = 1; } int criancas = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_childPassengers.m_averageCount; int adolescentes = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_teenPassengers.m_averageCount; int jovens = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_youngPassengers.m_averageCount; int adultos = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_adultPassengers.m_averageCount; int idosos = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_seniorPassengers.m_averageCount; int motoristas = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_carOwningPassengers.m_averageCount; int veiculosLinha = TLMLineUtils.GetVehiclesCount(lineID); int porcCriancas = (criancas * 100 / residentesPorc); int porcAdolescentes = (adolescentes * 100 / residentesPorc); int porcJovens = (jovens * 100 / residentesPorc); int porcAdultos = (adultos * 100 / residentesPorc); int porcIdosos = (idosos * 100 / residentesPorc); int soma = porcCriancas + porcAdolescentes + porcJovens + porcAdultos + porcIdosos; if (soma != 0 && soma != 100) { porcAdultos = 100 - (porcCriancas + porcAdolescentes + porcJovens + porcIdosos); } agesPanel.SetValues(new int[] { porcCriancas, porcAdolescentes, porcJovens, porcAdultos, porcIdosos }); passageirosEturistasLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[] { residentes, turistas }); int viagensSalvas = 0; int coeficienteViagens = 0; if (residentes + turistas != 0) { coeficienteViagens += criancas * 0; coeficienteViagens += adolescentes * 5; coeficienteViagens += jovens * ((15 * residentes + 20 * turistas + (residentes + turistas >> 1)) / (residentes + turistas)); coeficienteViagens += adultos * ((20 * residentes + 20 * turistas + (residentes + turistas >> 1)) / (residentes + turistas)); coeficienteViagens += idosos * ((10 * residentes + 20 * turistas + (residentes + turistas >> 1)) / (residentes + turistas)); } if (coeficienteViagens != 0) { viagensSalvas = (int)(((long)motoristas * 10000L + (long)(coeficienteViagens >> 1)) / (long)coeficienteViagens); viagensSalvas = Mathf.Clamp(viagensSalvas, 0, 100); } viagensEvitadasLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_TRIPSAVED", new object[] { viagensSalvas }); if (daytimeChange != null && daytimeChange.completedOrFailed) { linearMap.redrawLine(); daytimeChange = null; } else { linearMap.updateBidings(); } //lines info int stopsCount = TLMLineUtils.GetStopsCount(lineID); if (lastStopsCount != stopsCount) { float totalSize = TLMLineUtils.GetLineLength(lineID); lineLenghtLabel.text = string.Format(Locale.Get("TLM_LENGHT_AND_STOPS"), totalSize, stopsCount); lastStopsCount = stopsCount; } //estatisticas novas veiculosLinhaLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_VEHICLECOUNT", new object[] { veiculosLinha }); uint prefix = 0; if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u; } float overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f; float prefixMultiplier = TLMUtils.getExtensionFromConfigIndex(TLMCW.getConfigIndexForTransportInfo(info)).getBudgetMultiplierForHour(prefix, (int)Singleton <SimulationManager> .instance.m_currentDayTimeHour) / 100f; detailedStatsLabel.text = string.Format("{0:0%}", overallBudget * prefixMultiplier); detailedStatsLabel.tooltip = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN"), TLMCW.getNameForTransportType(TLMCW.getConfigIndexForTransportInfo(info)), TLMUtils.getStringOptionsForPrefix((ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX), true)[prefix + 1], overallBudget, prefixMultiplier, overallBudget * prefixMultiplier); //bool isZeroed = ((int)tl.m_flags & (int)TLMTransportLineFlags.ZERO_BUDGET_SETTED) > 0; //lineTime.isVisible = !isZeroed; //if (isZeroed) //{ // lineTimeTitle.localeID = ("TLM_LINE_DISABLED_NO_BUDGET"); // lineTimeTitle.tooltipLocaleID = ("TLM_LINE_DISABLED_NO_BUDGET_DESC"); //} //else //{ // lineTimeTitle.localeID = ("TRANSPORT_LINE_ACTIVITY"); // lineTimeTitle.tooltipLocaleID = (""); //} //generalDebugLabel.enabled = TransportLinesManagerMod.debugMode.value; //if (TransportLinesManagerMod.debugMode.value) //{ // string debugTxt = "!"; // var extraDatas = ExtraVehiclesStats.instance.getLineVehiclesData(lineID); // if (extraDatas.Count == 0) // { // debugTxt = "none"; // } // else // { // foreach (var item in extraDatas) // { // debugTxt += string.Format("BUS ID {0} - {1} Fill, {2} per lap ||", item.Key, item.Value.avgFill.ToString("0.00%"), string.Format("{0}d {1}h{2}m", item.Value.timeTakenLap.TotalDays, item.Value.timeTakenLap.Hours, item.Value.timeTakenLap.Minutes)); // } // } // generalDebugLabel.text = debugTxt; //} // //custos da linha // float costVehicles = 0; // ushort nextVehId = tl.m_vehicles; // while (nextVehId >0) { // costVehicles += Singleton<VehicleManager>.instance.m_vehicles.m_buffer [(int)nextVehId].Info.GetMaintenanceCost () ; // nextVehId = Singleton<VehicleManager>.instance.m_vehicles.m_buffer [(int)nextVehId].m_nextLineVehicle; // } // float costStops = 0; // int a = tl.m_stops; // for (int i = 0; i< stopsCount; i++) { // costStops += Singleton<NetManager>.instance.m_nodes.m_buffer [(int)tl.GetStop (i)].Info.GetMaintenanceCost () ; // } // custosLabel.text = String.Format (costsFormat, costVehicles, costStops, costVehicles + costStops); }
public void DoAutoName() { string format = (TLMCW.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.ADD_LINE_NUMBER_IN_AUTONAME)) ? "[{0}] {1}" : "{1}"; TLMUtils.setLineName(m_LineID, string.Format(format, lineNumberFormatted, TLMUtils.calculateAutoName(m_LineID))); }
public void redrawLine() { ushort lineID = parent.CurrentSelectedId; TransportLine t = TLMController.instance.tm.m_lines.m_buffer[(int)lineID]; int stopsCount = t.CountStops(lineID); int vehicleCount = t.CountVehicles(lineID); Color lineColor = TLMController.instance.tm.GetLineColor(lineID); setLinearMapColor(lineColor); clearStations(); updateSubIconLayer(); setLineNumberCircle(lineID); if (lineID == 0) { var tsd = TransportSystemDefinition.from(parent.CurrentTransportInfo); if (tsd != default(TransportSystemDefinition)) { linearMapLineNumberFormat.backgroundSprite = TLMLineUtils.GetIconForIndex(tsd.toConfigIndex()); } lineStationsPanel.width = 0; return; } ItemClass.SubService ss = TLMCW.getDefinitionForLine(lineID).subService; linearMapLineNumberFormat.backgroundSprite = TLMLineUtils.getIconForLine(lineID); m_autoName = TLMLineUtils.calculateAutoName(lineID, true); linearMapLineNumber.tooltip = m_autoName; string stationName; Vector3 local; string airport, taxi, harbor, regionalStation, cableCarStation; string namePrefix; bool isComplete = (Singleton <TransportManager> .instance.m_lines.m_buffer[TLMController.instance.CurrentSelectedId].m_flags & TransportLine.Flags.Complete) != TransportLine.Flags.None; bool simmetric = TLMLineUtils.CalculateSimmetry(ss, stopsCount, t, out int middle); float addedWidth = 0; lineStationsPanel.width = 0; if (t.Info.m_transportType != TransportInfo.TransportType.Bus && t.Info.m_transportType != TransportInfo.TransportType.Tram && simmetric && !showExtraStopInfo) { int maxIt = middle + stopsCount / 2; for (int j = middle; j <= maxIt; j++) { ushort stationId = t.GetStop(j); local = getStation(lineID, stationId, ss, out stationName, out List <ushort> intersections, out airport, out harbor, out taxi, out regionalStation, out cableCarStation, out namePrefix); addedWidth = addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, cableCarStation, stationId, ss, lineColor, false) + (j == middle + stopsCount / 2 ? 5 : 0); lineStationsPanel.width += addedWidth; } } else { int minI = 0, maxI = stopsCount; if (simmetric) { minI = middle + 1; maxI = stopsCount + middle + 1; } if (showExtraStopInfo) { int j = (minI - 1 + stopsCount) % stopsCount; ushort stationId = t.GetStop(j); local = getStation(lineID, stationId, ss, out stationName, out List <ushort> intersections, out airport, out harbor, out taxi, out regionalStation, out cableCarStation, out namePrefix); lineStationsPanel.width += addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, cableCarStation, stationId, ss, lineColor, true); } else if (TLMSingleton.showDistanceInLinearMap || parent.ForceShowStopsDistances) { minI--; } for (int i = minI; i < maxI; i++) { int j = (i + stopsCount) % stopsCount; ushort stationId = t.GetStop(j); local = getStation(lineID, stationId, ss, out stationName, out List <ushort> intersections, out airport, out harbor, out taxi, out regionalStation, out cableCarStation, out namePrefix); addedWidth = addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, cableCarStation, stationId, ss, lineColor, false); lineStationsPanel.width += addedWidth; } } lineStationsPanel.width -= addedWidth; if (showExtraStopInfo) { vehiclesOnStation.Clear(); for (int v = 0; v < vehicleCount; v++) { ushort vehicleId = t.GetVehicle(v); AddVehicleToLinearMap(lineColor, vehicleId); } } }
public void closeDepotInfo(UIComponent component, UIMouseEventParameter eventParam) { BuildingInfo basicInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info; DepotAI basicAI = basicInfo.GetAI() as DepotAI; Hide(); m_controller.defaultListingLinesPanel.Show(); TLMPublicTransportDetailPanel.instance.SetActiveTab(TLMPublicTransportDetailPanel.tabSystemOrder.Length + Array.IndexOf(TLMPublicTransportDetailPanel.tabSystemOrder, TLMCW.getConfigIndexForTransportInfo(basicAI.m_transportInfo))); }
public void SimulationStep(ushort lineID) { if (!m_initialized) { m_initialized = true; for (int i = 0; i < Singleton <TransportManager> .instance.m_lines.m_buffer.Length; i++) { m_flagsLastState[i] = Singleton <TransportManager> .instance.m_lines.m_buffer[i].m_flags; } } var flagsChanged = (m_flagsLastState[lineID] ^ Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags); m_flagsLastState[lineID] = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags; if ((flagsChanged & TransportLine.Flags.Complete) != TransportLine.Flags.None) { if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED)) { TLMController.instance.AutoColor(lineID); } if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_NAME_ENABLED)) { TLMUtils.setLineName(lineID, TLMUtils.calculateAutoName(lineID)); } } if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("LTLMTransportLine SimulationStep!"); } TransportInfo info = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].Info; TLMCW.ConfigIndex lineType = TLMCW.getDefinitionForLine(lineID).toConfigIndex(); float defaultCostPerPassengerCapacity = TLMCW.getCostPerPassengerCapacityLine(lineType); if (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].Complete) { int vehicleCount = 0; int installedCapacity = 0; if (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_vehicles != 0) { VehicleManager instance = Singleton <VehicleManager> .instance; ushort nextId = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_vehicles; int loopCount = 0; while (nextId != 0) { ushort nextLineVehicle = instance.m_vehicles.m_buffer[(int)nextId].m_nextLineVehicle; vehicleCount++; installedCapacity += TLMLineUtils.getVehicleCapacity(nextId); nextId = nextLineVehicle; if (++loopCount > 16384) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } } uint prefix = 0; if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u; } float budgetMultiplierPrefix = TLMUtils.getExtensionFromConfigIndex(TLMCW.getConfigIndexForTransportInfo(info)).getBudgetMultiplierForHour(prefix, (int)Singleton <SimulationManager> .instance.m_currentDayTimeHour) / 100f; var flagToCheck = (TransportLine.Flags.DisabledNight | TransportLine.Flags.DisabledDay); if (budgetMultiplierPrefix == 0 && (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & flagToCheck) == TransportLine.Flags.None) { int flagsToAdd = (int)(TransportLine.Flags.DisabledDay | TransportLine.Flags.DisabledNight) | (int)(TLMTransportLineFlags.ZERO_BUDGET_SETTED); if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_SETTED) == TransportLine.Flags.None) { if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.DisabledDay) == TransportLine.Flags.None) { flagsToAdd |= (int)TLMTransportLineFlags.ZERO_BUDGET_DAY; } if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.DisabledNight) == TransportLine.Flags.None) { flagsToAdd |= (int)TLMTransportLineFlags.ZERO_BUDGET_NIGHT; } } Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags |= (TransportLine.Flags)flagsToAdd; } else if ((budgetMultiplierPrefix > 0 && (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & (TransportLine.Flags)(TLMTransportLineFlags.ZERO_BUDGET_SETTED)) != TransportLine.Flags.None)) { bool actDay = (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_DAY) != TransportLine.Flags.None; bool actNight = (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_NIGHT) != TransportLine.Flags.None; Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags &= (TransportLine.Flags) ~(TLMTransportLineFlags.ZERO_BUDGET_DAY | TLMTransportLineFlags.ZERO_BUDGET_NIGHT | TLMTransportLineFlags.ZERO_BUDGET_SETTED); TLMLineUtils.setLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], actDay, actNight); } bool active; if (Singleton <SimulationManager> .instance.m_isNightTime) { active = ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.DisabledNight) == TransportLine.Flags.None); } else { active = ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.DisabledDay) == TransportLine.Flags.None); } uint steps = 0u; float distance = 0f; bool broken = false; if (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_stops != 0) { NetManager instance2 = Singleton <NetManager> .instance; ushort stops = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_stops; ushort nextStop = stops; int count = 0; while (nextStop != 0) { ushort num8 = 0; if (active) { NetNode[] expr_10A_cp_0 = instance2.m_nodes.m_buffer; ushort expr_10A_cp_1 = nextStop; expr_10A_cp_0[(int)expr_10A_cp_1].m_flags = (expr_10A_cp_0[(int)expr_10A_cp_1].m_flags & ~NetNode.Flags.Disabled); } else { NetNode[] expr_130_cp_0 = instance2.m_nodes.m_buffer; ushort expr_130_cp_1 = nextStop; expr_130_cp_0[(int)expr_130_cp_1].m_flags = (expr_130_cp_0[(int)expr_130_cp_1].m_flags | NetNode.Flags.Disabled); } for (int i = 0; i < 8; i++) { ushort segment = instance2.m_nodes.m_buffer[(int)nextStop].GetSegment(i); if (segment != 0 && instance2.m_segments.m_buffer[(int)segment].m_startNode == nextStop) { distance += instance2.m_segments.m_buffer[(int)segment].m_averageLength; num8 = instance2.m_segments.m_buffer[(int)segment].m_endNode; if ((instance2.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.PathLength) == NetSegment.Flags.None) { broken = true; } break; } } steps += 1u; nextStop = num8; if (nextStop == stops) { break; } if (++count >= 32768) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } } float lineCost = vehicleCount * info.m_maintenanceCostPerVehicle / 100;// * defaultCostPerPassengerCapacity; if (lineCost != 0) { Singleton <EconomyManager> .instance.FetchResource(EconomyManager.Resource.Maintenance, m_linesCost.m_buffer[lineID], info.m_class); } int budget = Singleton <EconomyManager> .instance.GetBudget(info.m_class); int necessaryVehicles; if (!active) { necessaryVehicles = 0; } else { necessaryVehicles = TLMVehiclesLineManager.instance[lineID]; if (necessaryVehicles == 0) { if (broken) { necessaryVehicles = vehicleCount; } else { necessaryVehicles = Mathf.CeilToInt(budget * budgetMultiplierPrefix * distance / (info.m_defaultVehicleDistance * 100f)); } } } if (steps != 0u && vehicleCount < necessaryVehicles) { TransferManager.TransferReason vehicleReason = info.m_vehicleReason; int index = Singleton <SimulationManager> .instance.m_randomizer.Int32(steps); ushort stop = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].GetStop(index); if (vehicleReason != TransferManager.TransferReason.None && stop != 0) { TransferManager.TransferOffer offer = default(TransferManager.TransferOffer); offer.Priority = necessaryVehicles - vehicleCount + 1; offer.TransportLine = lineID; offer.Position = Singleton <NetManager> .instance.m_nodes.m_buffer[stop].m_position; offer.Amount = 1; offer.Active = false; Singleton <TransferManager> .instance.AddIncomingOffer(vehicleReason, offer); } } else if (vehicleCount > necessaryVehicles) { int index2 = Singleton <SimulationManager> .instance.m_randomizer.Int32((uint)vehicleCount); ushort vehicle = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].GetVehicle(index2); if (vehicle != 0) { VehicleManager instance3 = Singleton <VehicleManager> .instance; VehicleInfo info2 = instance3.m_vehicles.m_buffer[(int)vehicle].Info; info2.m_vehicleAI.SetTransportLine(vehicle, ref instance3.m_vehicles.m_buffer[(int)vehicle], 0); } } } if ((Singleton <SimulationManager> .instance.m_currentFrameIndex & 4095u) >= 3840u) { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_passengers.Update(); Singleton <TransportManager> .instance.m_passengers[(int)info.m_transportType].Add(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_passengers); Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_passengers.Reset(); } }
public void RefreshData(bool colors, bool visible) { if (Singleton <TransportManager> .exists) { bool isRowVisible; if (this.m_LineOperation == null || this.m_LineOperation.completedOrFailed) { //this.m_DayLine.isVisible = (!isZeroed); //this.m_NightLine.isVisible = (!isZeroed); //this.m_DayNightLine.isVisible = (!isZeroed); //this.m_DisabledLine.isVisible = (!isZeroed); //this.m_noBudgetWarn.isVisible = (isZeroed); TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[m_LineID], out bool dayActive, out bool nightActive); bool zeroed; unchecked { zeroed = (Singleton <TransportManager> .instance.m_lines.m_buffer[m_LineID].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT) != 0; } if (!dayActive || !nightActive || zeroed) { m_LineColor.normalBgSprite = zeroed ? "NoBudgetIcon" : dayActive ? "DayIcon" : nightActive ? "NightIcon" : "DisabledIcon"; } else { m_LineColor.normalBgSprite = ""; } this.m_DayLine.isChecked = (dayActive && !nightActive); this.m_NightLine.isChecked = (nightActive && !dayActive); this.m_DayNightLine.isChecked = (dayActive && nightActive); this.m_DisabledLine.isChecked = (!dayActive && !nightActive); m_DisabledLine.relativePosition = new Vector3(730, 8); isRowVisible = TLMPublicTransportDetailPanel.instance.isActivityVisible(dayActive, nightActive) && TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_LineNumber); } else { m_LineColor.normalBgSprite = "DisabledIcon"; isRowVisible = TLMPublicTransportDetailPanel.instance.isActivityVisible(false, false) && TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_LineNumber); } if (!isRowVisible) { GetComponent <UIComponent>().isVisible = false; return; } GetComponent <UIComponent>().isVisible = true; this.m_LineName.text = Singleton <TransportManager> .instance.GetLineName(this.m_LineID); m_LineNumber = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_lineNumber; this.m_LineStops.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountStops(this.m_LineID).ToString("N0"); this.m_LineVehicles.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountVehicles(this.m_LineID).ToString("N0"); uint prefix = 0; TransportInfo info = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].Info; if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u; } float overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f; this.m_lineBudgetLabel.text = string.Format("{0:0%}", TLMLineUtils.getEffectiveBugdet(lineID));//585+1/7 = frames/week string vehTooltip = string.Format("{0} {1}", this.m_LineVehicles.text, Locale.Get("PUBLICTRANSPORT_VEHICLES")); this.m_LineVehicles.tooltip = vehTooltip; int averageCount = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_residentPassengers.m_averageCount; int averageCount2 = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_touristPassengers.m_averageCount; this.m_LinePassengers.text = (averageCount + averageCount2).ToString("N0"); // this.m_LineEarnings.text = string.Format("~₡ {0:0.00}", (averageCount + averageCount2) / 50f); // m_LineEarnings.relativePosition = m_LinePassengers.relativePosition + new Vector3(0, 20, 0); this.m_LinePassengers.tooltip = string.Format("{0}", LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[] { averageCount, averageCount2 })); TLMLineUtils.setLineNumberCircleOnRef(lineID, m_LineNumberFormatted, 0.8f); m_LineColor.normalFgSprite = TLMLineUtils.getIconForLine(lineID); m_lineBudgetLabel.tooltip = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN_2"), TLMCW.getNameForTransportType(TLMCW.getConfigIndexForTransportInfo(info)), overallBudget, Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget / 100f, TLMLineUtils.getEffectiveBugdet(lineID)); this.m_PassengerCount = averageCount + averageCount2; this.m_lineIncompleteWarning.isVisible = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Complete) == TransportLine.Flags.None); if (colors) { this.m_LineColor.selectedColor = Singleton <TransportManager> .instance.GetLineColor(this.m_LineID); } if (visible) { this.m_LineIsVisible.isChecked = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Hidden) == TransportLine.Flags.None); } m_lineBudgetLabel.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 19, 0); bool tlmPerHour = TLMLineUtils.isPerHourBudget(m_LineID); m_DayLine.isVisible = !tlmPerHour; m_DayNightLine.isVisible = !tlmPerHour; m_NightLine.isVisible = !tlmPerHour; m_DisabledLine.isVisible = !tlmPerHour; m_perHourBudgetInfo.isVisible = tlmPerHour; m_perHourBudgetInfo.relativePosition = new Vector3(615, 2); } }
Vector3 getStation(ushort lineId, ushort stopId, ItemClass.SubService ss, out string stationName, out List <ushort> linhas, out string airport, out string harbor, out string taxiStand, out string regionalTrainStation, out string cableCarStation, out string prefix) { NetManager nm = Singleton <NetManager> .instance; BuildingManager bm = Singleton <BuildingManager> .instance; NetNode nn = nm.m_nodes.m_buffer[(int)stopId]; stationName = TLMLineUtils.getStationName(stopId, lineId, ss, out ItemClass.Service servFound, out ItemClass.SubService subServFound, out prefix, out ushort buildingId); //paradas proximas (metro e trem) TransportManager tm = Singleton <TransportManager> .instance; TransportInfo thisLineInfo = tm.m_lines.m_buffer[(int)nn.m_transportLine].Info; TransportLine thisLine = tm.m_lines.m_buffer[(int)nn.m_transportLine]; linhas = new List <ushort>(); Vector3 location = nn.m_position; if (buildingId > 0 && ss == subServFound) { location = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].CalculateSidewalkPosition(); } TLMLineUtils.GetNearLines(location, 120f, ref linhas); airport = String.Empty; taxiStand = String.Empty; harbor = String.Empty; regionalTrainStation = String.Empty; cableCarStation = string.Empty; if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.TRAIN_SHOW_IN_LINEAR_MAP)) { ushort trainStation = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain, null, Building.Flags.None, Building.Flags.Untouchable | Building.Flags.Downgrading); if (trainStation > 0) { InstanceID iid = default(InstanceID); iid.Building = trainStation; regionalTrainStation = bm.GetBuildingName(trainStation, iid); } } if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.PLANE_SHOW_IN_LINEAR_MAP)) { ushort airportId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, new TransferManager.TransferReason[] { TransferManager.TransferReason.PassengerPlane }, Building.Flags.None, Building.Flags.Untouchable); if (airportId > 0) { InstanceID iid = default(InstanceID); iid.Building = airportId; airport = bm.GetBuildingName(airportId, iid); } } if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.SHIP_SHOW_IN_LINEAR_MAP)) { ushort harborId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip, new TransferManager.TransferReason[] { TransferManager.TransferReason.PassengerShip }, Building.Flags.None, Building.Flags.Untouchable); if (harborId > 0) { InstanceID iid = default(InstanceID); iid.Building = harborId; harbor = bm.GetBuildingName(harborId, iid); } } if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.TAXI_SHOW_IN_LINEAR_MAP)) { ushort taxiId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 50f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTaxi, null, Building.Flags.None, Building.Flags.Untouchable); if (taxiId > 0) { InstanceID iid = default(InstanceID); iid.Building = taxiId; taxiStand = bm.GetBuildingName(taxiId, iid); } } if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.CABLE_CAR_SHOW_IN_LINEAR_MAP)) { ushort cableCarId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportCableCar, null, Building.Flags.None, Building.Flags.Untouchable); if (cableCarId > 0) { InstanceID iid = default(InstanceID); iid.Building = cableCarId; cableCarStation = bm.GetBuildingName(cableCarId, iid); } } return(location); }
public void RefreshData(bool colors, bool visible) { if (Singleton <TransportManager> .exists) { bool isRowVisible; if (this.m_LineOperation == null || this.m_LineOperation.completedOrFailed) { //this.m_DayLine.isVisible = (!isZeroed); //this.m_NightLine.isVisible = (!isZeroed); //this.m_DayNightLine.isVisible = (!isZeroed); //this.m_DisabledLine.isVisible = (!isZeroed); //this.m_noBudgetWarn.isVisible = (isZeroed); bool isZeroed; bool dayActive; bool nightActive; TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID], out dayActive, out nightActive, out isZeroed); if (!isZeroed) { if (!dayActive || !nightActive) { m_LineColor.normalBgSprite = dayActive ? "DayIcon" : nightActive ? "NightIcon" : "DisabledIcon"; } else { m_LineColor.normalBgSprite = ""; } } else { m_LineColor.normalBgSprite = "NoBudgetIcon"; //m_noBudgetWarn.relativePosition = new Vector3(615, 2); } this.m_DayLine.isChecked = (dayActive && !nightActive); this.m_NightLine.isChecked = (nightActive && !dayActive); this.m_DayNightLine.isChecked = (dayActive && nightActive); this.m_DisabledLine.isChecked = (!dayActive && !nightActive); m_DisabledLine.relativePosition = new Vector3(730, 8); isRowVisible = TLMPublicTransportDetailPanel.instance.isActivityVisible(dayActive, nightActive) && TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_LineNumber); } else { m_LineColor.normalBgSprite = "DisabledIcon"; isRowVisible = TLMPublicTransportDetailPanel.instance.isActivityVisible(false, false) && TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_LineNumber); } if (!isRowVisible) { GetComponent <UIComponent>().isVisible = false; return; } GetComponent <UIComponent>().isVisible = true; this.m_LineName.text = Singleton <TransportManager> .instance.GetLineName(this.m_LineID); m_LineNumber = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_lineNumber; this.m_LineStops.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountStops(this.m_LineID).ToString("N0"); this.m_LineVehicles.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountVehicles(this.m_LineID).ToString("N0"); uint prefix = 0; TransportInfo info = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].Info; if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u; } float overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f; float prefixMultiplier = TLMUtils.getExtensionFromConfigIndex(TLMCW.getConfigIndexForTransportInfo(info)).getBudgetMultiplierForHour(prefix, (int)Singleton <SimulationManager> .instance.m_currentDayTimeHour) / 100f; this.m_budgetEffective.text = string.Format("{0:0%}", overallBudget * prefixMultiplier);//585+1/7 = frames/week string vehTooltip = string.Format("{0} {1}", this.m_LineVehicles.text, Locale.Get("PUBLICTRANSPORT_VEHICLES")); this.m_LineVehicles.tooltip = vehTooltip; int averageCount = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_residentPassengers.m_averageCount; int averageCount2 = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_touristPassengers.m_averageCount; this.m_LinePassengers.text = (averageCount + averageCount2).ToString("N0"); // this.m_LineEarnings.text = string.Format("~₡ {0:0.00}", (averageCount + averageCount2) / 50f); // m_LineEarnings.relativePosition = m_LinePassengers.relativePosition + new Vector3(0, 20, 0); this.m_LinePassengers.tooltip = string.Format("{0}", LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[] { averageCount, averageCount2 })); ModoNomenclatura prefixMode; Separador sep; ModoNomenclatura suffix; ModoNomenclatura nonPrefix; bool zerosEsquerda; bool invertPrefixSuffix; string bgSprite; TLMLineUtils.getLineNamingParameters(lineID, out prefixMode, out sep, out suffix, out nonPrefix, out zerosEsquerda, out invertPrefixSuffix, out bgSprite); TLMLineUtils.setLineNumberCircleOnRef(lineNumber, prefixMode, sep, suffix, nonPrefix, zerosEsquerda, m_LineNumberFormatted, invertPrefixSuffix, 0.8f); m_LineColor.normalFgSprite = bgSprite; m_budgetEffective.tooltip = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN"), TLMCW.getNameForTransportType(TLMCW.getConfigIndexForTransportInfo(info)), TLMUtils.getStringOptionsForPrefix(prefixMode, true)[prefix + 1], overallBudget, prefixMultiplier, overallBudget * prefixMultiplier); this.m_PassengerCount = averageCount + averageCount2; if (colors) { this.m_LineColor.selectedColor = Singleton <TransportManager> .instance.GetLineColor(this.m_LineID); } if (visible) { this.m_LineIsVisible.isChecked = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Hidden) == TransportLine.Flags.None); } m_budgetEffective.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 19, 0); } }