static bool Prefix(ref PawnGroupKindWorker_Trader __instance, PawnGroupMakerParms parms, PawnGroupMaker groupMaker, Pawn trader, List <Thing> wares, List <Pawn> outPawns) { if (parms.faction == FactionColonies.getPlayerColonyFaction()) { List <PawnKindDef> list = new List <PawnKindDef>(); foreach (ThingDef def in Find.World.GetComponent <FactionFC>().raceFilter.AllowedThingDefs) { list.Add(def.race.AnyPawnKind); } if (!groupMaker.guards.Any <PawnGenOption>()) { return(false); } foreach (PawnGenOption pawnGenOption in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.guards, parms)) { PawnKindDef pawnkind = new PawnKindDef(); pawnkind = list.RandomElement(); pawnkind.techHediffsTags = pawnGenOption.kind.techHediffsTags; pawnkind.apparelTags = pawnGenOption.kind.apparelTags; pawnkind.isFighter = pawnGenOption.kind.isFighter; pawnkind.combatPower = pawnGenOption.kind.combatPower; pawnkind.gearHealthRange = pawnGenOption.kind.gearHealthRange; pawnkind.weaponTags = pawnGenOption.kind.weaponTags; pawnkind.apparelMoney = pawnGenOption.kind.apparelMoney; pawnkind.weaponMoney = pawnGenOption.kind.weaponMoney; pawnkind.apparelAllowHeadgearChance = pawnGenOption.kind.apparelAllowHeadgearChance; pawnkind.techHediffsMoney = pawnGenOption.kind.techHediffsMoney; pawnkind.label = pawnGenOption.kind.label; PawnGenerationRequest request = PawnGenerationRequest.MakeDefault(); request.KindDef = pawnkind; Log.Message(request.KindDef.ToString()); request.Faction = parms.faction; request.Tile = parms.tile; request.MustBeCapableOfViolence = true; request.Inhabitant = parms.inhabitants; request.RedressValidator = ((Pawn x) => x.royalty == null || !x.royalty.AllTitlesForReading.Any <RoyalTitle>()); Pawn item = PawnGenerator.GeneratePawn(request); outPawns.Add(item); } return(false); } else { return(true); } }
static bool Prefix(ref PawnGroupKindWorker_Normal __instance, PawnGroupMakerParms parms, PawnGroupMaker groupMaker, List <Pawn> outPawns, bool errorOnZeroResults = true) { if (parms.faction == FactionColonies.getPlayerColonyFaction()) { List <PawnKindDef> list = new List <PawnKindDef>(); foreach (ThingDef def in Find.World.GetComponent <FactionFC>().raceFilter.AllowedThingDefs) { list.Add(def.race.AnyPawnKind); } if (!__instance.CanGenerateFrom(parms, groupMaker)) { if (errorOnZeroResults) { Log.Error(string.Concat(new object[] { "Cannot generate pawns for ", parms.faction, " with ", parms.points, ". Defaulting to a single random cheap group." }), false); } return(false); } bool allowFood = parms.raidStrategy == null || parms.raidStrategy.pawnsCanBringFood || (parms.faction != null && !parms.faction.HostileTo(Faction.OfPlayer)); Predicate <Pawn> validatorPostGear = (parms.raidStrategy != null) ? ((Pawn p) => parms.raidStrategy.Worker.CanUsePawn(p, outPawns)) : (Predicate <Pawn>)null; bool flag = false; foreach (PawnGenOption pawnGenOption in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms)) { PawnKindDef pawnkind = new PawnKindDef(); pawnkind = list.RandomElement(); pawnkind.techHediffsTags = pawnGenOption.kind.techHediffsTags; pawnkind.apparelTags = pawnGenOption.kind.apparelTags; pawnkind.isFighter = pawnGenOption.kind.isFighter; pawnkind.combatPower = pawnGenOption.kind.combatPower; pawnkind.gearHealthRange = pawnGenOption.kind.gearHealthRange; pawnkind.weaponTags = pawnGenOption.kind.weaponTags; pawnkind.apparelMoney = pawnGenOption.kind.apparelMoney; pawnkind.weaponMoney = pawnGenOption.kind.weaponMoney; pawnkind.apparelAllowHeadgearChance = pawnGenOption.kind.apparelAllowHeadgearChance; pawnkind.techHediffsMoney = pawnGenOption.kind.techHediffsMoney; pawnkind.label = pawnGenOption.kind.label; Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnkind, parms.faction, PawnGenerationContext.NonPlayer, parms.tile, false, false, false, false, true, true, 1f, false, true, allowFood, true, parms.inhabitants, false, false, false, 0f, null, 1f, null, validatorPostGear, null, null, null, null, null, null, null, null, null, null)); if (parms.forceOneIncap && !flag) { pawn.health.forceIncap = true; pawn.mindState.canFleeIndividual = false; flag = true; } outPawns.Add(pawn); } return(false); } else { return(true); } }