Rewrite description, change default radius to 1m, if two conflicting radii are given use whatever is non-default or the ShapeInfo one

This commit is contained in:
xen-42 2025-04-19 20:29:15 -04:00
parent 465a7ac2fb
commit 555418394e
2 changed files with 23 additions and 4 deletions

View File

@ -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<TVolume>(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)
{

View File

@ -19,9 +19,9 @@ namespace NewHorizons.External.Modules.Props
public ShapeType type = ShapeType.Sphere;
/// <summary>
/// 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.
/// </summary>
public float radius = 0.5f;
public float radius = 1f;
/// <summary>
/// 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;
/// <summary>
/// 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.
/// </summary>
public bool? useShape;
}