Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
        public void Reference(CookingContext context)
        {
            foreach (string item in context.Dependencies)
            {
                dependencies.Add(item);
            }

            if (context.CanHotload == false)
            {
                CanHotload = false;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 public CookingContext(CookingContext parent, string recipePath, GameAssetRecipe recipe)
     : this(parent.Kitchen, parent.Storage, parent, parent.baseDirectory, recipePath, recipe)
 {
 }
Ejemplo n.º 6
0
 public CookingReport(object asset, CookingContext context)
 {
     Asset        = asset;
     Dependencies = context.Dependencies;
     CanHotload   = context.CanHotload;
 }
Ejemplo n.º 7
0
 public abstract object CookObject(CookingContext context);