Skip to content

Commit

Permalink
Only fetch KethaneData once per batch cell refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
Majiir committed Aug 12, 2013
1 parent c027884 commit 1a26c43
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Plugin/MapOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,25 @@ public void RefreshCellColor(GeodesicGrid.Cell cell, CelestialBody body)
{
if (body != this.body) { return; }
var colors = mesh.colors32;
refreshCellColor(cell, body, colors);
refreshCellColor(cell, body, colors, KethaneData.Current);
mesh.colors32 = colors;
}

private void refreshCellColors()
{
var colors = new Color32[mesh.vertexCount];
var data = KethaneData.Current;
foreach (var cell in grid)
{
refreshCellColor(cell, body, colors);
refreshCellColor(cell, body, colors, data);
}
mesh.colors32 = colors;
}

private void refreshCellColor(GeodesicGrid.Cell cell, CelestialBody body, Color32[] colors)
private void refreshCellColor(GeodesicGrid.Cell cell, CelestialBody body, Color32[] colors, KethaneData data)
{
var deposit = KethaneData.Current.GetCellDeposit(resource.Resource, body, cell);
var scanned = KethaneData.Current.Scans[resource.Resource][body.name][cell];
var deposit = data.GetCellDeposit(resource.Resource, body, cell);
var scanned = data.Scans[resource.Resource][body.name][cell];
var color = (revealAll ? deposit != null : scanned) ? getDepositColor(resource, deposit) : colorUnknown;
setCellColor(cell, color, colors);
}
Expand Down

0 comments on commit 1a26c43

Please sign in to comment.