void ProcessResources(VesselResources 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 = ExRecipeDatabase.ResourceRecipe(res); if (recipe != null) { double density = ExRecipeDatabase.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 ProcessResource(VesselResources vr, string res, BuildResourceSet rd, bool xfer) { var amount = vr.ResourceAmount(res); var mass = amount * ExRecipeDatabase.ResourceDensity(res); ProcessIngredient(new Ingredient(res, mass), rd, xfer); }
void ProcessResources (VesselResources 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 = ExRecipeDatabase.ResourceRecipe (res); if (recipe != null) { double density = ExRecipeDatabase.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); } } }
List <BuildResource> PartResources(Part p) { Debug.Log(String.Format("[EL RSM] PartResources: {0} {1}", p.name, p.CrewCapacity)); var bc = new BuildCost(); bc.addPart(p); var rd = new BuildResourceSet(); bool xfer = true; VesselResources.ResourceProcessor process = delegate(VesselResources vr, string res) { ProcessResource(vr, res, rd, xfer); }; bc.resources.Process(process); var reslist = rd.Values; rd.Clear(); bc.container.Process(process); reslist.AddRange(rd.Values); rd.Clear(); xfer = false; bc.hullResoures.Process(process); reslist.AddRange(rd.Values); if (p.CrewCapacity > 0 && !p.name.Contains("kerbalEVA")) { rd.Clear(); for (int i = 0; i < p.protoModuleCrew.Count; i++) { var crew = p.protoModuleCrew[i]; ProcessKerbal(crew, rd); } reslist.AddRange(rd.Values); } return(reslist); }
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 = ExRecipeDatabase.TransferRecipe(res); } if (recipe == null) { recipe = ExRecipeDatabase.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 (ExRecipeDatabase.ResourceRecipe(res) != null) { } else { if (ingredient.isReal) { var br = new BuildResource(ingredient); rd.Add(br); } } } }
void ProcessKerbal(ProtoCrewMember crew, BuildResourceSet rd) { string message = crew.name + " was mulched"; ScreenMessages.PostScreenMessage(message, 30.0f, ScreenMessageStyle.UPPER_CENTER); var part_recipe = ExRecipeDatabase.KerbalRecipe(); if (part_recipe == null) { return; } var kerbal_recipe = part_recipe.Bake(0.09375); //FIXME for (int i = 0; i < kerbal_recipe.ingredients.Count; i++) { var ingredient = kerbal_recipe.ingredients[i]; ProcessIngredient(ingredient, rd, false); } foreach (var br in rd.Values) { Debug.Log(String.Format("[EL RSM] ProcessKerbal: {0} {1} {2}", crew.name, br.name, br.amount)); } }
public CostReport (BuildResourceSet req, BuildResourceSet opt) { required = req.Values; optional = opt.Values; }
List<BuildResource> PartResources (Part p) { Debug.Log (String.Format ("[EL RSM] PartResources: {0} {1}", p.name, p.CrewCapacity)); var bc = new BuildCost (); bc.addPart (p); var rd = new BuildResourceSet (); bool xfer = true; VesselResources.ResourceProcessor process = delegate (VesselResources vr, string res) { ProcessResource (vr, res, rd, xfer); }; bc.resources.Process (process); var reslist = rd.Values; rd.Clear (); bc.container.Process (process); reslist.AddRange (rd.Values); rd.Clear (); xfer = false; bc.hullResoures.Process (process); reslist.AddRange (rd.Values); if (p.CrewCapacity > 0 && !p.name.Contains ("kerbalEVA")) { rd.Clear (); for (int i = 0; i < p.protoModuleCrew.Count; i++) { var crew = p.protoModuleCrew[i]; ProcessKerbal (crew, rd); } reslist.AddRange (rd.Values); } return reslist; }
void ProcessKerbal (ProtoCrewMember crew, BuildResourceSet rd) { string message = crew.name + " was mulched"; ScreenMessages.PostScreenMessage (message, 30.0f, ScreenMessageStyle.UPPER_CENTER); var part_recipe = ExRecipeDatabase.KerbalRecipe (); if (part_recipe == null) { return; } var kerbal_recipe = part_recipe.Bake (0.09375);//FIXME for (int i = 0; i < kerbal_recipe.ingredients.Count; i++) { var ingredient = kerbal_recipe.ingredients[i]; ProcessIngredient (ingredient, rd, false); } foreach (var br in rd.Values) { Debug.Log (String.Format ("[EL RSM] ProcessKerbal: {0} {1} {2}", crew.name, br.name, br.amount)); } }
void ProcessResource (VesselResources vr, string res, BuildResourceSet rd, bool xfer) { var amount = vr.ResourceAmount (res); var mass = amount * ExRecipeDatabase.ResourceDensity (res); ProcessIngredient (new Ingredient (res, mass), rd, xfer); }
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 = ExRecipeDatabase.TransferRecipe (res); } if (recipe == null) { recipe = ExRecipeDatabase.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 (ExRecipeDatabase.ResourceRecipe (res) != null) { } else { if (ingredient.isReal) { var br = new BuildResource (ingredient); rd.Add (br); } } } }
public CostReport(BuildResourceSet req, BuildResourceSet opt) { required = req.Values; optional = opt.Values; }