Some tweaks

This commit is contained in:
Nick 2022-05-14 18:57:32 -04:00
parent cdcc215b65
commit eb4e5bf26e

View File

@ -2,7 +2,9 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
using System;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
@ -12,35 +14,17 @@ namespace NewHorizons.Builder.Body
{ {
var proxyName = $"{body.Config.Name}_Proxy"; var proxyName = $"{body.Config.Name}_Proxy";
// Stars don't work yet so uh
/*
if (body.Config.Star != null)
{
var sunProxy = SearchUtilities.CachedFind("SunProxy(Clone)");
var oldProxyEffectController = sunProxy.GetComponentInChildren<SunProxyEffectController>();
var newProxy = Object.Instantiate(sunProxy, gameObject.transform.position, Quaternion.identity);
newProxy.name = proxyName;
var proxyController = newProxy.GetComponent<SunProxy>();
proxyController._proxySunController = newProxy.GetComponentInChildren<SunProxyEffectController>();
proxyController._proxySunController._atmosphereMaterial = oldProxyEffectController._atmosphereMaterial;
proxyController._proxySunController._fogMaterial = oldProxyEffectController._fogMaterial;
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() =>
{
proxyController._sunTransform = gameObject.transform;
proxyController._realSunController = gameObject.GetComponent<SunController>();
});
}
*/
var newProxy = new GameObject(proxyName); var newProxy = new GameObject(proxyName);
try
{
// We want to take the largest size I think // We want to take the largest size I think
var realSize = body.Config.Base.SurfaceSize; var realSize = body.Config.Base.SurfaceSize;
if (body.Config.HeightMap != null) if (body.Config.HeightMap != null)
{ {
HeightMapBuilder.Make(newProxy, null, body.Config.HeightMap, body.Mod, 20); HeightMapBuilder.Make(newProxy, null, body.Config.HeightMap, body.Mod, 20);
if(realSize < body.Config.HeightMap.MaxHeight) realSize = body.Config.HeightMap.MaxHeight; if (realSize < body.Config.HeightMap.MaxHeight) realSize = body.Config.HeightMap.MaxHeight;
} }
if (body.Config.Base.GroundSize != 0) if (body.Config.Base.GroundSize != 0)
{ {
@ -62,7 +46,7 @@ namespace NewHorizons.Builder.Body
StarBuilder.MakeStarGraphics(newProxy, null, body.Config.Star); StarBuilder.MakeStarGraphics(newProxy, null, body.Config.Star);
if (realSize < body.Config.Star.Size) realSize = body.Config.Star.Size; if (realSize < body.Config.Star.Size) realSize = body.Config.Star.Size;
} }
if(body.Config.ProcGen != null) if (body.Config.ProcGen != null)
{ {
ProcGenBuilder.Make(newProxy, null, body.Config.ProcGen); ProcGenBuilder.Make(newProxy, null, body.Config.ProcGen);
if (realSize < body.Config.ProcGen.Scale) realSize = body.Config.ProcGen.Scale; if (realSize < body.Config.ProcGen.Scale) realSize = body.Config.ProcGen.Scale;
@ -73,12 +57,16 @@ namespace NewHorizons.Builder.Body
{ {
GameObject.Destroy(col); GameObject.Destroy(col);
} }
// Fix render idk
foreach (var renderer in newProxy.GetComponentsInChildren<Renderer>()) foreach (var renderer in newProxy.GetComponentsInChildren<Renderer>())
{ {
renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
renderer.receiveShadows = false; renderer.receiveShadows = false;
renderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.BlendProbes; renderer.enabled = true;
}
foreach (var tessellatedRenderer in newProxy.GetComponentsInChildren<TessellatedRenderer>())
{
tessellatedRenderer.enabled = true;
} }
var proxyController = newProxy.AddComponent<NHProxy>(); var proxyController = newProxy.AddComponent<NHProxy>();
@ -87,5 +75,11 @@ namespace NewHorizons.Builder.Body
proxyController.renderers = newProxy.GetComponentsInChildren<Renderer>(); proxyController.renderers = newProxy.GetComponentsInChildren<Renderer>();
proxyController.tessellatedRenderers = newProxy.GetComponentsInChildren<TessellatedRenderer>(); proxyController.tessellatedRenderers = newProxy.GetComponentsInChildren<TessellatedRenderer>();
} }
catch (Exception ex)
{
Logger.Log($"Exception thrown when generating proxy for [{body.Config.Name}] : {ex.Message}, {ex.StackTrace}");
GameObject.Destroy(newProxy);
}
}
} }
} }