public static Zombie DoGenerateZombiePawnFromSource(Pawn sourcePawn, string pawnKind, string factionName) { PawnKindDef pawnKindDef = PawnKindDef.Named(pawnKind); Faction factionDirect = Find.FactionManager.FirstFactionOfDef(FactionDef.Named(factionName)); Zombie pawn = (Zombie)ThingMaker.MakeThing(pawnKindDef.race, null); try { pawn.kindDef = pawnKindDef; pawn.SetFactionDirect(factionDirect); PawnComponentsUtility.CreateInitialComponents(pawn); pawn.gender = sourcePawn.gender; pawn.ageTracker.AgeBiologicalTicks = sourcePawn.ageTracker.AgeBiologicalTicks; pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks; pawn.workSettings = new Pawn_WorkSettings(pawn); if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer) { pawn.workSettings.EnableAndInitialize(); } pawn.needs.SetInitialLevels(); //Add hediffs? //Add relationships? if (pawn.RaceProps.Humanlike) { pawn.story.melanin = sourcePawn.story.melanin; pawn.story.crownType = sourcePawn.story.crownType; pawn.story.hairColor = sourcePawn.story.hairColor; pawn.story.childhood = sourcePawn.story.childhood; pawn.story.adulthood = sourcePawn.story.adulthood; pawn.story.bodyType = sourcePawn.story.bodyType; pawn.story.hairDef = sourcePawn.story.hairDef; SkillFixer(pawn, sourcePawn); RelationshipFixer(pawn, sourcePawn); AddedPartFixer(pawn, sourcePawn); //pawn.story.GenerateSkillsFromBackstory(); NameTriple nameTriple = sourcePawn.Name as NameTriple; pawn.Name = new NameTriple(nameTriple.First, string.Concat(new string[] { "* ", Translator.Translate("RE_Zombie"), " ", nameTriple.Nick, " *" }), nameTriple.Last); } string headGraphicPath = sourcePawn.story.HeadGraphicPath; typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath); GenerateZombieApparelFromSource(pawn, sourcePawn); PawnGenerationRequest con = new PawnGenerationRequest(); PawnInventoryGenerator.GenerateInventoryFor(pawn, con); GiveZombieSkinEffect(pawn, sourcePawn as Zombie); //if (isBerserk) //{ // pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); //} //Log.Message(pawn.Name.ToStringShort); return(pawn); } catch (Exception e) { //Cthulhu.Utility.DebugReport(e.ToString()); } return(null); }
private static void GiveTVirusCarrierEffect(Zombie pawn) { HealthUtility.AdjustSeverity(pawn, HediffDef.Named("RE_TVirusCarrier_Zombie"), 1.0f); }