private static void MakeFeral(Pawn pawn)
        {
            var loader     = Find.World.GetComponent <PawnmorphGameComp>();
            var inst       = loader.GetTransformedPawnContaining(pawn)?.Item1;
            var singleInst = inst as TransformedPawnSingle; //hacky, need to come up with a better solution eventually

            foreach (var instOriginalPawn in inst?.OriginalPawns ?? Enumerable.Empty <Pawn>())
            {
                ReactionsHelper.OnPawnPermFeral(instOriginalPawn, pawn, singleInst?.reactionStatus ?? FormerHumanReactionStatus.Wild);
            }

            //remove the original and destroy the pawns
            foreach (var instOriginalPawn in inst?.OriginalPawns ?? Enumerable.Empty <Pawn>())
            {
                instOriginalPawn.Destroy();
            }

            if (inst != null)
            {
                loader.RemoveInstance(inst);
            }

            if (inst != null || pawn.Faction == Faction.OfPlayer)
            {
                Find.LetterStack.ReceiveLetter("LetterHediffFromPermanentTFLabel".Translate(pawn.LabelShort).CapitalizeFirst(), "LetterHediffFromPermanentTF".Translate(pawn.LabelShort).CapitalizeFirst(), LetterDefOf.NegativeEvent, pawn, null, null);
            }
        }
Ejemplo n.º 2
0
        internal void MakePermanentlyFeral()
        {
            Hediff fHediff;

            if (StateDef.forcedHediff != null)
            {
                fHediff = Pawn.health.hediffSet.GetFirstHediffOfDef(StateDef.forcedHediff);
            }
            else
            {
                fHediff = null;
            }

            //transfer relationships back if possible
            var  gComp = Find.World.GetComponent <PawnmorphGameComp>();
            Pawn oPawn = gComp.GetTransformedPawnContaining(Pawn)?.Item1?.OriginalPawns.FirstOrDefault();

            if (oPawn == Pawn)
            {
                oPawn = null;
            }

            Pawn_RelationsTracker aRelations = Pawn.relations;

            if (aRelations != null && oPawn != null)
            {
                FormerHumanUtilities.TransferRelationsToOriginal(oPawn, Pawn);
            }

            Pawn.health.AddHediff(TfHediffDefOf.PermanentlyFeral);
            if (fHediff != null)
            {
                Pawn.health.RemoveHediff(fHediff);
            }

            var             loader     = Find.World.GetComponent <PawnmorphGameComp>();
            TransformedPawn inst       = loader.GetTransformedPawnContaining(Pawn)?.Item1;
            var             singleInst = inst as TransformedPawnSingle; //hacky, need to come up with a better solution

            foreach (Pawn instOriginalPawn in inst?.OriginalPawns ?? Enumerable.Empty <Pawn>()
                     ) //needed to handle merges correctly
            {
                ReactionsHelper.OnPawnPermFeral(instOriginalPawn, Pawn,
                                                singleInst?.reactionStatus ?? FormerHumanReactionStatus.Wild);
            }

            //remove the original and destroy the pawns
            foreach (Pawn instOriginalPawn in inst?.OriginalPawns ?? Enumerable.Empty <Pawn>())
            {
                instOriginalPawn.Destroy();
            }

            if (inst != null)
            {
                loader.RemoveInstance(inst);
            }

            if (inst != null || Pawn.Faction == Faction.OfPlayer)
            {
                Find.LetterStack.ReceiveLetter("LetterHediffFromPermanentTFLabel".Translate(Pawn.LabelShort).CapitalizeFirst(),
                                               "LetterHediffFromPermanentTF".Translate(Pawn.LabelShort).CapitalizeFirst(),
                                               LetterDefOf.NegativeEvent, Pawn);
            }

            Pawn.needs?.AddOrRemoveNeedsAsAppropriate(); //make sure any comps get added/removed as appropriate
            PawnComponentsUtility.AddAndRemoveDynamicComponents(Pawn);
        }