public void CheckWaves() { List <int> list = MyrmidexTeam.Keys.ToList(); for (int i = 0; i < list.Count; i++) { int wave = list[i]; List <BaseCreature> bcList = MyrmidexTeam[wave]; if (bcList == null) { continue; } if (bcList.All(bc => bc == null || bc.Deleted || !bc.Alive)) { ColUtility.Free(bcList); if (MyrmidexTeam.ContainsKey(wave)) { MyrmidexTeam.Remove(wave); } RegionMessage(i == 0 ? 1156604 : 1156605); // The Eodonians have secured new ground, the front line has moved up! } } list.Clear(); list = TribeTeam.Keys.ToList(); for (int i = 0; i < list.Count; i++) { int wave = list[i]; List <BaseCreature> bcList = TribeTeam[wave]; if (bcList == null) { continue; } if (bcList.All(bc => bc == null || bc.Deleted || !bc.Alive)) { ColUtility.Free(bcList); if (TribeTeam.ContainsKey(wave)) { TribeTeam.Remove(wave); } RegionMessage(i == 0 ? 1156602 : 1156603); // The Myrmidex have secured new ground, the front line has moved up! } } ColUtility.Free(list); }