Throw error when making signal without name or frequency #660

This commit is contained in:
Nick 2023-07-21 19:53:29 -04:00
parent 4565e50d37
commit 53f7bc0b67
2 changed files with 12 additions and 1 deletions

View File

@ -5,6 +5,7 @@ using NewHorizons.Utility.OWML;
using OWML.Common; using OWML.Common;
using OWML.Utils; using OWML.Utils;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
@ -134,6 +135,9 @@ namespace NewHorizons.Builder.Props.Audio
public static GameObject Make(GameObject planetGO, Sector sector, SignalInfo info, IModBehaviour mod) public static GameObject Make(GameObject planetGO, Sector sector, SignalInfo info, IModBehaviour mod)
{ {
if (string.IsNullOrEmpty(info.frequency)) throw new System.Exception("Cannot make a signal without a frequency");
if (string.IsNullOrEmpty(info.name)) throw new System.Exception("Cannot make a signal without a name");
var owAudioSource = GeneralAudioBuilder.Make(planetGO, sector, info, mod); var owAudioSource = GeneralAudioBuilder.Make(planetGO, sector, info, mod);
var signalGO = owAudioSource.gameObject; var signalGO = owAudioSource.gameObject;

View File

@ -224,9 +224,16 @@ namespace NewHorizons.Builder.Props
if (config.Props.signals != null) if (config.Props.signals != null)
{ {
foreach (var signal in config.Props.signals) foreach (var signal in config.Props.signals)
{
try
{ {
SignalBuilder.Make(go, sector, signal, mod); SignalBuilder.Make(go, sector, signal, mod);
} }
catch (Exception ex)
{
NHLogger.LogError($"Couldn't make signal on planet [{config.name}] - {ex}");
}
}
} }
if (config.Props.remotes != null) if (config.Props.remotes != null)
{ {