public static bool TrySpawnPawn(this HediffComp_RandySpawnUponDeath comp, Thing refThing, int randomQuantity) { string debugStr = comp.MyDebug ? (comp.Pawn.LabelShort + " TrySpawnPawn ") : ""; ThingSettings TS = comp.ChosenItem; IntVec3 position = refThing.Position; Map map = refThing.Map; /* * public PawnGenerationRequest( * 1 PawnKindDef kind, Faction faction = null, PawnGenerationContext context = PawnGenerationContext.NonPlayer, int tile = -1, bool forceGenerateNewPawn = false, * 2 bool newborn = false, bool allowDead = false, bool allowDowned = false, bool canGeneratePawnRelations = true, bool mustBeCapableOfViolence = false, * 3 float colonistRelationChanceFactor = 1, bool forceAddFreeWarmLayerIfNeeded = false, bool allowGay = true, bool allowFood = true, bool allowAddictions = true, * 4 bool inhabitant = false, bool certainlyBeenInCryptosleep = false, bool forceRedressWorldPawnIfFormerColonist = false, bool worldPawnFactionDoesntMatter = false, float biocodeWeaponChance = 0, * 5 Pawn extraPawnForExtraRelationChance = null, float relationWithExtraPawnChanceFactor = 1, Predicate<Pawn> validatorPreGear = null, Predicate<Pawn> validatorPostGear = null, IEnumerable<TraitDef> forcedTraits = null, * 6 IEnumerable<TraitDef> prohibitedTraits = null, float? minChanceToRedressWorldPawn = null, float? fixedBiologicalAge = null, float? fixedChronologicalAge = null, Gender? fixedGender = null, * 7 float? fixedMelanin = null, string fixedLastName = null, string fixedBirthName = null, RoyalTitleDef fixedTitle = null); */ //bool allowDead = false; bool allowDowned = false; bool canGeneratePawnRelations = true; bool mustBeCapableOfViolence = false; //float colonistRelationChanceFactor = 1; bool forceAddFreeWarmLayerIfNeeded = false; bool allowGay = true; bool allowFood = true; bool allowAddictions = true; //bool inhabitant = false; bool certainlyBeenInCryptosleep = false; bool forceRedressWorldPawnIfFormerColonist = false; bool worldPawnFactionDoesntMatter = false; float biocodeWeaponChance = 0; //Pawn extraPawnForExtraRelationChance = null; float relationWithExtraPawnChanceFactor = 1; //Predicate<Pawn> validatorPreGear = null; Predicate<Pawn> validatorPostGear = null; IEnumerable<TraitDef> forcedTraits = null; IEnumerable<TraitDef> prohibitedTraits = null; //float? minChanceToRedressWorldPawn = null; float? fixedBiologicalAge = null; float? fixedChronologicalAge = null; Gender? fixedGender = null; //PawnGenerationContext PGC = randomlyChosenItemfaction==Faction.OfPlayer ? PawnGenerationContext. PawnKindDef PKD = comp.PawnOfChoice; PawnGenerationRequest request = new PawnGenerationRequest( kind: PKD, faction: comp.RandomFaction, context: PawnGenerationContext.NonPlayer, tile: -1, forceGenerateNewPawn: false, newborn: TS.newBorn, colonistRelationChanceFactor: 0, allowAddictions: false, allowFood: false, relationWithExtraPawnChanceFactor: 0 ); for (int i = 0; i < randomQuantity; i++) { Pawn NewPawn = PawnGenerator.GeneratePawn(request); comp.SetAge(NewPawn); if (TS.IsCopier) { comp.SetName(NewPawn); comp.SetGender(NewPawn); comp.SetMelanin(NewPawn); comp.SetAlienSkinColor(NewPawn); comp.SetBodyType(NewPawn); comp.SetCrownType(NewPawn); comp.SetHair(NewPawn); comp.SetHairColor(NewPawn); comp.SetHediff(NewPawn); PawnCopyUtils.InitRememberBackstories(out Backstory rememberChildBS, out Backstory rememberAdultBS); if (comp.ChosenItem.copyParent.passions || comp.ChosenItem.copyParent.traits) { comp.RememberBackstories(NewPawn, out rememberChildBS, out rememberAdultBS); comp.ResetBackstories(NewPawn); //comp.ResetDisabledWorks(NewPawn, comp.MyDebug); comp.SetPassions(NewPawn); comp.SetSkills(NewPawn); comp.SetTraits(NewPawn); //comp.CopyDisabledWorks(NewPawn, comp.MyDebug); } if (rememberChildBS != null || rememberAdultBS != null) { comp.ReinjectBackstories(NewPawn, rememberChildBS, rememberAdultBS); } comp.SetBackstories(NewPawn); comp.UpdateDisabilities(NewPawn); } if (TS.IsRedresser) { comp.DestroyApparel(NewPawn); comp.DestroyEquipment(NewPawn); comp.DestroyInventory(NewPawn); } if (comp.HasContainerSpawn) { if (refThing is Building_Casket Casket) { if (!Casket.TryAcceptThing(NewPawn)) { if (comp.MyDebug) { Log.Warning(debugStr + " tried to add " + NewPawn.LabelShort + " to " + refThing.Label + ", but failed"); } } } } else { GenSpawn.Spawn(NewPawn, position, map, WipeMode.Vanish); } if (comp.ChosenItem.HasMentalStateParams) { comp.ComputeRandomMentalState(); if (comp.RandomMS != null) { NewPawn.mindState.mentalStateHandler.TryStartMentalState(comp.RandomMS, null, forceWake: false, causedByMood: false, otherPawn: null, transitionSilently: true); } } comp.TrySpawnAllFilth(refThing); if (comp.MyDebug) { Log.Warning("------------------"); } } return(true); }