From 555418394e1755108568d3d02bea671b22d45a3c Mon Sep 17 00:00:00 2001 From: xen-42 Date: Sat, 19 Apr 2025 20:29:15 -0400 Subject: [PATCH] Rewrite description, change default radius to 1m, if two conflicting radii are given use whatever is non-default or the ShapeInfo one --- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 18 ++++++++++++++++++ .../External/Modules/Props/ShapeInfo.cs | 9 +++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index 061ea559..b9e61394 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules.Volumes.VolumeInfos; using NewHorizons.Utility.OuterWilds; +using NewHorizons.Utility.OWML; using UnityEngine; namespace NewHorizons.Builder.Volumes @@ -9,6 +10,23 @@ namespace NewHorizons.Builder.Volumes { public static TVolume MakeExisting(GameObject go, GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour { + // Backwards compat for the two possible radii settings + // Both radii default to 1 + if (info.shape != null && info.shape.type == External.Modules.Props.ShapeType.Sphere && info.shape.radius != info.radius) + { + // If the info shape radius if the default but the info radius is not the default, use it + if (info.shape.radius == 1f && info.radius != 1f) + { + info.shape.radius = info.radius; + } + } + + // Warning if you set the radius to not be one but are using a non sphere shape + if (info.radius != 1f && (info.shape != null && info.shape.type != External.Modules.Props.ShapeType.Sphere)) + { + NHLogger.LogError($"Volume [{typeof(TVolume).Name}] on [{go.name}] has a radius value set but it's shape is [{info.shape.type}]"); + } + // Respect existing layer if set to a valid volume layer if (go.layer != Layer.AdvancedEffectVolume) { diff --git a/NewHorizons/External/Modules/Props/ShapeInfo.cs b/NewHorizons/External/Modules/Props/ShapeInfo.cs index 7c63eea5..e7a9ae20 100644 --- a/NewHorizons/External/Modules/Props/ShapeInfo.cs +++ b/NewHorizons/External/Modules/Props/ShapeInfo.cs @@ -19,9 +19,9 @@ namespace NewHorizons.External.Modules.Props public ShapeType type = ShapeType.Sphere; /// - /// The radius of the shape or collider. Defaults to 0.5 meters. Only used by spheres, capsules, cylinders, hemispheres, hemicapsules, and rings. + /// The radius of the shape or collider. Defaults to 1 meter. Only used by spheres, capsules, cylinders, hemispheres, hemicapsules, and rings. /// - public float radius = 0.5f; + public float radius = 1f; /// /// The height of the shape or collider. Defaults to 1 meter. Only used by capsules, cylinders, cones, hemicapsules, and rings. @@ -64,8 +64,9 @@ namespace NewHorizons.External.Modules.Props public bool hasCollision = false; /// - /// Whether to explicitly use a shape instead of a collider. Shapes do not support collision and are less performant, but support a wider set of shapes and are required by some components. - /// Defaults to using a shape, unless hasCollision is true where it defaults to using a collider. + /// Setting this to false will force it to use a collider, and setting to true will force it to use a shape. + /// Shapes do not support collision and are less performant, but support a wider set of shapes and are required by some components. + /// If left empty it will defaults to using a shape, unless hasCollision is true in which case it defaults to using a collider. /// public bool? useShape; }