From c9869171f57da402442b6b548d9eea98115c75d0 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Fri, 12 Dec 2025 00:23:39 +0100 Subject: [PATCH] Core(Box.cs) - Update class to be json serialisable --- PckStudio.Core/Box.cs | 11 +++++++++++ PckStudio.Core/Json/JsonDefaultModel.cs | 20 +------------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/PckStudio.Core/Box.cs b/PckStudio.Core/Box.cs index f2fe5a93..93d85b48 100644 --- a/PckStudio.Core/Box.cs +++ b/PckStudio.Core/Box.cs @@ -1,13 +1,24 @@ using System.Numerics; +using Newtonsoft.Json; namespace PckStudio.Core { public class Box(Vector3 position, Vector3 size, Vector2 uv, float inflate, bool mirror) { + + [JsonProperty("pos", Required = Required.Always)] public Vector3 Position { get; } = position; + + [JsonProperty("size", Required = Required.Always)] public Vector3 Size { get; } = size; + + [JsonProperty("uv", Required = Required.Always)] public Vector2 Uv { get; } = uv; + + [JsonProperty("mirror", NullValueHandling = NullValueHandling.Ignore)] public float Inflate { get; } = inflate; + + [JsonProperty("inflate", NullValueHandling = NullValueHandling.Ignore)] public bool Mirror { get; } = mirror; } } diff --git a/PckStudio.Core/Json/JsonDefaultModel.cs b/PckStudio.Core/Json/JsonDefaultModel.cs index 2fb3aadc..5b337421 100644 --- a/PckStudio.Core/Json/JsonDefaultModel.cs +++ b/PckStudio.Core/Json/JsonDefaultModel.cs @@ -25,24 +25,6 @@ namespace PckStudio.Core.Json public Vector3 Rotation { get; set; } = Vector3.Zero; [JsonProperty("boxes")] - public ModelDefaultBox[] Boxes { get; set; } - } - - public class ModelDefaultBox - { - [JsonProperty("pos")] - public Vector3 Position { get; set; } - - [JsonProperty("size")] - public Vector3 Size { get; set; } - - [JsonProperty("uv")] - public Vector2 Uv { get; set; } - - [JsonProperty("mirror")] - public bool Mirror { get; set; } = false; - - [JsonProperty("inflate")] - public float Inflate { get; set; } = 0f; + public Box[] Boxes { get; set; } } }