void ProcessResources(RMResourceSet resources, BuildResourceSet report_resources, BuildResourceSet required_resources = null) { var reslist = resources.resources.Keys.ToList(); foreach (string res in reslist) { double amount = resources.ResourceAmount(res); var recipe = ELRecipeDatabase.ResourceRecipe(res); if (recipe != null) { double density = ELRecipeDatabase.ResourceDensity(res); double mass = amount * density; recipe = recipe.Bake(mass); foreach (var ingredient in recipe.ingredients) { var br = new BuildResource(ingredient); var resset = report_resources; if (required_resources != null) { resset = required_resources; } resset.Add(br); } } else { var br = new BuildResource(res, amount); report_resources.Add(br); } } }
void ProcessIngredient(Ingredient ingredient, BuildResourceSet rd, bool xfer) { var res = ingredient.name; Recipe recipe = null; // If the resource is being transfered from a tank (rather than // coming from the part body itself), then a transfer recipe will // override a recycle recipe if (xfer) { recipe = ELRecipeDatabase.TransferRecipe(res); } if (recipe == null) { recipe = ELRecipeDatabase.RecycleRecipe(res); } if (recipe != null) { recipe = recipe.Bake(ingredient.ratio); foreach (var ing in recipe.ingredients) { if (ing.isReal) { var br = new BuildResource(ing); rd.Add(br); } } } else { if (ELRecipeDatabase.ResourceRecipe(res) != null) { } else { if (ingredient.isReal) { var br = new BuildResource(ingredient); rd.Add(br); } } } }
void ExpandResourceRecipes(Recipe recipe) { for (int i = recipe.ingredients.Count; i-- > 0;) { Ingredient ingredient = recipe.ingredients[i]; if (!ResourceDefined(ingredient.name)) { var resRecipe = ELRecipeDatabase.ResourceRecipe(ingredient.name); if (resRecipe != null) { resRecipe = resRecipe.Bake(ingredient.ratio); resRecipe.ingredients[0].heat = ingredient.heat; recipe.ingredients.RemoveAt(i); for (int j = resRecipe.ingredients.Count; j-- > 0;) { recipe.AddIngredient(resRecipe.ingredients[j]); } } } } }