Add canonical System.Text.Json converters for every CultMath value type

CultMathJson is the JSON twin of CultMathResolver: vectors, quaternion and
Color32 are objects keyed by field name, matrices are arrays of row objects,
rect is {min,max}. Consumers add them with AddCultMathConverters(); CultLib owns
no JSON options. CultCircle and CultSphere serialize and deserialize through
them, with [JsonConstructor] so the struct constructor is used. The Caching
README documents each MessagePack and JSON shape in one table.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 16:57:31 +02:00
commit 20c30224fd
6 changed files with 290 additions and 0 deletions

View file

@ -12,6 +12,7 @@ namespace GameCult.Geometry
public readonly struct CultCircle : IEquatable<CultCircle>
{
/// <summary>Creates a circle.</summary>
[JsonConstructor]
public CultCircle(float2 center, float radius)
{
if (radius < 0f)
@ -75,6 +76,7 @@ namespace GameCult.Geometry
public readonly struct CultSphere : IEquatable<CultSphere>
{
/// <summary>Creates a sphere.</summary>
[JsonConstructor]
public CultSphere(float3 center, float radius)
{
if (radius < 0f)