private void syncForm()
        {
            TransportSystemDefinition tsd = TransportSystemDefinition.from(transportTool.m_prefab);
            var configIdx = tsd.toConfigIndex();

            if (TLMLineUtils.hasPrefix(transportTool.m_prefab))
            {
                linePrefixDropDown.isVisible      = true;
                linePrefixDropDown.items          = TLMUtils.getPrefixesOptions(configIdx, false);
                linePrefixDropDown.selectedIndex  = getCurrentPrefix();
                lineNumberTxtBox.text             = getCurrentNumber().ToString();
                lineNumberTxtBox.width            = 90;
                lineNumberTxtBox.relativePosition = new Vector3(85f, 45f);
                lineNumberTxtBox.maxLength        = 3;
                prefixIncrementChk.isChecked      = TLMConfigWarehouse.getCurrentConfigBool(configIdx | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT);
                prefixIncrementChk.isVisible      = true;
            }
            else
            {
                linePrefixDropDown.isVisible      = false;
                lineNumberTxtBox.text             = getCurrentNumber().ToString();
                lineNumberTxtBox.width            = 170;
                lineNumberTxtBox.relativePosition = new Vector3(5f, 45f);
                lineNumberTxtBox.maxLength        = 4;
                prefixIncrementChk.isVisible      = false;
            }
            updateUI();
        }
        public void incrementNumber()
        {
            //TLMUtils.doLog("Increment Toolbox num");
            TransportSystemDefinition tsd = TransportSystemDefinition.from(transportTool.m_prefab);
            int  num = nextLineNumber;
            bool prefixIncrementVal = TLMConfigWarehouse.getCurrentConfigBool(tsd.toConfigIndex() | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT);

            //TLMUtils.doLog("prefixIncrement = " + prefixIncrementVal + "| num = " + num);
            while (((num + 1) & 0xFFFF) == 0 || TLMLineUtils.isNumberUsed((num + 1) & 0xFFFF, tsd, 0))
            {
                if (!TLMLineUtils.hasPrefix(transportTool.m_prefab) || !prefixIncrementVal)
                {
                    num++;
                }
                else
                {
                    num++;
                    num /= 1000;
                    num++;
                    num &= 0x4F;
                    num *= 1000;
                    num--;
                }
            }
            nextLineNumber = (ushort)num;
            syncForm();
        }
Пример #3
0
        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 int getCurrentNumber()
 {
     if (TLMLineUtils.hasPrefix(transportTool.m_prefab))
     {
         return(((nextLineNumber + 1) & 0xFFFF) % 1000);
     }
     else
     {
         return((nextLineNumber + 1) & 0xFFFF);
     }
 }
        public override void RefreshLines()
        {
            var tsd = Singleton <T> .instance.GetTSD();

            bool hasPrefix = TLMLineUtils.hasPrefix(ref tsd);
            int  count     = 0;

            foreach (ushort buildingID in TLMDepotAI.getAllDepotsFromCity())
            {
                PrefabAI prefabAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI();
                if (prefabAI is ShelterAI && tsd.isShelterAiDepot())
                {
                    AddToList(buildingID, false, ref count);
                }
                else if (!tsd.isShelterAiDepot() && prefabAI is DepotAI ai)
                {
                    var tiArray = new TransportInfo[] { ai.m_transportInfo, ai.m_secondaryTransportInfo };
                    foreach (TransportInfo info in tiArray)
                    {
                        if (tsd.isFromSystem(info) && (!hasPrefix || m_prefixFilter.selectedIndex == 0 || TLMDepotAI.getPrefixesServedByDepot(buildingID, info == ai.m_secondaryTransportInfo).Contains((uint)(m_prefixFilter.selectedIndex - 1))))
                        {
                            AddToList(buildingID, info == ai.m_secondaryTransportInfo, ref count);
                        }
                    }
                }
            }

            RemoveExtraLines(count);

            switch (m_LastSortCriterion)
            {
            case DepotSortCriterion.NAME: OnNameSort(); break;

            case DepotSortCriterion.DISTRICT: OnDistrictSort(); break;
            }
            isUpdated = true;
        }
Пример #6
0
        public override void RefreshLines()
        {
            m_DayIcon.relativePosition      = new Vector3(655, 14);
            m_NightIcon.relativePosition    = new Vector3(682, 14);
            m_DayNightIcon.relativePosition = new Vector3(701, 14);
            m_visibilityToggle.area         = new Vector4(8, 5, 28, 28);

            var tsd = Singleton <T> .instance.GetTSD();

            bool hasPrefix = TLMLineUtils.hasPrefix(ref tsd);
            int  count     = 0;

            for (ushort lineID = 1; lineID < TransportManager.instance.m_lines.m_buffer.Length; lineID++)
            {
                TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID];
                if (tl.Complete && Singleton <T> .instance.GetTSD().isFromSystem(tl) && (!hasPrefix || m_prefixFilter.selectedIndex == 0 || m_prefixFilter.selectedIndex - 1 == TLMLineUtils.getPrefix(lineID)))
                {
                    AddToList(lineID, ref count);
                }
            }
            RemoveExtraLines(count);

            switch (m_LastSortCriterionLines)
            {
            case LineSortCriterion.NAME: OnNameSort(); break;

            case LineSortCriterion.PASSENGER: OnPassengerSort(); break;

            case LineSortCriterion.STOP: OnStopSort(); break;

            case LineSortCriterion.VEHICLE: OnVehicleSort(); break;

            case LineSortCriterion.LINE_NUMBER:
            default: OnLineNumberSort(); break;
            }
            isUpdated = true;
        }
Пример #7
0
        public void OnSetTarget(Type source)
        {
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            m_firstStopSelect.items         = TLMLineUtils.getAllStopsFromLine(lineID);
            m_firstStopSelect.selectedIndex = 0;
            if (source == GetType())
            {
                return;
            }

            if (lineID != 0)
            {
                m_colorField.selectedColor = Singleton <TransportManager> .instance.GetLineColor(lineID);

                LineType lineType = UVMPublicTransportWorldInfoPanel.GetLineType(lineID);
                m_weeklyPassengersString   = ((lineType != LineType.WalkingTour) ? "TRANSPORT_LINE_PASSENGERS" : "TRANSPORT_LINE_PASSENGERS_WALKINGTOUR");
                m_ageChart.tooltipLocaleID = ((lineType != LineType.WalkingTour) ? "PUBLICTRANSPORT_PASSENGERAGEGROUPS_TOOLTIP" : "PUBLICTRANSPORT_PASSENGERAGEGROUPS_TOOLTIP_WALKINGTOUR");
                m_tripSaved.isVisible      = (lineType == LineType.Default);
                m_pullValuePanel.isVisible = (lineType == LineType.WalkingTour);
                m_lineLengthLabel.text     = StringUtils.SafeFormat(Locale.Get("LINEINFOPANEL_LINELENGTH"), (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_totalLength / 1000f).ToString("F2", LocaleManager.cultureInfo));

                m_linePrefixDropDown.eventSelectedIndexChanged -= SaveLineNumber;
                m_lineNumberLabel.eventLostFocus -= SaveLineNumber;

                ref TransportLine t          = ref TransportManager.instance.m_lines.m_buffer[lineID];
                ushort            lineNumber = t.m_lineNumber;

                var tsd           = TransportSystemDefinition.GetDefinitionForLine(lineID);
                var transportType = tsd.ToConfigIndex();
                var mnPrefixo     = (ModoNomenclatura)TLMConfigWarehouse.GetCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType);

                if (TLMLineUtils.hasPrefix(lineID))
                {
                    m_lineNumberLabel.maxLength  = 3;
                    m_lineNumberLabel.width      = 40;
                    m_lineNumberLabel.text       = (lineNumber % 1000).ToString();
                    m_linePrefixDropDown.enabled = false;

                    string[] temp = TLMUtils.GetStringOptionsForPrefix(tsd, true, true, false);
                    m_linePrefixDropDown.items         = temp;
                    m_linePrefixDropDown.selectedIndex = lineNumber / 1000;
                    m_linePrefixDropDown.enabled       = true;
                    bool invertPrefixSuffix = TLMConfigWarehouse.GetCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.INVERT_PREFIX_SUFFIX | transportType);
                    if (invertPrefixSuffix)
                    {
                        m_linePrefixDropDown.zOrder = 9999;
                    }
                    else
                    {
                        m_lineNumberLabel.zOrder = 9999;
                    }
                }
                else
                {
                    m_lineNumberLabel.maxLength  = 4;
                    m_lineNumberLabel.width      = 180;
                    m_lineNumberLabel.text       = (lineNumber).ToString();
                    m_linePrefixDropDown.enabled = false;
                }



                m_lineNumberLabel.color = TransportManager.instance.GetLineColor(lineID);



                m_linePrefixDropDown.eventSelectedIndexChanged += SaveLineNumber;
                m_lineNumberLabel.eventLostFocus += SaveLineNumber;
            }
Пример #8
0
 public bool MayBeVisible() => TLMLineUtils.hasPrefix(GetLineID()) && !TLMTransportLineExtension.Instance.IsUsingCustomConfig(GetLineID());