From b8c28e373496b78d3a95d21d096b06281efc7c97 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 11 Sep 2022 02:57:24 -0400 Subject: [PATCH] Me when --- NewHorizons/Builder/Body/WaterBuilder.cs | 4 +++- NewHorizons/Main.cs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 1ea6df3f..ef55887a 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -12,6 +12,7 @@ namespace NewHorizons.Builder.Body private static MeshGroup _oceanMeshGroup; private static Material[] _oceanLowAltitudeMaterials; private static GameObject _oceanFog; + private static GameObject _oceanAmbientLight; internal static void InitPrefabs() { @@ -30,6 +31,7 @@ namespace NewHorizons.Builder.Body } if (_oceanLowAltitudeMaterials == null) _oceanLowAltitudeMaterials = SearchUtilities.Find("Ocean_GD").GetComponent()._lowAltitudeMaterials.MakePrefabMaterials(); if (_oceanFog == null) _oceanFog = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/OceanFog").InstantiateInactive().Rename("Prefab_GD_OceanFog").DontDestroyOnLoad(); + if (_oceanAmbientLight == null) _oceanAmbientLight = SearchUtilities.Find("Ocean_GD").GetComponent()._ambientLight.gameObject.InstantiateInactive().Rename("OceanAmbientLight").DontDestroyOnLoad(); } public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module) @@ -74,7 +76,7 @@ namespace NewHorizons.Builder.Body var OLC = waterGO.AddComponent(); OLC._sector = sector; - OLC._ambientLight = null; // this needs to be set or else is black + OLC._ambientLight = _oceanAmbientLight.GetComponent(); // this needs to be set or else is black // trigger sector enter Delay.FireOnNextUpdate(() => diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index b4661ef3..fb388ba6 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -447,10 +447,24 @@ namespace NewHorizons var distantSun = eyeSector.gameObject.FindChild("DistantSun/Directional light"); var starController = distantSun.AddComponent(); - starController.Light = distantSun.GetComponent(); + var sunLight = distantSun.GetComponent(); + starController.Light = sunLight; + var ambientLightFake = new GameObject("AmbientLightFake", typeof(Light)); + ambientLightFake.transform.SetParent(distantSun.transform, false); + ambientLightFake.SetActive(false); + var ambientLight = ambientLightFake.GetComponent(); + ambientLight.intensity = 0; + ambientLight.range = 0; + ambientLight.enabled = false; + starController.AmbientLight = ambientLight; starController.Intensity = 0.2f; starController.SunColor = new Color(0.3569f, 0.7843f, 1, 1); - distantSun.AddComponent().Awake(); + var sunLightController = distantSun.AddComponent(); + sunLightController._sunLight = sunLight; + sunLightController._ambientLight = ambientLight; + sunLightController.Initialize(); + var starLightController = distantSun.AddComponent(); + starLightController.Awake(); StarLightController.AddStar(starController); if (IsWarpingFromShip && _ship != null)