diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 27d52206..143f52dc 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -137,9 +137,19 @@ namespace NewHorizons.Builder.Body controller.size = starModule.size; controller.atmosphere = sunAtmosphere; controller.supernova = supernova; - controller.StartColour = starModule.tint; - controller.EndColour = starModule.endTint; - controller.WillExplode = starModule.goSupernova; + controller.startColour = starModule.tint?.ToColor(); + controller.endColour = starModule.tint != null ? starModule.tint.ToColor() * 4.5948f : null; + controller.willExplode = starModule.goSupernova; + if (!string.IsNullOrEmpty(starModule.starRampTexture)) + { + var ramp = ImageUtilities.GetTexture(mod, starModule.starRampTexture); + controller.normalRamp = ramp; + } + if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture)) + { + var ramp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture); + controller.collapseRamp = ramp; + } surfaceAudio.SetStarEvolutionController(controller); starGO.SetActive(true); @@ -177,8 +187,8 @@ namespace NewHorizons.Builder.Body if (starModule.curve != null) controller.SetScaleCurve(starModule.curve); controller.size = starModule.size; controller.supernova = supernova; - controller.StartColour = starModule.tint; - controller.EndColour = starModule.endTint; + controller.startColour = starModule.tint?.ToColor(); + controller.endColour = starModule.tint != null ? starModule.tint.ToColor() * 4.5948f : null; controller.enabled = true; starGO.SetActive(true); diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index d27486fb..054ade43 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -15,9 +15,11 @@ namespace NewHorizons.Components.SizeControllers { public GameObject atmosphere; public SupernovaEffectController supernova; - public bool WillExplode { get; set; } - public MColor StartColour { get; set; } - public MColor EndColour { get; set; } + public bool willExplode; + public Color? startColour; + public Color? endColour; + public Texture normalRamp; + public Texture collapseRamp; private Color _startColour; private Color _endColour; @@ -43,6 +45,8 @@ namespace NewHorizons.Components.SizeControllers private Material _collapseEndSurfaceMaterial; private Material _startSurfaceMaterial; private Material _endSurfaceMaterial; + private Texture _normalRamp; + private Texture _collapseRamp; private StarEvolutionController _proxy; @@ -60,31 +64,45 @@ namespace NewHorizons.Components.SizeControllers _endSurfaceMaterial = new Material(sun._endSurfaceMaterial); var supernovaSurfaceColorRamp = supernova._surface.sharedMaterial.GetTexture(ColorRamp); + if (normalRamp == null) + { + _normalRamp = supernovaSurfaceColorRamp; + } else + { + _normalRamp = normalRamp; + } + if (collapseRamp == null) + { + _collapseRamp = supernovaSurfaceColorRamp; + } else + { + _collapseRamp = collapseRamp; + } // Copy over the material that was set in star builder - _collapseStartSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); - _collapseEndSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); - _startSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); - _endSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); + _collapseStartSurfaceMaterial.SetTexture(ColorRamp, _collapseRamp); + _collapseEndSurfaceMaterial.SetTexture(ColorRamp, _collapseRamp); + _startSurfaceMaterial.SetTexture(ColorRamp, _normalRamp); + _endSurfaceMaterial.SetTexture(ColorRamp, _normalRamp); - if (StartColour == null) + if (startColour == null) { _startColour = _startSurfaceMaterial.color; } else { - _startColour = StartColour.ToColor(); + _startColour = startColour.Value; _startSurfaceMaterial.color = _startColour; } - if (EndColour == null) + if (endColour == null) { _endColour = _startColour; _endSurfaceMaterial.color = _startColour; } else { - _endColour = EndColour.ToColor(); + _endColour = endColour.Value; _endSurfaceMaterial.color = _endColour; } @@ -97,7 +115,7 @@ namespace NewHorizons.Components.SizeControllers _atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren(); } - if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); + if (willExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); if (scaleCurve != null) { @@ -115,7 +133,7 @@ namespace NewHorizons.Components.SizeControllers public void OnDestroy() { - if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); + if (willExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); } public void SetProxy(StarEvolutionController proxy) @@ -165,12 +183,13 @@ namespace NewHorizons.Components.SizeControllers base.FixedUpdate(); // Only do colour transition stuff if they set an end colour - if (EndColour != null) + 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].SetTexture(ColorRamp, _normalRamp); supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t); } else @@ -190,6 +209,7 @@ namespace NewHorizons.Components.SizeControllers currentColour = Color.Lerp(_endColour, Color.white, t); + supernova._surface._materials[0].SetTexture(ColorRamp, _collapseRamp); supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t); // After the collapse is done we go supernova diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index 627fca8c..ea303ab0 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -61,6 +61,11 @@ namespace NewHorizons.External.Modules.VariableSize /// public string starRampTexture; + /// + /// Path to the texture to put as the star ramp while it is collapsing. Optional. + /// + public string starCollapseRampTexture; + /// /// How far the light from the star can reach. /// diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 61b75b12..9626080c 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1968,6 +1968,10 @@ "type": "string", "description": "Path to the texture to put as the star ramp. Optional." }, + "starRampCollapseTexture": { + "type": "string", + "description": "Path to the texture to put as the star ramp while it is collapsing. Optional." + }, "lightRadius": { "type": "number", "description": "How far the light from the star can reach.",