Пример #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 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);
            }
        }
Пример #2
0
        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));
            }
        }