public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient) { float efficiency; if (recipeDef.efficiencyStat == null) { efficiency = 1f; } else { efficiency = worker.GetStatValue(recipeDef.efficiencyStat, true); } if (recipeDef.products != null) { for (int i = 0; i < recipeDef.products.Count; i++) { ThingCountClass prod = recipeDef.products[i]; ThingDef stuffDef; if (prod.thingDef.MadeFromStuff) { stuffDef = dominantIngredient.def; } else { stuffDef = null; } Thing product = ThingMaker.MakeThing(prod.thingDef, stuffDef); product.stackCount = Mathf.CeilToInt((float)prod.count * efficiency); if (dominantIngredient != null) { product.SetColor(dominantIngredient.DrawColor, false); } CompIngredients ingredientsComp = product.TryGetComp <CompIngredients>(); if (ingredientsComp != null) { for (int l = 0; l < ingredients.Count; l++) { ingredientsComp.RegisterIngredient(ingredients[l].def); } } CompFoodPoisonable foodPoisonable = product.TryGetComp <CompFoodPoisonable>(); if (foodPoisonable != null) { float num = worker.GetStatValue(StatDefOf.FoodPoisonChance, true); Room room = worker.GetRoom(RegionType.Set_Passable); if (room != null) { num *= room.GetStat(RoomStatDefOf.FoodPoisonChanceFactor); } if (Rand.Value < num) { foodPoisonable.PoisonPercent = 1f; } } yield return(GenRecipe.PostProcessProduct(product, recipeDef, worker)); } } if (recipeDef.specialProducts != null) { for (int j = 0; j < recipeDef.specialProducts.Count; j++) { for (int k = 0; k < ingredients.Count; k++) { Thing ing = ingredients[k]; SpecialProductType specialProductType = recipeDef.specialProducts[j]; if (specialProductType != SpecialProductType.Butchery) { if (specialProductType == SpecialProductType.Smelted) { foreach (Thing product2 in ing.SmeltProducts(efficiency)) { yield return(GenRecipe.PostProcessProduct(product2, recipeDef, worker)); } } } else { foreach (Thing product3 in ing.ButcherProducts(worker, efficiency)) { yield return(GenRecipe.PostProcessProduct(product3, recipeDef, worker)); } } } } } }
public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient, IBillGiver billGiver) { float efficiency; if (recipeDef.efficiencyStat == null) { efficiency = 1f; } else { efficiency = worker.GetStatValue(recipeDef.efficiencyStat, true); } if (recipeDef.workTableEfficiencyStat != null) { Building_WorkTable building_WorkTable = billGiver as Building_WorkTable; if (building_WorkTable != null) { efficiency *= building_WorkTable.GetStatValue(recipeDef.workTableEfficiencyStat, true); } } if (recipeDef.products != null) { for (int i = 0; i < recipeDef.products.Count; i++) { ThingDefCountClass prod = recipeDef.products[i]; ThingDef stuffDef; if (prod.thingDef.MadeFromStuff) { stuffDef = dominantIngredient.def; } else { stuffDef = null; } Thing product = ThingMaker.MakeThing(prod.thingDef, stuffDef); product.stackCount = Mathf.CeilToInt((float)prod.count * efficiency); if (dominantIngredient != null) { product.SetColor(dominantIngredient.DrawColor, false); } CompIngredients ingredientsComp = product.TryGetComp <CompIngredients>(); if (ingredientsComp != null) { for (int l = 0; l < ingredients.Count; l++) { ingredientsComp.RegisterIngredient(ingredients[l].def); } } CompFoodPoisonable foodPoisonable = product.TryGetComp <CompFoodPoisonable>(); if (foodPoisonable != null) { Room room = worker.GetRoom(RegionType.Set_Passable); float chance = (room == null) ? RoomStatDefOf.FoodPoisonChance.roomlessScore : room.GetStat(RoomStatDefOf.FoodPoisonChance); if (Rand.Chance(chance)) { foodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen); } else { float statValue = worker.GetStatValue(StatDefOf.FoodPoisonChance, true); if (Rand.Chance(statValue)) { foodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook); } } } yield return(GenRecipe.PostProcessProduct(product, recipeDef, worker)); } } if (recipeDef.specialProducts != null) { for (int j = 0; j < recipeDef.specialProducts.Count; j++) { for (int k = 0; k < ingredients.Count; k++) { Thing ing = ingredients[k]; SpecialProductType specialProductType = recipeDef.specialProducts[j]; if (specialProductType != SpecialProductType.Butchery) { if (specialProductType == SpecialProductType.Smelted) { foreach (Thing product2 in ing.SmeltProducts(efficiency)) { yield return(GenRecipe.PostProcessProduct(product2, recipeDef, worker)); } } } else { foreach (Thing product3 in ing.ButcherProducts(worker, efficiency)) { yield return(GenRecipe.PostProcessProduct(product3, recipeDef, worker)); } } } } } }
public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient) { float efficiency = (float)((recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat, true) : 1.0); if (recipeDef.products != null) { int k = 0; if (k < recipeDef.products.Count) { ThingCountClass prod = recipeDef.products[k]; ThingDef stuffDef = (!prod.thingDef.MadeFromStuff) ? null : dominantIngredient.def; Thing product3 = ThingMaker.MakeThing(prod.thingDef, stuffDef); product3.stackCount = Mathf.CeilToInt((float)prod.count * efficiency); if (dominantIngredient != null) { product3.SetColor(dominantIngredient.DrawColor, false); } CompIngredients ingredientsComp = product3.TryGetComp <CompIngredients>(); if (ingredientsComp != null) { for (int l = 0; l < ingredients.Count; l++) { ingredientsComp.RegisterIngredient(ingredients[l].def); } } CompFoodPoisonable foodPoisonable = product3.TryGetComp <CompFoodPoisonable>(); if (foodPoisonable != null) { float num = worker.GetStatValue(StatDefOf.FoodPoisonChance, true); Room room = worker.GetRoom(RegionType.Set_Passable); if (room != null) { num *= room.GetStat(RoomStatDefOf.FoodPoisonChanceFactor); } if (Rand.Value < num) { foodPoisonable.PoisonPercent = 1f; } } yield return(GenRecipe.PostProcessProduct(product3, recipeDef, worker)); /*Error: Unable to find new state assignment for yield return*/; } } if (recipeDef.specialProducts != null) { for (int j = 0; j < recipeDef.specialProducts.Count; j++) { for (int i = 0; i < ingredients.Count; i++) { Thing ing = ingredients[i]; switch (recipeDef.specialProducts[j]) { case SpecialProductType.Butchery: using (IEnumerator <Thing> enumerator2 = ing.ButcherProducts(worker, efficiency).GetEnumerator()) { if (enumerator2.MoveNext()) { Thing product = enumerator2.Current; yield return(GenRecipe.PostProcessProduct(product, recipeDef, worker)); /*Error: Unable to find new state assignment for yield return*/; } } break; case SpecialProductType.Smelted: using (IEnumerator <Thing> enumerator = ing.SmeltProducts(efficiency).GetEnumerator()) { if (enumerator.MoveNext()) { Thing product2 = enumerator.Current; yield return(GenRecipe.PostProcessProduct(product2, recipeDef, worker)); /*Error: Unable to find new state assignment for yield return*/; } } break; } } } } yield break; IL_0473: /*Error near IL_0474: Unexpected return in MoveNext()*/; }