Skip to content

Commit

Permalink
Localized resource conc limits
Browse files Browse the repository at this point in the history
  • Loading branch information
DMagic1 committed Aug 15, 2020
1 parent 3224aa9 commit eef5673
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions SCANsat/SCAN_UI/SCANsatRPM.cs
Expand Up @@ -750,7 +750,9 @@ private void calcTerrainLimits(CelestialBody b)

float max = -200000;
float min = 100000;
float terrain = 0;

float resourceMax = 0;
float resourceMin = 100;

for (int i = 0; i < map.MapHeight; i += 4)
{
Expand All @@ -762,7 +764,22 @@ private void calcTerrainLimits(CelestialBody b)
lat = map.unprojectLatitude(lo, la);
lon = map.unprojectLongitude(lo, la);

terrain = (float)SCANUtil.getElevation(b, lon, lat);
float terrain = (float)SCANUtil.getElevation(b, lon, lat);

if (map.Resource != null)
{
float resource = SCANUtil.ResourceOverlay(lat, lon, map.Resource.Name, orbitingBody, false) * 100f;

if (resource < resourceMin)
resourceMin = resource;
if (resource > resourceMax)
resourceMax = resource;
}
else
{
resourceMax = 100;
resourceMin = 0;
}

if (terrain < min)
min = terrain;
Expand All @@ -777,7 +794,22 @@ private void calcTerrainLimits(CelestialBody b)
if (min == max)
min = max - 1f;

map.setCustomRange(min, max);
if (map.Resource != null && map.Resource.CurrentBody != null && resourceMin < map.Resource.CurrentBody.MinValue)
resourceMin = map.Resource.CurrentBody.MinValue;

if (resourceMin >= resourceMax)
resourceMax = resourceMin + 1f;

if (resourceMin < 0)
resourceMin = 0;

if (map.Resource != null && map.Resource.CurrentBody != null && resourceMax > map.Resource.CurrentBody.MaxValue)
resourceMax = map.Resource.CurrentBody.MaxValue;

if (resourceMin >= resourceMax)
resourceMin = resourceMax - 1f;

map.setCustomRange(min, max, resourceMin, resourceMax);
}

private bool UpdateCheck()
Expand Down

0 comments on commit eef5673

Please sign in to comment.