public static List <T> LoadJsonListFromDirectory <T>(String DirectoryPath, Object Context, Func <T, String> Name)
        {
            var result = new Dictionary <String, T>();

            foreach (var resolvedAssetPath in AssetManager.EnumerateAllFiles(DirectoryPath))
            {
                try
                {
                    var item = LoadJsonFromAbsolutePath <T>(resolvedAssetPath, Context);
                    var name = Name(item);

                    if (!result.ContainsKey(name))
                    {
                        result.Add(name, item);
                    }
                }
                catch (Exception e)
                {
                    DwarfGame.LogSentryBreadcrumb("AssetManager", String.Format("Could not load json: {0} msg: {1}", resolvedAssetPath, e.Message), SharpRaven.Data.BreadcrumbLevel.Error);
                    Console.WriteLine("Error loading asset {0}: {1}", resolvedAssetPath, e.Message);
                }
            }

            return(new List <T>(result.Values));
        }
Beispiel #2
0
        public static Palette ExtractPaletteFromDirectoryRecursive(String Path)
        {
            var r = new Palette();

            foreach (var file in AssetManager.EnumerateAllFiles(Path))
            {
                var texture = AssetManager.RawLoadTexture(file);
                if (texture != null)
                {
                    r.AddRange(OptimizedPaletteFromMemoryTexture(MemoryTextureFromTexture2D(texture)));
                }
            }
            r = new Palette(r.Distinct());
            r.Sort((a, b) => (int)a.PackedValue - (int)b.PackedValue);
            return(r);
        }
Beispiel #3
0
        public static List <T> LoadJsonListFromDirectory <T>(String DirectoryPath, Object Context, Func <T, String> Name)
        {
            var result = new Dictionary <String, T>();

            foreach (var resolvedAssetPath in AssetManager.EnumerateAllFiles(DirectoryPath))
            {
                var item = LoadJsonFromAbsolutePath <T>(resolvedAssetPath, Context);
                var name = Name(item);
                if (!result.ContainsKey(name))
                {
                    result.Add(name, item);
                }
            }

            return(new List <T>(result.Values));
        }