Split up more volumes, move FluidType enum

This commit is contained in:
Nick 2023-03-25 14:09:54 -04:00
parent 7d384b7067
commit ce7ef3ee93
13 changed files with 277 additions and 226 deletions

View File

@ -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
{

View File

@ -1,3 +1,4 @@
using NewHorizons.External.Modules.SerializableEnums;
using NewHorizons.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

View File

@ -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
{

View File

@ -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
}
}

View File

@ -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
{
/// <summary>
/// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string audio;
[DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM;
/// <summary>
/// The audio track of this audio volume
/// </summary>
[DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment;
/// <summary>
/// Whether to loop this audio while in this audio volume or just play it once
/// </summary>
[DefaultValue(true)] public bool loop = true;
/// <summary>
/// The loudness of the audio
/// </summary>
[Range(0f, 1f)]
[DefaultValue(1f)]
public float volume = 1f;
/// <summary>
/// How long it will take to fade this sound in and out when entering/exiting this volume.
/// </summary>
[DefaultValue(2f)]
public float fadeSeconds = 2f;
/// <summary>
/// Play the sound instantly without any fading.
/// </summary>
public bool noFadeFromBeginning;
/// <summary>
/// Randomize what time the audio starts at.
/// </summary>
public bool randomizePlayhead;
/// <summary>
/// Pause the music when exiting the volume.
/// </summary>
public bool pauseOnFadeOut;
}
}

View File

@ -0,0 +1,15 @@
using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes
{
[JsonObject]
public class DestructionVolumeInfo : VanishVolumeInfo
{
/// <summary>
/// The type of death the player will have if they enter this volume.
/// </summary>
[DefaultValue("default")] public DeathType deathType = DeathType.Default;
}
}

View File

@ -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
{
/// <summary>
/// Density of the fluid. The higher the density, the harder it is to go through this fluid.
/// </summary>
[DefaultValue(1.2f)] public float density = 1.2f;
/// <summary>
/// The type of fluid for this volume.
/// </summary>
public FluidType type;
/// <summary>
/// Should the player and rafts align to this fluid.
/// </summary>
[DefaultValue(true)] public bool alignmentFluid = true;
/// <summary>
/// Should the ship align to the fluid by rolling.
/// </summary>
public bool allowShipAutoroll;
/// <summary>
/// Disable this fluid volume immediately?
/// </summary>
public bool disableOnStart;
}
}

View File

@ -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
{
/// <summary>
/// The type of hazard for this volume.
/// </summary>
[DefaultValue("general")] public HazardType type = HazardType.GENERAL;
/// <summary>
/// The amount of damage you will take per second while inside this volume.
/// </summary>
[DefaultValue(10f)] public float damagePerSecond = 10f;
/// <summary>
/// The type of damage you will take when you first touch this volume.
/// </summary>
[DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact;
/// <summary>
/// The amount of damage you will take when you first touch this volume.
/// </summary>
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
}
}
}

View File

@ -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
{
/// <summary>
/// What the notification will show for.
/// </summary>
[DefaultValue("all")] public NotificationTarget target = NotificationTarget.All;
/// <summary>
/// The notification that will play when you enter this volume.
/// </summary>
public NotificationInfo entryNotification;
/// <summary>
/// The notification that will play when you exit this volume.
/// </summary>
public NotificationInfo exitNotification;
[JsonObject]
public class NotificationInfo
{
/// <summary>
/// The message that will be displayed.
/// </summary>
public string displayMessage;
/// <summary>
/// The duration this notification will be displayed.
/// </summary>
[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,
}
}
}

View File

@ -0,0 +1,20 @@
using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes
{
[JsonObject]
public class OxygenVolumeInfo : VolumeInfo
{
/// <summary>
/// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled".
/// </summary>
public bool treeVolume;
/// <summary>
/// Whether to play the oxygen tank refill sound or just fill quietly.
/// </summary>
[DefaultValue(true)] public bool playRefillAudio = true;
}
}

View File

@ -0,0 +1,20 @@
using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes
{
[JsonObject]
public class VanishVolumeInfo : VolumeInfo
{
/// <summary>
/// Whether the bodies will shrink when they enter this volume or just disappear instantly.
/// </summary>
[DefaultValue(true)] public bool shrinkBodies = true;
/// <summary>
/// Whether this volume only affects the player and ship.
/// </summary>
public bool onlyAffectsPlayerAndShip;
}
}

View File

@ -16,220 +16,11 @@ namespace NewHorizons.External.Modules.Volumes
[DefaultValue(1f)] public float radius = 1f;
}
[JsonObject]
public class AudioVolumeInfo : PriorityVolumeInfo
{
/// <summary>
/// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string audio;
[DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM;
/// <summary>
/// The audio track of this audio volume
/// </summary>
[DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment;
/// <summary>
/// Whether to loop this audio while in this audio volume or just play it once
/// </summary>
[DefaultValue(true)] public bool loop = true;
/// <summary>
/// The loudness of the audio
/// </summary>
[Range(0f, 1f)]
[DefaultValue(1f)]
public float volume = 1f;
/// <summary>
/// How long it will take to fade this sound in and out when entering/exiting this volume.
/// </summary>
[DefaultValue(2f)]
public float fadeSeconds = 2f;
/// <summary>
/// Play the sound instantly without any fading.
/// </summary>
public bool noFadeFromBeginning;
/// <summary>
/// Randomize what time the audio starts at.
/// </summary>
public bool randomizePlayhead;
/// <summary>
/// Pause the music when exiting the volume.
/// </summary>
public bool pauseOnFadeOut;
}
[JsonObject]
public class NotificationVolumeInfo : VolumeInfo
{
/// <summary>
/// What the notification will show for.
/// </summary>
[DefaultValue("all")] public NotificationTarget target = NotificationTarget.All;
/// <summary>
/// The notification that will play when you enter this volume.
/// </summary>
public NotificationInfo entryNotification;
/// <summary>
/// The notification that will play when you exit this volume.
/// </summary>
public NotificationInfo exitNotification;
[JsonObject]
public class NotificationInfo
{
/// <summary>
/// The message that will be displayed.
/// </summary>
public string displayMessage;
/// <summary>
/// The duration this notification will be displayed.
/// </summary>
[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
{
/// <summary>
/// The type of hazard for this volume.
/// </summary>
[DefaultValue("general")] public HazardType type = HazardType.GENERAL;
/// <summary>
/// The amount of damage you will take per second while inside this volume.
/// </summary>
[DefaultValue(10f)] public float damagePerSecond = 10f;
/// <summary>
/// The type of damage you will take when you first touch this volume.
/// </summary>
[DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact;
/// <summary>
/// The amount of damage you will take when you first touch this volume.
/// </summary>
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
{
/// <summary>
/// Whether the bodies will shrink when they enter this volume or just disappear instantly.
/// </summary>
[DefaultValue(true)] public bool shrinkBodies = true;
/// <summary>
/// Whether this volume only affects the player and ship.
/// </summary>
public bool onlyAffectsPlayerAndShip;
}
[JsonObject]
public class DestructionVolumeInfo : VanishVolumeInfo
{
/// <summary>
/// The type of death the player will have if they enter this volume.
/// </summary>
[DefaultValue("default")] public DeathType deathType = DeathType.Default;
}
[JsonObject]
public class OxygenVolumeInfo : VolumeInfo
{
/// <summary>
/// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled".
/// </summary>
public bool treeVolume;
/// <summary>
/// Whether to play the oxygen tank refill sound or just fill quietly.
/// </summary>
[DefaultValue(true)] public bool playRefillAudio = true;
}
[JsonObject]
public class FluidVolumeInfo : PriorityVolumeInfo
{
/// <summary>
/// Density of the fluid. The higher the density, the harder it is to go through this fluid.
/// </summary>
[DefaultValue(1.2f)] public float density = 1.2f;
/// <summary>
/// The type of fluid for this volume.
/// </summary>
public FluidType type;
/// <summary>
/// Should the player and rafts align to this fluid.
/// </summary>
[DefaultValue(true)] public bool alignmentFluid = true;
/// <summary>
/// Should the ship align to the fluid by rolling.
/// </summary>
public bool allowShipAutoroll;
/// <summary>
/// Disable this fluid volume immediately?
/// </summary>
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

View File

@ -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;