Ejemplo n.º 1
0
        public static string GetBuildingDetails(ushort buildingId, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix, out NamingType namingType, ushort lineId = 0)
        {
            BuildingManager bm = Singleton <BuildingManager> .instance;

            Building b = bm.m_buildings.m_buffer[buildingId];

            while (b.m_parentBuilding > 0)
            {
                LogUtils.DoLog("getBuildingName(): building id {0} - parent = {1}", buildingId, b.m_parentBuilding);
                buildingId = b.m_parentBuilding;
                b          = bm.m_buildings.m_buffer[buildingId];
            }
            InstanceID iid = default;

            iid.Building    = buildingId;
            serviceFound    = b.Info?.GetService() ?? default;
            subserviceFound = b.Info?.GetSubService() ?? default;
            TransportSystemDefinition tsd = TransportSystemDefinition.From(b.Info.GetAI());

            if (tsd is null)
            {
                var data = TLMBaseConfigXML.CurrentContextConfig.GetAutoNameData(serviceFound);
                prefix     = data?.NamingPrefix?.Trim();
                namingType = NamingTypeExtensions.From(serviceFound, subserviceFound);
            }
            else
            {
                prefix = tsd.GetConfig().NamingPrefix?.TrimStart();
                LogUtils.DoLog($"getBuildingName(): serviceFound {serviceFound} - subserviceFound = {subserviceFound} - tsd = {tsd} - prefix = {prefix}");
                namingType = NamingTypeExtensions.From(tsd);
            }
            return(bm.GetBuildingName(buildingId, iid));
        }
Ejemplo n.º 2
0
        public static string getBuildingName(ushort buildingId, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix, ushort lineId = 0)
        {
            NetManager      nm = Singleton <NetManager> .instance;
            BuildingManager bm = Singleton <BuildingManager> .instance;

            Building b = bm.m_buildings.m_buffer[buildingId];

            while (b.m_parentBuilding > 0)
            {
                doLog("getBuildingName(): building id {0} - parent = {1}", buildingId, b.m_parentBuilding);
                buildingId = b.m_parentBuilding;
                b          = bm.m_buildings.m_buffer[buildingId];
            }
            InstanceID iid = default;

            iid.Building    = buildingId;
            serviceFound    = b.Info?.GetService() ?? default;
            subserviceFound = b.Info?.GetSubService() ?? default;
            var index = GameServiceExtensions.ToConfigIndex(serviceFound, subserviceFound);
            TransportSystemDefinition tsd = default;

            if ((index & TLMCW.ConfigIndex.DESC_DATA) == TLMCW.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG)
            {
                tsd   = TransportSystemDefinition.From(b.Info.GetAI());
                index = tsd.ToConfigIndex();
            }
            prefix = index.GetSystemStationNamePrefix(lineId)?.TrimStart();
            doLog($"getBuildingName(): serviceFound {serviceFound} - subserviceFound = {subserviceFound} - tsd = {tsd} - index = {index} - prefix = {prefix}");

            return(bm.GetBuildingName(buildingId, iid));
        }
Ejemplo n.º 3
0
        private static int CompareLineNumbers(UIComponent left, UIComponent right)
        {
            if (left == null || right == null)
            {
                return(0);
            }

            UVMLineListItem component  = left.GetComponent <UVMLineListItem>();
            UVMLineListItem component2 = right.GetComponent <UVMLineListItem>();

            if (component == null || component2 == null)
            {
                return(0);
            }
            var tsd  = TransportSystemDefinition.From(component.LineID);
            var tsd2 = TransportSystemDefinition.From(component2.LineID);

            if (tsd == tsd2)
            {
                return(component.LineNumber.CompareTo(component2.LineNumber));
            }
            else
            {
                return(tsd.GetHashCode().CompareTo(tsd2.GetHashCode()));
            }
        }
Ejemplo n.º 4
0
        private void PrintIncomeExpenseVehicle(ushort lineID, int idx, UILabel labelVehicle, long income, long expense, float scale)
        {
            var tsd = TransportSystemDefinition.From(lineID);

            m_vehicleButtons.items[idx].color = Color.Lerp(Color.white, income > expense ? Color.green : Color.red, Mathf.Max(income, expense) / scale * TLMLineUtils.GetTicketPriceForLine(tsd, lineID).First.Value);
            labelVehicle.text   = $"\n<color #00cc00>{(income / 100.0f).ToString(Settings.moneyFormat, LocaleManager.cultureInfo)}</color>";
            labelVehicle.suffix = $"\n<color #ff0000>{(expense / 100.0f).ToString(Settings.moneyFormat, LocaleManager.cultureInfo)}</color>";
        }
Ejemplo n.º 5
0
 public static IBasicExtensionStorage GetEffectiveConfigForLine(ushort lineId)
 {
     if (TLMTransportLineExtension.Instance.IsUsingCustomConfig(lineId))
     {
         return(TLMTransportLineExtension.Instance.SafeGet(lineId));
     }
     else
     {
         var tsd = TransportSystemDefinition.From(lineId);
         return((tsd.GetTransportExtension() as ISafeGettable <TLMPrefixConfiguration>).SafeGet(TLMPrefixesUtils.GetPrefix(lineId)));
     }
 }
Ejemplo n.º 6
0
 public static IBasicExtension GetEffectiveExtensionForLine(ushort lineId)
 {
     if (TLMTransportLineExtension.Instance.IsUsingCustomConfig(lineId))
     {
         return(TLMTransportLineExtension.Instance);
     }
     else
     {
         var tsd = TransportSystemDefinition.From(lineId);
         return(tsd.GetTransportExtension());
     }
 }
Ejemplo n.º 7
0
 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 CapacityEditor_eventTextSubmitted(UIComponent x, string y)
        {
            if (m_isLoading || !int.TryParse(y.IsNullOrWhiteSpace() ? "0" : y, out int value))
            {
                return;
            }
            var         capacityEditor = x as UITextField;
            string      assetName      = x.parent.GetComponentInChildren <UICheckBox>().objectUserData.ToString();
            VehicleInfo info           = PrefabCollection <VehicleInfo> .FindLoaded(assetName);

            TransportSystemDefinition.From(info).GetTransportExtension().SetVehicleCapacity(assetName, value);
            m_isLoading         = true;
            capacityEditor.text = VehicleUtils.GetCapacity(info).ToString("0");
            m_isLoading         = false;
        }
Ejemplo n.º 9
0
        public static bool StartTransfer(DepotAI __instance, ushort buildingID, TransferManager.TransferReason reason, TransferManager.TransferOffer offer)
        {
            if (!m_managedReasons.Contains(reason) || offer.TransportLine == 0)
            {
                return(true);
            }

            TLMUtils.doLog("START TRANSFER!!!!!!!!");
            TransportInfo m_transportInfo = __instance.m_transportInfo;
            BuildingInfo  m_info          = __instance.m_info;

            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))
            {
                var tsd = TransportSystemDefinition.From(__instance.m_transportInfo);

                Instance.SetRandomBuilding(ref tsd, offer.TransportLine, ref buildingID);

                TLMUtils.doLog("randomVehicleInfo");
                VehicleInfo 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[vehicleID], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(vehicleID, ref vehicles.m_buffer[vehicleID], reason, offer);
                    }
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 10
0
        protected static bool OnSetTarget()
        {
            ushort lineID = GetLineID();

            if (lineID != 0)
            {
                m_obj.m_nameField.text = Singleton <TransportManager> .instance.GetLineName(lineID);

                m_obj.m_specificConfig.isVisible = TransportSystemDefinition.From(lineID).HasVehicles();
                m_obj.m_specificConfig.isChecked = TLMTransportLineExtension.Instance.IsUsingCustomConfig(lineID);
            }

            foreach (KeyValuePair <string, IUVMPTWIPChild> tab in m_obj.m_childControls)
            {
                if (tab.Value.MayBeVisible())
                {
                    m_obj.m_lineConfigTabs.ShowTab(tab.Key);
                    tab.Value.OnSetTarget(m_dirtySource);
                }
                else
                {
                    m_obj.m_lineConfigTabs.HideTab(tab.Key);
                    tab.Value.Hide();
                }
            }

            m_obj.m_cachedLength = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_totalLength;
            if (!m_dirty)
            {
                ReflectionUtils.RunPrivateMethod <object>(m_obj.origInstance, "UpdateBindings");
            }

            m_dirty       = false;
            m_dirtySource = null;
            return(false);
        }
Ejemplo n.º 11
0
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            ushort lineID = GetLineID();

            if (lineID != 0)
            {
                LineType lineType = GetLineType(lineID);
                bool     isTour   = (lineType == LineType.WalkingTour);
                m_mapModeDropDown.isVisible = !isTour;
                m_vehiclesLabel.isVisible   = !isTour && m_currentMode != MapMode.CONNECTIONS;
                m_connectionLabel.isVisible = !isTour || m_currentMode == MapMode.CONNECTIONS;


                if (isTour)
                {
                    m_currentMode = MapMode.CONNECTIONS;
                    m_stopsLabel.relativePosition      = new Vector3(215f, 12f, 0f);
                    m_stopsLineSprite.relativePosition = m_kLineSSpritePositionForWalkingTours;
                    m_actualStopsX = m_kstopsXForWalkingTours;
                }
                else
                {
                    m_stopsLabel.relativePosition      = new Vector3(215f, 12f, 0f);
                    m_stopsLineSprite.relativePosition = m_kLineSSpritePosition;
                    m_actualStopsX = m_kstopsX;
                }
                m_lineStringLabel.text  = TLMLineUtils.GetIconString(lineID);
                m_stopsLineSprite.color = Singleton <TransportManager> .instance.GetLineColor(lineID);

                NetManager instance      = Singleton <NetManager> .instance;
                int        stopsCount    = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].CountStops(lineID);
                float[]    stopPositions = new float[stopsCount];
                m_cachedStopOrder = new ushort[stopsCount];
                float     minDistance  = float.MaxValue;
                float     lineLength   = 0f;
                UIPanel[] stopsButtons = m_stopButtons.SetItemCount(stopsCount);
                ushort    firstStop    = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_stops;
                ushort    currentStop  = firstStop;
                int       idx          = 0;
                while (currentStop != 0 && idx < stopsButtons.Length)
                {
                    stopsButtons[idx].GetComponentInChildren <UIButton>().objectUserData = currentStop;

                    m_cachedStopOrder[idx] = currentStop;
                    UILabel uilabel = stopsButtons[idx].Find <UILabel>("PassengerCount");

                    uilabel.prefix = TLMStationUtils.GetFullStationName(currentStop, lineID, TransportSystemDefinition.GetDefinitionForLine(lineID).SubService);
                    uilabel.text   = "";

                    UILabel dist = stopsButtons[idx].Find <UILabel>("Distance");
                    dist.text = "(???)";


                    CreateConnectionPanel(instance, stopsButtons[idx], currentStop);
                    UIButton button = stopsButtons[idx].GetComponentInChildren <UIButton>();
                    UpdateTerminalStatus(lineID, currentStop, button);
                    button.tooltipLocaleID
                        = !TransportSystemDefinition.From(lineID).CanHaveTerminals() ? ""
                        : currentStop == firstStop ? "K45_TLM_FIRSTSTOPALWAYSTERMINAL"
                        : "K45_TLM_RIGHTCLICKSETTERMINAL";

                    if (uilabel.objectUserData == null)
                    {
                        UITextField stopNameField = stopsButtons[idx].Find <UITextField>("StopNameField");
                        uilabel.eventMouseEnter += (c, r) => uilabel.backgroundSprite = "TextFieldPanelHovered";
                        uilabel.eventMouseLeave += (c, r) => uilabel.backgroundSprite = string.Empty;
                        uilabel.eventClick      += (c, r) =>
                        {
                            uilabel.Hide();
                            stopNameField.Show();
                            stopNameField.text = TLMStationUtils.GetStationName((ushort)button.objectUserData, GetLineID(), TransportSystemDefinition.GetDefinitionForLine(GetLineID()).SubService);
                            stopNameField.Focus();
                        };
                        stopNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r)
                        {
                            stopNameField.Hide();
                            uilabel.Show();
                        };
                        stopNameField.eventTextSubmitted += (x, y) => TLMStationUtils.SetStopName(y.Trim(), (ushort)button.objectUserData, GetLineID(), () => uilabel.prefix = $"<color white>{TLMStationUtils.GetFullStationName((ushort)button.GetComponentInChildren<UIButton>().objectUserData, GetLineID(), TransportSystemDefinition.GetDefinitionForLine(GetLineID()).SubService)}</color>");
                        button.eventMouseUp += (x, y) =>
                        {
                            var stop   = (ushort)x.objectUserData;
                            var lineId = GetLineID();
                            if ((y.buttons & UIMouseButton.Right) != 0 && TransportSystemDefinition.From(lineId).CanHaveTerminals() && stop != Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_stops)
                            {
                                var newVal = TLMStopDataContainer.Instance.SafeGet(stop).IsTerminal;
                                TLMStopDataContainer.Instance.SafeGet(stop).IsTerminal = !newVal;
                                NetProperties properties = NetManager.instance.m_properties;
                                if (!(properties is null) && !(properties.m_drawSound is null))
                                {
                                    AudioManager.instance.DefaultGroup.AddPlayer(0, properties.m_drawSound, 1f);
                                }
                                m_dirtyTerminal = true;
                            }
                        };

                        uilabel.objectUserData = true;
                    }
                    for (int i = 0; i < 8; i++)
                    {
                        ushort segmentId = instance.m_nodes.m_buffer[currentStop].GetSegment(i);
                        if (segmentId != 0 && instance.m_segments.m_buffer[segmentId].m_startNode == currentStop)
                        {
                            currentStop = instance.m_segments.m_buffer[segmentId].m_endNode;
                            dist.text   = (instance.m_segments.m_buffer[segmentId].m_averageLength).ToString("0");
                            float segmentSize = m_unscaledMode ? m_kminStopDistance : instance.m_segments.m_buffer[segmentId].m_averageLength;
                            if (segmentSize == 0f)
                            {
                                CODebugBase <LogChannel> .Error(LogChannel.Core, "Two transport line stops have zero distance");

                                segmentSize = 100f;
                            }
                            stopPositions[idx] = segmentSize;
                            if (segmentSize < minDistance)
                            {
                                minDistance = segmentSize;
                            }
                            lineLength += stopPositions[idx];
                            break;
                        }
                    }

                    if (stopsCount > 2 && currentStop == firstStop)
                    {
                        break;
                    }
                    if (stopsCount == 2 && idx > 0)
                    {
                        break;
                    }
                    if (stopsCount == 1)
                    {
                        break;
                    }
                    if (++idx >= 32768)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                float stopDistanceFactor = m_kminStopDistance / minDistance;
                m_uILineLength = stopDistanceFactor * lineLength;
                if (m_uILineLength < m_kminUILineLength)
                {
                    m_uILineLength     = m_kminUILineLength;
                    stopDistanceFactor = m_uILineLength / lineLength;
                }
                else if (m_uILineLength > m_kmaxUILineLength)
                {
                    m_uILineLength     = m_kmaxUILineLength;
                    stopDistanceFactor = m_uILineLength / lineLength;
                }
                if (stopsCount <= 2)
                {
                    m_uILineOffset = (stopDistanceFactor * stopPositions[stopPositions.Length - 1]) - 30f;
                }
                if (m_uILineOffset < 20f || stopsCount > 2)
                {
                    m_uILineOffset = stopDistanceFactor * stopPositions[stopPositions.Length - 1] / 2f;
                }
                m_uILineLength          += 20;
                m_stopsLineSprite.height = m_uILineLength;
                m_stopsContainer.height  = m_uILineLength + m_kvehicleButtonHeight;
                Vector3 relativePosition = m_lineEnd.relativePosition;
                relativePosition.y         = m_uILineLength + 13f;
                relativePosition.x         = m_stopsLineSprite.relativePosition.x + 4f;
                m_lineEnd.relativePosition = relativePosition;
                float num8 = 0f;
                for (int j = 0; j < stopsCount; j++)
                {
                    Vector3 relativePosition2 = m_stopButtons.items[j].relativePosition;
                    relativePosition2.x = m_actualStopsX;
                    relativePosition2.y = ShiftVerticalPosition(num8);
                    m_stopButtons.items[j].relativePosition = relativePosition2;
                    num8 += stopPositions[j] * stopDistanceFactor;
                }
                RefreshVehicleButtons(lineID);
                if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.Complete) != TransportLine.Flags.None)
                {
                    m_labelLineIncomplete.isVisible = false;
                    m_stopsContainer.isVisible      = true;
                }
                else
                {
                    m_labelLineIncomplete.isVisible = true;
                    m_stopsContainer.isVisible      = false;
                }
            }
        }
Ejemplo n.º 12
0
 public static string GetVehicleTypeIcon(ushort lineId) => TransportSystemDefinition.From(lineId).GetTransportTypeIcon();
Ejemplo n.º 13
0
 public static bool OnLinesOverviewClicked()
 {
     TransportLinesManagerMod.Instance.OpenPanelAtModTab();
     TLMPanel.Instance.OpenAt(TransportSystemDefinition.From(GetLineID()));
     return(false);
 }
 public static bool HasPrefix(TransportInfo t) => HasPrefix(TransportSystemDefinition.From(t));
Ejemplo n.º 15
0
        public static string GetStationName(ushort stopId, ushort lineId, ItemClass.SubService ss, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix, out ushort buildingID, out NamingType resultNamingType, bool excludeCargo = false, bool useRestrictionForAreas = false, bool useRoadMainNameOnAddress = false)
        {
            if (lineId == 0)
            {
                buildingID = stopId;
                return(GetBuildingNameForStation(lineId, out serviceFound, out subserviceFound, out prefix, stopId, out resultNamingType));
            }
            string savedName = GetStopName(stopId);
            var    tsd       = TransportSystemDefinition.From(lineId);

            if (savedName != null)
            {
                serviceFound     = ItemClass.Service.PublicTransport;
                subserviceFound  = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].Info.m_class.m_subService;
                prefix           = tsd.GetConfig().NamingPrefix?.TrimStart();
                buildingID       = 0;
                resultNamingType = NamingTypeExtensions.From(tsd);
                return(savedName);
            }

            NetManager nm       = Singleton <NetManager> .instance;
            NetNode    nn       = nm.m_nodes.m_buffer[stopId];
            Vector3    location = nn.m_position;

            if (tsd.VehicleType == VehicleInfo.VehicleType.Car || tsd.VehicleType == VehicleInfo.VehicleType.Tram || tsd.VehicleType == VehicleInfo.VehicleType.Trolleybus)
            {
                List <ushort> nearStops = StopSearchUtils.FindNearStops(location, nn.Info.GetService(), true, 50f, out _, out _);

                foreach (ushort otherStop in nearStops)
                {
                    if (otherStop != stopId)
                    {
                        savedName = GetStopName(otherStop);
                        ;
                        if (savedName != null)
                        {
                            ushort targetLineId = NetManager.instance.m_nodes.m_buffer[otherStop].m_transportLine;
                            var    tsd2         = TransportSystemDefinition.From(targetLineId);

                            serviceFound     = ItemClass.Service.PublicTransport;
                            subserviceFound  = Singleton <TransportManager> .instance.m_lines.m_buffer[targetLineId].Info.m_class.m_subService;
                            prefix           = tsd2.GetConfig().NamingPrefix?.TrimStart();
                            buildingID       = 0;
                            resultNamingType = NamingTypeExtensions.From(tsd2);
                            return(savedName);
                        }
                    }
                }
            }


            buildingID = GetStationBuilding(stopId, ss, excludeCargo);

            if (buildingID > 0)
            {
                return(GetBuildingNameForStation(lineId, out serviceFound, out subserviceFound, out prefix, buildingID, out resultNamingType));
            }


            prefix = "";
            byte parkId = DistrictManager.instance.GetPark(location);

            if (parkId > 0)
            {
                var idx       = DistrictManager.instance.m_parks.m_buffer[parkId].GetNamingClass();
                var idxConfig = idx.GetConfig();
                if (!useRestrictionForAreas || idxConfig.UseInAutoName)
                {
                    prefix           = idxConfig.NamingPrefix?.TrimStart();
                    serviceFound     = 0;
                    subserviceFound  = 0;
                    resultNamingType = idx.ToNamingType();
                    return(DistrictManager.instance.GetParkName(parkId));
                }
            }
            int number = 0;

            if ((useRoadMainNameOnAddress ? TransportLinesManagerMod.Controller.ConnectorADR.GetStreetSuffix(location, location, out string streetName) : TransportLinesManagerMod.Controller.ConnectorADR.GetAddressStreetAndNumber(location, location, out number, out streetName)) &&
                !streetName.IsNullOrWhiteSpace() &&
                (!useRestrictionForAreas || TLMSpecialNamingClass.Address.GetConfig().UseInAutoName))
            {
                prefix           = TLMSpecialNamingClass.Address.GetConfig().NamingPrefix?.TrimStart();
                serviceFound     = ItemClass.Service.Road;
                subserviceFound  = ItemClass.SubService.PublicTransportBus;
                resultNamingType = NamingType.ADDRESS;
                return(useRoadMainNameOnAddress ? streetName : streetName + ", " + number);
            }
 protected TransportSystemDefinition ToTSD() => TransportSystemDefinition.From(TransportType, SubService, VehicleType, Level);
Ejemplo n.º 17
0
 public override bool MayBeVisible() => TransportSystemDefinition.From(UVMPublicTransportWorldInfoPanel.GetLineID()).HasVehicles();
Ejemplo n.º 18
0
 private void UpdateTerminalStatus(ushort lineID, ushort currentStop, UIButton button) => button.normalBgSprite =
     TransportSystemDefinition.From(lineID).CanHaveTerminals() && (currentStop == Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_stops || TLMStopDataContainer.Instance.SafeGet(currentStop).IsTerminal)
                         ? KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_S05StarIcon, true)
                         : "";// KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_CircleIcon, true);
        public static IEnumerator UpdateCapacityUnitsFromTSD()
        {
            int count = 0;
            Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
            int i = 0;
            TransportSystemDefinition  tsd;
            ITLMTransportTypeExtension ext;

            while (i < (long)((ulong)vehicles.m_size))
            {
                if ((vehicles.m_buffer[i].m_flags & Vehicle.Flags.Spawned) == Vehicle.Flags.Spawned && (tsd = TransportSystemDefinition.From(vehicles.m_buffer[i].Info)) != default && (ext = tsd.GetTransportExtension()).IsCustomCapacity(vehicles.m_buffer[i].Info.name))
                {
                    int capacity = ext.GetCustomCapacity(vehicles.m_buffer[i].Info.name);
                    if (capacity != -1)
                    {
                        CitizenUnit[] units            = Singleton <CitizenManager> .instance.m_units.m_buffer;
                        uint          unit             = vehicles.m_buffer[i].m_citizenUnits;
                        int           currentUnitCount = GetTotalUnitGroups(unit);
                        int           newUnitCount     = Mathf.CeilToInt(capacity / 5f);
                        if (newUnitCount < currentUnitCount)
                        {
                            uint j = unit;
                            for (int k = 1; k < newUnitCount; k++)
                            {
                                j = units[(int)((UIntPtr)j)].m_nextUnit;
                            }
                            Singleton <CitizenManager> .instance.ReleaseUnits(units[(int)((UIntPtr)j)].m_nextUnit);

                            units[(int)((UIntPtr)j)].m_nextUnit = 0u;
                            count++;
                        }
                        else if (newUnitCount > currentUnitCount)
                        {
                            uint l = unit;
                            while (units[(int)((UIntPtr)l)].m_nextUnit != 0u)
                            {
                                l = units[(int)((UIntPtr)l)].m_nextUnit;
                            }
                            int newCapacity = capacity - currentUnitCount * 5;
                            if (!Singleton <CitizenManager> .instance.CreateUnits(out units[l].m_nextUnit, ref Singleton <SimulationManager> .instance.m_randomizer, 0, (ushort)i, 0, 0, 0, newCapacity, 0))
                            {
                                LogUtils.DoErrorLog("FAILED CREATING UNITS!!!!");
                            }
                            count++;
                        }
                    }
                }
                if (i % 256 == 255)
                {
                    yield return(i % 256);
                }
                i++;
            }
            yield break;
        }