Example #1
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients,
                                         Bill bill)
        {
            if (billDoer == null)
            {
                return;
            }

            if (!CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);

                var hediff = pawn?.health?.hediffSet?.GetHediffs <Hediff>()
                             ?.Where(x => x.def == PS_DefOf.PS_HediffDefs_BotchedLaryngoplasty).FirstOrDefault();
                if (hediff != null)
                {
                    pawn.health.RemoveHediff(hediff);
                }
                else if (pawn != null && pawn.story.traits.allTraits.Any(x => x.def == TraitDefOf.AnnoyingVoice))
                {
                    PS_TraitChanger.Remove(pawn, new Trait(TraitDefOf.AnnoyingVoice));
                }
                else if (pawn != null && pawn.story.traits.allTraits.Any(x => x.def == TraitDefOf.CreepyBreathing))
                {
                    PS_TraitChanger.Remove(pawn, new Trait(TraitDefOf.CreepyBreathing));
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Success".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_Laryngoplasty".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.TaskCompletion);
            }
            else
            {
                var hasHediff = pawn?.health?.hediffSet?.GetHediffs <Hediff>()
                                ?.Where(x => x.def == PS_DefOf.PS_HediffDefs_BotchedLaryngoplasty).Any() ?? false;
                if (!hasHediff)
                {
                    var hediff = HediffMaker.MakeHediff(PS_DefOf.PS_HediffDefs_BotchedLaryngoplasty, pawn, part);
                    pawn?.health?.AddHediff(hediff);
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Botched".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_Laryngoplasty".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.NegativeHealthEvent);
            }
        }
Example #2
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients,
                                         Bill bill)
        {
            if (billDoer == null)
            {
                return;
            }

            if (!CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);

                var trait = pawn?.story?.traits?.allTraits?.Where(x => x.def.defName == "Immunity")
                            .FirstOrDefault();
                if (trait != null && trait.Degree == -1)
                {
                    PS_TraitChanger.Remove(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), -1));
                }
                else if (trait == null)
                {
                    PS_TraitChanger.AddTrait(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), 1));
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Success".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_ImmunityBoost".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.TaskCompletion);
            }
            else
            {
                var trait = pawn?.story?.traits?.allTraits?.Where(x => x.def.defName == "Immunity")
                            .FirstOrDefault();
                if (trait != null && trait.Degree == 1)
                {
                    PS_TraitChanger.Remove(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), 1));
                }
                else if (trait == null)
                {
                    PS_TraitChanger.AddTrait(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), -1));
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Botched".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_ImmunityBoost".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.NegativeHealthEvent);
            }
        }
        private static void SetBeauty(Pawn pawn, int degree)
        {
            if (degree > 2)
            {
                degree = 2;
            }

            if (degree < -2)
            {
                degree = -2;
            }

            if (pawn.story.traits.HasTrait(TraitDefOf.Beauty))
            {
                PS_TraitChanger.Remove(pawn, pawn.story.traits.GetTrait(TraitDefOf.Beauty));
            }

            if (degree != 0)
            {
                PS_TraitChanger.AddTrait(pawn, new Trait(TraitDefOf.Beauty, degree));
            }
        }