Fix burnt star colours

This commit is contained in:
Nick 2022-05-19 19:13:57 -04:00
parent 850500392f
commit 2280ba3b83
2 changed files with 23 additions and 10 deletions

View File

@ -197,12 +197,19 @@ namespace NewHorizons.Builder.Body
var giantMaterial = sun.GetComponent<SunController>().GetValue<Material>("_endSurfaceMaterial");
surface.sharedMaterial = new Material(starModule.Size >= 3000 ? giantMaterial : mainSequenceMaterial);
var mod = Mathf.Max(0.5f, 2f * Mathf.Sqrt(starModule.SolarLuminosity));
var mod = Mathf.Max(1f, 2f * Mathf.Sqrt(starModule.SolarLuminosity));
var adjustedColour = new Color(colour.r * mod, colour.g * mod, colour.b * mod);
surface.sharedMaterial.color = adjustedColour;
Color.RGBToHSV(adjustedColour, out float H, out float S, out float V);
var darkenedColor = Color.HSVToRGB(H, S, V * 0.05f);
var darkenedColor = Color.HSVToRGB(H, S * 1.2f, V * 0.05f);
if (starModule.EndTint != null)
{
var endColour = starModule.EndTint.ToColor();
darkenedColor = new Color(endColour.r * mod, endColour.g * mod, endColour.b * mod);
}
surface.sharedMaterial.SetTexture("_ColorRamp", ImageUtilities.LerpGreyscaleImage(_colorOverTime, adjustedColour, darkenedColor));
}

View File

@ -14,7 +14,6 @@ namespace NewHorizons.Components.SizeControllers
public GameObject atmosphere;
public SupernovaEffectController supernova;
public bool willExplode;
public MColor startColour { get; set; }
public MColor endColour { get; set; }
@ -148,13 +147,20 @@ namespace NewHorizons.Components.SizeControllers
if (!_isCollapsing)
{
base.FixedUpdate();
// Use the age if theres no resizing happening, else make it get redder the larger it is or wtv
var t = ageValue;
if(maxScale > 0) t = CurrentScale / maxScale;
currentColour = Color.Lerp(_startColour, _endColour, t);
supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t);
// Only do colour transition stuff if they set an end colour
if (endColour != null)
{
// Use the age if theres no resizing happening, else make it get redder the larger it is or wtv
var t = ageValue;
if (maxScale > 0) t = CurrentScale / maxScale;
currentColour = Color.Lerp(_startColour, _endColour, t);
supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t);
}
else
{
currentColour = _startColour;
}
}
else
{