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); } }
private void AddVehicleToLinearMap(Color lineColor, ushort vehicleId) { UILabel vehicleLabel = null; int fill, cap; TLMLineUtils.GetVehicleCapacityAndFill(vehicleId, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId], out fill, out cap); TLMUtils.createUIElement <UILabel>(ref vehicleLabel, lineStationsPanel.transform); vehicleLabel.autoSize = false; vehicleLabel.text = string.Format("{0}/{1}", fill, cap); vehicleLabel.useOutline = true; vehicleLabel.width = 50; vehicleLabel.height = 33; vehicleLabel.pivot = UIPivotPoint.TopCenter; vehicleLabel.verticalAlignment = UIVerticalAlignment.Middle; vehicleLabel.atlas = TLMController.taLineNumber; vehicleLabel.padding = new RectOffset(0, 0, 2, 0); vehicleLabel.textScale = 0.6f; vehicleLabel.backgroundSprite = "VehicleLinearMap"; vehicleLabel.color = lineColor; vehicleLabel.textAlignment = UIHorizontalAlignment.Center; vehicleLabel.tooltip = Singleton <VehicleManager> .instance.GetVehicleName(vehicleId); vehicleLabel.eventClick += (x, y) => { InstanceID id = default(InstanceID); id.Vehicle = vehicleId; Camera.main.GetComponent <CameraController>().SetTarget(id, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId].GetLastFramePosition(), true); }; updateVehiclePosition(vehicleId, vehicleLabel); lineVehicles.Add(vehicleId, vehicleLabel); }
private void InitCapacitiesInAssets() { var keys = AssetConfigurations.Keys.ToList(); foreach (string entry in keys) { try { VehicleInfo info = PrefabCollection <VehicleInfo> .FindLoaded(entry); if (info != null) { VehicleAI ai = info.m_vehicleAI; UpdateDefaultCapacity(ai); SetVehicleCapacity(ai, SafeGetAsset(entry).Capacity); } else { AssetConfigurations.Remove(entry); } } catch (Exception e) { LogUtils.DoErrorLog($"ERROR LOADING ASSET CONFIG: {e}=> {e.Message}\n{e.StackTrace}"); } } SimulationManager.instance.StartCoroutine(TLMLineUtils.UpdateCapacityUnits()); }
public void SetVehicleCapacity(string assetName, int newCapacity) { VehicleInfo vehicle = PrefabCollection <VehicleInfo> .FindLoaded(assetName); if (vehicle != null && !VehicleUtils.IsTrailer(vehicle)) { Dictionary <string, MutableTuple <float, int> > assetsCapacitiesPercentagePerTrailer = GetCapacityRelative(vehicle); int capacityUsed = 0; foreach (KeyValuePair <string, MutableTuple <float, int> > entry in assetsCapacitiesPercentagePerTrailer) { SafeGetAsset(entry.Key).Capacity = Mathf.RoundToInt(newCapacity <= 0 ? -1f : entry.Value.First *newCapacity); capacityUsed += SafeGetAsset(entry.Key).Capacity *entry.Value.Second; } if (newCapacity > 0 && capacityUsed != newCapacity) { SafeGetAsset(assetsCapacitiesPercentagePerTrailer.Keys.ElementAt(0)).Capacity += (newCapacity - capacityUsed) / assetsCapacitiesPercentagePerTrailer[assetsCapacitiesPercentagePerTrailer.Keys.ElementAt(0)].Second; } foreach (string entry in assetsCapacitiesPercentagePerTrailer.Keys) { VehicleAI vai = PrefabCollection <VehicleInfo> .FindLoaded(entry).m_vehicleAI; SetVehicleCapacity(vai, SafeGetAsset(entry).Capacity); } SimulationManager.instance.StartCoroutine(TLMLineUtils.UpdateCapacityUnits()); } }
private static int ticketPriceForPrefix(ushort vehicleID, ref Vehicle vehicleData, int defaultPrice) { var def = TransportSystemDefinition.from(vehicleData.Info); if (def == default(TransportSystemDefinition)) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("NULL TSysDef! {0}+{1}+{2}", vehicleData.Info.GetAI().GetType(), vehicleData.Info.m_class.m_subService, vehicleData.Info.m_vehicleType); } return(defaultPrice); } if (vehicleData.m_transportLine == 0) { var value = (int)def.GetTransportExtension().GetDefaultTicketPrice(0); return(value); } else { if (TLMTransportLineExtension.instance.GetUseCustomConfig(vehicleData.m_transportLine)) { return((int)TLMTransportLineExtension.instance.GetTicketPrice(vehicleData.m_transportLine)); } else { return((int)def.GetTransportExtension().GetTicketPrice(TLMLineUtils.getPrefix(vehicleData.m_transportLine))); } } }
private void changeLineTime(int selection) { daytimeChange = Singleton <SimulationManager> .instance.AddAction(delegate { ushort lineID = m_lineIdSelecionado.TransportLine; TLMLineUtils.setLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID], ((selection & 0x2) == 0), ((selection & 0x1) == 0)); }); }
private void AddEntry() { ushort lineId = UVMPublicTransportWorldInfoPanel.GetLineID(); Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId); config.SetTicketPriceToLine(lineId, 0, 0); RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID()); }
private void ActionCopy() { ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID(); m_clipboard = XmlUtils.DefaultXmlSerialize(TLMLineUtils.GetEffectiveExtensionForLine(lineID).GetBudgetsMultiplierForLine(lineID)); m_pasteButton.isVisible = true; UVMBudgetConfigTab.Instance.RebuildList(lineID); }
public static bool StartTransfer(DepotAI __instance, ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer) { if (!managedReasons.Contains(reason) || offer.TransportLine == 0) { return(true); } TLMUtils.doLog("START TRANSFER!!!!!!!!"); TransportInfo m_transportInfo = __instance.m_transportInfo; BuildingInfo m_info = __instance.m_info; if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine); } if (reason == m_transportInfo.m_vehicleReason || (__instance.m_secondaryTransportInfo != null && reason == __instance.m_secondaryTransportInfo.m_vehicleReason)) { VehicleInfo randomVehicleInfo = null; var tsd = TransportSystemDefinition.from(__instance.m_transportInfo); TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[offer.TransportLine]; TransportInfo.TransportType t = tl.Info.m_transportType; if (TLMLineUtils.hasPrefix(ref tl)) { setRandomBuildingByPrefix(tsd, tl.m_lineNumber / 1000u, ref buildingID); } else { setRandomBuildingByPrefix(tsd, 0, ref buildingID); } TLMUtils.doLog("randomVehicleInfo"); randomVehicleInfo = doModelDraw(offer.TransportLine); if (randomVehicleInfo == null) { randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level); } if (randomVehicleInfo != null) { TLMUtils.doLog("randomVehicleInfo != null"); Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles; __instance.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector); if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort vehicleID, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true)) { TLMUtils.doLog("CreatedVehicle!!!"); randomVehicleInfo.m_vehicleAI.SetSource(vehicleID, ref vehicles.m_buffer[(int)vehicleID], buildingID); randomVehicleInfo.m_vehicleAI.StartTransfer(vehicleID, ref vehicles.m_buffer[(int)vehicleID], reason, offer); } return(false); } } return(true); }
public void setLineNumberCircle(ushort lineID) { TLMLineUtils.setLineNumberCircleOnRef(lineID, linearMapLineNumber); try { m_autoName = TLMLineUtils.calculateAutoName(lineID); linearMapLineNumber.tooltip = m_autoName; } catch { } }
private void RemoveTime(BudgetEntryXml entry) { TimeableList <BudgetEntryXml> config = TLMLineUtils.GetEffectiveConfigForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).BudgetEntries; if (config != default) { config.RemoveAtHour(entry.HourOfDay ?? -1); m_isDirty = true; } }
private void updateSliders() { if (TLMSingleton.isIPTLoaded) { m_lineBudgetSlidersTitle.parent.isVisible = false; return; } TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex(); ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType); uint[] multipliers; IBudgetableExtension bte; uint idx; var tsdRef = tsd; idx = (uint)SelectedPrefix; bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef); multipliers = bte.GetBudgetsMultiplier(idx); m_lineBudgetSlidersTitle.text = string.Format(Locale.Get("TLM_BUDGET_MULTIPLIER_TITLE_PREFIX"), idx > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)idx + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsdRef.toConfigIndex())); bool budgetPerHourEnabled = multipliers.Length == 8; m_disableBudgetPerHour.isVisible = budgetPerHourEnabled; m_enableBudgetPerHour.isVisible = !budgetPerHourEnabled && tsdRef.hasVehicles(); for (int i = 0; i < m_budgetSliders.Length; i++) { UILabel budgetSliderLabel = m_budgetSliders[i].transform.parent.GetComponentInChildren <UILabel>(); if (i == 0) { if (multipliers.Length == 1) { budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL_ALL"); } else { budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL", 0); } } else { m_budgetSliders[i].isEnabled = budgetPerHourEnabled; m_budgetSliders[i].parent.isVisible = budgetPerHourEnabled; } if (i < multipliers.Length) { m_budgetSliders[i].value = multipliers[i] / 100f; } } }
public int getCurrentNumber() { if (TLMLineUtils.hasPrefix(transportTool.m_prefab)) { return(((nextLineNumber + 1) & 0xFFFF) % 1000); } else { return((nextLineNumber + 1) & 0xFFFF); } }
private void AddEntry() { TimeableList <BudgetEntryXml> config = TLMLineUtils.GetEffectiveConfigForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).BudgetEntries; config.Add(new BudgetEntryXml() { HourOfDay = 0, Value = 100 }); RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID()); }
private void ActionPaste() { if (m_clipboard == null) { return; } ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID(); TLMLineUtils.GetEffectiveExtensionForLine(lineID).SetAllBudgetMultipliersForLine(lineID, XmlUtils.DefaultXmlDeserialize <TimeableList <BudgetEntryXml> >(m_clipboard)); UVMBudgetConfigTab.Instance.RebuildList(lineID); }
public static void RemoveAllUnwantedVehicles() { 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) { uint idx; IAssetSelectorExtension extension; if (TLMTransportLineExtension.instance.IsUsingCustomConfig(lineId)) { idx = lineId; extension = TLMTransportLineExtension.instance; } else { idx = TLMLineUtils.getPrefix(lineId); var def = TransportSystemDefinition.from(lineId); extension = def.GetTransportExtension(); } TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId]; var modelList = extension.GetAssetList(idx); VehicleManager vm = Singleton <VehicleManager> .instance; VehicleInfo info = vm.m_vehicles.m_buffer[Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].GetVehicle(0)].Info; if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("removeAllUnwantedVehicles: models found: {0}", modelList == null ? "?!?" : modelList.Count.ToString()); } if (modelList.Count > 0) { Dictionary <ushort, VehicleInfo> vehiclesToRemove = new Dictionary <ushort, VehicleInfo>(); for (int i = 0; i < tl.CountVehicles(lineId); i++) { var vehicle = tl.GetVehicle(i); if (vehicle != 0) { VehicleInfo info2 = vm.m_vehicles.m_buffer[(int)vehicle].Info; if (!modelList.Contains(info2.name)) { vehiclesToRemove[vehicle] = info2; } } } foreach (var item in vehiclesToRemove) { item.Value.m_vehicleAI.SetTransportLine(item.Key, ref vm.m_vehicles.m_buffer[item.Key], 0); } } } } }
private void updateNearLines(UIPanel parent, bool force = false) { if (parent != null) { Transform linesPanelObj = parent.transform.Find("TLMLinesNear"); if (!linesPanelObj) { linesPanelObj = initPanelNearLinesOnWorldInfoPanel(parent); } var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building; if (lastBuildingSelected == buildingId && !force) { return; } else { lastBuildingSelected = buildingId; } Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId]; List <ushort> nearLines = new List <ushort>(); TLMLineUtils.GetNearLines(b.CalculateSidewalkPosition(), 120f, ref nearLines); bool showPanel = nearLines.Count > 0; // DebugOutputPanel.AddMessage (PluginManager.MessageType.Warning, "nearLines.Count = " + nearLines.Count); if (showPanel) { foreach (Transform t in linesPanelObj) { if (t.GetComponent <UILabel>() == null) { GameObject.Destroy(t.gameObject); } } Dictionary <string, ushort> lines = TLMLineUtils.SortLines(nearLines); TLMLineUtils.PrintIntersections("", "", "", "", linesPanelObj.GetComponent <UIPanel>(), lines, scale, perLine); } linesPanelObj.GetComponent <UIPanel>().isVisible = showPanel; } else { var go = GameObject.Find("TLMLinesNear"); if (!go) { return; } Transform linesPanelObj = go.transform; linesPanelObj.GetComponent <UIPanel>().isVisible = false; } }
public void Update() { if (m_container.isVisible) { ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID(); m_minutePointer.transform.localEulerAngles = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour % 1 * -360) + 180); m_hourPointer.transform.localEulerAngles = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour / 24 * -360) + 180); var tsd = TransportSystemDefinition.From(lineID); Tuple <TicketPriceEntryXml, int> value = TLMLineUtils.GetTicketPriceForLine(ref tsd, lineID); m_effectiveLabel.color = value.Second < 0 ? Color.gray : TLMTicketConfigTab.m_colorOrder[value.Second % TLMTicketConfigTab.m_colorOrder.Count]; m_effectiveLabel.text = (value.First.Value / 100f).ToString(Settings.moneyFormat, LocaleManager.cultureInfo); } }
private void setBudgetMultiplierDropDownSelection(int index, uint prefix, bool global = false) { uint[] saveData; if (m_chkSingleBudget.isChecked) { saveData = new uint[] { m_hourBudgets[0] }; } else { saveData = m_hourBudgets; } TLMLineUtils.getExtensionFromConfigIndex(getConfigIndexFromDropDownSelection(index)).SetBudgetMultiplier(prefix, saveData); }
public MapTransportLine(Color32 color, bool day, bool night, ushort lineId) { TransportLine t = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId]; this.lineName = Singleton <TransportManager> .instance.GetLineName(lineId); this.lineStringIdentifier = TLMLineUtils.getLineStringId(lineId); transportType = t.Info.m_transportType; stations = new List <Station>(); lineColor = color; activeDay = day; activeNight = night; this.lineId = lineId; }
private void saveLineNumber() { String value = "0" + lineNumberLabel.text; int valPrefixo = linePrefixDropDown.selectedIndex; ModoNomenclatura sufixo; ModoNomenclatura prefixo; ModoNomenclatura nonPrefix; Separador sep; bool zeros; bool invertPrefixSuffix; TLMLineUtils.getLineNamingParameters(m_lineIdSelecionado.TransportLine, out prefixo, out sep, out sufixo, out nonPrefix, out zeros, out invertPrefixSuffix); ushort num = ushort.Parse(value); if (prefixo != ModoNomenclatura.Nenhum) { num = (ushort)(valPrefixo * 1000 + (num % 1000)); } bool numeroUsado = isNumeroUsado(num, m_lineIdSelecionado.TransportLine); if (num < 1) { lineNumberLabel.textColor = new Color(1, 0, 0, 1); return; } if (numeroUsado) { lineNumberLabel.textColor = new Color(1, 0, 0, 1); } else { lineNumberLabel.textColor = new Color(1, 1, 1, 1); m_controller.tm.m_lines.m_buffer[(int)m_lineIdSelecionado.TransportLine].m_lineNumber = num; m_linearMap.setLineNumberCircle(num, prefixo, sep, sufixo, nonPrefix, zeros, invertPrefixSuffix); m_autoNameLabel.text = m_linearMap.autoName; if (prefixo != ModoNomenclatura.Nenhum) { lineNumberLabel.text = (num % 1000).ToString(); linePrefixDropDown.selectedIndex = (num / 1000); } else { lineNumberLabel.text = (num % 10000).ToString(); } } }
public void Update() { if (m_container.isVisible) { ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID(); m_minutePointer.transform.localEulerAngles = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour % 1 * -360) + 180); m_hourPointer.transform.localEulerAngles = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour / 24 * -360) + 180); Tuple <float, int, int, float> value = TLMLineUtils.GetBudgetMultiplierLineWithIndexes(lineID); m_effectiveSprite.color = UVMBudgetConfigTab.m_colorOrder[value.Second % UVMBudgetConfigTab.m_colorOrder.Count]; m_effectiveSprite.progressColor = UVMBudgetConfigTab.m_colorOrder[value.Third % UVMBudgetConfigTab.m_colorOrder.Count]; m_effectiveSprite.value = value.Fourth; int currentVehicleCount = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].CountVehicles(lineID); int targetVehicleCount = TransportLineOverrides.NewCalculateTargetVehicleCount(lineID); m_effectiveLabel.prefix = (value.First * 100).ToString("0"); m_effectiveLabel.suffix = $"{currentVehicleCount.ToString("0")}/{targetVehicleCount.ToString("0")}"; } }
public void RebuildList(ushort lineID) { TimeableList <TicketPriceEntryXml> config = TLMLineUtils.GetEffectiveConfigForLine(lineID).TicketPriceEntries; int stopsCount = config.Count; if (stopsCount == 0) { config.Add(new TicketPriceEntryXml() { HourOfDay = 0, Value = 0 }); } RecountRows(config, stopsCount, ref TransportManager.instance.m_lines.m_buffer[lineID]); RedrawList(); }
public VehicleInfo GetAModel(ushort lineID) { var prefix = TLMLineUtils.getPrefix(lineID); VehicleInfo info = null; List <string> assetList = GetAssetList(prefix); while (info == null && assetList.Count > 0) { info = TLMUtils.GetRandomModel(assetList, out string modelName); if (info == null) { RemoveAsset(prefix, modelName); assetList = GetAssetList(prefix); } } return(info); }
public TLMMapTransportLine(Color32 color, bool day, bool night, ushort lineId) { TransportLine t = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId]; lineName = Singleton <TransportManager> .instance.GetLineName(lineId); lineStringIdentifier = TLMLineUtils.GetLineStringId(lineId); TransportType = t.Info.m_transportType; subservice = t.Info.GetSubService(); vehicleType = t.Info.m_vehicleType; stations = new List <TLMMapStation>(); lineColor = color; activeDay = day; activeNight = night; this.lineId = lineId; lineNumber = t.m_lineNumber; }
public static bool SimulationStepPre(ushort lineID) { try { TransportLine t = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID]; bool activeDayNightManagedByTLM = TLMLineUtils.isPerHourBudget(lineID); if (t.m_lineNumber != 0 && t.m_stops != 0) { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget = (ushort)(TLMLineUtils.getBudgetMultiplierLine(lineID) * 100); } unchecked { TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], out bool day, out bool night); bool isNight = Singleton <SimulationManager> .instance.m_isNightTime; bool zeroed = false; if ((activeDayNightManagedByTLM || (isNight && night) || (!isNight && day)) && Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget == 0) { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags |= (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT; zeroed = true; } else { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags &= ~(TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT; } TLMUtils.doLog("activeDayNightManagedByTLM = {0}; zeroed = {1}", activeDayNightManagedByTLM, zeroed); if (activeDayNightManagedByTLM) { if (zeroed) { TLMLineUtils.setLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], false, false); } else { TLMLineUtils.setLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], true, true); } } } } catch (Exception e) { TLMUtils.doErrorLog("Error processing budget for line: {0}\n{1}", lineID, e); } return(true); }
public void RebuildList(ushort lineID) { Interfaces.IBasicExtensionStorage effectiveConfig = TLMLineUtils.GetEffectiveConfigForLine(lineID); TimeableList <BudgetEntryXml> budgetEntries = effectiveConfig.BudgetEntries; int stopsCount = budgetEntries.Count; if (stopsCount == 0) { budgetEntries.Add(new BudgetEntryXml() { HourOfDay = 0, Value = effectiveConfig is TLMTransportLineConfiguration ? 100u : TransportManager.instance.m_lines.m_buffer[lineID].m_budget }); } RecountRows(budgetEntries, stopsCount); RedrawList(); }
public void updateBidings() { if (showExtraStopInfo) { foreach (var resLabel in residentCounters) { TLMLineUtils.GetQuantityPassengerWaiting(resLabel.Key, out int residents, out int tourists, out int ttb); resLabel.Value.text = residents.ToString(); touristCounters[resLabel.Key].text = tourists.ToString(); ttbTimers[resLabel.Key].text = ttb.ToString(); ttbTimers[resLabel.Key].color = getColorForTTB(ttb); } ushort lineID = parent.CurrentSelectedId; TransportLine t = TLMController.instance.tm.m_lines.m_buffer[(int)lineID]; Color lineColor = TLMController.instance.tm.GetLineColor(lineID); int vehicleCount = t.CountVehicles(lineID); List <ushort> oldItems = lineVehicles.Keys.ToList(); vehiclesOnStation.Clear(); for (int v = 0; v < vehicleCount; v++) { ushort vehicleId = t.GetVehicle(v); UILabel vehicleLabel = null; if (oldItems.Contains(vehicleId)) { vehicleLabel = lineVehicles[vehicleId]; TLMLineUtils.GetVehicleCapacityAndFill(vehicleId, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId], out int fill, out int cap); vehicleLabel.text = string.Format("{0}/{1}", fill, cap); var labelStation = residentCounters[Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId].m_targetBuilding]; updateVehiclePosition(vehicleLabel); oldItems.Remove(vehicleId); } else { AddVehicleToLinearMap(lineColor, vehicleId); } } foreach (ushort dead in oldItems) { GameObject.Destroy(lineVehicles[dead].gameObject); lineVehicles.Remove(dead); } } }
private void setBudgetHour(float x, int selectedHourIndex) { if (!isChanging && m_prefixSelector.selectedIndex >= 0) { uint idx = (uint)SelectedPrefix; ushort val = (ushort)(x * 100 + 0.5f); IBudgetableExtension bte; uint[] saveData; var tsdRef = tsd; bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef); saveData = bte.GetBudgetsMultiplier(idx); if (selectedHourIndex >= saveData.Length || saveData[selectedHourIndex] == val) { return; } saveData[selectedHourIndex] = val; bte.SetBudgetMultiplier(idx, saveData); } }
: "";// KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_CircleIcon, true); private void CreateConnectionPanel(NetManager instance, UIPanel basePanel, ushort currentStop) { ushort lineID = GetLineID(); var linesFound = new List <ushort>(); TLMLineUtils.GetNearLines(instance.m_nodes.m_buffer[currentStop].m_position, 150f, ref linesFound); linesFound.Remove(lineID); UIPanel connectionPanel = basePanel.Find <UIPanel>("ConnectionPanel"); while (connectionPanel.childCount < linesFound.Count) { KlyteMonoUtils.CreateUIElement(out UILabel lineLabel, connectionPanel.transform, "", new Vector4(0, 0, 17, 17)); lineLabel.processMarkup = true; lineLabel.textScale = 0.5f; lineLabel.eventClicked += OpenLineLabel; lineLabel.verticalAlignment = UIVerticalAlignment.Middle; } while (connectionPanel.childCount > linesFound.Count) { UIComponent comp = connectionPanel.components[linesFound.Count]; connectionPanel.components.RemoveAt(linesFound.Count); GameObject.Destroy(comp); connectionPanel.Invalidate(); } int multiplier = linesFound.Count > m_kMaxConnectionsLine ? 1 : 2; for (int i = 0; i < linesFound.Count; i++) { ushort line = linesFound[i]; UILabel lineLabel = connectionPanel.components[i].GetComponent <UILabel>(); lineLabel.name = $"L{line}"; lineLabel.tooltip = Singleton <TransportManager> .instance.GetLineName(line); lineLabel.text = TLMLineUtils.GetIconString(line); lineLabel.stringUserData = line.ToString(); lineLabel.size = m_kBasicConnectionLogoSize * multiplier; lineLabel.textScale = m_kBasicConnectionLogoFontSize * multiplier; } connectionPanel.isVisible = m_currentMode == MapMode.CONNECTIONS; }