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); } }
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); } }
public void Reference(CookingContext context) { foreach (string item in context.Dependencies) { dependencies.Add(item); } if (context.CanHotload == false) { CanHotload = false; } }
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); }
public CookingContext(CookingContext parent, string recipePath, GameAssetRecipe recipe) : this(parent.Kitchen, parent.Storage, parent, parent.baseDirectory, recipePath, recipe) { }
public CookingReport(object asset, CookingContext context) { Asset = asset; Dependencies = context.Dependencies; CanHotload = context.CanHotload; }
public abstract object CookObject(CookingContext context);