From 637fa401cf800b3c0bb868b831d4f2a298cc1418 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 5 Oct 2024 00:55:40 -0500 Subject: [PATCH] Disable ambient lights in dream world --- .../Builder/General/AmbientLightBuilder.cs | 3 +++ NewHorizons/Components/AmbientLight.cs | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 NewHorizons/Components/AmbientLight.cs 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); + } + } +}