public Statistics(GnomanEmpire gnomanEmpire) { Globals.Logger.Info("Creating statistics..."); if (gnomanEmpire == null) { Globals.Logger.Error("World is not loaded"); return; } worldName = gnomanEmpire.World.AIDirector.PlayerFaction.Name; var names = Enum.GetNames(typeof(MineralID)); for (int i = 0; i < names.Length; i++) { minerals[i] = new MineralStatistic((MineralID)Enum.Parse(typeof(MineralID), names[i])); } for (var level = 0; level < gnomanEmpire.Map.MapDepth; level++) { for (var height = 0; height < gnomanEmpire.Map.MapHeight; height++) { for (var width = 0; width < gnomanEmpire.Map.MapWidth; width++) { var cell = gnomanEmpire.Map.GetCell(level, height, width); if (!cell.HasEmbeddedWall()) { continue; } var embeddedWall = cell.EmbeddedWall; var mineral = embeddedWall as Mineral; if (mineral == null) { continue; } int index2 = 0; foreach (string i in Enum.GetNames(typeof(MineralID))) { if (mineral.MaterialID == ((MineralID)Enum.Parse(typeof(MineralID), i)).GetHashCode()) { minerals[index2].Count++; } index2++; } } } } Globals.Logger.Info("Statistics has been created"); }
public Statistics(GnomanEmpire gnomanEmpire) { Globals.Logger.Info("Creating statistics..."); if (gnomanEmpire == null) { Globals.Logger.Error("World is not loaded"); return; } worldName = gnomanEmpire.World.AIDirector.PlayerFaction.Name; var names = Enum.GetNames(typeof(MineralID)); for (int i = 0; i < names.Length; i++) minerals[i] = new MineralStatistic((MineralID)Enum.Parse(typeof(MineralID), names[i])); for (var level = 0; level < gnomanEmpire.Map.MapDepth; level++) for (var height = 0; height < gnomanEmpire.Map.MapHeight; height++) for (var width = 0; width < gnomanEmpire.Map.MapWidth; width++) { var cell = gnomanEmpire.Map.GetCell(level, height, width); if (!cell.HasEmbeddedWall()) continue; var embeddedWall = cell.EmbeddedWall; var mineral = embeddedWall as Mineral; if (mineral == null) continue; int index2 = 0; foreach (string i in Enum.GetNames(typeof(MineralID))) { if (mineral.MaterialID == ((MineralID)Enum.Parse(typeof(MineralID), i)).GetHashCode()) minerals[index2].Count++; index2++; } } Globals.Logger.Info("Statistics has been created"); }