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);
        }
Beispiel #2
0
        public void RefreshData(bool updateColors, bool updateVisibility)
        {
            if (this.m_LineOperation == null || this.m_LineOperation.completedOrFailed)
            {
                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);
            }
            else
            {
                m_LineColor.normalBgSprite = "DisabledIcon";
            }
            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;

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

            if (TLMConfigWarehouse.getCurrentConfigInt(tsd.toConfigIndex() | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
            {
                prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u;
            }


            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_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);

            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 (updateColors)
            {
                this.m_LineColor.selectedColor = Singleton <TransportManager> .instance.GetLineColor(this.m_LineID);
            }
            if (updateVisibility)
            {
                this.m_LineIsVisible.isChecked = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Hidden) == TransportLine.Flags.None);
            }


            if (tsd.hasVehicles())
            {
                TransportInfo info          = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].Info;
                float         overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f;

                string vehTooltip = string.Format("{0} {1}", this.m_LineVehicles.text, Locale.Get("PUBLICTRANSPORT_VEHICLES"));
                this.m_LineVehicles.tooltip = vehTooltip;
                if (!TLMTransportLineExtension.instance.IsUsingCustomConfig(this.lineID) || !TLMTransportLineExtension.instance.IsUsingAbsoluteVehicleCount(this.lineID))
                {
                    this.m_lineBudgetLabel.text = string.Format("{0:0%}", TLMLineUtils.getEffectiveBugdet(lineID));//585+1/7 = frames/week
                    m_lineBudgetLabel.tooltip   = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN_2"),
                                                                TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex()),
                                                                overallBudget, Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget / 100f, TLMLineUtils.getEffectiveBugdet(lineID));
                    m_lineBudgetLabel.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 19, 0);
                    m_lineBudgetLabel.isVisible        = true;
                }
                else
                {
                    m_lineBudgetLabel.isVisible = false;
                }


                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);
            }
            else
            {
                m_DayLine.isVisible      = true;
                m_DayNightLine.isVisible = true;
                m_NightLine.isVisible    = true;
                m_DisabledLine.isVisible = true;
            }
        }
Beispiel #3
0
        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);
            }
        }