Fix water inside of cloaking fields

This commit is contained in:
Nick 2023-08-23 01:54:40 -04:00
parent 95af39497c
commit 13c2b8badc
3 changed files with 54 additions and 2 deletions

View File

@ -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<OceanLODController>()._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<MeshRenderer>().material.SetFloat("_Radius2", 0);
}
if (config.Cloak != null)
{
fluidVolume.gameObject.AddComponent<WaterCloakFixerVolume>().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;

View File

@ -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<RadialFluidVolume>().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;
}
}
}
}

View File

@ -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)