/* * Handles creation and removal of humans * * Note: Just because a human has been removed visually, it does not mean * it is removed as far as the game is concerned. The human is only truly removed * when the frame covers the human's id, and that's when we will remove the * human from our records. */ public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (_terminated) { return; } if (!_helper.HumanMonitorSpinnable) { return; } if (!_settings.Enable._HumanMonitor) { return; } try { if (!_initialized) { _data = Data.Instance; _mapping = new HumanPrefabMapping(); _paused = false; _instance = Singleton <CitizenManager> .instance; _capacity = _instance.m_citizens.m_buffer.Length; _id = (uint)_capacity; for (int i = 0; i < _capacity; i++) { UpdateHuman((uint)i); } _lastProcessedFrame = GetFrame(); _initialized = true; _helper.HumanMonitorSpun = true; _helper.HumanMonitor = this; _helper.Log("Human monitor initialized"); } else if (!SimulationManager.instance.SimulationPaused) { _data._HumansUpdated.Clear(); _data._HumansRemoved.Clear(); int end = GetFrame(); while (_lastProcessedFrame != end) { _lastProcessedFrame = GetFrame(_lastProcessedFrame + 1); int[] boundaries = GetFrameBoundaries(); uint id; for (int i = boundaries[0]; i <= boundaries[1]; i++) { id = (uint)i; if (UpdateHuman(id)) { _data._HumansUpdated.Add(id); } else if (_data._Humans.Contains(id)) { _data._HumansRemoved.Add(id); RemoveHuman(id); } } } } OutputDebugLog(); } catch (Exception e) { string error = "Human 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 humans * * Note: Just because a human has been removed visually, it does not mean * it is removed as far as the game is concerned. The human is only truly removed * when the frame covers the human's id, and that's when we will remove the * human from our records. */ public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (_terminated) return; if (!_helper.HumanMonitorSpinnable) return; if (!_settings.Enable._HumanMonitor) return; try { if (!_initialized) { _data = Data.Instance; _mapping = new HumanPrefabMapping(); _paused = false; _instance = Singleton<CitizenManager>.instance; _capacity = _instance.m_citizens.m_buffer.Length; _id = (uint)_capacity; for (int i = 0; i < _capacity; i++) UpdateHuman((uint)i); _lastProcessedFrame = GetFrame(); _initialized = true; _helper.HumanMonitorSpun = true; _helper.HumanMonitor = this; _helper.NotifyPlayer("Human monitor initialized"); } else if (!SimulationManager.instance.SimulationPaused) { _data._HumansUpdated.Clear(); _data._HumansRemoved.Clear(); int end = GetFrame(); while (_lastProcessedFrame != end) { _lastProcessedFrame = GetFrame(_lastProcessedFrame + 1); int[] boundaries = GetFrameBoundaries(); uint id; for (int i = boundaries[0]; i <= boundaries[1]; i++) { id = (uint)i; if (UpdateHuman(id)) _data._HumansUpdated.Add(id); else if (_data._Humans.Contains(id)) { _data._HumansRemoved.Add(id); RemoveHuman(id); } } } } OutputDebugLog(); } catch (Exception e) { string error = "Human 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); }