public static List <FloatMenuOption> AddedPartOptionsThatAffect(this RecipeDef r, PawnCapacityDef capacity, Pawn pawn, bool negative = false) { var options = new List <FloatMenuOption>(); if (!r?.addsHediff?.IsAddedPart() ?? true) { return(options); } if (!NotMissingVitalIngredient(pawn, r)) { return(options); } var after = r.addsHediff.addedPartProps.partEfficiency; var parts = r.Worker.GetPartsToApplyOn(pawn, r) .Where(p => p.Affects(capacity) && !pawn.health.hediffSet.AncestorHasDirectlyAddedParts(p)); foreach (var part in parts) { var current = PawnCapacityUtility.CalculatePartEfficiency(pawn.health.hediffSet, part); if (after < current == negative) { options.Add(GenerateSurgeryOption(pawn, pawn, r, r.PotentiallyMissingIngredients(null, pawn.Map), part)); } } return(options); }
public static bool NotMissingVitalIngredient(Pawn pawn, RecipeDef r) { return(!r.PotentiallyMissingIngredients(null, pawn.Map).Any()); }
public static bool NotMissingVitalIngredient(Pawn pawn, RecipeDef r) { return(!r.PotentiallyMissingIngredients(null, pawn.Map) .Any(td => td.IsDrug || td.isBodyPartOrImplant)); }