0.2.0-dev Download ZIP
54 lines ·1.5 KB Raw
| 1 | namespace EvilEngine.Formats.Records; |
| 2 | |
| 3 | public sealed record ModelRef(ContentId Model) |
| 4 | { |
| 5 | public int Skin { get; init; } |
| 6 | |
| 7 | public string? Body { get; init; } |
| 8 | |
| 9 | public int Choice(int group) |
| 10 | { |
| 11 | return Body is { } body && group < body.Length && body[group] is var digit && char.IsAsciiDigit(digit) |
| 12 | ? digit - '0' |
| 13 | : 0; |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | public sealed record PlayerTable |
| 18 | { |
| 19 | public string? Title { get; init; } |
| 20 | |
| 21 | public string? Category { get; init; } |
| 22 | |
| 23 | public bool Fallback { get; init; } |
| 24 | } |
| 25 | |
| 26 | public sealed record PersonRecord(ContentId Id, ModelRef Body) |
| 27 | { |
| 28 | public string? Name { get; init; } |
| 29 | |
| 30 | public ModelRef? Hands { get; init; } |
| 31 | |
| 32 | public PlayerTable? Player { get; init; } |
| 33 | |
| 34 | public IReadOnlyDictionary<string, ContentId> Motion { get; init; } = new Dictionary<string, ContentId>(); |
| 35 | |
| 36 | public bool Equals(PersonRecord? other) |
| 37 | { |
| 38 | return other is not null && Id == other.Id && Body == other.Body && Name == other.Name && |
| 39 | Hands == other.Hands && |
| 40 | Player == other.Player && Motion.Count == other.Motion.Count && |
| 41 | Motion.All(pair => other.Motion.TryGetValue(pair.Key, out var id) && id == pair.Value); |
| 42 | } |
| 43 | |
| 44 | public override int GetHashCode() |
| 45 | { |
| 46 | return HashCode.Combine(Id, Body, Name, Hands, Player, Motion.Count); |
| 47 | } |
| 48 | |
| 49 | public static bool IsSlot(string slot) |
| 50 | { |
| 51 | return slot.Length > 0 && slot.Split('.').All(part => |
| 52 | part.Length > 0 && part.All(c => char.IsAsciiLetterLower(c) || char.IsAsciiDigit(c) || c == '_')); |
| 53 | } |
| 54 | } |