Beispiel #1
0
        public static bool Prefix(ref RecipeWorker __instance, Thing ingredient, RecipeDef recipe, Map map)
        {
            if (recipe.defName != "AY_WashApparel" || !ingredient.def.IsApparel)
            {
                return(true);
            }

            if (!((Apparel)ingredient).WornByCorpse)
            {
                return(false);
            }

            var loseQual = Controller.Settings.WashLowersQual;

            AYWashUtility.AYWashHaulJob(AYWashUtility.AYWashApparel(ref ingredient, map, loseQual));

            return(false);
        }
 public static bool IsSurgeryViolationOnExtraFactionMember(this Bill_Medical bill, Pawn billDoer)
 {
     if (bill.recipe.IsSurgery && bill.recipe.Worker != null)
     {
         RecipeWorker worker             = bill.recipe.Worker;
         Faction      sharedExtraFaction = billDoer.GetSharedExtraFaction(bill.GiverPawn, ExtraFactionType.HomeFaction);
         if (sharedExtraFaction != null && worker.IsViolationOnPawn(bill.GiverPawn, bill.Part, sharedExtraFaction))
         {
             return(true);
         }
         Faction sharedExtraFaction2 = billDoer.GetSharedExtraFaction(bill.GiverPawn, ExtraFactionType.MiniFaction);
         if (sharedExtraFaction2 != null && worker.IsViolationOnPawn(bill.GiverPawn, bill.Part, sharedExtraFaction2))
         {
             return(true);
         }
     }
     return(false);
 }
 public static void AddQualityToImplant(RecipeWorker __instance, Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (__instance.recipe?.removesHediff != null)
     {
         if (!pawn.health?.hediffSet?.GetNotMissingParts().Contains(part) ?? false)
         {
             return;
         }
         Hediff hediff = pawn.health?.hediffSet?.hediffs?.FirstOrDefault((Hediff x) => x.def == __instance.recipe.removesHediff);
         if (hediff != null)
         {
             if (hediff.def.spawnThingOnRemoved != null)
             {
                 var comp = hediff.TryGetComp <HediffCompImplantQuality>();
                 if (comp != null)
                 {
                     implantQuality = new Pair <ThingDef, QualityCategory>(hediff.def.spawnThingOnRemoved, comp.quality);
                 }
             }
         }
     }
 }
Beispiel #4
0
        public static void AddQualityToHediff(RecipeWorker __instance, Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            if (__instance.recipe?.addsHediff != null && ingredients != null)
            {
                var hediff = pawn.health?.hediffSet?.hediffs?.FindLast(x => x.def == __instance.recipe.addsHediff);

                if (hediff != null)
                {
                    var comp = hediff.TryGetComp <HediffCompImplantQuality>();
                    if (comp != null)
                    {
                        foreach (var ingredient in ingredients)
                        {
                            if (ingredient != null && hediff.def.spawnThingOnRemoved == ingredient.def && ingredient.TryGetQuality(out var qualityCategory))
                            {
                                comp.quality = qualityCategory;
                                comp.SelectSeverity(qualityCategory);
                                break;
                            }
                        }
                    }
                }
            }
        }