public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics) { if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { if (m_speedData.currentPath != vehicleData.m_path) { m_speedData.currentPath = vehicleData.m_path; m_speedData.SetRandomSpeedMultiplier(0.65f, 1.05f); } m_speedData.ApplySpeedMultiplier(this.m_info); } if ((vehicleData.m_flags & Vehicle.Flags.Stopped) != Vehicle.Flags.None) { vehicleData.m_waitCounter += 1; if (this.CanLeave(vehicleID, ref vehicleData)) { vehicleData.m_flags &= ~Vehicle.Flags.Stopped; vehicleData.m_flags |= Vehicle.Flags.Leaving; vehicleData.m_waitCounter = 0; } } CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics); if ((vehicleData.m_flags & Vehicle.Flags.GoingBack) == Vehicle.Flags.None && this.ShouldReturnToSource(vehicleID, ref vehicleData)) { this.SetTransportLine(vehicleID, ref vehicleData, 0); } if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { m_speedData.RestoreVehicleSpeed(this.m_info); } }
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics) { if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { if (m_speedData.currentPath != vehicleData.m_path) { m_speedData.currentPath = vehicleData.m_path; m_speedData.SetRandomSpeedMultiplier(0.6f, 1.4f); } m_speedData.ApplySpeedMultiplier(this.m_info); } base.SimulationStep(vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics); if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { m_speedData.RestoreVehicleSpeed(this.m_info); } // For future modifications //if ((vehicleData.m_flags & Vehicle.Flags.Stopped) != Vehicle.Flags.None) //{ // vehicleData.m_waitCounter += 1; // if (this.CanLeave(vehicleID, ref vehicleData)) // { // vehicleData.m_flags &= ~Vehicle.Flags.Stopped; // vehicleData.m_waitCounter = 0; // } //} //base.SimulationStep(vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics); }
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ushort leaderID, ref Vehicle leaderData, int lodPhysics) { if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { if (m_speedData.currentPath != vehicleData.m_path) { m_speedData.currentPath = vehicleData.m_path; m_speedData.SetRandomSpeedMultiplier(0.7f, 1.1f); } m_speedData.ApplySpeedMultiplier(this.m_info); } if ((vehicleData.m_flags & Vehicle.Flags.Spawned) != Vehicle.Flags.None) { Vehicle.Frame lastFrameData = vehicleData.GetLastFrameData(); if (this.m_info.m_isLargeVehicle) { int num = Mathf.Clamp((int)(lastFrameData.m_position.x / 320f + 27f), 0, 53); int num2 = Mathf.Clamp((int)(lastFrameData.m_position.z / 320f + 27f), 0, 53); CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref lastFrameData, leaderID, ref leaderData, lodPhysics); int num3 = Mathf.Clamp((int)(lastFrameData.m_position.x / 320f + 27f), 0, 53); int num4 = Mathf.Clamp((int)(lastFrameData.m_position.z / 320f + 27f), 0, 53); if ((num3 != num || num4 != num2) && (vehicleData.m_flags & Vehicle.Flags.Spawned) != Vehicle.Flags.None) { Singleton <VehicleManager> .instance.RemoveFromGrid(vehicleID, ref vehicleData, true, num, num2); Singleton <VehicleManager> .instance.AddToGrid(vehicleID, ref vehicleData, true, num3, num4); } } else { int num5 = Mathf.Clamp((int)(lastFrameData.m_position.x / 32f + 270f), 0, 539); int num6 = Mathf.Clamp((int)(lastFrameData.m_position.z / 32f + 270f), 0, 539); CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref lastFrameData, leaderID, ref leaderData, lodPhysics); int num7 = Mathf.Clamp((int)(lastFrameData.m_position.x / 32f + 270f), 0, 539); int num8 = Mathf.Clamp((int)(lastFrameData.m_position.z / 32f + 270f), 0, 539); if ((num7 != num5 || num8 != num6) && (vehicleData.m_flags & Vehicle.Flags.Spawned) != Vehicle.Flags.None) { Singleton <VehicleManager> .instance.RemoveFromGrid(vehicleID, ref vehicleData, false, num5, num6); Singleton <VehicleManager> .instance.AddToGrid(vehicleID, ref vehicleData, false, num7, num8); } } if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) == Vehicle.Flags.Created) { this.FrameDataUpdated(vehicleID, ref vehicleData, ref lastFrameData); vehicleData.SetFrameData(Singleton <SimulationManager> .instance.m_currentFrameIndex, lastFrameData); } } if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { m_speedData.RestoreVehicleSpeed(this.m_info); } }
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics) { if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { if (m_speedData.currentPath != vehicleData.m_path) { m_speedData.currentPath = vehicleData.m_path; if ((vehicleData.m_flags & Vehicle.Flags.Emergency2) == Vehicle.Flags.Emergency2) m_speedData.SetRandomSpeedMultiplier(1f, 1.75f); else m_speedData.SetRandomSpeedMultiplier(0.7f, 1.1f); } m_speedData.ApplySpeedMultiplier(this.m_info); } frameData.m_blinkState = (((vehicleData.m_flags & Vehicle.Flags.Emergency2) == Vehicle.Flags.None) ? 0f : 10f); this.TryCollectCrime(vehicleID, ref vehicleData, ref frameData); CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics); if ((vehicleData.m_flags & Vehicle.Flags.Stopped) != Vehicle.Flags.None) { if (this.CanLeave(vehicleID, ref vehicleData)) { vehicleData.m_flags &= ~Vehicle.Flags.Stopped; vehicleData.m_flags |= Vehicle.Flags.Leaving; } } else { if ((vehicleData.m_flags & Vehicle.Flags.Arriving) != Vehicle.Flags.None && vehicleData.m_targetBuilding != 0 && (vehicleData.m_flags & (Vehicle.Flags.Emergency2 | Vehicle.Flags.WaitingPath | Vehicle.Flags.GoingBack | Vehicle.Flags.WaitingTarget)) == Vehicle.Flags.None) { this.ArriveAtTarget(vehicleID, ref vehicleData); } } if ((vehicleData.m_flags & Vehicle.Flags.GoingBack) == Vehicle.Flags.None && this.ShouldReturnToSource(vehicleID, ref vehicleData)) { this.SetTarget(vehicleID, ref vehicleData, 0); } if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { m_speedData.RestoreVehicleSpeed(this.m_info); } }
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics) { if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { if (m_speedData.currentPath != vehicleData.m_path) { m_speedData.currentPath = vehicleData.m_path; m_speedData.SetRandomSpeedMultiplier(0.75f, 0.95f); } m_speedData.ApplySpeedMultiplier(this.m_info); } if ((vehicleData.m_flags & Vehicle.Flags.TransferToSource) != Vehicle.Flags.None) { if ((int)vehicleData.m_transferSize < this.m_cargoCapacity) { this.TryCollectGarbage(vehicleID, ref vehicleData, ref frameData); } if ((int)vehicleData.m_transferSize >= this.m_cargoCapacity && (vehicleData.m_flags & Vehicle.Flags.GoingBack) == Vehicle.Flags.None && vehicleData.m_targetBuilding != 0) { this.SetTarget(vehicleID, ref vehicleData, 0); } } CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics); if ((vehicleData.m_flags & Vehicle.Flags.Arriving) != Vehicle.Flags.None && vehicleData.m_targetBuilding != 0 && (vehicleData.m_flags & (Vehicle.Flags.WaitingPath | Vehicle.Flags.GoingBack | Vehicle.Flags.WaitingTarget)) == Vehicle.Flags.None) { this.ArriveAtTarget(vehicleID, ref vehicleData); } if ((vehicleData.m_flags & (Vehicle.Flags.TransferToSource | Vehicle.Flags.GoingBack)) == Vehicle.Flags.TransferToSource && this.ShouldReturnToSource(vehicleID, ref vehicleData)) { this.SetTarget(vehicleID, ref vehicleData, 0); } if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { m_speedData.RestoreVehicleSpeed(this.m_info); } }
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics) { if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { if (m_speedData.currentPath != vehicleData.m_path) { m_speedData.currentPath = vehicleData.m_path; if ((vehicleData.m_flags & Vehicle.Flags.Emergency2) == Vehicle.Flags.Emergency2) { m_speedData.SetRandomSpeedMultiplier(1f, 1.75f); } else { m_speedData.SetRandomSpeedMultiplier(0.65f, 1f); } } m_speedData.ApplySpeedMultiplier(this.m_info); } frameData.m_blinkState = (((vehicleData.m_flags & (Vehicle.Flags.Emergency1 | Vehicle.Flags.Emergency2)) == Vehicle.Flags.None) ? 0f : 10f); CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics); bool flag = false; if (vehicleData.m_targetBuilding != 0) { BuildingManager instance = Singleton <BuildingManager> .instance; Vector3 a = instance.m_buildings.m_buffer[(int)vehicleData.m_targetBuilding].CalculateSidewalkPosition(); flag = ((a - frameData.m_position).sqrMagnitude < 4096f); bool flag2 = (vehicleData.m_flags & Vehicle.Flags.Stopped) != Vehicle.Flags.None || frameData.m_velocity.sqrMagnitude < 0.0100000007f; if (flag && (vehicleData.m_flags & Vehicle.Flags.Emergency2) != Vehicle.Flags.None) { vehicleData.m_flags = ((vehicleData.m_flags & ~Vehicle.Flags.Emergency2) | Vehicle.Flags.Emergency1); } if (flag && flag2) { if (vehicleData.m_blockCounter > 8) { vehicleData.m_blockCounter = 8; } if (vehicleData.m_blockCounter == 8 && (vehicleData.m_flags & Vehicle.Flags.Stopped) == Vehicle.Flags.None) { this.ArriveAtTarget(leaderID, ref leaderData); } if (this.ExtinguishFire(vehicleID, ref vehicleData, vehicleData.m_targetBuilding, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)vehicleData.m_targetBuilding])) { this.SetTarget(vehicleID, ref vehicleData, 0); } } else { if (instance.m_buildings.m_buffer[(int)vehicleData.m_targetBuilding].m_fireIntensity == 0) { this.SetTarget(vehicleID, ref vehicleData, 0); } } } if ((vehicleData.m_flags & Vehicle.Flags.Stopped) != Vehicle.Flags.None && !flag && this.CanLeave(vehicleID, ref vehicleData)) { vehicleData.m_flags &= ~Vehicle.Flags.Stopped; vehicleData.m_flags |= Vehicle.Flags.Leaving; } if ((vehicleData.m_flags & Vehicle.Flags.GoingBack) == Vehicle.Flags.None) { if (this.ShouldReturnToSource(vehicleID, ref vehicleData)) { this.SetTarget(vehicleID, ref vehicleData, 0); } } else { if ((ulong)(Singleton <SimulationManager> .instance.m_currentFrameIndex >> 4 & 15u) == (ulong)((long)(vehicleID & 15)) && !this.ShouldReturnToSource(vehicleID, ref vehicleData)) { TransferManager.TransferOffer offer = default(TransferManager.TransferOffer); offer.Priority = 3; offer.Vehicle = vehicleID; offer.Position = frameData.m_position; offer.Amount = 1; offer.Active = true; Singleton <TransferManager> .instance.AddIncomingOffer((TransferManager.TransferReason) vehicleData.m_transferType, offer); } } if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds) { m_speedData.RestoreVehicleSpeed(this.m_info); } }