Adjust the relative sizes

This commit is contained in:
Nick 2023-08-22 20:10:40 -04:00
parent 14744bbb02
commit 6880b5be20

View File

@ -79,10 +79,19 @@ namespace NewHorizons.Handlers
// Resize planets relative to each other // Resize planets relative to each other
// If there are multiple planets shrink them down to 30% of the size // If there are multiple planets shrink them down to 30% of the size
var maxSize = planetSizes.Select(x => x.size).Max(); var maxSize = planetSizes.Select(x => x.size).Max();
var minSize = planetSizes.Select(x => x.size).Min();
var multiplePlanets = planetSizes.Count > 1; var multiplePlanets = planetSizes.Count > 1;
foreach (var (planet, size) in planetSizes) foreach (var (planet, size) in planetSizes)
{ {
planet.transform.localScale *= (size / maxSize) * (multiplePlanets ? 0.3f : 1f); var adjustedSize = size / maxSize;
// If some planets would be too small we'll do a funny thing
if (minSize / maxSize < 0.3f)
{
var t = Mathf.InverseLerp(minSize, maxSize, size);
adjustedSize = Mathf.Lerp(0.3f, 1f, t * t);
}
planet.transform.localScale *= adjustedSize * (multiplePlanets ? 0.3f : 1f);
} }
} }