Change color to use lowercase properties

This commit is contained in:
Ben C 2022-05-22 19:08:51 -04:00
parent 466df12003
commit 71874669c9
4 changed files with 37 additions and 12 deletions

View File

@ -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
/// <summary>
/// How dense the fog is, if you put fog.
/// </summary>
// FIXME: Min & Max Needed!
[Range(0f, 1f)]
public float fogDensity;
/// <summary>
/// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog.
/// </summary>
[Range(0f, float.MaxValue)]
public float fogSize;
/// <summary>

View File

@ -20,6 +20,7 @@
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<Reference Include="..\NJsonSchema\*.dll" />
<PackageReference Include="HarmonyX" Version="2.10.0" />
<PackageReference Include="OWML" Version="2.3.3" />

View File

@ -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; }
/// <summary>
/// The red component of this colour
/// </summary>
[System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)]
public int r;
public Color32 ToColor32() => new Color32((byte)R, (byte)G, (byte)B, (byte)A);
/// <summary>
/// The green component of this colour
/// </summary>
[System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)]
public int g;
public Color ToColor() => new Color(R / 255f, G / 255f, B / 255f, A / 255f);
/// <summary>
/// The blue component of this colour
/// </summary>
[System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)]
public int b;
/// <summary>
/// The alpha (opacity) component of this colour
/// </summary>
[System.ComponentModel.DataAnnotations.Range(0f, int.MaxValue)]
public int a;
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);
}
}

View File

@ -25,6 +25,7 @@
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
<PackageReference Include="NJsonSchema" Version="10.7.1" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" IncludeAssets="compile" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NewHorizons\NewHorizons.csproj" />