Make VanishVolumes never use shapes

This commit is contained in:
xen-42 2025-04-25 11:48:48 -04:00
parent 96e32001ee
commit b20cda59e9
4 changed files with 16 additions and 2 deletions

View File

@ -13,7 +13,6 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static NewHorizons.External.Modules.BrambleModule;
using static NewHorizons.External.Modules.SignalModule;
namespace NewHorizons.Builder.Props
{

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
@ -7,6 +8,17 @@ namespace NewHorizons.Builder.Volumes
{
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VanishVolumeInfo info) where TVolume : VanishVolume
{
if (info.shape != null && (info.shape?.type != External.Modules.Props.ShapeType.Sphere || info.shape?.useShape == false))
{
NHLogger.LogError($"Destruction/VanishVolumes only support sphere colliders. Affects planet [{planetGO.name}]");
}
// VanishVolume is only compatible with sphere colliders
// If info.shape was null, it will still default to using info.radius, just make sure it does so with a collider
info.shape ??= new();
info.shape.useShape = false;
info.shape.type = External.Modules.Props.ShapeType.Sphere;
var volume = VolumeBuilder.Make<TVolume>(planetGO, sector, info);
var collider = volume.gameObject.GetComponent<SphereCollider>();

View File

@ -45,7 +45,7 @@ namespace NewHorizons.Builder.Volumes
return volume;
}
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too.
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour // Could be BaseVolume but I need to create vanilla volumes too.
{
var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info);
return MakeExisting<TVolume>(go, planetGO, sector, info);

View File

@ -4,6 +4,9 @@ using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
/// <summary>
/// Note: Only sphere colliders work on vanish volumes!
/// </summary>
[JsonObject]
public class VanishVolumeInfo : VolumeInfo
{