From 8d78c49c64f4f263bf0120e296a4ed7e9f3ce9d2 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 25 Aug 2022 19:29:06 -0400 Subject: [PATCH] Move TimeValuePair to Utility, Ring no longer inherits from VariableSizeModule Also migrated the old value for curve to scaleCurve. --- NewHorizons/Builder/Body/ProxyBuilder.cs | 4 ++-- NewHorizons/Builder/Body/RingBuilder.cs | 1 - NewHorizons/Builder/Body/SingularityBuilder.cs | 4 ++-- .../Components/RingOpacityController.cs | 3 ++- .../SizeControllers/SizeController.cs | 3 ++- NewHorizons/External/Configs/PlanetConfig.cs | 6 ++++++ .../Modules/{VariableSize => }/RingModule.cs | 11 +++++++++-- .../Modules/VariableSize/VariableSizeModule.cs | 17 ++--------------- NewHorizons/Handlers/TitleSceneHandler.cs | 1 - NewHorizons/Utility/TimeValuePair.cs | 18 ++++++++++++++++++ 10 files changed, 43 insertions(+), 25 deletions(-) rename NewHorizons/External/Modules/{VariableSize => }/RingModule.cs (86%) create mode 100644 NewHorizons/Utility/TimeValuePair.cs diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 87888e45..077a4f8f 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -188,7 +188,7 @@ namespace NewHorizons.Builder.Body newProxy.SetActive(true); } - private static GameObject AddColouredSphere(GameObject rootObj, float size, VariableSizeModule.TimeValuePair[] curve, Color color) + private static GameObject AddColouredSphere(GameObject rootObj, float size, TimeValuePair[] curve, Color color) { GameObject sphereGO = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphereGO.transform.name = "ProxySphere"; @@ -206,7 +206,7 @@ namespace NewHorizons.Builder.Body return sphereGO; } - private static void AddSizeController(GameObject go, VariableSizeModule.TimeValuePair[] curve, float size) + private static void AddSizeController(GameObject go, TimeValuePair[] curve, float size) { var sizeController = go.AddComponent(); sizeController.SetScaleCurve(curve); diff --git a/NewHorizons/Builder/Body/RingBuilder.cs b/NewHorizons/Builder/Body/RingBuilder.cs index 5a5cb311..e4e93087 100644 --- a/NewHorizons/Builder/Body/RingBuilder.cs +++ b/NewHorizons/Builder/Body/RingBuilder.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using NewHorizons.External.Modules; using UnityEngine; using Logger = NewHorizons.Utility.Logger; -using NewHorizons.External.Modules.VariableSize; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 1676879a..bbd3c761 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -95,7 +95,7 @@ namespace NewHorizons.Builder.Body } public static GameObject MakeBlackHole(GameObject planetGO, Sector sector, Vector3 localPosition, float size, - bool hasDestructionVolume, string targetSolarSystem, VariableSizeModule.TimeValuePair[] curve, bool makeAudio = true) + bool hasDestructionVolume, string targetSolarSystem, TimeValuePair[] curve, bool makeAudio = true) { var blackHole = new GameObject("BlackHole"); blackHole.SetActive(false); @@ -181,7 +181,7 @@ namespace NewHorizons.Builder.Body } public static GameObject MakeWhiteHole(GameObject planetGO, Sector sector, OWRigidbody OWRB, Vector3 localPosition, float size, - VariableSizeModule.TimeValuePair[] curve, bool makeZeroGVolume = true) + TimeValuePair[] curve, bool makeZeroGVolume = true) { var whiteHole = new GameObject("WhiteHole"); whiteHole.SetActive(false); diff --git a/NewHorizons/Components/RingOpacityController.cs b/NewHorizons/Components/RingOpacityController.cs index 3823529c..fde75452 100644 --- a/NewHorizons/Components/RingOpacityController.cs +++ b/NewHorizons/Components/RingOpacityController.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules.VariableSize; +using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Components @@ -35,7 +36,7 @@ namespace NewHorizons.Components _meshRenderer.material.SetFloat(Alpha, CurrentOpacity); } - public void SetOpacityCurve(VariableSizeModule.TimeValuePair[] curve) + public void SetOpacityCurve(TimeValuePair[] curve) { opacityCurve = new AnimationCurve(); foreach (var pair in curve) diff --git a/NewHorizons/Components/SizeControllers/SizeController.cs b/NewHorizons/Components/SizeControllers/SizeController.cs index 83702bec..9839b2a7 100644 --- a/NewHorizons/Components/SizeControllers/SizeController.cs +++ b/NewHorizons/Components/SizeControllers/SizeController.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules.VariableSize; +using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Components.SizeControllers { @@ -22,7 +23,7 @@ namespace NewHorizons.Components.SizeControllers base.transform.localScale = Vector3.one * CurrentScale; } - public void SetScaleCurve(VariableSizeModule.TimeValuePair[] curve) + public void SetScaleCurve(TimeValuePair[] curve) { scaleCurve = new AnimationCurve(); foreach (var pair in curve) diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 057aba8f..80d065a6 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -362,6 +362,12 @@ namespace NewHorizons.External.Configs if (!string.IsNullOrEmpty(Cloak.audioClip)) Cloak.audio = Cloak.audioClip; if (!string.IsNullOrEmpty(Cloak.audioFilePath)) Cloak.audio = Cloak.audioFilePath; } + + // Rings are no longer variable size module + if (Ring != null) + { + if (Ring.curve != null) Ring.scaleCurve = Ring.curve; + } } } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/RingModule.cs b/NewHorizons/External/Modules/RingModule.cs similarity index 86% rename from NewHorizons/External/Modules/VariableSize/RingModule.cs rename to NewHorizons/External/Modules/RingModule.cs index 80f004e3..dc8e6fad 100644 --- a/NewHorizons/External/Modules/VariableSize/RingModule.cs +++ b/NewHorizons/External/Modules/RingModule.cs @@ -1,10 +1,12 @@ +using System; using System.ComponentModel.DataAnnotations; +using NewHorizons.Utility; using Newtonsoft.Json; -namespace NewHorizons.External.Modules.VariableSize +namespace NewHorizons.External.Modules { [JsonObject] - public class RingModule : VariableSizeModule + public class RingModule { /// /// Fluid type for sounds/effects when colliding with this ring. @@ -46,6 +48,11 @@ namespace NewHorizons.External.Modules.VariableSize /// public bool unlit; + #region Obsolete + [Obsolete("curve is deprecated, please use scaleCurve instead")] + public TimeValuePair[] curve; + #endregion + /// /// Scale rings over time. Optional. Value between 0-1, time is in minutes. /// diff --git a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs index d220a15d..92ba2dd1 100644 --- a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs +++ b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs @@ -1,3 +1,4 @@ +using NewHorizons.Utility; using Newtonsoft.Json; using UnityEngine; @@ -7,22 +8,8 @@ namespace NewHorizons.External.Modules.VariableSize public class VariableSizeModule { /// - /// Scale this module over time + /// Scale this object over time /// public TimeValuePair[] curve; - - [JsonObject] - public class TimeValuePair - { - /// - /// A specific point in time - /// - public float time; - - /// - /// The value for this point in time - /// - public float value; - } } } \ No newline at end of file diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index 42b6e6a4..b4fb22dc 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; using Logger = NewHorizons.Utility.Logger; -using NewHorizons.External.Modules.VariableSize; namespace NewHorizons.Handlers { diff --git a/NewHorizons/Utility/TimeValuePair.cs b/NewHorizons/Utility/TimeValuePair.cs new file mode 100644 index 00000000..acacda16 --- /dev/null +++ b/NewHorizons/Utility/TimeValuePair.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace NewHorizons.Utility +{ + [JsonObject] + public class TimeValuePair + { + /// + /// A specific point in time + /// + public float time; + + /// + /// The value for this point in time + /// + public float value; + } +}