public override IEnumerable <Thing> GenerateThings(int forTile, Faction faction = null) { if (this.respectPopulationIntent && Rand.Value > StorytellerUtilityPopulation.PopulationIntent) { yield break; } int count = this.countRange.RandomInRange; for (int i = 0; i < count; i++) { Faction mercenaryFaction; if (!(from fac in Find.FactionManager.AllFactionsVisible where fac != Faction.OfPlayer && fac.def.humanlikeFaction select fac).TryRandomElement(out mercenaryFaction)) { yield break; } var mercenaryPawnKindDef = RatkinPawnKindDefOf.RatkinMercenary; PawnGenerationRequest request = PawnGenerationRequest.MakeDefault(); request.KindDef = mercenaryPawnKindDef; request.Faction = mercenaryFaction; request.Tile = forTile; request.ForceAddFreeWarmLayerIfNeeded = !this.trader.orbital; yield return(PawnGenerator.GeneratePawn(request)); } yield break; }
public static bool MovePawnToColony(Pawn pawn, Pawn inviter, Map destination) { Map map = destination; if (map.ParentFaction != Faction.OfPlayer) { if (inviter.IsCaravanMember() || PawnUtility.IsTravelingInTransportPodWorldObject(pawn) || inviter.Map.ParentFaction != Faction.OfPlayer) { map = Find.AnyPlayerHomeMap; } else { map = inviter.Map; } } if (!TryFindEntryCell(map, out IntVec3 cell)) { return(false); } if (pawn.apparel.AnyApparelLocked) { var req = PawnGenerationRequest.MakeDefault(); req.Tile = inviter.Map.Tile; PawnApparelGenerator.GenerateStartingApparelFor(pawn, req); } GenSpawn.Spawn(pawn, cell, map, WipeMode.Vanish); Letters.SendJoinLetter(pawn, inviter, map); return(true); }
public override IEnumerable <Thing> GenerateThings(int forTile, Faction faction = null) { int count = MoreSlavesSettings.slaveCount.RandomInRange; int num; for (int i = 0; i < count; i = num + 1) { if (!(from fac in Find.FactionManager.AllFactionsVisible where fac != Faction.OfPlayer && fac.def.humanlikeFaction select fac).TryRandomElement(out Faction faction2)) { yield break; } PawnGenerationRequest request = PawnGenerationRequest.MakeDefault(); request.KindDef = slaveKindDef ?? PawnKindDefOf.Slave; request.Faction = faction2; request.Tile = forTile; request.ForceAddFreeWarmLayerIfNeeded = !trader.orbital; request.RedressValidator = (Pawn x) => x.royalty == null || !x.royalty.AllTitlesForReading.Any <RoyalTitle>(); Pawn pawn = PawnGenerator.GeneratePawn(request); yield return(pawn); num = i; } }
private Pawn GeneratePawn() { var request = PawnGenerationRequest.MakeDefault(); request.KindDef = AnimalDef; request.FixedGender = Gender; request.Faction = SpawnTamed && !SpawnManhunter ? Faction.OfPlayer : null; Pawn pawn = PawnGenerator.GeneratePawn(request); return(pawn); }
private void SpawnAnimal() { if (Proxy.Thing.Thing.race.Humanlike) { // ReSharper disable once StringLiteralTypo TkUtils.Logger.Warn("Tried to spawn a humanlike -- Humanlikes should be spawned via !buy pawn"); return; } string animal = Proxy.Thing.Thing.label.CapitalizeFirst(); if (Quantity > 1) { animal = animal.Pluralize(); } var coordinator = Current.Game.GetComponent <Coordinator>(); if (coordinator?.HasActivePortals == true) { for (var _ = 0; _ < Quantity; _++) { var request = PawnGenerationRequest.MakeDefault(); request.KindDef = PawnKindDef.Named(Proxy.Thing.Thing.defName); request.FixedGender = Proxy.Gender; request.Faction = Faction.OfPlayer; Pawn pawn = PawnGenerator.GeneratePawn(request); coordinator.TrySpawnAnimal(Map, pawn); _animalsForLetter.Add(pawn); } _sendAnimalLetter = true; return; } var worker = new AnimalSpawnWorker { Label = "TKUtils.ItemLetter.Animal".LocalizeKeyed(animal), AnimalDef = PawnKindDef.Named(Proxy.Thing.Thing.defName), Gender = Proxy.Gender, def = IncidentDef.Named("FarmAnimalsWanderIn"), Quantity = Quantity, SpawnTamed = true }; worker.TryExecute(StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Map)); }
// Token: 0x060054FE RID: 21758 RVA: 0x001C42E9 File Offset: 0x001C24E9 public override IEnumerable <Thing> GenerateThings(int forTile, Faction faction = null) { if (this.respectPopulationIntent && Rand.Value > StorytellerUtilityPopulation.PopulationIntent) { yield break; } int count = this.countRange.RandomInRange; int num; for (int i = 0; i < count; i = num + 1) { Faction faction2; if (faction != null) { faction2 = faction; } else { faction2 = Faction.OfPlayer; /* * if (!(from fac in Find.FactionManager.AllFactionsVisible * where fac != Faction.OfPlayer && fac.def.humanlikeFaction * select fac).TryRandomElement(out faction2)) * { * yield break; * } */ } if (!(from kind in DefDatabase <PawnKindDef> .AllDefsListForReading where kind.defaultFactionType != null && kind.RaceProps.Humanlike && (kind.defaultFactionType == Faction.OfPlayer.def || kind.defaultFactionType == faction2.def) select kind).TryRandomElement(out this.slaveKindDef)) { yield break; } PawnGenerationRequest request = PawnGenerationRequest.MakeDefault(); request.KindDef = ((this.slaveKindDef != null) ? this.slaveKindDef : PawnKindDefOf.Slave); request.Faction = null; request.Tile = forTile; request.ForceAddFreeWarmLayerIfNeeded = !this.trader.orbital; request.RedressValidator = ((Pawn x) => x.royalty == null || !x.royalty.AllTitlesForReading.Any <RoyalTitle>()); yield return(PawnGenerator.GeneratePawn(request)); num = i; } yield break; }
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); } }
private void GenerateGuards(PawnGroupMakerParms parms, PawnGroupMaker groupMaker, Pawn trader, List <Thing> wares, List <Pawn> outPawns) { if (groupMaker.guards.Any()) { foreach (PawnGenOption item2 in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.guards, parms)) { PawnGenerationRequest request = PawnGenerationRequest.MakeDefault(); request.KindDef = item2.kind; 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()); Pawn item = PawnGenerator.GeneratePawn(request); outPawns.Add(item); } } }
public override IEnumerable <Thing> GenerateThings(int forTile, Faction faction = null) { if (respectPopulationIntent && Rand.Value > StorytellerUtilityPopulation.PopulationIntent) { yield break; } int count = countRange.RandomInRange; for (int i = 0; i < count; i++) { if (!Find.FactionManager.AllFactionsVisible.Where((Faction fac) => fac != Faction.OfPlayer && fac.def.humanlikeFaction && !fac.temporary).TryRandomElement(out var result)) { break; } PawnGenerationRequest request = PawnGenerationRequest.MakeDefault(); request.KindDef = ((slaveKindDef != null) ? slaveKindDef : PawnKindDefOf.Slave); request.Faction = result; request.Tile = forTile; request.ForceAddFreeWarmLayerIfNeeded = !trader.orbital; request.RedressValidator = (Pawn x) => x.royalty == null || !x.royalty.AllTitlesForReading.Any(); yield return(PawnGenerator.GeneratePawn(request)); } }