mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add ranges to external classes
This commit is contained in:
parent
71874669c9
commit
7b49dfff55
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NewHorizons.External.Modules
|
namespace NewHorizons.External.Modules
|
||||||
@ -9,7 +10,7 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount of asteroids to create.
|
/// Amount of asteroids to create.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(-1)] public int amount = -1;
|
[Range(0, 200)] [DefaultValue(-1)] public int amount = -1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Angle between the rings and the equatorial plane of the planet.
|
/// Angle between the rings and the equatorial plane of the planet.
|
||||||
@ -19,7 +20,7 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lowest distance from the planet asteroids can spawn
|
/// Lowest distance from the planet asteroids can spawn
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float innerRadius;
|
[Range(0f, double.MaxValue)] public float innerRadius;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero.
|
/// 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
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum size of the asteroids.
|
/// Maximum size of the asteroids.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(50)] public float maxSize = 50f;
|
[Range(0f, double.MaxValue)] [DefaultValue(50)]
|
||||||
|
public float maxSize = 50f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimum size of the asteroids.
|
/// Minimum size of the asteroids.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(20)] public float minSize = 20;
|
[Range(0f, double.MaxValue)] [DefaultValue(20)]
|
||||||
|
public float minSize = 20;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Greatest distance from the planet asteroids can spawn
|
/// Greatest distance from the planet asteroids can spawn
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float outerRadius;
|
[Range(0f, double.MaxValue)] public float outerRadius;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How the asteroids are generated
|
/// How the asteroids are generated
|
||||||
|
|||||||
@ -37,14 +37,12 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// How dense the fog is, if you put fog.
|
/// How dense the fog is, if you put fog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Range(0f, 1f)]
|
[Range(0f, 1f)] public float fogDensity;
|
||||||
public float fogDensity;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog.
|
/// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Range(0f, float.MaxValue)]
|
[Range(0f, double.MaxValue)] public float fogSize;
|
||||||
public float fogSize;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Colour of fog on the planet, if you put fog.
|
/// Colour of fog on the planet, if you put fog.
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
using NewHorizons.Utility;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NewHorizons.External.Modules
|
namespace NewHorizons.External.Modules
|
||||||
{
|
{
|
||||||
|
[JsonObject]
|
||||||
public class HeightMapModule
|
public class HeightMapModule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -12,12 +15,12 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The highest points on your planet will be at this height.
|
/// The highest points on your planet will be at this height.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float maxHeight;
|
[Range(0f, double.MaxValue)] public float maxHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The lowest points on your planet will be at this height.
|
/// The lowest points on your planet will be at this height.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float minHeight;
|
[Range(0f, double.MaxValue)] public float minHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The scale of the terrain.
|
/// The scale of the terrain.
|
||||||
|
|||||||
5
NewHorizons/External/Modules/OrbitModule.cs
vendored
5
NewHorizons/External/Modules/OrbitModule.cs
vendored
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using NewHorizons.Components.Orbital;
|
using NewHorizons.Components.Orbital;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
|
|
||||||
@ -66,6 +67,8 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.
|
/// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Range(0f, double.MaxValue)]
|
||||||
|
[DefaultValue(5000f)]
|
||||||
public float SemiMajorAxis { get; set; }
|
public float SemiMajorAxis { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,7 +85,7 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is.
|
/// At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// FIXME: Needs Min & Max!
|
[Range(0f, 0.9999999999f)]
|
||||||
public float Eccentricity { get; set; }
|
public float Eccentricity { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.Utility;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using NewHorizons.Utility;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NewHorizons.External.Modules
|
namespace NewHorizons.External.Modules
|
||||||
@ -7,6 +8,7 @@ namespace NewHorizons.External.Modules
|
|||||||
public class ProcGenModule
|
public class ProcGenModule
|
||||||
{
|
{
|
||||||
public MColor color;
|
public MColor color;
|
||||||
public float scale;
|
|
||||||
|
[Range(0, double.MaxValue)] public float scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
3
NewHorizons/External/Modules/PropModule.cs
vendored
3
NewHorizons/External/Modules/PropModule.cs
vendored
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -475,7 +476,7 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The z euler angle for this arc.
|
/// The z euler angle for this arc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float zRotation;
|
[Range(0f, 360f)] public float zRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
|||||||
6
NewHorizons/External/Modules/SignalModule.cs
vendored
6
NewHorizons/External/Modules/SignalModule.cs
vendored
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using Newtonsoft.Json;
|
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"
|
/// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected"
|
||||||
/// notification.
|
/// notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float detectionRadius;
|
[Range(0f, double.MaxValue)] public float detectionRadius;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`,
|
/// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`,
|
||||||
@ -40,7 +41,8 @@ namespace NewHorizons.External.Modules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// How close the player must get to the signal to identify it. This is when you learn its name.
|
/// How close the player must get to the signal to identify it. This is when you learn its name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(10f)] public float identificationRadius = 10f;
|
[DefaultValue(10f)] [Range(0f, double.MaxValue)]
|
||||||
|
public float identificationRadius = 10f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only set to `true` if you are putting this signal inside a cloaking field.
|
/// Only set to `true` if you are putting this signal inside a cloaking field.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NewHorizons.External.Modules.VariableSize
|
namespace NewHorizons.External.Modules.VariableSize
|
||||||
{
|
{
|
||||||
@ -18,7 +19,7 @@ namespace NewHorizons.External.Modules.VariableSize
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inner radius of the disk
|
/// Inner radius of the disk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float innerRadius;
|
[Range(0, double.MaxValue)] public float innerRadius;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero.
|
/// 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
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Outer radius of the disk
|
/// Outer radius of the disk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float outerRadius;
|
[Range(0, double.MaxValue)] public float outerRadius;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows the rings to rotate.
|
/// Allows the rings to rotate.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using Newtonsoft.Json;
|
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
|
/// 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.
|
/// has warped effects in it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float size;
|
[Range(0f, double.MaxValue)] public float size;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If you want a black hole to load a new star system scene, put its name here.
|
/// If you want a black hole to load a new star system scene, put its name here.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@ -31,12 +32,14 @@ namespace NewHorizons.External.Modules.VariableSize
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Radius of the star.
|
/// Radius of the star.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(2000f)] public float size = 2000f;
|
[DefaultValue(2000f)] [Range(0f, double.MaxValue)]
|
||||||
|
public float size = 2000f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Relative strength of the light compared to the sun.
|
/// Relative strength of the light compared to the sun.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1f)] public float solarLuminosity = 1f;
|
[DefaultValue(1f)] [Range(0f, double.MaxValue)]
|
||||||
|
public float solarLuminosity = 1f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The tint of the supernova this star creates when it dies.
|
/// The tint of the supernova this star creates when it dies.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using System.ComponentModel;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Utility
|
namespace NewHorizons.Utility
|
||||||
{
|
{
|
||||||
@ -34,7 +35,8 @@ namespace NewHorizons.Utility
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The alpha (opacity) component of this colour
|
/// The alpha (opacity) component of this colour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)]
|
[System.ComponentModel.DataAnnotations.Range(0f, 255f)]
|
||||||
|
[DefaultValue(255f)]
|
||||||
public int a;
|
public int a;
|
||||||
|
|
||||||
public Color32 ToColor32() => new Color32((byte)r, (byte)g, (byte)b, (byte)a);
|
public Color32 ToColor32() => new Color32((byte)r, (byte)g, (byte)b, (byte)a);
|
||||||
|
|||||||
@ -4,15 +4,38 @@ using NewHorizons.External.Configs;
|
|||||||
using NJsonSchema;
|
using NJsonSchema;
|
||||||
using NJsonSchema.Generation;
|
using NJsonSchema.Generation;
|
||||||
|
|
||||||
|
|
||||||
namespace SchemaExporter;
|
namespace SchemaExporter;
|
||||||
|
|
||||||
public static class SchemaExporter
|
public static class SchemaExporter
|
||||||
{
|
{
|
||||||
private struct Schema<T>
|
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<PlanetConfig>("Celestial Body Schema", $"{folderName}/body_schema", settings);
|
||||||
|
bodySchema.Output();
|
||||||
|
Console.WriteLine("Outputting Star System Schema");
|
||||||
|
var systemSchema =
|
||||||
|
new Schema<StarSystemConfig>("Star System Schema", $"{folderName}/star_system_schema", settings);
|
||||||
|
systemSchema.Output();
|
||||||
|
Console.WriteLine("Outputting Translation Schema");
|
||||||
|
var translationSchema =
|
||||||
|
new Schema<TranslationConfig>("Translation Schema", $"{folderName}/translation_schema", settings);
|
||||||
|
translationSchema.Output();
|
||||||
|
Console.WriteLine("Done!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly struct Schema<T>
|
||||||
{
|
{
|
||||||
private readonly JsonSchemaGeneratorSettings _generatorSettings;
|
private readonly JsonSchemaGeneratorSettings _generatorSettings;
|
||||||
private string _title;
|
private readonly string _title;
|
||||||
private readonly string _outFileName;
|
private readonly string _outFileName;
|
||||||
|
|
||||||
public Schema(string schemaTitle, string fileName, JsonSchemaGeneratorSettings settings)
|
public Schema(string schemaTitle, string fileName, JsonSchemaGeneratorSettings settings)
|
||||||
@ -21,7 +44,7 @@ public static class SchemaExporter
|
|||||||
_outFileName = fileName;
|
_outFileName = fileName;
|
||||||
_generatorSettings = settings;
|
_generatorSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Output()
|
public void Output()
|
||||||
{
|
{
|
||||||
File.WriteAllText($"{_outFileName}.json", ToString());
|
File.WriteAllText($"{_outFileName}.json", ToString());
|
||||||
@ -31,7 +54,7 @@ public static class SchemaExporter
|
|||||||
{
|
{
|
||||||
return GetJsonSchema().ToJson();
|
return GetJsonSchema().ToJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonSchema GetJsonSchema()
|
public JsonSchema GetJsonSchema()
|
||||||
{
|
{
|
||||||
var schema = JsonSchema.FromType<T>(_generatorSettings);
|
var schema = JsonSchema.FromType<T>(_generatorSettings);
|
||||||
@ -39,26 +62,4 @@ public static class SchemaExporter
|
|||||||
return schema;
|
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<PlanetConfig>("Celestial Body Schema", "body_schema", settings);
|
|
||||||
bodySchema.Output();
|
|
||||||
Console.WriteLine("Outputting Star System Schema");
|
|
||||||
var systemSchema = new Schema<StarSystemConfig>("Star System Schema", "star_system_schema", settings);
|
|
||||||
systemSchema.Output();
|
|
||||||
Console.WriteLine("Outputting Translation Schema");
|
|
||||||
var translationSchema = new Schema<TranslationConfig>("Translation Schema", "translation_schema", settings);
|
|
||||||
translationSchema.Output();
|
|
||||||
Console.WriteLine("Done!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -22,7 +22,6 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
|
|
||||||
<PackageReference Include="NJsonSchema" Version="10.7.1" />
|
<PackageReference Include="NJsonSchema" Version="10.7.1" />
|
||||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" IncludeAssets="compile" />
|
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" IncludeAssets="compile" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user