diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index c07172d3..2c4f2183 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -2,26 +2,13 @@ using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; +using NewHorizons.External.Modules.SerializableEnums; using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace NewHorizons.External.Modules { - [JsonConverter(typeof(StringEnumConverter))] - public enum FluidType - { - [EnumMember(Value = @"none")] None = 0, - - [EnumMember(Value = @"water")] Water = 1, - - [EnumMember(Value = @"cloud")] Cloud = 2, - - [EnumMember(Value = @"sand")] Sand = 3, - - [EnumMember(Value = @"plasma")] Plasma = 4 - } - [JsonConverter(typeof(StringEnumConverter))] public enum CloudPrefabType { diff --git a/NewHorizons/External/Modules/Props/TornadoInfo.cs b/NewHorizons/External/Modules/Props/TornadoInfo.cs index bff1d71d..59be2128 100644 --- a/NewHorizons/External/Modules/Props/TornadoInfo.cs +++ b/NewHorizons/External/Modules/Props/TornadoInfo.cs @@ -1,3 +1,4 @@ +using NewHorizons.External.Modules.SerializableEnums; using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; diff --git a/NewHorizons/External/Modules/RingModule.cs b/NewHorizons/External/Modules/RingModule.cs index ef60c6cf..c85b4cce 100644 --- a/NewHorizons/External/Modules/RingModule.cs +++ b/NewHorizons/External/Modules/RingModule.cs @@ -1,7 +1,8 @@ -using System; -using System.ComponentModel.DataAnnotations; +using NewHorizons.External.Modules.SerializableEnums; using NewHorizons.External.Modules.VariableSize; using Newtonsoft.Json; +using System; +using System.ComponentModel.DataAnnotations; namespace NewHorizons.External.Modules { diff --git a/NewHorizons/External/Modules/SerializableEnums/FluidType.cs b/NewHorizons/External/Modules/SerializableEnums/FluidType.cs new file mode 100644 index 00000000..b1e6fe12 --- /dev/null +++ b/NewHorizons/External/Modules/SerializableEnums/FluidType.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Modules.SerializableEnums +{ + [JsonConverter(typeof(StringEnumConverter))] + public enum FluidType + { + [EnumMember(Value = @"none")] None = 0, + + [EnumMember(Value = @"water")] Water = 1, + + [EnumMember(Value = @"cloud")] Cloud = 2, + + [EnumMember(Value = @"sand")] Sand = 3, + + [EnumMember(Value = @"plasma")] Plasma = 4 + } +} diff --git a/NewHorizons/External/Modules/Volumes/AudioVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/AudioVolumeInfo.cs new file mode 100644 index 00000000..48803e6f --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/AudioVolumeInfo.cs @@ -0,0 +1,57 @@ +using NewHorizons.External.Modules.Audio; +using Newtonsoft.Json; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace NewHorizons.External.Modules.Volumes +{ + [JsonObject] + public class AudioVolumeInfo : PriorityVolumeInfo + { + /// + /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. + /// + public string audio; + + [DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM; + + /// + /// The audio track of this audio volume + /// + [DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment; + + /// + /// Whether to loop this audio while in this audio volume or just play it once + /// + [DefaultValue(true)] public bool loop = true; + + /// + /// The loudness of the audio + /// + [Range(0f, 1f)] + [DefaultValue(1f)] + public float volume = 1f; + + /// + /// How long it will take to fade this sound in and out when entering/exiting this volume. + /// + [DefaultValue(2f)] + public float fadeSeconds = 2f; + + /// + /// Play the sound instantly without any fading. + /// + public bool noFadeFromBeginning; + + /// + /// Randomize what time the audio starts at. + /// + public bool randomizePlayhead; + + /// + /// Pause the music when exiting the volume. + /// + public bool pauseOnFadeOut; + } + +} diff --git a/NewHorizons/External/Modules/Volumes/DestructionVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/DestructionVolumeInfo.cs new file mode 100644 index 00000000..eb3cd662 --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/DestructionVolumeInfo.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Modules.Volumes +{ + [JsonObject] + public class DestructionVolumeInfo : VanishVolumeInfo + { + /// + /// The type of death the player will have if they enter this volume. + /// + [DefaultValue("default")] public DeathType deathType = DeathType.Default; + } + +} diff --git a/NewHorizons/External/Modules/Volumes/FluidVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/FluidVolumeInfo.cs new file mode 100644 index 00000000..80e89be0 --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/FluidVolumeInfo.cs @@ -0,0 +1,35 @@ +using NewHorizons.External.Modules.SerializableEnums; +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Modules.Volumes +{ + [JsonObject] + public class FluidVolumeInfo : PriorityVolumeInfo + { + /// + /// Density of the fluid. The higher the density, the harder it is to go through this fluid. + /// + [DefaultValue(1.2f)] public float density = 1.2f; + + /// + /// The type of fluid for this volume. + /// + public FluidType type; + + /// + /// Should the player and rafts align to this fluid. + /// + [DefaultValue(true)] public bool alignmentFluid = true; + + /// + /// Should the ship align to the fluid by rolling. + /// + public bool allowShipAutoroll; + + /// + /// Disable this fluid volume immediately? + /// + public bool disableOnStart; + } +} diff --git a/NewHorizons/External/Modules/Volumes/HazardVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/HazardVolumeInfo.cs new file mode 100644 index 00000000..c5ffa978 --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/HazardVolumeInfo.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Modules.Volumes +{ + + [JsonObject] + public class HazardVolumeInfo : VolumeInfo + { + /// + /// The type of hazard for this volume. + /// + [DefaultValue("general")] public HazardType type = HazardType.GENERAL; + + /// + /// The amount of damage you will take per second while inside this volume. + /// + [DefaultValue(10f)] public float damagePerSecond = 10f; + + /// + /// The type of damage you will take when you first touch this volume. + /// + [DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact; + + /// + /// The amount of damage you will take when you first touch this volume. + /// + public float firstContactDamage; + + [JsonConverter(typeof(StringEnumConverter))] + public enum HazardType + { + [EnumMember(Value = @"none")] NONE = 0, + [EnumMember(Value = @"general")] GENERAL = 1, + [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2, + [EnumMember(Value = @"heat")] HEAT = 4, + [EnumMember(Value = @"fire")] FIRE = 8, + [EnumMember(Value = @"sandfall")] SANDFALL = 16, + [EnumMember(Value = @"electricity")] ELECTRICITY = 32, + [EnumMember(Value = @"rapids")] RAPIDS = 64, + [EnumMember(Value = @"riverHeat")] RIVERHEAT = 128, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum InstantDamageType + { + [EnumMember(Value = @"impact")] Impact, + [EnumMember(Value = @"puncture")] Puncture, + [EnumMember(Value = @"electrical")] Electrical + } + } +} diff --git a/NewHorizons/External/Modules/Volumes/NotificationVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/NotificationVolumeInfo.cs new file mode 100644 index 00000000..ddd83290 --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/NotificationVolumeInfo.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Modules.Volumes +{ + [JsonObject] + public class NotificationVolumeInfo : VolumeInfo + { + /// + /// What the notification will show for. + /// + [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; + + /// + /// The notification that will play when you enter this volume. + /// + public NotificationInfo entryNotification; + + /// + /// The notification that will play when you exit this volume. + /// + public NotificationInfo exitNotification; + + + [JsonObject] + public class NotificationInfo + { + /// + /// The message that will be displayed. + /// + public string displayMessage; + + /// + /// The duration this notification will be displayed. + /// + [DefaultValue(5f)] public float duration = 5f; + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NotificationTarget + { + [EnumMember(Value = @"all")] All = 0, + [EnumMember(Value = @"ship")] Ship = 1, + [EnumMember(Value = @"player")] Player = 2, + } + } + +} diff --git a/NewHorizons/External/Modules/Volumes/OxygenVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/OxygenVolumeInfo.cs new file mode 100644 index 00000000..b69d62a2 --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/OxygenVolumeInfo.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Modules.Volumes +{ + [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; + } + +} diff --git a/NewHorizons/External/Modules/Volumes/VanishVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VanishVolumeInfo.cs new file mode 100644 index 00000000..83104719 --- /dev/null +++ b/NewHorizons/External/Modules/Volumes/VanishVolumeInfo.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Modules.Volumes +{ + [JsonObject] + public class VanishVolumeInfo : VolumeInfo + { + /// + /// Whether the bodies will shrink when they enter this volume or just disappear instantly. + /// + [DefaultValue(true)] public bool shrinkBodies = true; + + /// + /// Whether this volume only affects the player and ship. + /// + public bool onlyAffectsPlayerAndShip; + } + +} diff --git a/NewHorizons/External/Modules/Volumes/VolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VolumeInfo.cs index 434a0007..561c2be7 100644 --- a/NewHorizons/External/Modules/Volumes/VolumeInfo.cs +++ b/NewHorizons/External/Modules/Volumes/VolumeInfo.cs @@ -16,220 +16,11 @@ namespace NewHorizons.External.Modules.Volumes [DefaultValue(1f)] public float radius = 1f; } - [JsonObject] - public class AudioVolumeInfo : PriorityVolumeInfo - { - /// - /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. - /// - public string audio; - - [DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM; - - /// - /// The audio track of this audio volume - /// - [DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment; - - /// - /// Whether to loop this audio while in this audio volume or just play it once - /// - [DefaultValue(true)] public bool loop = true; - - /// - /// The loudness of the audio - /// - [Range(0f, 1f)] - [DefaultValue(1f)] - public float volume = 1f; - - /// - /// How long it will take to fade this sound in and out when entering/exiting this volume. - /// - [DefaultValue(2f)] - public float fadeSeconds = 2f; - - /// - /// Play the sound instantly without any fading. - /// - public bool noFadeFromBeginning; - - /// - /// Randomize what time the audio starts at. - /// - public bool randomizePlayhead; - - /// - /// Pause the music when exiting the volume. - /// - public bool pauseOnFadeOut; - } - - [JsonObject] - public class NotificationVolumeInfo : VolumeInfo - { - /// - /// What the notification will show for. - /// - [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; - - /// - /// The notification that will play when you enter this volume. - /// - public NotificationInfo entryNotification; - - /// - /// The notification that will play when you exit this volume. - /// - public NotificationInfo exitNotification; - [JsonObject] - public class NotificationInfo - { - /// - /// The message that will be displayed. - /// - public string displayMessage; - /// - /// The duration this notification will be displayed. - /// - [DefaultValue(5f)] public float duration = 5f; - } - [JsonConverter(typeof(StringEnumConverter))] - public enum NotificationTarget - { - [EnumMember(Value = @"all")] All = 0, - [EnumMember(Value = @"ship")] Ship = 1, - [EnumMember(Value = @"player")] Player = 2, - } - } - [JsonObject] - public class HazardVolumeInfo : VolumeInfo - { - /// - /// The type of hazard for this volume. - /// - [DefaultValue("general")] public HazardType type = HazardType.GENERAL; - - /// - /// The amount of damage you will take per second while inside this volume. - /// - [DefaultValue(10f)] public float damagePerSecond = 10f; - - /// - /// The type of damage you will take when you first touch this volume. - /// - [DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact; - - /// - /// The amount of damage you will take when you first touch this volume. - /// - public float firstContactDamage; - - [JsonConverter(typeof(StringEnumConverter))] - public enum HazardType - { - [EnumMember(Value = @"none")] NONE = 0, - [EnumMember(Value = @"general")] GENERAL = 1, - [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2, - [EnumMember(Value = @"heat")] HEAT = 4, - [EnumMember(Value = @"fire")] FIRE = 8, - [EnumMember(Value = @"sandfall")] SANDFALL = 16, - [EnumMember(Value = @"electricity")] ELECTRICITY = 32, - [EnumMember(Value = @"rapids")] RAPIDS = 64, - [EnumMember(Value = @"riverHeat")] RIVERHEAT = 128, - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum InstantDamageType - { - [EnumMember(Value = @"impact")] Impact, - [EnumMember(Value = @"puncture")] Puncture, - [EnumMember(Value = @"electrical")] Electrical - } - } - - [JsonObject] - public class VanishVolumeInfo : VolumeInfo - { - /// - /// Whether the bodies will shrink when they enter this volume or just disappear instantly. - /// - [DefaultValue(true)] public bool shrinkBodies = true; - - /// - /// Whether this volume only affects the player and ship. - /// - public bool onlyAffectsPlayerAndShip; - } - - [JsonObject] - public class DestructionVolumeInfo : VanishVolumeInfo - { - /// - /// The type of death the player will have if they enter this volume. - /// - [DefaultValue("default")] public DeathType deathType = DeathType.Default; - } - - [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; - } - - [JsonObject] - public class FluidVolumeInfo : PriorityVolumeInfo - { - /// - /// Density of the fluid. The higher the density, the harder it is to go through this fluid. - /// - [DefaultValue(1.2f)] public float density = 1.2f; - - /// - /// The type of fluid for this volume. - /// - public FluidType type; - - /// - /// Should the player and rafts align to this fluid. - /// - [DefaultValue(true)] public bool alignmentFluid = true; - - /// - /// Should the ship align to the fluid by rolling. - /// - public bool allowShipAutoroll; - - /// - /// Disable this fluid volume immediately? - /// - public bool disableOnStart; - - [JsonConverter(typeof(StringEnumConverter))] - public enum FluidType - { - [EnumMember(Value = @"none")] NONE = 0, - [EnumMember(Value = @"air")] AIR, - [EnumMember(Value = @"water")] WATER, - [EnumMember(Value = @"cloud")] CLOUD, - [EnumMember(Value = @"sand")] SAND, - [EnumMember(Value = @"plasma")] PLASMA, - [EnumMember(Value = @"fog")] FOG - } - } [JsonObject] public class ProbeModule diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index ca3a2cf1..c4189727 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -1,5 +1,5 @@ using NewHorizons.External.Configs; -using NewHorizons.External.Modules; +using NewHorizons.External.Modules.SerializableEnums; using Newtonsoft.Json; using OWML.Utils; using System;