public void Despawn(Shopper s, bool removeShopper = true) { if (s.IsInfectious()) { m_NumInfectious--; } // Update running totals of healthy and exposed. if (s.IsHealthy()) { m_FinalHealthy++; NumHealthyChanged?.Invoke(m_FinalHealthy); } if (s.IsExposed()) { m_FinalExposed++; NumContagiousChanged?.Invoke(m_FinalExposed); } if (removeShopper) { m_AllShoppers.Remove(s); } Destroy(s.gameObject); }
public void ResetSimulation() { foreach (var shopper in m_AllShoppers) { Despawn(shopper, false); } foreach (var register in Registers) { Destroy(register.GetComponent <StoreSimulationQueue>()); } m_AllShoppers.Clear(); m_FinalExposed = 0; m_FinalHealthy = 0; m_CurrentServingQueue = 0; NumHealthyChanged?.Invoke(m_FinalHealthy); NumContagiousChanged?.Invoke(m_FinalExposed); m_NumInfectious = 0; m_RegistersQueues.Clear(); InitializeRegisters(); InitWaypoints(); }
void OnDisable() { // Update the final counts. foreach (var s in m_AllShoppers) { if (s.IsHealthy()) { m_FinalHealthy++; NumHealthyChanged?.Invoke(m_FinalHealthy); } if (s.IsExposed()) { m_FinalExposed++; NumContagiousChanged?.Invoke(m_FinalExposed); } } var exposureRate = m_FinalExposed + m_FinalHealthy == 0 ? 0 : m_FinalExposed / (float)(m_FinalExposed + m_FinalHealthy); Debug.Log($"total healthy: {m_FinalHealthy} total exposed: {m_FinalExposed} exposure rate: {100.0 * exposureRate}%"); }