public void Draw(IMyCubeGrid grid, StringBuilder target) { target.AppendLine("Power:"); var totalDistribution = new Distribution(); foreach (var row in distributionByGrid.Enumerate()) { totalDistribution = totalDistribution.Accumulate(new Distribution { ProducedMegawatts = row.Total.ProducedMegawatts, ConsumedMegawatts = row.Total.ConsumedMegawatts, // Ignore storage on non-producing grids. StoredMegawattHours = row.Total.ProducedMegawatts > 0 ? row.Total.StoredMegawattHours : 0, CapacityMegawattHours = row.Total.ProducedMegawatts > 0 ? row.Total.CapacityMegawattHours : 0, }); } WriteRow(target, "TOTAL", totalDistribution); foreach (var row in distributionByGrid.Enumerate(grid.CustomName)) { WriteRow(target, row.Key, row.Total); } }