private void UseResources(Vessel craft)
{
VesselResources craftResources = new VesselResources(craft);
// Remove all resources that we might later fill (hull resources will not be touched)
HashSet<string> resources_to_remove = new HashSet<string>(uis.requiredresources.Keys);
craftResources.RemoveAllResources(resources_to_remove);
// remove rocket parts required for the hull and solid fuel
padResources.TransferResource("RocketParts", -uis.hullRocketParts);
// use resources
foreach (KeyValuePair<string, double> pair in uis.requiredresources) {
// If resource is "JetFuel", rename to "LiquidFuel"
string res = pair.Key;
if (pair.Key == "JetFuel") {
res = "LiquidFuel";
if (pair.Value == 0)
continue;
}
if (!uis.resourcesliders.ContainsKey(pair.Key)) {
Debug.Log(String.Format("[EL] missing slider {0}", pair.Key));
continue;
}
// Calculate resource cost based on slider position - note use pair.Key NOT res! we need to use the position of the dedicated LF slider not the LF component of LFO slider
double tot = pair.Value * uis.resourcesliders[pair.Key];
// Transfer the resource from the vessel doing the building to the vessel being built
padResources.TransferResource(res, -tot);
craftResources.TransferResource(res, tot);
}
}