private void UnloadPassengers(ushort vehicleID, ref Vehicle data, ushort currentStop, ushort nextStop) { if (currentStop == 0) { return; } VehicleManager instance = Singleton <VehicleManager> .instance; NetManager instance2 = Singleton <NetManager> .instance; TransportManager instance3 = Singleton <TransportManager> .instance; Vector3 position = instance2.m_nodes.m_buffer [(int)currentStop].m_position; Vector3 targetPos = Vector3.zero; if (nextStop != 0) { targetPos = instance2.m_nodes.m_buffer [(int)nextStop].m_position; } int num = 0; int num2 = 0; while (vehicleID != 0) { if (data.m_transportLine != 0) { BusAI.TransportArriveAtTarget(vehicleID, ref instance.m_vehicles.m_buffer [(int)vehicleID], position, targetPos, ref num, ref instance3.m_lines.m_buffer [(int)data.m_transportLine].m_passengers, nextStop == 0); } else { BusAI.TransportArriveAtTarget(vehicleID, ref instance.m_vehicles.m_buffer [(int)vehicleID], position, targetPos, ref num, ref instance3.m_passengers [(int)this.m_transportInfo.m_transportType], nextStop == 0); } vehicleID = instance.m_vehicles.m_buffer [(int)vehicleID].m_trailingVehicle; if (++num2 > 65536) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } StatisticBase statisticBase = Singleton <StatisticsManager> .instance.Acquire <StatisticArray> (StatisticType.PassengerCount); statisticBase.Acquire <StatisticInt32> ((int)this.m_transportInfo.m_transportType, 8).Add(num); num += (int)instance2.m_nodes.m_buffer [(int)currentStop].m_tempCounter; instance2.m_nodes.m_buffer [(int)currentStop].m_tempCounter = (ushort)Mathf.Min(num, 65535); }
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); } } } } }
protected void SimulationStepImpl(int subStep) { if (subStep == 0 || subStep == 1000) { return; } //all managers refresh at that frequency. We must not change that value! int num1 = (int)Singleton <SimulationManager> .instance.m_currentFrameIndex & (int)byte.MaxValue; //begin mod int num2 = num1 * 2; //two lines at single time. 256*2 = 512 > 450 int minX = -1; int maxX = -1; int minZ = -1; int maxZ = -1; for (int z = num2; z <= num2 + 1; z++) { if (z > GRID - 1) { continue; } int num3 = 0; int num4 = GRID - 1; for (int x = num3; x <= num4; ++x) { int index1 = (z * GRID + x) * 24; if (CalculateLocalResources(x, z, m_localTempResources, m_globalFinalResources, m_localFinalResources, index1)) { minX = minX == -1 ? x : Math.Min(minX, x); maxX = Math.Max(maxX, x); minZ = minZ == -1 ? z : Math.Min(minZ, z); maxZ = Math.Max(maxZ, z); } int num5 = (int)m_localFinalResources[index1 + 16]; for (int index2 = 0; index2 < 24; ++index2) { int num6 = (int)m_localFinalResources[index1 + index2]; m_totalTempResources[index2] += num6; m_totalTempResourcesMul[index2] += (long)(num6 * num5); m_localTempResources[index1 + index2] = (ushort)0; } } } //end mod if (num1 == byte.MaxValue) //all managers refresh at that frequency. We must not change that value! { //begin mod CalculateTotalResources(m_totalTempResources, m_totalTempResourcesMul, m_totalFinalResources); //end mod StatisticBase statisticBase = Singleton <StatisticsManager> .instance.Acquire <StatisticArray>(StatisticType.ImmaterialResource); for (int index = 0; index < 24; ++index) { //begin mod m_globalFinalResources[index] = m_globalTempResources[index]; m_globalTempResources[index] = 0; m_totalTempResources[index] = 0; m_totalTempResourcesMul[index] = 0; statisticBase.Acquire <StatisticInt32>(index, 24).Set(m_totalFinalResources[index]); //end mod } } if (minX == -1) { return; } //begin mod this.AreaModified(minX, minZ, maxX, maxZ); //end mod }