/// <summary> /// Tries to revert the transformed pawn instance, implementation. /// </summary> /// <param name="transformedPawn">The transformed pawn.</param> /// <returns></returns> protected override bool TryRevertImpl(TransformedPawnSingle transformedPawn) { if (transformedPawn == null) { throw new ArgumentNullException(nameof(transformedPawn)); } if (!transformedPawn.IsValid) { Log.Warning(nameof(SimpleMechaniteMutagen) + " received an invalid transformed pawn to revert"); return(false); } Pawn animal = transformedPawn.animal; if (animal == null) { return(false); } var rFaction = transformedPawn.FactionResponsible; var spawned = (Pawn)GenSpawn.Spawn(transformedPawn.original, animal.PositionHeld, animal.MapHeld); if (spawned.Faction != animal.Faction && rFaction == null) //if the responsible faction is null (no one knows who did it) have the reverted pawn join that faction { spawned.SetFaction(animal.Faction); } for (var i = 0; i < 10; i++) { IntermittentMagicSprayer.ThrowMagicPuffDown(spawned.Position.ToVector3(), spawned.MapHeld); IntermittentMagicSprayer.ThrowMagicPuffUp(spawned.Position.ToVector3(), spawned.MapHeld); } //transfer hediffs from the former human back onto the original pawn FormerHumanUtilities.TransferHediffs(animal, spawned); SetHumanoidSapience(spawned, animal); FixBondRelationship(spawned, animal); FormerHumanUtilities.TransferEverything(animal, spawned); spawned.Faction?.Notify_MemberReverted(spawned, animal, spawned.Map == null, spawned.Map); ReactionsHelper.OnPawnReverted(spawned, animal, transformedPawn.reactionStatus); spawned.health.AddHediff(MorphTransformationDefOf.StabiliserHigh); //add stabilizer on reversion TransformerUtility.CleanUpHumanPawnPostTf(animal, null); animal.Destroy(); return(true); }
/// <summary> /// Tries to revert the transformed pawn instance, implementation. /// </summary> /// <param name="transformedPawn">The transformed pawn.</param> /// <returns></returns> protected override bool TryRevertImpl(TransformedPawnSingle transformedPawn) { if (transformedPawn == null) { throw new ArgumentNullException(nameof(transformedPawn)); } if (!transformedPawn.IsValid) { Log.Warning(nameof(SimpleMechaniteMutagen) + " received an invalid transformed pawn to revert"); return(false); } Pawn animal = transformedPawn.animal; Hediff tfHumanHediff = animal?.health?.hediffSet?.GetFirstHediffOfDef(TfHediffDefOf.TransformedHuman); if (tfHumanHediff == null) { return(false); } var rFaction = transformedPawn.FactionResponsible; Log.Message($"going to spawn {transformedPawn.original.Name} {transformedPawn.original.KindLabel}"); var spawned = (Pawn)GenSpawn.Spawn(transformedPawn.original, animal.PositionHeld, animal.MapHeld); if (spawned.Faction != animal.Faction && rFaction == null) //if the responsible faction is null (no one knows who did it) have the reverted pawn join that faction { spawned.SetFaction(animal.Faction); } for (var i = 0; i < 10; i++) { IntermittentMagicSprayer.ThrowMagicPuffDown(spawned.Position.ToVector3(), spawned.MapHeld); IntermittentMagicSprayer.ThrowMagicPuffUp(spawned.Position.ToVector3(), spawned.MapHeld); } FixBondRelationship(spawned, animal); FormerHumanUtilities.TransferEverything(animal, spawned); spawned.Faction?.Notify_MemberReverted(spawned, animal, spawned.Map == null, spawned.Map); ReactionsHelper.OnPawnReverted(spawned, animal, transformedPawn.reactionStatus); spawned.health.AddHediff(MorphTransformationDefOf.StabiliserHigh); //add stabilizer on reversion animal.Destroy(); return(true); }