Code/CharacterKit/CharacterMarkingData.cs

Data class representing one editable character ink marking. Stores style, region, normalized placement (horizontal, vertical), scale, rotation, spacing, and an Ink MakeupLayerData with defaults. Provides a JsonIgnored Valid boolean computed from placement, catalog lookup and ink validity, and a DeepCopy method.

File AccessNetworking
using System;
using System.Text.Json.Serialization;

namespace CharacterEditor;
/// <summary>One independently editable ink layer. Placement is normalized within a curated surface region.</summary>
public sealed class CharacterMarkingData
{
	public string Style { get; set; } = "crescent";
	public string Region { get; set; } = "face";
	public float Horizontal { get; set; } = .5f;
	public float Vertical { get; set; } = .5f;
	public float Scale { get; set; } = .5f;
	public float Rotation { get; set; } = .5f;
	public float Spacing { get; set; } = .5f;
	public MakeupLayerData Ink { get; set; } = new()
	{
		Red = .1f,
		Green = .12f,
		Blue = .16f,
		Amount = .8f
	};

	[JsonIgnore]
	public bool Valid => MarkingCatalog.ValidPlacement(Style, Region) && Ink?.Valid == true && new[]
	{
		Horizontal,
		Vertical,
		Scale,
		Rotation,
		Spacing
	}.All(x => float.IsFinite(x) && x >= 0 && x <= 1) && (Style != "barbed-band" || (Horizontal == .5f && Rotation == .5f));

	public CharacterMarkingData DeepCopy() => new()
	{
		Style = Style,
		Region = Region,
		Horizontal = Horizontal,
		Vertical = Vertical,
		Scale = Scale,
		Rotation = Rotation,
		Spacing = Spacing,
		Ink = Ink?.DeepCopy()
	};
}