private bool TrySetVars(Slate slate, bool test) { Pawn asker = slate.Get <Pawn>("asker"); Thing mustBeHostileToFactionOfResolved = mustBeHostileToFactionOf.GetValue(slate); if (!SiteMakerHelper.TryFindRandomFactionFor(sitePartDefs.GetValue(slate), out Faction faction, disallowNonHostileFactions : true, delegate(Faction x) { if (asker != null && asker.Faction == x) { return(false); } return((mustBeHostileToFactionOfResolved == null || mustBeHostileToFactionOfResolved.Faction == null || (x != mustBeHostileToFactionOfResolved.Faction && x.HostileTo(mustBeHostileToFactionOfResolved.Faction))) ? true : false); })) { return(false); } if (!Find.Storyteller.difficulty.allowViolentQuests && faction.HostileTo(Faction.OfPlayer)) { return(false); } slate.Set(storeAs.GetValue(slate), faction); if (!test && faction != null && !faction.def.hidden) { QuestPart_InvolvedFactions questPart_InvolvedFactions = new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(faction); QuestGen.quest.AddPart(questPart_InvolvedFactions); } return(true); }
protected override void RunInt() { Slate slate = QuestGen.slate; Pawn pawn; if (this.questGiver != null && this.storeAs.GetValue(slate) == "asker") { slate.Set <Pawn>(this.storeAs.GetValue(slate), this.questGiver, false); return; } if (QuestGen.slate.TryGet <Pawn>(this.storeAs.GetValue(slate), out pawn, false) && this.IsGoodPawn(pawn, slate)) { return; } IEnumerable <Pawn> source = this.ExistingUsablePawns(slate); int num = source.Count <Pawn>(); Faction faction; if (Rand.Chance(this.canGeneratePawn.GetValue(slate) ? Mathf.Clamp01(1f - (float)num / (float)this.maxUsablePawnsToGenerate.GetValue(slate)) : 0f) && (this.mustHaveNoFaction.GetValue(slate) || this.TryFindFactionForPawnGeneration(slate, out faction))) { pawn = this.GeneratePawn(slate, null); } else { pawn = source.RandomElement <Pawn>(); } if (pawn.Faction != null && !pawn.Faction.def.hidden) { QuestPart_InvolvedFactions questPart_InvolvedFactions = new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(pawn.Faction); QuestGen.quest.AddPart(questPart_InvolvedFactions); } QuestGen.slate.Set <Pawn>(this.storeAs.GetValue(slate), pawn, false); }
protected override void RunInt() { Slate slate = QuestGen.slate; if (this.questGiverFaction != null && (this.storeAs.GetValue(slate) == "faction" || this.storeAs.GetValue(slate) == "askerFaction")) { slate.Set <Faction>(this.storeAs.GetValue(slate), this.questGiverFaction, false); return; } Faction faction; if (QuestGen.slate.TryGet <Faction>(this.storeAs.GetValue(slate), out faction, false) && this.IsGoodFaction(faction, QuestGen.slate)) { return; } if (this.TryFindFaction(out faction, QuestGen.slate)) { QuestGen.slate.Set <Faction>(this.storeAs.GetValue(slate), faction, false); if (!faction.def.hidden) { QuestPart_InvolvedFactions questPart_InvolvedFactions = new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(faction); QuestGen.quest.AddPart(questPart_InvolvedFactions); } } }
public static QuestPart_InvolvedFactions AddInvolvedFaction(this Quest quest, Faction faction) { QuestPart_InvolvedFactions questPart_InvolvedFactions = ((QuestPart_InvolvedFactions)quest.PartsListForReading.First((QuestPart p) => p is QuestPart_InvolvedFactions)) ?? new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(faction); if (!quest.PartsListForReading.Contains(questPart_InvolvedFactions)) { quest.AddPart(questPart_InvolvedFactions); } return(questPart_InvolvedFactions); }
protected override void RunInt() { Slate slate = QuestGen.slate; if (factionDef != null && SetFaction(out Faction var, slate) || (!QuestGen.slate.TryGet(storeAs.GetValue(slate), out var) || !IsGoodFaction(var, QuestGen.slate)) && TryFindFaction(out var, QuestGen.slate)) { QuestGen.slate.Set(storeAs.GetValue(slate), var); if (!var.Hidden) { QuestPart_InvolvedFactions questPart_InvolvedFactions = new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(var); QuestGen.quest.AddPart(questPart_InvolvedFactions); } } }
public static Pawn GetPawn(this Quest quest, GetPawnParms parms) { _ = QuestGen.slate; IEnumerable <Pawn> source = ExistingUsablePawns(parms); int num = source.Count(); Faction faction; Pawn pawn = ((!Rand.Chance(parms.canGeneratePawn ? Mathf.Clamp01(1f - (float)num / 10f) : 0f) || (!parms.mustHaveNoFaction && !TryFindFactionForPawnGeneration(parms, out faction))) ? source.RandomElement() : GeneratePawn(parms)); if (pawn.Faction != null && !pawn.Faction.Hidden) { QuestPart_InvolvedFactions questPart_InvolvedFactions = new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(pawn.Faction); quest.AddPart(questPart_InvolvedFactions); } QuestGen.AddToGeneratedPawns(pawn); return(pawn); }
protected override void RunInt() { Slate slate = QuestGen.slate; if (!QuestGen.slate.TryGet(storeAs.GetValue(slate), out Pawn var) || !IsGoodPawn(var, slate)) { IEnumerable <Pawn> source = ExistingUsablePawns(slate); int num = source.Count(); var = ((!Rand.Chance(canGeneratePawn.GetValue(slate) ? Mathf.Clamp01(1f - (float)num / (float)maxUsablePawnsToGenerate.GetValue(slate)) : 0f) || (!mustHaveNoFaction.GetValue(slate) && !TryFindFactionForPawnGeneration(slate, out Faction _))) ? source.RandomElementByWeight((Pawn x) => (x.Faction != null && x.Faction.HostileTo(Faction.OfPlayer)) ? (hostileWeight.GetValue(slate) ?? 1f) : (nonHostileWeight.GetValue(slate) ?? 1f)) : GeneratePawn(slate)); if (var.Faction != null && !var.Faction.def.hidden) { QuestPart_InvolvedFactions questPart_InvolvedFactions = new QuestPart_InvolvedFactions(); questPart_InvolvedFactions.factions.Add(var.Faction); QuestGen.quest.AddPart(questPart_InvolvedFactions); } QuestGen.slate.Set(storeAs.GetValue(slate), var); } }
protected override void RunInt() { var slate = QuestGen.slate; var pawn = PawnsFinder.AllMaps_FreeColonistsAndPrisoners.Where(p => GoodPawn(p, slate)) .RandomElementByWeight(GetWeight); if (pawn.Faction != null && !pawn.Faction.def.hidden) { QuestPart_InvolvedFactions factionPart = new QuestPart_InvolvedFactions() { factions = new List <Faction> { pawn.Faction } }; QuestGen.quest.AddPart(factionPart); } slate.Set(storeAs.GetValue(slate), pawn); }