Beispiel #1
0
        public static IEnumerator <object> LoadCorps(bool LoadResources, bool LoadCorps)
        {
            var CustomCorps = GetCCDirectory;

            if (LoadResources)
            {
                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                var cbPng = CustomCorps.GetFiles("*.png", SearchOption.AllDirectories);
                int Count = 0;
                BlockLoader.Timer.Log("Loading json images...");
                yield return(null);

                foreach (FileInfo Png in cbPng)
                {
                    try
                    {
                        Texture2D tex = GameObjectJSON.ImageFromFile(Png.FullName);
                        GameObjectJSON.AddObjectToUserResources <Texture2D>(tex, Png.Name);
                        GameObjectJSON.AddObjectToUserResources <Texture>(tex, Png.Name);
                        GameObjectJSON.AddObjectToUserResources <Sprite>(GameObjectJSON.SpriteFromImage(tex), Png.Name);
                        Count++;
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Could not read image " + Png.Name + "\n at " + Png.FullName + "\n" + E.Message + "\n" + E.StackTrace);
                    }
                    yield return(null);
                }
                BlockLoader.Timer.ReplaceLast("Loaded " + Count.ToString() + " corp images");
                Console.WriteLine($"Took {sw.ElapsedMilliseconds} MS to get corp images");
            }
            if (LoadCorps)
            {
                var ccJson = CustomCorps.GetFiles("*.json", SearchOption.AllDirectories);
                //yield return null;
                foreach (FileInfo Json in ccJson)
                {
                    CreateJSONCorp(Json, Input.GetKey(KeyCode.LeftControl));
                    yield return(null);
                }
            }
            yield break;
        }