Add fluid type to tornado/hurricane

This commit is contained in:
Noah Pilarski 2022-08-23 19:07:58 -04:00
parent 2af4e5b0cd
commit 9af15e1051
2 changed files with 35 additions and 2 deletions

View File

@ -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<CapsuleShape>().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<TornadoFluidVolume>()._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<TornadoFluidVolume>()._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<HurricaneFluidVolume>();
fluidVolume._fluidType = fluidType;
fluidVolume._density = 8;
var effects = hurricaneGO.transform.Find("Effects_GD_Hurricane").gameObject;

View File

@ -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.
/// </summary>
public float audioDistance;
/// <summary>
/// Fluid type for sounds/effects when colliding with this tornado.
/// </summary>
[DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud;
}
[JsonObject]