Skip to content

Commit

Permalink
Rename Map -> CellMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Majiir committed Sep 1, 2014
1 parent be87d24 commit d09ce32
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Plugin/CellularResourceGenerator.cs
Expand Up @@ -10,7 +10,7 @@ public IBodyResources Load(CelestialBody body, ConfigNode node)
{
if (node == null)
{
var amounts = new Map<double>(MapOverlay.GridLevel);
var amounts = new CellMap<double>(MapOverlay.GridLevel);
Initialize(body, amounts);
return new BodyResources(amounts);
}
Expand All @@ -19,7 +19,7 @@ public IBodyResources Load(CelestialBody body, ConfigNode node)
var bytes = Misc.FromBase64String(node.GetValue("amounts"));
ensureBigEndian(bytes);

var amounts = new Map<double>(MapOverlay.GridLevel);
var amounts = new CellMap<double>(MapOverlay.GridLevel);
var count = Cell.CountAtLevel(MapOverlay.GridLevel);
for (uint i = 0; i < count; i++) {
amounts[new Cell(i)] = BitConverter.ToDouble(bytes, (int)i * 8);
Expand All @@ -29,7 +29,7 @@ public IBodyResources Load(CelestialBody body, ConfigNode node)
}
}

public abstract void Initialize(CelestialBody body, Map<double> amounts);
public abstract void Initialize(CelestialBody body, CellMap<double> amounts);

private static void ensureBigEndian(byte[] bytes)
{
Expand All @@ -49,9 +49,9 @@ private static void ensureBigEndian(byte[] bytes)

private class BodyResources : IBodyResources
{
private readonly Map<double> amounts;
private readonly CellMap<double> amounts;

public BodyResources(Map<double> amounts)
public BodyResources(CellMap<double> amounts)
{
this.amounts = amounts;
MaxQuantity = amounts.Max(p => p.Value);
Expand Down
6 changes: 3 additions & 3 deletions Plugin/GeodesicGrid/Map.cs → Plugin/GeodesicGrid/CellMap.cs
Expand Up @@ -5,16 +5,16 @@

namespace Kethane.GeodesicGrid
{
public class Map<T> : IEnumerable<KeyValuePair<Cell, T>>
public class CellMap<T> : IEnumerable<KeyValuePair<Cell, T>>
{
private readonly T[] values;

public Map(int level)
public CellMap(int level)
{
values = new T[Cell.CountAtLevel(level)];
}

public Map(int level, Func<Cell, T> selector)
public CellMap(int level, Func<Cell, T> selector)
{
values = Cell.AtLevel(level).Select(selector).ToArray();
}
Expand Down
2 changes: 1 addition & 1 deletion Plugin/Kethane.csproj
Expand Up @@ -49,7 +49,7 @@
<Compile Include="GeodesicGrid\Cell.cs" />
<Compile Include="CellularResourceGenerator.cs" />
<Compile Include="CompatibilityChecker.cs" />
<Compile Include="GeodesicGrid\Map.cs" />
<Compile Include="GeodesicGrid\CellMap.cs" />
<Compile Include="GeodesicGrid\Set.cs" />
<Compile Include="InstallCleanup.cs" />
<Compile Include="IWindowToggle.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Plugin/MapOverlay.cs
Expand Up @@ -498,7 +498,7 @@ private static void export()
{
var sb = new StringBuilder();

var cells = new Map<string>(MapOverlay.GridLevel);
var cells = new CellMap<string>(MapOverlay.GridLevel);
foreach (var cell in Cell.AtLevel(MapOverlay.GridLevel))
{
var pos = cell.Position;
Expand Down
4 changes: 2 additions & 2 deletions Plugin/TerrainData.cs
Expand Up @@ -23,12 +23,12 @@ public static TerrainData ForBody(CelestialBody body)
return bodies[body.name];
}

private readonly Map<float> heightRatios;
private readonly CellMap<float> heightRatios;

private TerrainData(CelestialBody body)
{
if (body.pqsController == null) { throw new ArgumentException("Body doesn't have a PQS controller"); }
heightRatios = new Map<float>(MapOverlay.GridLevel, c => (float)(body.pqsController.GetSurfaceHeight(c.Position) / body.pqsController.radius));
heightRatios = new CellMap<float>(MapOverlay.GridLevel, c => (float)(body.pqsController.GetSurfaceHeight(c.Position) / body.pqsController.radius));
}

public float GetHeightRatio(Cell cell)
Expand Down

0 comments on commit d09ce32

Please sign in to comment.