Tornado Fluid Type (#289)

This commit is contained in:
Noah 2022-08-25 20:10:57 -04:00 committed by GitHub
commit 90b2490a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 42 deletions

View File

@ -85,19 +85,7 @@ namespace NewHorizons.Builder.Atmosphere
fluidCLFV._layer = 5; fluidCLFV._layer = 5;
fluidCLFV._priority = 1; fluidCLFV._priority = 1;
fluidCLFV._density = 1.2f; fluidCLFV._density = 1.2f;
fluidCLFV._fluidType = atmo.clouds.fluidType.ConvertToOW(FluidVolume.Type.CLOUD);
var fluidType = FluidVolume.Type.CLOUD;
try
{
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), atmo.clouds.fluidType).ToUpper());
}
catch (Exception ex)
{
Logger.LogError($"Couldn't parse fluid volume type [{atmo.clouds.fluidType}]:\n{ex}");
}
fluidCLFV._fluidType = fluidType;
fluidCLFV._allowShipAutoroll = true; fluidCLFV._allowShipAutoroll = true;
fluidCLFV._disableOnStart = false; fluidCLFV._disableOnStart = false;

View File

@ -46,18 +46,7 @@ namespace NewHorizons.Builder.Body
trigger._shape = ringShape; trigger._shape = ringShape;
var sfv = ringVolume.AddComponent<RingFluidVolume>(); var sfv = ringVolume.AddComponent<RingFluidVolume>();
var fluidType = FluidVolume.Type.NONE; sfv._fluidType = ring.fluidType.ConvertToOW();
try
{
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), ring.fluidType).ToUpper());
}
catch (Exception ex)
{
Logger.LogError($"Couldn't parse fluid volume type [{ring.fluidType}]:\n{ex}");
}
sfv._fluidType = fluidType;
sfv._density = 5f; sfv._density = 5f;
ringVolume.SetActive(true); ringVolume.SetActive(true);

View File

@ -2,6 +2,7 @@ using NewHorizons.Components;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using System;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
@ -143,15 +144,9 @@ namespace NewHorizons.Builder.Props
tornadoGO.GetComponentInChildren<CapsuleShape>().enabled = true; tornadoGO.GetComponentInChildren<CapsuleShape>().enabled = true;
// Resize it so the force volume goes all the way up // Resize it so the force volume goes all the way up
switch (downwards) var fluidGO = tornadoGO.transform.Find(downwards ? "MockDownTornado_FluidCenter" : "MockUpTornado_FluidCenter");
{ fluidGO.GetComponent<TornadoFluidVolume>()._fluidType = info.fluidType.ConvertToOW(FluidVolume.Type.CLOUD);
case true: fluidGO.localScale = new Vector3(1, 2f, 1);
tornadoGO.transform.Find("MockDownTornado_FluidCenter").localScale = new Vector3(1, 2f, 1);
break;
default:
tornadoGO.transform.Find("MockUpTornado_FluidCenter").localScale = new Vector3(1, 2f, 1);
break;
}
if (info.tint != null) if (info.tint != null)
{ {
@ -176,6 +171,7 @@ namespace NewHorizons.Builder.Props
hurricaneGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(position.normalized)); hurricaneGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(position.normalized));
var fluidVolume = hurricaneGO.GetComponentInChildren<HurricaneFluidVolume>(); var fluidVolume = hurricaneGO.GetComponentInChildren<HurricaneFluidVolume>();
fluidVolume._fluidType = info.fluidType.ConvertToOW(FluidVolume.Type.CLOUD);
fluidVolume._density = 8; fluidVolume._density = 8;
var effects = hurricaneGO.transform.Find("Effects_GD_Hurricane").gameObject; var effects = hurricaneGO.transform.Find("Effects_GD_Hurricane").gameObject;

View File

@ -9,7 +9,7 @@ using Newtonsoft.Json.Converters;
namespace NewHorizons.External.Modules namespace NewHorizons.External.Modules
{ {
[JsonConverter(typeof(StringEnumConverter))] [JsonConverter(typeof(StringEnumConverter))]
public enum CloudFluidType public enum FluidType
{ {
[EnumMember(Value = @"none")] None = 0, [EnumMember(Value = @"none")] None = 0,
@ -126,7 +126,7 @@ namespace NewHorizons.External.Modules
/// <summary> /// <summary>
/// Fluid type for sounds/effects when colliding with this cloud. /// Fluid type for sounds/effects when colliding with this cloud.
/// </summary> /// </summary>
[DefaultValue("cloud")] public CloudFluidType fluidType = CloudFluidType.Cloud; [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud;
/// <summary> /// <summary>
/// Add lightning to this planet like on Giant's Deep. /// Add lightning to this planet like on Giant's Deep.
@ -202,8 +202,8 @@ namespace NewHorizons.External.Modules
[Obsolete("CloudRamp is deprecated, please use CloudInfo instead")] [Obsolete("CloudRamp is deprecated, please use CloudInfo instead")]
public string cloudRamp; public string cloudRamp;
[Obsolete("CloudFluidType is deprecated, please use CloudInfo instead")] [Obsolete("FluidType is deprecated, please use CloudInfo instead")]
public CloudFluidType fluidType; public FluidType fluidType;
[Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")] [Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")]
public bool useBasicCloudShader; public bool useBasicCloudShader;

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

View File

@ -9,7 +9,7 @@ namespace NewHorizons.External.Modules.VariableSize
/// <summary> /// <summary>
/// Fluid type for sounds/effects when colliding with this ring. /// Fluid type for sounds/effects when colliding with this ring.
/// </summary> /// </summary>
public CloudFluidType fluidType = CloudFluidType.None; public FluidType fluidType = FluidType.None;
/// <summary> /// <summary>
/// Angle between the rings and the equatorial plane of the planet. /// Angle between the rings and the equatorial plane of the planet.

View File

@ -327,7 +327,7 @@
"fluidType": { "fluidType": {
"description": "Fluid type for sounds/effects when colliding with this cloud.", "description": "Fluid type for sounds/effects when colliding with this cloud.",
"default": "cloud", "default": "cloud",
"$ref": "#/definitions/CloudFluidType" "$ref": "#/definitions/FluidType"
}, },
"hasLightning": { "hasLightning": {
"type": "boolean", "type": "boolean",
@ -388,7 +388,7 @@
"basic" "basic"
] ]
}, },
"CloudFluidType": { "FluidType": {
"type": "string", "type": "string",
"description": "", "description": "",
"x-enumNames": [ "x-enumNames": [
@ -1675,6 +1675,11 @@
"type": "number", "type": "number",
"description": "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.", "description": "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.",
"format": "float" "format": "float"
},
"fluidType": {
"description": "Fluid type for sounds/effects when colliding with this tornado.",
"default": "cloud",
"$ref": "#/definitions/FluidType"
} }
} }
}, },
@ -2124,7 +2129,7 @@
}, },
"fluidType": { "fluidType": {
"description": "Fluid type for sounds/effects when colliding with this ring.", "description": "Fluid type for sounds/effects when colliding with this ring.",
"$ref": "#/definitions/CloudFluidType" "$ref": "#/definitions/FluidType"
}, },
"inclination": { "inclination": {
"type": "number", "type": "number",

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -215,5 +216,18 @@ namespace NewHorizons.Utility
Utility.Logger.LogVerbose($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]"); Utility.Logger.LogVerbose($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]");
return xCorrect && yCorrect && zCorrect; return xCorrect && yCorrect && zCorrect;
} }
public static FluidVolume.Type ConvertToOW(this FluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE)
{
try
{
return (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(FluidType), fluidType).ToUpper());
}
catch (Exception ex)
{
Logger.LogError($"Couldn't parse fluid volume type [{fluidType}]:\n{ex}");
return @default;
}
}
} }
} }