// Credit goes to Justin C for the Zombie Apocalypse code. // Taken from Verse.ZombieMod_Utility public static Pawn GenerateZombiePawnFromSource(Pawn sourcePawn) { PawnKindDef pawnKindDef = PawnKindDef.Named("RE_ZombieKind"); Faction factionDirect = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile); Pawn pawn = (Pawn)ThingMaker.MakeThing(pawnKindDef.race, null); pawn.kindDef = pawnKindDef; pawn.SetFactionDirect(factionDirect); 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.natives = new Pawn_NativeVerbs(pawn); PawnComponentsUtility.CreateInitialComponents(pawn); if (pawn.RaceProps.ToolUser) { pawn.equipment = new Pawn_EquipmentTracker(pawn); pawn.carryTracker = 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.relations = new Pawn_RelationsTracker(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); } //pawn.gender = Gender.None; pawn.gender = sourcePawn.gender; MiscUtility.GenerateRandomAge(pawn, pawn.Map); pawn.needs.SetInitialLevels(); if (pawn.RaceProps.Humanlike) { string headGraphicPath = sourcePawn.story.HeadGraphicPath; typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath); pawn.story.melanin = sourcePawn.story.melanin; pawn.story.crownType = sourcePawn.story.crownType; pawn.story.hairColor = sourcePawn.story.hairColor; NameTriple name = sourcePawn.Name as NameTriple; pawn.Name = name; pawn.story.childhood = sourcePawn.story.childhood; pawn.story.adulthood = sourcePawn.story.adulthood; pawn.story.hairDef = sourcePawn.story.hairDef; foreach (Trait current in sourcePawn.story.traits.allTraits) { pawn.story.traits.GainTrait(current); } //pawn.story.GenerateSkillsFromBackstory(); } GenerateZombieApparelFromSource(pawn, sourcePawn); PawnGenerationRequest con = new PawnGenerationRequest(); PawnInventoryGenerator.GenerateInventoryFor(pawn, con); //Graphic nakedBodyGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(sourcePawn.story.bodyType, ShaderDatabase.CutoutSkin, new Color(0.37f, 0.48f, 0.35f, 1f)); Graphic nakedBodyGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, new Color(0.37f, 0.48f, 0.35f, 1f)); Graphic headGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.HeadGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, new Color(0.37f, 0.48f, 0.35f, 1f)); Graphic hairGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, sourcePawn.story.hairColor); pawn.Drawer.renderer.graphics.headGraphic = headGraphic; pawn.Drawer.renderer.graphics.nakedGraphic = nakedBodyGraphic; pawn.Drawer.renderer.graphics.hairGraphic = hairGraphic; return(pawn); }