0.2.0-dev Download ZIP
50 lines ·1.2 KB Raw
| 1 | using EvilEngine.Formats; |
| 2 | using EvilEngine.Formats.Animations; |
| 3 | using EvilEngine.Formats.Models; |
| 4 | |
| 5 | namespace EvilEngine.Shared.World; |
| 6 | |
| 7 | public sealed partial class Materialiser |
| 8 | { |
| 9 | public Animation? Animation(ContentId id) |
| 10 | { |
| 11 | var result = conversion.Get(ContentKind.Animation, id); |
| 12 | if (result.Content is not { } content) |
| 13 | { |
| 14 | foreach (var line in result.Diagnostics) |
| 15 | _problems.Enqueue(line); |
| 16 | return null; |
| 17 | } |
| 18 | |
| 19 | try |
| 20 | { |
| 21 | return AnimationFile.ReadAnimation(content.Data, id.ToString()); |
| 22 | } |
| 23 | catch (ModelFormatException error) |
| 24 | { |
| 25 | _problems.Enqueue(error.Message); |
| 26 | return null; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | public Clip? Clip(ContentId id) |
| 31 | { |
| 32 | var result = conversion.Get(ContentKind.Animation, id); |
| 33 | if (result.Content is not { } content) |
| 34 | { |
| 35 | foreach (var line in result.Diagnostics) |
| 36 | _problems.Enqueue(line); |
| 37 | return null; |
| 38 | } |
| 39 | |
| 40 | try |
| 41 | { |
| 42 | return AnimationFile.Read(content.Data, id.ToString()); |
| 43 | } |
| 44 | catch (ModelFormatException error) |
| 45 | { |
| 46 | _problems.Enqueue(error.Message); |
| 47 | return null; |
| 48 | } |
| 49 | } |
| 50 | } |