diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 3039d6dd..c525099e 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -5,6 +5,9 @@ using NewHorizons.External.Modules.VariableSize; using Tessellation; using NewHorizons.Utility.OWML; using NewHorizons.Utility.OuterWilds; +using NewHorizons.External.Configs; +using NewHorizons.Components.Volumes; +using System.Linq; namespace NewHorizons.Builder.Body { @@ -41,10 +44,12 @@ namespace NewHorizons.Builder.Body if (_oceanAmbientLight == null) _oceanAmbientLight = SearchUtilities.Find("Ocean_GD").GetComponent()._ambientLight.gameObject.InstantiateInactive().Rename("OceanAmbientLight").DontDestroyOnLoad(); } - public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module) + public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigidbody rb, PlanetConfig config) { InitPrefabs(); + var module = config.Water; + var waterSize = module.size; GameObject waterGO = new GameObject("Water"); @@ -154,6 +159,11 @@ namespace NewHorizons.Builder.Body fogGO.GetComponent().material.SetFloat("_Radius2", 0); } + if (config.Cloak != null) + { + fluidVolume.gameObject.AddComponent().material = TSR.sharedMaterials.First(x => x.name == "Ocean_GD_Surface_mat"); + } + // TODO: fix ruleset making the sand bubble pop up waterGO.transform.position = planetGO.transform.position; diff --git a/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs b/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs new file mode 100644 index 00000000..06cbb8c9 --- /dev/null +++ b/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace NewHorizons.Components.Volumes +{ + internal class WaterCloakFixerVolume : MonoBehaviour + { + public Material material; + private OWTriggerVolume _volume; + + public void Start() + { + _volume = GetComponent().GetOWTriggerVolume(); + + _volume.OnEntry += WaterCloakFixerVolume_OnEntry; + _volume.OnExit += WaterCloakFixerVolume_OnExit; + + material.renderQueue = 3000; + } + + public void OnDestroy() + { + _volume.OnEntry -= WaterCloakFixerVolume_OnEntry; + _volume.OnExit -= WaterCloakFixerVolume_OnExit; + } + + private void WaterCloakFixerVolume_OnEntry(GameObject hitObj) + { + if (hitObj.CompareTag("PlayerDetector")) + { + material.renderQueue = 2990; + } + } + + private void WaterCloakFixerVolume_OnExit(GameObject hitObj) + { + if (hitObj.CompareTag("PlayerDetector")) + { + material.renderQueue = 3000; + } + } + } +} diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index d15c97a9..85e8dd3c 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -627,7 +627,7 @@ namespace NewHorizons.Handlers if (body.Config.Water != null) { - WaterBuilder.Make(go, sector, rb, body.Config.Water); + WaterBuilder.Make(go, sector, rb, body.Config); } if (body.Config.Sand != null)