protected override bool FinishWorking(Building_Miner working, out List <Thing> products) { products = GenRecipe2.MakeRecipeProducts(this.workingBill.recipe, this, new List <Thing>(), null, this).ToList(); this.workingBill.Notify_IterationCompleted(null, new List <Thing>()); this.workingBill = null; return(true); }
protected override bool FinishWorking(Building_Miner working, out List <Thing> products) { products = GenRecipe2.MakeRecipeProducts(this.workingBill.recipe, this, new List <Thing>(), null, this).ToList(); // Because we use custom GenRecipe2, we have to handle bonus items and product modifications (bonuses) directly: this.def.GetModExtension <ModExtension_ModifyProduct>()?.ProcessProducts(products, this as IBillGiver, this, this.workingBill.recipe); this.workingBill.Notify_IterationCompleted(null, new List <Thing>()); this.workingBill = null; return(true); }
protected override bool FinishWorking(Building_Miner working, out List <Thing> products) { var bonus = this.def.GetModExtension <ModExtension_Miner>()?.GetBonusYield(this.workingBill.recipe.ProducedThingDef); if (bonus == null) { products = GenRecipe2.MakeRecipeProducts(this.workingBill.recipe, this, new List <Thing>(), null, this).ToList(); } else { products = new List <Thing>().Append(bonus); } this.workingBill.Notify_IterationCompleted(null, new List <Thing>()); this.workingBill = null; return(true); }
public static IEnumerable <Thing> MakeRecipeProductsInt(RecipeDef recipeDef, IRecipeProductWorker 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(GenRecipe2.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(GenRecipe2.PostProcessProduct(product2, recipeDef, worker)); } } } else { foreach (Thing product3 in ButcherProducts(ing, efficiency, worker)) { yield return(GenRecipe2.PostProcessProduct(product3, recipeDef, worker)); } } } } } }