private void UpdateProgress()
        {
            VehicleManager instance     = Singleton <VehicleManager> .instance;
            ushort         vehicle      = WorldInfoPanel.GetCurrentInstanceID().Vehicle;
            ushort         firstVehicle = instance.m_vehicles.m_buffer[(int)vehicle].GetFirstVehicle(vehicle);
            float          current;
            float          max;

            if (BusAIMod.GetProgressStatus(firstVehicle, ref instance.m_vehicles.m_buffer[(int)firstVehicle], out current, out max) || (int)firstVehicle != (int)(ushort)this._cachedProgressVehicle.GetValue((object)this._publicTransportVehicleWorldInfoPanel))
            {
                this._cachedCurrentProgress.SetValue((object)this._publicTransportVehicleWorldInfoPanel, (object)current);
                this._cachedTotalProgress.SetValue((object)this._publicTransportVehicleWorldInfoPanel, (object)max);
                this._cachedProgressVehicle.SetValue((object)this._publicTransportVehicleWorldInfoPanel, (object)firstVehicle);
            }
            else
            {
                current = (float)this._cachedCurrentProgress.GetValue((object)this._publicTransportVehicleWorldInfoPanel);
                max     = (float)this._cachedTotalProgress.GetValue((object)this._publicTransportVehicleWorldInfoPanel);
            }
            if ((double)max == 0.0)
            {
                return;
            }
            this._distanceTraveled.parent.Show();
            this._distanceProgress.parent.Show();
            float num = current / max;
            int   p   = Mathf.RoundToInt(num * 100f);

            this._distanceTraveled.value = num;
            this._distanceProgress.text  = LocaleFormatter.FormatPercentage(p);
        }
Пример #2
0
        private static bool IsUnbunchingDone(ushort vehicleID, ref Vehicle vehicleData)
        {
            bool flag;

            try
            {
                if ((int)vehicleData.m_transportLine == 0 || (int)ImprovedPublicTransportMod.Settings.IntervalAggressionFactor == 0 || (!TransportLineMod.GetUnbunchingState(vehicleData.m_transportLine) || (int)vehicleData.m_waitCounter >= (int)(byte)Mathf.Min((int)ImprovedPublicTransportMod.Settings.IntervalAggressionFactor * 6 + 12, (int)byte.MaxValue)))
                {
                    flag = true;
                }
                else
                {
                    TransportManager instance1 = Singleton <TransportManager> .instance;
                    int length = instance1.m_lines.m_buffer[(int)vehicleData.m_transportLine].CountVehicles(vehicleData.m_transportLine);
                    if (length == 1)
                    {
                        flag = true;
                    }
                    else
                    {
                        ushort currentStop = VehicleManagerMod.m_cachedVehicleData[(int)vehicleID].CurrentStop;
                        if ((int)currentStop != 0 && !NetManagerMod.m_cachedNodeData[(int)currentStop].Unbunching)
                        {
                            flag = true;
                        }
                        else if ((int)vehicleData.m_lastFrame != 0)
                        {
                            flag = false;
                        }
                        else
                        {
                            ushort         vehicleID1 = instance1.m_lines.m_buffer[(int)vehicleData.m_transportLine].m_vehicles;
                            VehicleManager instance2  = Singleton <VehicleManager> .instance;
                            float          max        = 0.0f;
                            ushort[]       numArray   = new ushort[length];
                            float[]        keys       = new float[length];
                            for (int index = 0; index < length; ++index)
                            {
                                float current;
                                BusAIMod.GetProgressStatus(vehicleID1, ref instance2.m_vehicles.m_buffer[(int)vehicleID1], out current, out max);
                                numArray[index] = vehicleID1;
                                keys[index]     = current;
                                vehicleID1      = instance2.m_vehicles.m_buffer[(int)vehicleID1].m_nextLineVehicle;
                            }
                            Array.Sort <float, ushort>(keys, numArray);
                            int index1 = Array.IndexOf <ushort>(numArray, vehicleID);
                            if (index1 == -1)
                            {
                                flag = true;
                            }
                            else
                            {
                                int index2 = index1 + 1;
                                if (index2 == length)
                                {
                                    index2 = 0;
                                }
                                float num = keys[index2] - keys[index1];
                                if ((double)num < 0.0)
                                {
                                    num += max;
                                }
                                flag = (double)num > (double)max / (double)length * 0.899999976158142;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (BusAIMod._isDeployed)
                {
                    Utils.Log((object)(ex.Message + System.Environment.NewLine + System.Environment.StackTrace));
                }
                flag = true;
            }
            VehicleManagerMod.m_cachedVehicleData[(int)vehicleID].IsUnbunchingInProgress = !flag;
            return(flag);
        }