namespace EvilEngine.Formats.Records; public sealed record ModelRef(ContentId Model) { public int Skin { get; init; } public string? Body { get; init; } public int Choice(int group) { return Body is { } body && group < body.Length && body[group] is var digit && char.IsAsciiDigit(digit) ? digit - '0' : 0; } } public sealed record PlayerTable { public string? Title { get; init; } public string? Category { get; init; } public bool Fallback { get; init; } } public sealed record PersonRecord(ContentId Id, ModelRef Body) { public string? Name { get; init; } public ModelRef? Hands { get; init; } public PlayerTable? Player { get; init; } public IReadOnlyDictionary Motion { get; init; } = new Dictionary(); public bool Equals(PersonRecord? other) { return other is not null && Id == other.Id && Body == other.Body && Name == other.Name && Hands == other.Hands && Player == other.Player && Motion.Count == other.Motion.Count && Motion.All(pair => other.Motion.TryGetValue(pair.Key, out var id) && id == pair.Value); } public override int GetHashCode() { return HashCode.Combine(Id, Body, Name, Hands, Player, Motion.Count); } public static bool IsSlot(string slot) { return slot.Length > 0 && slot.Split('.').All(part => part.Length > 0 && part.All(c => char.IsAsciiLetterLower(c) || char.IsAsciiDigit(c) || c == '_')); } }