public void Initialize() { _attentionCode = 0x00; // 0b00000000 // MORALE { _morale = Convert.ToInt32(Cities.Average(city => city.Morale)); _moraleColumn = _morale + " Avg"; _moraleModifiersColumn = ""; foreach (HCity city in _cities) { int sum = city.MoraleModifiers.Values.Sum(); if (!_moraleModifiers.Contains(sum)) { if (_moraleModifiersColumn != "") { _moraleModifiersColumn += ", "; } _moraleModifiersColumn += sum.ToString("+#0;-#0;±#0"); } _moraleModifiers.Add(sum); } _moraleModifiersColumn = Math.Floor(_moraleModifiers.Average()).ToString("+#0;-#0;±#0") + " (" + _moraleModifiersColumn + ")"; _moraleOverview = "WIP"; } // Decay { _abandonment = Cities.Min(city => city.Abandonment); _abandonmentMax = Cities.Min(city => city.AbandonmentMax); bool decaying = Cities.Any(city => city.DistressOverview.Contains("City is decaying.")); if (decaying) { _abandonmentColumn = " Decaying"; } else if (_abandonmentMax < Hazeron.AbandonmentInterval) { _abandonmentColumn = " Unstable"; } else if (_abandonment == _abandonmentMax) { _abandonmentColumn = _abandonment.ToString("00") + "~/" + _abandonmentMax.ToString("00") + " days"; } else if (_abandonment > 0) { _abandonmentColumn = _abandonment.ToString("00") + " /" + _abandonmentMax.ToString("00") + " days"; } else { _abandonmentColumn = " ERROR!?"; } } // POPULATION & LIVING CONDITIONS { _population = Cities.Sum(city => city.Population); _homes = Cities.Sum(city => city.Homes); _jobs = Cities.Sum(city => city.Jobs); _populationLimit = Cities.Sum(city => city.PopulationLimit); _populationColumn = "Population " + _population + ", Homes " + _homes; _loyalty = Cities.Sum(city => city.Loyalty); _loyaltyColumn = _loyalty + " citizens (" + Math.Round(((float)_loyalty / _population) * 100, 2) + "%)"; } // Population overwiew { _populationOverview = "City's population:"; _populationOverview += Environment.NewLine + " " + _loyalty.ToString().PadLeft(5) + ", Loyal citizens"; if (_loyalty != _population) { int minutesToLoyal; bool disloyal = (_cities.Min(city => city.Loyalty) < 0); if (!disloyal) { minutesToLoyal = ((_cities.Max(city => (city.Population - city.Loyalty))) * 13); } else { minutesToLoyal = (Math.Abs(_loyalty) * 13); } _populationOverview += " [color=" + (disloyal ? "red" : "orange") + "]("; if (minutesToLoyal < 120) // Less than two hours. { _populationOverview += minutesToLoyal + " minutes"; } else if (minutesToLoyal < 2980) // Less than two days. { _populationOverview += (minutesToLoyal / 60) + " hours"; } else // More than two days. { _populationOverview += (minutesToLoyal / 1490) + " days"; } _populationOverview += " to " + (disloyal ? "loyal" : "full") + ")[/color]"; } _populationOverview += Environment.NewLine + " " + _population.ToString().PadLeft(5) + ", Citizens"; _populationOverview += Environment.NewLine + " " + _homes.ToString().PadLeft(5) + ", Homes"; _populationOverview += Environment.NewLine + " " + _jobs.ToString().PadLeft(5) + ", Jobs"; _populationOverview += Environment.NewLine + " " + _populationLimit.ToString().PadLeft(5) + ", Population limit"; } // Technology overview { _technologyOverview = ""; _reseatchProjects = new Dictionary <string, int>(); _factilitiesTL = new Dictionary <string, int>(); // Get all the info from the cities foreach (HCity city in Cities) { foreach (KeyValuePair <string, int> project in city.ReseatchProjects) { if (!_reseatchProjects.ContainsKey(project.Key)) { _reseatchProjects.Add(project.Key, project.Value); } else { _reseatchProjects[project.Key] += project.Value; } } foreach (KeyValuePair <string, int> tech in city.FactilitiesTL) { if (!_factilitiesTL.ContainsKey(tech.Key)) { _factilitiesTL.Add(tech.Key, tech.Value); } else if (_factilitiesTL[tech.Key] != tech.Value) { _factilitiesTL[tech.Key] = -Math.Max(Math.Abs(_factilitiesTL[tech.Key]), Math.Abs(tech.Value)); } } } if (_reseatchProjects.Count != 0) { _technologyOverview = "System's technology projects:"; foreach (string building in _reseatchProjects.Keys) { if (_factilitiesTL.ContainsKey(building)) { _technologyOverview += Environment.NewLine + " " + _reseatchProjects[building].ToString().PadLeft(2) + " (TL" + Math.Abs(_factilitiesTL[building]).ToString().PadLeft(2) + ") running, " + building; } else { _technologyOverview += Environment.NewLine + " [color=red]" + _reseatchProjects[building].ToString().PadLeft(2) + " running, " + building + " (wasted, none in city)[/color]"; } } } if (_technologyOverview != "") { _technologyOverview += Environment.NewLine + Environment.NewLine; } _technologyOverview += "System's technology levels:"; List <string> buildingList = _factilitiesTL.Keys.ToList(); buildingList.Sort(); foreach (string building in buildingList) { _technologyOverview += Environment.NewLine + " TL" + Math.Abs(_factilitiesTL[building]).ToString().PadLeft(2) + ", " + building; if (_factilitiesTL[building] < 0) { _technologyOverview += " [color=red](not all cities)[/color]"; } } } // Overview _overview = "WIP"; // AttentionCodes if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x01); // 0b00000001 } if (_population < _homes || _population > _homes) // Population not full, or more than full. { _attentionCode = (byte)(_attentionCode | 0x02); // 0b00000010 } if (Hazeron.AbandonmentInterval * 2 >= _abandonment) // Less than or equal to (Hazeron.AbandonmentInterval * 2) days to decay. { _attentionCode = (byte)(_attentionCode | 0x04); // 0b00000100 } if (Hazeron.AbandonmentInterval >= _abandonment) // Less than or equal to (Hazeron.AbandonmentInterval) days to decay. { _attentionCode = (byte)(_attentionCode | 0x08); // 0b00001000 } if (_population == 0 || _population > _populationLimit) // Population is 0, or zone over populated! { _attentionCode = (byte)(_attentionCode | 0x10); // 0b00010000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x20); // 0b00100000 } if (_morale < 20) // Morale not full. { _attentionCode = (byte)(_attentionCode | 0x40); // 0b01000000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x80); // 0b10000000 } _initialized = true; }