예제 #1
0
        public object Cook(CookingContext parent, string recipePath)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (string.IsNullOrEmpty(recipePath))
            {
                throw new ArgumentNullException("recipePath");
            }

            GameAssetRecipe recipe = BeginCook(parent.BaseDirectory, recipePath);

            if (recipe != null)
            {
                CookingContext context = new CookingContext(parent, recipePath, recipe);
                context.AddDependency(Path.Combine(parent.BaseDirectory, recipePath));
                object asset = recipe.Cook.CookObject(context);
                parent.Reference(context);
                return(asset);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public CookingReport Cook(string baseDirectory, string recipePath)
        {
            if (string.IsNullOrEmpty(baseDirectory))
            {
                throw new ArgumentNullException("baseDirectory");
            }
            if (string.IsNullOrEmpty(recipePath))
            {
                throw new ArgumentNullException("recipePath");
            }

            GameAssetRecipe recipe = BeginCook(baseDirectory, recipePath);

            if (recipe != null)
            {
                CookingContext context = new CookingContext(this, baseDirectory, recipePath, recipe);
                context.AddDependency(Path.Combine(baseDirectory, recipePath));
                context.SetVariable("AssetName", Path.GetFileNameWithoutExtension(recipePath));
                return(new CookingReport(recipe.Cook.CookObject(context), context));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        public void Reference(CookingContext context)
        {
            foreach (string item in context.Dependencies)
            {
                dependencies.Add(item);
            }

            if (context.CanHotload == false)
            {
                CanHotload = false;
            }
        }
예제 #4
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);
        }
예제 #5
0
 public CookingContext(CookingContext parent, string recipePath, GameAssetRecipe recipe)
     : this(parent.Kitchen, parent.Storage, parent, parent.baseDirectory, recipePath, recipe)
 {
 }
예제 #6
0
 public CookingReport(object asset, CookingContext context)
 {
     Asset        = asset;
     Dependencies = context.Dependencies;
     CanHotload   = context.CanHotload;
 }
예제 #7
0
파일: CookingNode.cs 프로젝트: halak/bibim
 public abstract object CookObject(CookingContext context);