Exemplo n.º 1
0
        private static void Precook(GameAssetServer assetServer, string directory, string assetPath)
        {
            try
            {
                assetServer.Precook(directory, assetPath);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }

            while (assetServer.IsBusy)
            {
                Thread.Sleep(100);
            }
        }
Exemplo n.º 2
0
        private static void Precook(GameAssetServer assetServer, string path)
        {
            try
            {
                string[] files         = Directory.GetFiles(path, "*." + GameAsset.TextFileExtension, SearchOption.AllDirectories);
                int      countingIndex = files.Length / 10;
                for (int i = 0, k = 0; i < files.Length; i++, k++)
                {
                    try
                    {
                        string assetPath = files[i].Substring(path.Length + 1);

                        if (i == files.Length - 1)
                        {
                            assetServer.Precook(path, assetPath, (_, __, ___) => { Trace.TraceInformation("LAST COOKING!"); }, () => { Trace.TraceInformation("LAST COOKING!"); });
                        }
                        else if (k == countingIndex)
                        {
                            k = 0;
                            int count = i;
                            assetServer.Precook(path, assetPath, (_, __, ___) => { Trace.TraceInformation("({0}/{1})", count, files.Length); }, () => { Trace.TraceInformation("({0}/{1})", count, files.Length); });
                        }
                        else
                        {
                            assetServer.Precook(path, assetPath);
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }

            while (assetServer.IsBusy)
            {
                Thread.Sleep(100);
            }
        }