From 9af15e1051190b21e8dfb0f8d31577c2882ccce4 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Tue, 23 Aug 2022 19:07:58 -0400 Subject: [PATCH] Add fluid type to tornado/hurricane --- NewHorizons/Builder/Props/TornadoBuilder.cs | 32 +++++++++++++++++++-- NewHorizons/External/Modules/PropModule.cs | 5 ++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index e166bea0..dd9ac6c1 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.Components; using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using System; using UnityEngine; using Logger = NewHorizons.Utility.Logger; using Random = UnityEngine.Random; @@ -142,14 +143,29 @@ namespace NewHorizons.Builder.Props tornadoGO.GetComponentInChildren().enabled = true; + var fluidType = FluidVolume.Type.CLOUD; + + try + { + fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(FluidType), info.fluidType).ToUpper()); + } + catch (Exception ex) + { + Logger.LogError($"Couldn't parse fluid volume type [{info.fluidType}]:\n{ex}"); + } + // Resize it so the force volume goes all the way up switch (downwards) { case true: - tornadoGO.transform.Find("MockDownTornado_FluidCenter").localScale = new Vector3(1, 2f, 1); + var fluidDown = tornadoGO.transform.Find("MockDownTornado_FluidCenter"); + fluidDown.GetComponent()._fluidType = fluidType; + fluidDown.localScale = new Vector3(1, 2f, 1); break; default: - tornadoGO.transform.Find("MockUpTornado_FluidCenter").localScale = new Vector3(1, 2f, 1); + var fluidUp = tornadoGO.transform.Find("MockUpTornado_FluidCenter"); + fluidUp.GetComponent()._fluidType = fluidType; + fluidUp.localScale = new Vector3(1, 2f, 1); break; } @@ -175,7 +191,19 @@ namespace NewHorizons.Builder.Props hurricaneGO.transform.position = planetGO.transform.TransformPoint(position); hurricaneGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(position.normalized)); + var fluidType = FluidVolume.Type.CLOUD; + + try + { + fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(FluidType), info.fluidType).ToUpper()); + } + catch (Exception ex) + { + Logger.LogError($"Couldn't parse fluid volume type [{info.fluidType}]:\n{ex}"); + } + var fluidVolume = hurricaneGO.GetComponentInChildren(); + fluidVolume._fluidType = fluidType; fluidVolume._density = 8; var effects = hurricaneGO.transform.Find("Effects_GD_Hurricane").gameObject; diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 70ebc244..863c3669 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -325,6 +325,11 @@ namespace NewHorizons.External.Modules /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. /// public float audioDistance; + + /// + /// Fluid type for sounds/effects when colliding with this tornado. + /// + [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud; } [JsonObject]