summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Content.Pipeline/Animations/AstridAnimatorProcessor.cs
blob: e22d65b349731d3dd9f7e4b5e7a6d8db1435b87b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace MonoGame.Extended.Content.Pipeline.Animations
{
    [ContentProcessor(DisplayName = "Astrid Animator Processor - MonoGame.Extended")]
    public class AstridAnimatorProcessor :
        ContentProcessor<ContentImporterResult<AstridAnimatorFile>, AstridAnimatorProcessorResult>
    {
        public override AstridAnimatorProcessorResult Process(ContentImporterResult<AstridAnimatorFile> input,
            ContentProcessorContext context)
        {
            var data = input.Data;
            var directory = Path.GetDirectoryName(input.FilePath);
            var frames = data.Animations
                .SelectMany(i => i.Frames)
                .OrderBy(f => f)
                .Distinct();

            return new AstridAnimatorProcessorResult(directory, data, frames);
        }
    }
}