diff --git a/NewHorizons/Builder/General/AmbientLightBuilder.cs b/NewHorizons/Builder/General/AmbientLightBuilder.cs index d177679f..0688850b 100644 --- a/NewHorizons/Builder/General/AmbientLightBuilder.cs +++ b/NewHorizons/Builder/General/AmbientLightBuilder.cs @@ -2,6 +2,7 @@ using UnityEngine; using NewHorizons.Utility; using NewHorizons.External.Modules; using NewHorizons.Utility.Files; +using NewHorizons.Components; namespace NewHorizons.Builder.General { @@ -64,6 +65,8 @@ namespace NewHorizons.Builder.General } } + lightGO.AddComponent(); + return light; } } diff --git a/NewHorizons/Components/AmbientLight.cs b/NewHorizons/Components/AmbientLight.cs new file mode 100644 index 00000000..a86a473e --- /dev/null +++ b/NewHorizons/Components/AmbientLight.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace NewHorizons.Components +{ + public class AmbientLight : MonoBehaviour + { + Light light; + float cachedIntensity; + + void Awake() + { + light = GetComponent(); + cachedIntensity = light.intensity; + } + + void Update() + { + var targetIntensity = PlayerState.InDreamWorld() ? 0f : cachedIntensity; + light.intensity = Mathf.MoveTowards(light.intensity, targetIntensity, Time.deltaTime * 5f); + } + } +}