// apply deferred requests for a vessel and synchronize the new amount in the vessel public void Sync(Vessel v, double elapsed_s) { // execute all possible recipes bool executing = true; while (executing) { executing = false; for (int i = 0; i < recipes.Count; ++i) { resource_recipe recipe = recipes[i]; if (recipe.left > double.Epsilon) { executing |= recipe.Execute(v, this); } } } // forget the recipes recipes.Clear(); // apply all deferred requests and synchronize to vessel foreach (var pair in resources) { pair.Value.Sync(v, elapsed_s); } }