From 439eebd2b593a5a75887658d3d9c4bece8409df5 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 25 Nov 2022 16:35:59 -0500 Subject: [PATCH] Add oxygen volumes --- .../Builder/Volumes/OxygenVolumeBuilder.cs | 18 ++++++++++++++++++ .../Builder/Volumes/VolumesBuildManager.cs | 7 +++++++ NewHorizons/External/Modules/VolumesModule.cs | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs diff --git a/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs b/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs new file mode 100644 index 00000000..0722fbaf --- /dev/null +++ b/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs @@ -0,0 +1,18 @@ +using NewHorizons.External.Modules; +using UnityEngine; + +namespace NewHorizons.Builder.Volumes +{ + public static class OxygenVolumeBuilder + { + public static OxygenVolume Make(GameObject planetGO, Sector sector, VolumesModule.OxygenVolumeInfo info) + { + var volume = VolumeBuilder.Make(planetGO, sector, info); + + volume._treeVolume = info.treeVolume; + volume._playRefillAudio = info.playRefillAudio; + + return volume; + } + } +} diff --git a/NewHorizons/Builder/Volumes/VolumesBuildManager.cs b/NewHorizons/Builder/Volumes/VolumesBuildManager.cs index fdb2c2f1..e40c2cba 100644 --- a/NewHorizons/Builder/Volumes/VolumesBuildManager.cs +++ b/NewHorizons/Builder/Volumes/VolumesBuildManager.cs @@ -92,6 +92,13 @@ namespace NewHorizons.Builder.Volumes DestructionVolumeBuilder.Make(go, sector, destructionVolume); } } + if (config.Volumes.oxygenVolumes != null) + { + foreach (var oxygenVolume in config.Volumes.oxygenVolumes) + { + OxygenVolumeBuilder.Make(go, sector, oxygenVolume); + } + } } } } diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 473950a3..e252d52f 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -50,6 +50,11 @@ namespace NewHorizons.External.Modules /// public NotificationVolumeInfo[] notificationVolumes; + /// + /// Add oxygen volumes to this planet. + /// + public OxygenVolumeInfo[] oxygenVolumes; + /// /// Add triggers that reveal parts of the ship log on this planet. /// @@ -319,6 +324,20 @@ namespace NewHorizons.External.Modules [EnumMember(Value = @"crushedByElevator")] CrushedByElevator } } + + [JsonObject] + public class OxygenVolumeInfo : VolumeInfo + { + /// + /// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled". + /// + public bool treeVolume; + + /// + /// Whether to play the oxygen tank refill sound or just fill quietly. + /// + [DefaultValue(true)] public bool playRefillAudio = true; + } } [JsonConverter(typeof(StringEnumConverter))]