From 71874669c91c5f626693f713da6ecc6005bf8e33 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 22 May 2022 19:08:51 -0400 Subject: [PATCH] Change color to use lowercase properties --- .../External/Modules/AtmosphereModule.cs | 4 +- NewHorizons/NewHorizons.csproj | 1 + NewHorizons/Utility/MColor.cs | 43 ++++++++++++++----- SchemaExporter/SchemaExporter.csproj | 1 + 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index 543776ea..8cbff64a 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using NewHorizons.Utility; using Newtonsoft.Json; @@ -36,12 +37,13 @@ namespace NewHorizons.External.Modules /// /// How dense the fog is, if you put fog. /// - // FIXME: Min & Max Needed! + [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; /// diff --git a/NewHorizons/NewHorizons.csproj b/NewHorizons/NewHorizons.csproj index 2c5736c7..cb332645 100644 --- a/NewHorizons/NewHorizons.csproj +++ b/NewHorizons/NewHorizons.csproj @@ -20,6 +20,7 @@ 1701;1702;1591 + diff --git a/NewHorizons/Utility/MColor.cs b/NewHorizons/Utility/MColor.cs index 0600f28a..2212bac0 100644 --- a/NewHorizons/Utility/MColor.cs +++ b/NewHorizons/Utility/MColor.cs @@ -1,23 +1,44 @@ -using UnityEngine; +using Newtonsoft.Json; +using UnityEngine; namespace NewHorizons.Utility { + [JsonObject] public class MColor { public MColor(int r, int g, int b, int a) { - R = r; - G = g; - B = b; - A = a; + this.r = r; + this.g = g; + this.b = b; + this.a = a; } - public int R { get; } - public int G { get; } - public int B { get; } - public int A { get; } + /// + /// The red component of this colour + /// + [System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)] + public int r; - public Color32 ToColor32() => new Color32((byte)R, (byte)G, (byte)B, (byte)A); + /// + /// The green component of this colour + /// + [System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)] + public int g; + + /// + /// The blue component of this colour + /// + [System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)] + public int b; + + /// + /// The alpha (opacity) component of this colour + /// + [System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)] + public int a; - public Color ToColor() => new Color(R / 255f, G / 255f, B / 255f, A / 255f); + public Color32 ToColor32() => new Color32((byte)r, (byte)g, (byte)b, (byte)a); + + public Color ToColor() => new Color(r / 255f, g / 255f, b / 255f, a / 255f); } } diff --git a/SchemaExporter/SchemaExporter.csproj b/SchemaExporter/SchemaExporter.csproj index c1610f90..8bc3295a 100644 --- a/SchemaExporter/SchemaExporter.csproj +++ b/SchemaExporter/SchemaExporter.csproj @@ -25,6 +25,7 @@ +