public override string BillRequirementsDescription(RecipeDef r, IngredientCount ing) { if (!ing.filter.AllowedThingDefs.Any((ThingDef td) => td.smallVolume) || ing.filter.AllowedThingDefs.Any((ThingDef td) => td.smallVolume && !r.GetPremultipliedSmallIngredients().Contains(td))) { return("BillRequires".Translate(new object[] { ing.GetBaseCount(), ing.filter.Summary })); } return("BillRequires".Translate(new object[] { ing.GetBaseCount() * 10f, ing.filter.Summary })); }
public override string ExtraDescriptionLine(RecipeDef r) { string result; if (r.ingredients.Any((IngredientCount ing) => ing.filter.AllowedThingDefs.Any((ThingDef td) => td.smallVolume && !r.GetPremultipliedSmallIngredients().Contains(td)))) { result = "BillRequiresMayVary".Translate(new object[] { 10.ToStringCached() }); } else { result = null; } return(result); }
private static IEnumerable <Pair <ThingDef, float> > CheapestIngredients(RecipeDef d) { using (List <IngredientCount> .Enumerator enumerator = d.ingredients.GetEnumerator()) { if (enumerator.MoveNext()) { IngredientCount ing = enumerator.Current; ThingDef thing = (from td in ing.filter.AllowedThingDefs where td != ThingDefOf.Meat_Human select td).MinBy((ThingDef td) => td.BaseMarketValue / td.VolumePerUnit); yield return(new Pair <ThingDef, float>(thing, ing.GetBaseCount() / d.IngredientValueGetter.ValuePerUnitOf(thing))); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0135: /*Error near IL_0136: Unexpected return in MoveNext()*/; }
private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, Pawn worker) { CompQuality compQuality = product.TryGetComp <CompQuality>(); if (compQuality != null) { if (recipeDef.workSkill == null) { Log.Error(recipeDef + " needs workSkill because it creates a product with a quality."); } int level = worker.skills.GetSkill(recipeDef.workSkill).Level; QualityCategory qualityCategory = QualityUtility.RandomCreationQuality(level); if (worker.InspirationDef == InspirationDefOf.InspiredArt && (product.def.IsArt || (product.def.minifiedDef != null && product.def.minifiedDef.IsArt))) { qualityCategory = qualityCategory.AddLevels(3); worker.mindState.inspirationHandler.EndInspiration(InspirationDefOf.InspiredArt); } compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony); } CompArt compArt = product.TryGetComp <CompArt>(); if (compArt != null) { compArt.JustCreatedBy(worker); if (compQuality.Quality >= QualityCategory.Excellent) { TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[] { worker, product }); } } if (product.def.Minifiable) { product = product.MakeMinified(); } return(product); }
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 virtual string ExtraDescriptionLine(RecipeDef r) { return(null); }
public abstract string BillRequirementsDescription(RecipeDef r, IngredientCount ing);
public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient, IBillGiver billGiver) { float efficiency = (recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat) : 1f; if (recipeDef.workTableEfficiencyStat != null) { Building_WorkTable building_WorkTable = billGiver as Building_WorkTable; if (building_WorkTable != null) { efficiency *= building_WorkTable.GetStatValue(recipeDef.workTableEfficiencyStat); } } if (recipeDef.products != null) { int k = 0; if (k < recipeDef.products.Count) { ThingDefCountClass prod = recipeDef.products[k]; Thing product3 = ThingMaker.MakeThing(stuff: (!prod.thingDef.MadeFromStuff) ? null : dominantIngredient.def, def: prod.thingDef); product3.stackCount = Mathf.CeilToInt((float)prod.count * efficiency); if (dominantIngredient != null) { product3.SetColor(dominantIngredient.DrawColor, reportFailure: 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 chance = worker.GetRoom()?.GetStat(RoomStatDefOf.FoodPoisonChance) ?? RoomStatDefOf.FoodPoisonChance.roomlessScore; if (Rand.Chance(chance)) { foodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen); } else { float statValue = worker.GetStatValue(StatDefOf.FoodPoisonChance); if (Rand.Chance(statValue)) { foodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook); } } } yield return(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(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(PostProcessProduct(product2, recipeDef, worker)); /*Error: Unable to find new state assignment for yield return*/; } } break; } } } } yield break; IL_04dd: /*Error near IL_04de: Unexpected return in MoveNext()*/; }
public virtual void ConsumeIngredient(Thing ingredient, RecipeDef recipe, Map map) { ingredient.Destroy(); }
private static float TrueWorkWithCarryTime(RecipeDef d) { ThingDef stuffDef = CheapestNonDerpStuff(d); return((float)d.ingredients.Count * 90f + d.WorkAmountTotal(stuffDef) + 90f); }
public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient, IBillGiver billGiver) { float efficiency = (recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat) : 1f; if (recipeDef.workTableEfficiencyStat != null) { Building_WorkTable building_WorkTable = billGiver as Building_WorkTable; if (building_WorkTable != null) { efficiency *= building_WorkTable.GetStatValue(recipeDef.workTableEfficiencyStat); } } if (recipeDef.products != null) { for (int k = 0; k < recipeDef.products.Count; k++) { ThingDefCountClass thingDefCountClass = recipeDef.products[k]; Thing thing = ThingMaker.MakeThing(stuff: (!thingDefCountClass.thingDef.MadeFromStuff) ? null : dominantIngredient.def, def: thingDefCountClass.thingDef); thing.stackCount = Mathf.CeilToInt((float)thingDefCountClass.count * efficiency); if (dominantIngredient != null) { thing.SetColor(dominantIngredient.DrawColor, reportFailure: false); } CompIngredients compIngredients = thing.TryGetComp <CompIngredients>(); if (compIngredients != null) { for (int l = 0; l < ingredients.Count; l++) { compIngredients.RegisterIngredient(ingredients[l].def); } } CompFoodPoisonable compFoodPoisonable = thing.TryGetComp <CompFoodPoisonable>(); if (compFoodPoisonable != null) { if (Rand.Chance(worker.GetRoom()?.GetStat(RoomStatDefOf.FoodPoisonChance) ?? RoomStatDefOf.FoodPoisonChance.roomlessScore)) { compFoodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen); } else if (Rand.Chance(worker.GetStatValue(StatDefOf.FoodPoisonChance))) { compFoodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook); } } yield return(PostProcessProduct(thing, recipeDef, worker)); } } if (recipeDef.specialProducts == null) { yield break; } for (int k = 0; k < recipeDef.specialProducts.Count; k++) { for (int i = 0; i < ingredients.Count; i++) { Thing thing2 = ingredients[i]; switch (recipeDef.specialProducts[k]) { case SpecialProductType.Butchery: foreach (Thing item in thing2.ButcherProducts(worker, efficiency)) { yield return(PostProcessProduct(item, recipeDef, worker)); } break; case SpecialProductType.Smelted: foreach (Thing item2 in thing2.SmeltProducts(efficiency)) { yield return(PostProcessProduct(item2, recipeDef, worker)); } break; } } } }
public override string BillRequirementsDescription(RecipeDef r, IngredientCount ing) { return("BillRequiresNutrition".Translate(ing.GetBaseCount()) + " (" + ing.filter.Summary + ")"); }
// Token: 0x06000017 RID: 23 RVA: 0x00003205 File Offset: 0x00001405 public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient) { Log.Message(string.Concat(new string[] { "init WPGenRecipe: recipeDef ", (recipeDef != null) ? recipeDef.ToString() : null, " worker ", (worker != null) ? worker.ToString() : null, " ingredients ", (ingredients != null) ? ingredients.ToString() : null, " dominantIngredient ", (dominantIngredient != null) ? dominantIngredient.ToString() : null }), false); bool flag = recipeDef.efficiencyStat == null; float efficiency; if (flag) { efficiency = 1f; } else { efficiency = worker.GetStatValue(recipeDef.efficiencyStat, true); } bool flag2 = recipeDef.products != null; if (flag2) { int num2; for (int i = 0; i < recipeDef.products.Count; i = num2 + 1) { ThingDefCountClass prod = recipeDef.products[i]; bool madeFromStuff = prod.thingDef.MadeFromStuff; ThingDef stuffDef; if (madeFromStuff) { stuffDef = dominantIngredient.def; } else { stuffDef = null; } Thing product = ThingMaker.MakeThing(prod.thingDef, stuffDef); product.stackCount = Mathf.CeilToInt((float)prod.count * efficiency); bool flag3 = dominantIngredient != null; if (flag3) { product.SetColor(dominantIngredient.DrawColor, false); } CompIngredients ingredientsComp = product.TryGetComp <CompIngredients>(); bool flag4 = ingredientsComp != null; if (flag4) { for (int j = 0; j < ingredients.Count; j = num2 + 1) { ingredientsComp.RegisterIngredient(ingredients[j].def); num2 = j; } } CompFoodPoisonable foodPoisonable = product.TryGetComp <CompFoodPoisonable>(); bool flag5 = foodPoisonable != null; if (flag5) { float num = worker.GetStatValue(StatDefOf.FoodPoisonChance, true); Room room = worker.GetRoom(RegionType.Set_Passable); float chance = (room == null) ? RoomStatDefOf.FoodPoisonChance.roomlessScore : room.GetStat(RoomStatDefOf.FoodPoisonChance); bool flag6 = Rand.Chance(chance); if (flag6) { foodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen); } else { float statValue = worker.GetStatValue(StatDefOf.FoodPoisonChance, true); bool flag7 = Rand.Chance(statValue); if (flag7) { foodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook); } } room = null; } yield return(WPGenRecipe.PostProcessProduct(product, recipeDef, worker)); prod = null; stuffDef = null; product = null; ingredientsComp = null; foodPoisonable = null; num2 = i; } } bool flag8 = recipeDef.specialProducts != null; if (flag8) { string str = "special recipedef not null"; List <SpecialProductType> specialProducts = recipeDef.specialProducts; Log.Message(str + ((specialProducts != null) ? specialProducts.ToString() : null), false); Log.Message("recipeDef.specialProducts.Count " + recipeDef.specialProducts.Count.ToString(), false); int num2; for (int k = 0; k < recipeDef.specialProducts.Count; k = num2 + 1) { Log.Message("recipeDef.specialProducts[j] " + recipeDef.specialProducts[k].ToString(), false); Log.Message("ingredients.Count " + ingredients.Count.ToString(), false); string str2 = "recipeDef.ingredients "; List <IngredientCount> ingredients2 = recipeDef.ingredients; Log.Message(str2 + ((ingredients2 != null) ? ingredients2.ToString() : null), false); for (int l = 0; l < ingredients.Count; l = num2 + 1) { Thing ing = ingredients[l]; string str3 = "ingredients[k] "; Thing thing = ingredients[l]; Log.Message(str3 + ((thing != null) ? thing.ToString() : null), false); string str4 = "ing "; Thing thing2 = ing; Log.Message(str4 + ((thing2 != null) ? thing2.ToString() : null), false); SpecialProductType specialProductType = recipeDef.specialProducts[k]; bool flag9 = specialProductType > SpecialProductType.Butchery; if (flag9) { Log.Message("not butchery", false); bool flag10 = specialProductType == SpecialProductType.Smelted; if (flag10) { foreach (Thing product2 in ing.SmeltProducts(efficiency)) { yield return(WPGenRecipe.PostProcessProduct(product2, recipeDef, worker)); } } } else { Log.Message("butchery", false); foreach (Thing product3 in ing.ButcherProducts(worker, efficiency)) { string[] array = new string[8]; array[0] = "recipeDef.specialProducts[k] "; array[1] = recipeDef.specialProducts[l].ToString(); array[2] = "product3 "; int num3 = 3; Thing thing3 = product3; array[num3] = ((thing3 != null) ? thing3.ToString() : null); array[4] = " recipeDef "; array[5] = ((recipeDef != null) ? recipeDef.ToString() : null); array[6] = " worker "; array[7] = ((worker != null) ? worker.ToString() : null); Log.Message(string.Concat(array), false); yield return(WPGenRecipe.PostProcessProduct(product3, recipeDef, worker)); } } ing = null; num2 = l; } num2 = k; } } Log.Message("yield break", false); yield break; }
private static float WorkValueEstimate(RecipeDef d) { return(DebugOutputsEconomy.TrueWorkWithCarryTime(d) * 0.01f); }
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()*/; }
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 virtual IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe) { yield break; }
private static float WorkValueEstimate(RecipeDef d) { return(TrueWorkWithCarryTime(d) * 0.01f); }
public int CountRequiredOfFor(ThingDef thingDef, RecipeDef recipe) { float num = recipe.IngredientValueGetter.ValuePerUnitOf(thingDef); return(Mathf.CeilToInt(count / num)); }
public static void Bill(Bill __instance, Verse.RecipeDef recipe) { __instance.ingredientFilter = new MarketValueFilter(); __instance.ingredientFilter.CopyAllowancesFrom(recipe.defaultIngredientFilter); }