/* * Handles creation and removal of vehicles * * Note: Just because a vehicle has been removed visually, it does not mean * it is removed as far as the game is concerned. The vehicle is only truly removed * when the frame covers the vehicle's id, and that's when we will remove the * vehicle from our records. */ public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (_terminated) { return; } if (!_helper.VehicleMonitorSpinnable) { return; } if (!_settings.Enable._VehicleMonitor) { return; } try { if (!_initialized) { _data = Data.Instance; _mapping = new VehiclePrefabMapping(); _paused = false; _instance = Singleton <VehicleManager> .instance; _capacity = _instance.m_vehicles.m_buffer.Length; _id = (ushort)_capacity; _initialized = true; _helper.VehicleMonitorSpun = true; _helper.VehicleMonitor = this; _helper.NotifyPlayer("Vehicle monitor initialized"); } else if (!SimulationManager.instance.SimulationPaused) { _data._VehiclesUpdated.Clear(); _data._VehiclesRemoved.Clear(); int end = GetFrame(); while (_lastProcessedFrame != end) { _lastProcessedFrame = GetFrame(_lastProcessedFrame + 1); int[] boundaries = GetFrameBoundaries(); ushort id; for (int i = boundaries[0]; i <= boundaries[1]; i++) { id = (ushort)i; if (UpdateVehicle(id)) { _data._VehiclesUpdated.Add(id); } else if (_data._Vehicles.Contains(id)) { _data._VehiclesRemoved.Add(id); RemoveVehicle(id); } } } } OutputDebugLog(); } catch (Exception e) { string error = "Vehicle monitor failed to initialize\r\n"; error += String.Format("Error: {0}\r\n", e.Message); error += "\r\n"; error += "==== STACK TRACE ====\r\n"; error += e.StackTrace; _helper.Log(error); _terminated = true; } base.OnUpdate(realTimeDelta, simulationTimeDelta); }
/* * Handles creation and removal of vehicles * * Note: Just because a vehicle has been removed visually, it does not mean * it is removed as far as the game is concerned. The vehicle is only truly removed * when the frame covers the vehicle's id, and that's when we will remove the * vehicle from our records. */ public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (_terminated) return; if (!_helper.VehicleMonitorSpinnable) return; if (!_settings.Enable._VehicleMonitor) return; try { if (!_initialized) { _data = Data.Instance; _mapping = new VehiclePrefabMapping(); _paused = false; _instance = Singleton<VehicleManager>.instance; _capacity = _instance.m_vehicles.m_buffer.Length; _id = (ushort)_capacity; _initialized = true; _helper.VehicleMonitorSpun = true; _helper.VehicleMonitor = this; _helper.NotifyPlayer("Vehicle monitor initialized"); } else if (!SimulationManager.instance.SimulationPaused) { _data._VehiclesUpdated.Clear(); _data._VehiclesRemoved.Clear(); int end = GetFrame(); while (_lastProcessedFrame != end) { _lastProcessedFrame = GetFrame(_lastProcessedFrame + 1); int[] boundaries = GetFrameBoundaries(); ushort id; for (int i = boundaries[0]; i <= boundaries[1]; i++) { id = (ushort)i; if (UpdateVehicle(id)) _data._VehiclesUpdated.Add(id); else if (_data._Vehicles.Contains(id)) { _data._VehiclesRemoved.Add(id); RemoveVehicle(id); } } } } OutputDebugLog(); } catch (Exception e) { string error = "Vehicle monitor failed to initialize\r\n"; error += String.Format("Error: {0}\r\n", e.Message); error += "\r\n"; error += "==== STACK TRACE ====\r\n"; error += e.StackTrace; _helper.Log(error); _terminated = true; } base.OnUpdate(realTimeDelta, simulationTimeDelta); }