Account for all properties

This commit is contained in:
TerrificTrifid 2022-11-08 23:18:56 -06:00
parent bdf715d1d4
commit 00688b4531

View File

@ -10,6 +10,8 @@ namespace NewHorizons.Builder.Body
public static class LavaBuilder
{
private static readonly int HeightScale = Shader.PropertyToID("_HeightScale");
private static readonly int EdgeFade = Shader.PropertyToID("_EdgeFade");
private static readonly int TexHeight = Shader.PropertyToID("_TexHeight");
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
private static GameObject _lavaSphere;
@ -33,11 +35,11 @@ namespace NewHorizons.Builder.Body
{
InitPrefabs();
var heightScale = module.size;
var multiplier = module.size / 100f;
if (module.curve != null)
{
var modifier = module.curve.Max(pair => pair.value);
heightScale = Mathf.Max(0.1f, heightScale * modifier);
multiplier *= modifier;
}
var moltenCore = new GameObject("MoltenCore");
@ -49,7 +51,9 @@ namespace NewHorizons.Builder.Body
var lavaSphere = GameObject.Instantiate(_lavaSphere, moltenCore.transform);
lavaSphere.transform.localScale = Vector3.one;
lavaSphere.transform.name = "LavaSphere";
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, 150f * multiplier);
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(EdgeFade, 15f * multiplier);
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(TexHeight, 15f * multiplier);
if (module.tint != null) lavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.tint.ToColor());
lavaSphere.SetActive(true);
@ -63,7 +67,9 @@ namespace NewHorizons.Builder.Body
var proxyLavaSphere = moltenCoreProxy.transform.Find("LavaSphere (1)");
proxyLavaSphere.transform.localScale = Vector3.one;
proxyLavaSphere.name = "LavaSphere_Proxy";
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, 150f * multiplier);
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(EdgeFade, 15f * multiplier);
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(TexHeight, 15f * multiplier);
if (module.tint != null) proxyLavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.tint.ToColor());
var sectorProxy = moltenCoreProxy.GetComponent<SectorProxy>();