Exemplo n.º 1
0
        private CookingContext(GameAssetKitchen kitchen, GameAssetStorage storage, CookingContext parent, string baseDirectory, string recipePath, GameAssetRecipe recipe)
        {
            int    variableCapacity = 4;
            string directory        = Path.GetDirectoryName(recipePath);

            this.Kitchen             = kitchen;
            this.Storage             = storage;
            this.Parent              = parent;
            this.baseDirectory       = baseDirectory ?? string.Empty;
            this.directory           = directory ?? string.Empty;
            this.variables           = new Dictionary <string, string>(variableCapacity);
            this.expandableVariables = new Dictionary <string, string>(variableCapacity);
            this.readonlyVariables   = new ReadOnlyDictionary <string, string>(this.variables);

            this.dependencies = new SortedSet <string>();
            this.CanHotload   = recipe != null ? recipe.CanHotload : false;

            SetVariable("Directory", directory);
            SetVariable("Path", recipePath);
        }
Exemplo n.º 2
0
        static void Run()
        {
            Trace.WriteLine("================================");
            Trace.WriteLine("Halak Bibim Asset Server");
            Trace.WriteLine("================================");
            Trace.WriteLine(string.Format("Listen Port: {0}", NetworkAssetProvider.DefaultPort));

            var modules      = new GameModuleTree();
            var assetStorage = new GameAssetStorage();
            var assetKitchen = new GameAssetKitchen(assetStorage);
            var assetServer  = new NetworkGameAssetServer(assetKitchen);

            modules.Root.AttachChild(assetStorage);
            modules.Root.AttachChild(assetKitchen);
            modules.Root.AttachChild(assetServer);

            bool closed = false;

            while (closed == false)
            {
                string command;
                if (ConsoleWindow.CommandQueue.TryDequeue(out command))
                {
                    switch (command.ToLower())
                    {
                    case "exit":
                        closed = true;
                        break;
                    }

                    if (command.StartsWith("deletecache "))
                    {
                        int    numberOfDeletedFiles = 0;
                        string path = command.Substring("deletecache ".Length).Trim();
                        try
                        {
                            string[] files = Directory.GetFiles(path, "*." + GameAsset.BinaryFileExtension, SearchOption.AllDirectories);
                            foreach (string item in files)
                            {
                                try
                                {
                                    File.Delete(item);
                                    numberOfDeletedFiles++;
                                }
                                catch (Exception ex)
                                {
                                    Trace.WriteLine(ex);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine(ex);
                        }

                        Trace.TraceInformation("Asset cache deleted ({0}).", numberOfDeletedFiles);
                    }

                    if (command.StartsWith("precook "))
                    {
                        int index1 = "precook ".Length;
                        int index2 = command.IndexOf(">>", index1);
                        if (index2 == -1)
                        {
                            Precook(assetServer, command.Substring(index1).Trim());
                        }
                        else
                        {
                            Precook(assetServer,
                                    command.Substring(index1, index2 - index1).Trim(),
                                    command.Substring(index2 + ">>".Length).Trim());
                        }
                    }

                    if (command.StartsWith("compress "))
                    {
                        int index1 = "compress ".Length;
                        int index2 = command.IndexOf(">>", index1);

                        string directory   = command.Substring(index1, index2 - index1).Trim();
                        string zipFilePath = Path.ChangeExtension(command.Substring(index2 + ">>".Length), "zip").Trim();
                        Compress(directory, zipFilePath);
                    }


                    if (command.StartsWith("precook_and_compress "))
                    {
                        int index1 = "precook_and_compress ".Length;
                        int index2 = command.IndexOf(">>", index1);

                        string directory   = command.Substring(index1, index2 - index1).Trim();
                        string zipFilePath = Path.ChangeExtension(command.Substring(index2 + ">>".Length), "zip").Trim();
                        Precook(assetServer, directory);
                        Compress(directory, zipFilePath);
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(10);
                }
            }

            assetServer.Alive = false;
            Trace.TraceInformation("AssetServer closed.");
        }
Exemplo n.º 3
0
 public GameAssetKitchen(GameAssetStorage storage)
 {
     Storage = storage;
     LoadBuiltinRecipes();
 }