public List <SpriteFile> GetAllSpriteFiles(SpriteType type)
        {
            if (!_fallbackSpriteProvider.IsDefaultsPopulated)
            {
                return(new List <SpriteFile>());
            }
            var dict = new Dictionary <SpriteType, Dictionary <int, SpriteFile> >();

            foreach (var i in _fallbackSpriteProvider.GetAllSpriteFiles(type))
            {
                if (!dict.TryGetValue(i.Type, out Dictionary <int, SpriteFile> subDict))
                {
                    subDict      = new Dictionary <int, SpriteFile>();
                    dict[i.Type] = subDict;
                }
                subDict[i.Id] = i;
            }
            string overrideFolder = Path.Combine(_mod.FolderPath, GraphicsInfoResource.Get(type).PngFolder);

            if (Directory.Exists(overrideFolder))
            {
                foreach (var i in Directory.GetFiles(overrideFolder)
                         .Select(i => new SpriteFile(type: type, id: int.Parse(Path.GetFileNameWithoutExtension(i)), file: i, isOverride: true)))
                {
                    dict[i.Type][i.Id] = i;
                }
            }
            return(dict.Values.SelectMany(i => i.Values).ToList());
        }
Beispiel #2
0
        public List <SpriteFile> GetAllSpriteFiles(SpriteType type)
        {
            string dir = Path.Combine(_defaultDataFolder, GraphicsInfoResource.Get(type).PngFolder);

            if (!Directory.Exists(dir))
            {
                return(new List <SpriteFile>());
            }
            return(Directory.GetFiles(dir)
                   .Select(i => new SpriteFile(type, int.Parse(Path.GetFileNameWithoutExtension(i)), i, isOverride: false))
                   .ToList());
        }