private void SetEditLine(ushort line, bool forceRefresh)
 {
     if (line != this.m_lastEditLine || forceRefresh)
     {
         TransportManager instance = Singleton <TransportManager> .instance;
         if (this.m_lastEditLine != 0)
         {
             TransportLine[] expr_39_cp_0 = instance.m_lines.m_buffer;
             ushort          expr_39_cp_1 = this.m_lastEditLine;
             expr_39_cp_0[(int)expr_39_cp_1].m_flags = (expr_39_cp_0[(int)expr_39_cp_1].m_flags & ~(TransportLine.Flags.Hidden | TransportLine.Flags.Selected));
         }
         this.m_lastEditLine  = line;
         this.m_lastMoveIndex = -2;
         this.m_lastAddIndex  = -2;
         this.m_lastMovePos   = Vector3.zero;
         this.m_lastAddPos    = Vector3.zero;
         if (this.m_lastEditLine != 0)
         {
             TransportLine[] expr_95_cp_0 = instance.m_lines.m_buffer;
             ushort          expr_95_cp_1 = this.m_lastEditLine;
             expr_95_cp_0[(int)expr_95_cp_1].m_flags = (expr_95_cp_0[(int)expr_95_cp_1].m_flags | (TransportLine.Flags.Hidden | TransportLine.Flags.Selected));
         }
         if (this.m_tempLine != 0)
         {
             instance.m_lines.m_buffer[(int)this.m_tempLine].CloneLine(this.m_tempLine, this.m_lastEditLine);
             BusTransportLineAI.UpdateMeshData(ref instance.m_lines.m_buffer[(int)this.m_tempLine], this.m_tempLine);
         }
     }
 }
Beispiel #2
0
        protected override void SimulationStepImpl(int subStep)
        {
            if (this.m_linesUpdated)
            {
                this.m_linesUpdated = false;
                int num = this.m_updatedLines.Length;
                for (int i = 0; i < num; i++)
                {
                    ulong num2 = this.m_updatedLines[i];
                    if (num2 != 0uL)
                    {
                        for (int j = 0; j < 64; j++)
                        {
                            if ((num2 & 1uL << j) != 0uL)
                            {
                                ushort num3 = (ushort)(i << 6 | j);
                                if (this.m_lines.m_buffer[(int)num3].m_flags != TransportLine.Flags.None)
                                {
                                    if (BusTransportLineAI.UpdatePaths(ref this.m_lines.m_buffer[(int)num3], num3) && BusTransportLineAI.UpdateMeshData(ref this.m_lines.m_buffer[(int)num3], num3))
                                    //if (this.m_lines.m_buffer[(int)num3].UpdatePaths(num3) && this.m_lines.m_buffer[(int)num3].UpdateMeshData(num3))
                                    {
                                        num2 &= ~(1uL << j);
                                    }
                                }
                                else
                                {
                                    num2 &= ~(1uL << j);
                                }
                            }
                        }
                        this.m_updatedLines[i] = num2;
                        if (num2 != 0uL)
                        {
                            this.m_linesUpdated = true;
                        }
                    }
                }
            }
            if (this.m_patchesDirty)
            {
                this.m_patchesDirty = false;
                int num4 = this.m_patches.Length;
                for (int k = 0; k < num4; k++)
                {
                    TransportPatch transportPatch = this.m_patches[k];
                    int            num5           = 0;
                    while (transportPatch != null)
                    {
                        if (transportPatch.m_isDirty)
                        {
                            transportPatch.UpdateMeshData();
                        }
                        transportPatch = transportPatch.m_nextPatch;
                        if (++num5 >= 100)
                        {
                            CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                            break;
                        }
                    }
                }
            }
            if (subStep != 0)
            {
                int num6 = (int)(Singleton <SimulationManager> .instance.m_currentFrameIndex & 255u);
                int num7 = num6 * 1;
                int num8 = (num6 + 1) * 1 - 1;
                for (int l = num7; l <= num8; l++)
                {
                    TransportLine.Flags flags = this.m_lines.m_buffer[l].m_flags;
                    if ((flags & (TransportLine.Flags.Created | TransportLine.Flags.Temporary)) == TransportLine.Flags.Created)
                    {
                        this.m_lines.m_buffer[l].SimulationStep((ushort)l);
                    }
                }
                if ((Singleton <SimulationManager> .instance.m_currentFrameIndex & 4095u) == 0u)
                {
                    StatisticsManager instance      = Singleton <StatisticsManager> .instance;
                    StatisticBase     statisticBase = instance.Acquire <StatisticArray>(StatisticType.AveragePassengers);
                    for (int m = 0; m < 5; m++)
                    {
                        this.m_passengers[m].Update();
                        this.m_passengers[m].Reset();
                        statisticBase.Acquire <StatisticInt32>(m, 5).Set((int)(this.m_passengers[m].m_residentPassengers.m_averageCount + this.m_passengers[m].m_touristPassengers.m_averageCount));
                    }
                }
            }
            if (subStep <= 1)
            {
                int num9  = (int)(Singleton <SimulationManager> .instance.m_currentTickIndex & 1023u);
                int num10 = num9 * PrefabCollection <TransportInfo> .PrefabCount() >> 10;

                int num11 = ((num9 + 1) * PrefabCollection <TransportInfo> .PrefabCount() >> 10) - 1;
                for (int n = num10; n <= num11; n++)
                {
                    TransportInfo prefab = PrefabCollection <TransportInfo> .GetPrefab((uint)n);

                    if (prefab != null)
                    {
                        MilestoneInfo unlockMilestone = prefab.m_UnlockMilestone;
                        if (unlockMilestone != null)
                        {
                            Singleton <UnlockManager> .instance.CheckMilestone(unlockMilestone, false, false);
                        }
                    }
                }
            }
        }