public static Pawn Copy(Pawn sourcePawn, PawnKindDef kindDef, Faction faction, bool forceBodyVisual = false, bool forceApparel = false, bool forceWeapon = false) { Pawn pawn = (Pawn)ThingMaker.MakeThing(kindDef.race, null); pawn.kindDef = kindDef; pawn.SetFactionDirect(faction); pawn.pather = new Pawn_PathFollower(pawn); pawn.ageTracker = new Pawn_AgeTracker(pawn); pawn.health = new Pawn_HealthTracker(pawn); pawn.jobs = new Pawn_JobTracker(pawn); pawn.mindState = new Pawn_MindState(pawn); pawn.filth = new Pawn_FilthTracker(pawn); pawn.needs = new Pawn_NeedsTracker(pawn); pawn.stances = new Pawn_StanceTracker(pawn); pawn.InitUnsavedUniversalComponents(); if (pawn.RaceProps.ToolUser) { pawn.equipment = new Pawn_EquipmentTracker(pawn); pawn.carrier = new Pawn_CarryTracker(pawn); pawn.apparel = new Pawn_ApparelTracker(pawn); pawn.inventory = new Pawn_InventoryTracker(pawn); } if (pawn.RaceProps.Humanlike) { pawn.ownership = new Pawn_Ownership(pawn); pawn.skills = new Pawn_SkillTracker(pawn); pawn.talker = new Pawn_TalkTracker(pawn); pawn.story = new Pawn_StoryTracker(pawn); pawn.workSettings = new Pawn_WorkSettings(pawn); } if (pawn.RaceProps.intelligence <= Intelligence.ToolUser) { pawn.caller = new Pawn_CallTracker(pawn); } PawnUtility.AddAndRemoveComponentsAsAppropriate(pawn); if (pawn.RaceProps.hasGenders) { if ((sourcePawn != null) && (sourcePawn.RaceProps.hasGenders) && (sourcePawn.gender != Gender.None)) { pawn.gender = sourcePawn.gender; } else { if (Rand.Value < 0.5f) { pawn.gender = Gender.Male; } else { pawn.gender = Gender.Female; } } } else { pawn.gender = Gender.None; } AbilityEffect_Revive.GenerateRandomAge_Coping(pawn, sourcePawn); AbilityEffect_Revive.GenerateInitialHediffs_Coping(pawn, sourcePawn); if (pawn.RaceProps.Humanlike) { if ((sourcePawn != null) && (forceBodyVisual)) { pawn.story.skinColor = sourcePawn.story.skinColor; pawn.story.crownType = sourcePawn.story.crownType; pawn.story.headGraphicPath = sourcePawn.story.headGraphicPath; pawn.story.hairColor = sourcePawn.story.hairColor; AbilityEffect_Revive.GiveAppropriateBioTo_Coping(pawn, sourcePawn); pawn.story.hairDef = sourcePawn.story.hairDef; AbilityEffect_Revive.GiveRandomTraitsTo_Coping(pawn, sourcePawn); pawn.story.GenerateSkillsFromBackstory(); } else { pawn.story.skinColor = PawnSkinColors.RandomSkinColor(); pawn.story.crownType = ((Rand.Value >= 0.5f) ? CrownType.Narrow : CrownType.Average); pawn.story.headGraphicPath = GraphicDatabaseHeadRecords.GetHeadRandom(pawn.gender, pawn.story.skinColor, pawn.story.crownType).GraphicPath; pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.skinColor, pawn.ageTracker.AgeBiologicalYears); PawnBioGenerator.GiveAppropriateBioTo(pawn, faction.def); pawn.story.hairDef = PawnHairChooser.RandomHairDefFor(pawn, faction.def); AbilityEffect_Revive.GiveRandomTraitsTo(pawn); pawn.story.GenerateSkillsFromBackstory(); } } AbilityEffect_Revive.GenerateStartingApparelFor_Coping(pawn, sourcePawn, forceApparel); AbilityEffect_Revive.TryGenerateWeaponFor_Coping(pawn, sourcePawn, forceWeapon); AbilityEffect_Revive.GenerateInventoryFor_Coping(pawn, sourcePawn); PawnUtility.AddAndRemoveComponentsAsAppropriate(pawn); return(pawn); }