diff --git a/NewHorizons/External/Modules/AsteroidBeltModule.cs b/NewHorizons/External/Modules/AsteroidBeltModule.cs
index 96bff135..5a145562 100644
--- a/NewHorizons/External/Modules/AsteroidBeltModule.cs
+++ b/NewHorizons/External/Modules/AsteroidBeltModule.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
namespace NewHorizons.External.Modules
@@ -9,7 +10,7 @@ namespace NewHorizons.External.Modules
///
/// Amount of asteroids to create.
///
- [DefaultValue(-1)] public int amount = -1;
+ [Range(0, 200)] [DefaultValue(-1)] public int amount = -1;
///
/// Angle between the rings and the equatorial plane of the planet.
@@ -19,7 +20,7 @@ namespace NewHorizons.External.Modules
///
/// Lowest distance from the planet asteroids can spawn
///
- public float innerRadius;
+ [Range(0f, double.MaxValue)] public float innerRadius;
///
/// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero.
@@ -29,17 +30,19 @@ namespace NewHorizons.External.Modules
///
/// Maximum size of the asteroids.
///
- [DefaultValue(50)] public float maxSize = 50f;
+ [Range(0f, double.MaxValue)] [DefaultValue(50)]
+ public float maxSize = 50f;
///
/// Minimum size of the asteroids.
///
- [DefaultValue(20)] public float minSize = 20;
+ [Range(0f, double.MaxValue)] [DefaultValue(20)]
+ public float minSize = 20;
///
/// Greatest distance from the planet asteroids can spawn
///
- public float outerRadius;
+ [Range(0f, double.MaxValue)] public float outerRadius;
///
/// How the asteroids are generated
diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs
index 8cbff64a..e7ca0ed9 100644
--- a/NewHorizons/External/Modules/AtmosphereModule.cs
+++ b/NewHorizons/External/Modules/AtmosphereModule.cs
@@ -37,14 +37,12 @@ namespace NewHorizons.External.Modules
///
/// How dense the fog is, if you put fog.
///
- [Range(0f, 1f)]
- public float fogDensity;
+ [Range(0f, 1f)] public float fogDensity;
///
/// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog.
///
- [Range(0f, float.MaxValue)]
- public float fogSize;
+ [Range(0f, double.MaxValue)] public float fogSize;
///
/// Colour of fog on the planet, if you put fog.
diff --git a/NewHorizons/External/Modules/HeightMapModule.cs b/NewHorizons/External/Modules/HeightMapModule.cs
index bb407959..4a40603f 100644
--- a/NewHorizons/External/Modules/HeightMapModule.cs
+++ b/NewHorizons/External/Modules/HeightMapModule.cs
@@ -1,7 +1,10 @@
-using NewHorizons.Utility;
+using System.ComponentModel.DataAnnotations;
+using NewHorizons.Utility;
+using Newtonsoft.Json;
namespace NewHorizons.External.Modules
{
+ [JsonObject]
public class HeightMapModule
{
///
@@ -12,12 +15,12 @@ namespace NewHorizons.External.Modules
///
/// The highest points on your planet will be at this height.
///
- public float maxHeight;
+ [Range(0f, double.MaxValue)] public float maxHeight;
///
/// The lowest points on your planet will be at this height.
///
- public float minHeight;
+ [Range(0f, double.MaxValue)] public float minHeight;
///
/// The scale of the terrain.
diff --git a/NewHorizons/External/Modules/OrbitModule.cs b/NewHorizons/External/Modules/OrbitModule.cs
index 7b255e98..b181ceda 100644
--- a/NewHorizons/External/Modules/OrbitModule.cs
+++ b/NewHorizons/External/Modules/OrbitModule.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using NewHorizons.Components.Orbital;
using NewHorizons.Utility;
@@ -66,6 +67,8 @@ namespace NewHorizons.External.Modules
///
/// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.
///
+ [Range(0f, double.MaxValue)]
+ [DefaultValue(5000f)]
public float SemiMajorAxis { get; set; }
///
@@ -82,7 +85,7 @@ namespace NewHorizons.External.Modules
///
/// At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is.
///
- // FIXME: Needs Min & Max!
+ [Range(0f, 0.9999999999f)]
public float Eccentricity { get; set; }
///
diff --git a/NewHorizons/External/Modules/ProcGenModule.cs b/NewHorizons/External/Modules/ProcGenModule.cs
index 06018b65..4a515774 100644
--- a/NewHorizons/External/Modules/ProcGenModule.cs
+++ b/NewHorizons/External/Modules/ProcGenModule.cs
@@ -1,4 +1,5 @@
-using NewHorizons.Utility;
+using System.ComponentModel.DataAnnotations;
+using NewHorizons.Utility;
using Newtonsoft.Json;
namespace NewHorizons.External.Modules
@@ -7,6 +8,7 @@ namespace NewHorizons.External.Modules
public class ProcGenModule
{
public MColor color;
- public float scale;
+
+ [Range(0, double.MaxValue)] public float scale;
}
}
\ No newline at end of file
diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs
index dfb84e05..910a0eb0 100644
--- a/NewHorizons/External/Modules/PropModule.cs
+++ b/NewHorizons/External/Modules/PropModule.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using NewHorizons.Utility;
using Newtonsoft.Json;
@@ -475,7 +476,7 @@ namespace NewHorizons.External.Modules
///
/// The z euler angle for this arc.
///
- public float zRotation;
+ [Range(0f, 360f)] public float zRotation;
}
[JsonObject]
diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs
index 45da2369..19a86fee 100644
--- a/NewHorizons/External/Modules/SignalModule.cs
+++ b/NewHorizons/External/Modules/SignalModule.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using NewHorizons.Utility;
using Newtonsoft.Json;
@@ -29,7 +30,7 @@ namespace NewHorizons.External.Modules
/// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected"
/// notification.
///
- public float detectionRadius;
+ [Range(0f, double.MaxValue)] public float detectionRadius;
///
/// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`,
@@ -40,7 +41,8 @@ namespace NewHorizons.External.Modules
///
/// How close the player must get to the signal to identify it. This is when you learn its name.
///
- [DefaultValue(10f)] public float identificationRadius = 10f;
+ [DefaultValue(10f)] [Range(0f, double.MaxValue)]
+ public float identificationRadius = 10f;
///
/// Only set to `true` if you are putting this signal inside a cloaking field.
diff --git a/NewHorizons/External/Modules/VariableSize/RingModule.cs b/NewHorizons/External/Modules/VariableSize/RingModule.cs
index 8eac1ed4..e7c21ffe 100644
--- a/NewHorizons/External/Modules/VariableSize/RingModule.cs
+++ b/NewHorizons/External/Modules/VariableSize/RingModule.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using System.ComponentModel.DataAnnotations;
+using Newtonsoft.Json;
namespace NewHorizons.External.Modules.VariableSize
{
@@ -18,7 +19,7 @@ namespace NewHorizons.External.Modules.VariableSize
///
/// Inner radius of the disk
///
- public float innerRadius;
+ [Range(0, double.MaxValue)] public float innerRadius;
///
/// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero.
@@ -28,7 +29,7 @@ namespace NewHorizons.External.Modules.VariableSize
///
/// Outer radius of the disk
///
- public float outerRadius;
+ [Range(0, double.MaxValue)] public float outerRadius;
///
/// Allows the rings to rotate.
diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs
index fb4719f5..e91c70e8 100644
--- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs
+++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using NewHorizons.Utility;
using Newtonsoft.Json;
@@ -36,7 +37,7 @@ namespace NewHorizons.External.Modules.VariableSize
/// Radius of the singularity. Note that this isn't the same as the event horizon, but includes the entire volume that
/// has warped effects in it.
///
- public float size;
+ [Range(0f, double.MaxValue)] public float size;
///
/// If you want a black hole to load a new star system scene, put its name here.
diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs
index 0d1a9342..e3056c44 100644
--- a/NewHorizons/External/Modules/VariableSize/StarModule.cs
+++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using NewHorizons.Utility;
using Newtonsoft.Json;
@@ -31,12 +32,14 @@ namespace NewHorizons.External.Modules.VariableSize
///
/// Radius of the star.
///
- [DefaultValue(2000f)] public float size = 2000f;
+ [DefaultValue(2000f)] [Range(0f, double.MaxValue)]
+ public float size = 2000f;
///
/// Relative strength of the light compared to the sun.
///
- [DefaultValue(1f)] public float solarLuminosity = 1f;
+ [DefaultValue(1f)] [Range(0f, double.MaxValue)]
+ public float solarLuminosity = 1f;
///
/// The tint of the supernova this star creates when it dies.
diff --git a/NewHorizons/Utility/MColor.cs b/NewHorizons/Utility/MColor.cs
index 2212bac0..dd85c08c 100644
--- a/NewHorizons/Utility/MColor.cs
+++ b/NewHorizons/Utility/MColor.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using System.ComponentModel;
+using Newtonsoft.Json;
using UnityEngine;
namespace NewHorizons.Utility
{
@@ -34,7 +35,8 @@ namespace NewHorizons.Utility
///
/// The alpha (opacity) component of this colour
///
- [System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)]
+ [System.ComponentModel.DataAnnotations.Range(0f, 255f)]
+ [DefaultValue(255f)]
public int a;
public Color32 ToColor32() => new Color32((byte)r, (byte)g, (byte)b, (byte)a);
diff --git a/SchemaExporter/SchemaExporter.cs b/SchemaExporter/SchemaExporter.cs
index 3d1ec172..c6437612 100644
--- a/SchemaExporter/SchemaExporter.cs
+++ b/SchemaExporter/SchemaExporter.cs
@@ -4,15 +4,38 @@ using NewHorizons.External.Configs;
using NJsonSchema;
using NJsonSchema.Generation;
-
namespace SchemaExporter;
public static class SchemaExporter
{
- private struct Schema
+ public static void Main(string[] args)
+ {
+ const string folderName = "Schemas";
+
+ Directory.CreateDirectory(folderName);
+ Console.WriteLine("Schema Generator: We're winning!");
+ var settings = new JsonSchemaGeneratorSettings
+ {
+ IgnoreObsoleteProperties = true
+ };
+ Console.WriteLine("Outputting Body Schema");
+ var bodySchema = new Schema("Celestial Body Schema", $"{folderName}/body_schema", settings);
+ bodySchema.Output();
+ Console.WriteLine("Outputting Star System Schema");
+ var systemSchema =
+ new Schema("Star System Schema", $"{folderName}/star_system_schema", settings);
+ systemSchema.Output();
+ Console.WriteLine("Outputting Translation Schema");
+ var translationSchema =
+ new Schema("Translation Schema", $"{folderName}/translation_schema", settings);
+ translationSchema.Output();
+ Console.WriteLine("Done!");
+ }
+
+ private readonly struct Schema
{
private readonly JsonSchemaGeneratorSettings _generatorSettings;
- private string _title;
+ private readonly string _title;
private readonly string _outFileName;
public Schema(string schemaTitle, string fileName, JsonSchemaGeneratorSettings settings)
@@ -21,7 +44,7 @@ public static class SchemaExporter
_outFileName = fileName;
_generatorSettings = settings;
}
-
+
public void Output()
{
File.WriteAllText($"{_outFileName}.json", ToString());
@@ -31,7 +54,7 @@ public static class SchemaExporter
{
return GetJsonSchema().ToJson();
}
-
+
public JsonSchema GetJsonSchema()
{
var schema = JsonSchema.FromType(_generatorSettings);
@@ -39,26 +62,4 @@ public static class SchemaExporter
return schema;
}
}
-
- public static void Main(string[] args)
- {
- const string folderName = "Schemas";
-
- Directory.CreateDirectory(folderName);
- Console.WriteLine("Schema Generator: We're winning!");
- var settings = new JsonSchemaGeneratorSettings
- {
- IgnoreObsoleteProperties = true,
- };
- Console.WriteLine("Outputting Body Schema");
- var bodySchema = new Schema("Celestial Body Schema", "body_schema", settings);
- bodySchema.Output();
- Console.WriteLine("Outputting Star System Schema");
- var systemSchema = new Schema("Star System Schema", "star_system_schema", settings);
- systemSchema.Output();
- Console.WriteLine("Outputting Translation Schema");
- var translationSchema = new Schema("Translation Schema", "translation_schema", settings);
- translationSchema.Output();
- Console.WriteLine("Done!");
- }
}
\ No newline at end of file
diff --git a/SchemaExporter/SchemaExporter.csproj b/SchemaExporter/SchemaExporter.csproj
index 8bc3295a..22ed94f8 100644
--- a/SchemaExporter/SchemaExporter.csproj
+++ b/SchemaExporter/SchemaExporter.csproj
@@ -22,7 +22,6 @@
PreserveNewest
-