Disable ambient lights in dream world

This commit is contained in:
Joshua Thome 2024-10-05 00:55:40 -05:00
parent 6528d2c654
commit 637fa401cf
2 changed files with 30 additions and 0 deletions

View File

@ -2,6 +2,7 @@ using UnityEngine;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility.Files; using NewHorizons.Utility.Files;
using NewHorizons.Components;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
@ -64,6 +65,8 @@ namespace NewHorizons.Builder.General
} }
} }
lightGO.AddComponent<AmbientLight>();
return light; return light;
} }
} }

View File

@ -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<Light>();
cachedIntensity = light.intensity;
}
void Update()
{
var targetIntensity = PlayerState.InDreamWorld() ? 0f : cachedIntensity;
light.intensity = Mathf.MoveTowards(light.intensity, targetIntensity, Time.deltaTime * 5f);
}
}
}