Code/CharacterKit/UnifiedNeckAssets.cs

Utility for loading neck-specific materials/textures for head skins. It caches Material instances keyed by the skin filename (without extension), loads a .vmat asynchronously, validates and marks the color texture as used, and exposes a helper to get the color Texture for a skin.

File Access
using System;
using System.Threading.Tasks;

namespace CharacterEditor;
/// <summary>Head albedos with only the lower-neck band matched to the body atlas.</summary>
public static class UnifiedNeckAssets
{
	static readonly Dictionary<string, Material> carriers = new();
	public static async Task LoadHeadAsync(string skin)
	{
		var id = System.IO.Path.GetFileNameWithoutExtension(skin);
		if (!carriers.TryGetValue(id, out var material))
			material = await Material.LoadAsync($"materials/makeup/neck/{id}.vmat");
		var texture = material?.GetTexture("g_tColor");
		if (texture is null || texture.IsError)
			throw new InvalidOperationException("The matched neck texture is unavailable: " + id);
		texture.MarkUsed(Math.Max(texture.Width, texture.Height));
		carriers[id] = material;
	}

	public static Texture ColorTexture(string skin) => carriers[System.IO.Path.GetFileNameWithoutExtension(skin)].GetTexture("g_tColor");
}