protected override void RunInt() { Slate slate = QuestGen.slate; PawnsArrivalModeDef pawnsArrivalModeDef = this.arrivalMode.GetValue(slate) ?? PawnsArrivalModeDefOf.EdgeWalkIn; // this line is the only thing changed (we are using custom QuestPart) var pawnsArrive = new Kyrun.Reunion.QuestPart_PawnsArrive(); pawnsArrive.inSignal = (QuestGenUtility.HardcodedSignalWithQuestID(this.inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal", null, false)); pawnsArrive.pawns.AddRange(this.pawns.GetValue(slate)); pawnsArrive.arrivalMode = pawnsArrivalModeDef; pawnsArrive.joinPlayer = this.joinPlayer.GetValue(slate); pawnsArrive.mapParent = QuestGen.slate.Get <Map>("map", null, false).Parent; if (pawnsArrivalModeDef.walkIn) { pawnsArrive.spawnNear = (this.walkInSpot.GetValue(slate) ?? (QuestGen.slate.Get <IntVec3?>("walkInSpot", null, false) ?? IntVec3.Invalid)); } if (!this.customLetterLabel.GetValue(slate).NullOrEmpty() || this.customLetterLabelRules.GetValue(slate) != null) { QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterLabel = x; }, QuestGenUtility.MergeRules(this.customLetterLabelRules.GetValue(slate), this.customLetterLabel.GetValue(slate), "root")); } if (!this.customLetterText.GetValue(slate).NullOrEmpty() || this.customLetterTextRules.GetValue(slate) != null) { QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterText = x; }, QuestGenUtility.MergeRules(this.customLetterTextRules.GetValue(slate), this.customLetterText.GetValue(slate), "root")); } QuestGen.quest.AddPart(pawnsArrive); }
protected override void RunInt() { var slate = QuestGen.slate; var pawn = target.GetValue(slate); var range = sapienceRange.GetValue(slate); if (pawn == null) { throw new QuestException($"required quest parameter {nameof(target)} is not set in node {nameof(TransformPawn)}"); } var tfTarget = GetTransformations(slate).RandomElement(); if (tfTarget == null) { Log.Error($"{nameof(TransformPawn)} Could not get valid transformation target!"); return; } var sig = (QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? slate.Get <string>("inSignal")); var quest = QuestGen.quest; var tfPart = new Part_TransformPawn() { target = pawn, inSignal = sig, pawnKind = tfTarget, debugLabel = "TransformPawn", maxSapience = range.max, minSapience = range.min, }; quest.AddPart(tfPart); }
protected override void RunInt() { var slate = QuestGen.slate; var numMutations = addRange.GetValue(slate).RandomInRange; if (numMutations == 0) { return; } var mPawn = pawn.GetValue(slate); if (mPawn == null) { throw new QuestException($"required pawn ${nameof(pawn)}/\"{((ISlateRef) pawn).SlateRef}\" is missing!"); } var sig = (QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? slate.Get <string>("inSignal")); var allMutations = GetAllAvailableMutations(slate).Distinct().ToList(); var part = new Part_MutatePawn() { target = mPawn, countToAdd = numMutations, debugLabel = "Mutate Pawn", mutations = allMutations, inSignal = sig }; QuestGen.quest.AddPart(part); }
public void AppendPrefixToAllKeywords(string prefix) { tmpPrefix = prefix; if (output == null) { Log.Error("Rule_String output was null."); output = ""; } output = Regex.Replace(output, "\\[(.*?)\\]", RegexMatchEvaluatorAppendPrefix); if (constantConstraints == null) { return; } for (int i = 0; i < constantConstraints.Count; i++) { ConstantConstraint value = default(ConstantConstraint); value.key = constantConstraints[i].key; if (!prefix.NullOrEmpty()) { value.key = prefix + "/" + value.key; } value.key = QuestGenUtility.NormalizeVarPath(value.key); value.value = constantConstraints[i].value; value.type = constantConstraints[i].type; constantConstraints[i] = value; } }
protected override void RunInt() { GameComponentCentaurStory.trishotTraceEnabled = true; Find.ResearchManager.AddTechprints(CentaurStoryProjectStep1Def, 1); Find.ResearchManager.FinishProject(CentaurStoryProjectStep1Def, false, null); Slate slate = QuestGen.slate; QuestPart_Choice questPart_Choice = new QuestPart_Choice { inSignalChoiceUsed = QuestGenUtility.HardcodedSignalWithQuestID(inSignalChoiceUsed.GetValue(slate)) }; QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice(); choice.rewards.Add(new Reward_FisteverTrishot_Trishot()); choice.rewards.Add(new Reward_CentaurStoryProgress_Start()); questPart_Choice.choices.Add(choice); QuestPart_HyperLinks questPart_HyperLinks = new QuestPart_HyperLinks() { DefDatabase <ThingDef> .GetNamed("FabricationBench"), DefDatabase <RecipeDef> .GetNamed("Repair_Trishot_1Stage"), }; QuestGen.quest.AddPart(questPart_Choice); QuestGen.quest.AddPart(questPart_HyperLinks); }
protected override void RunInt() { Slate slate = QuestGen.slate; QuestPart_ReplaceLostLeaderReferences questPart_ReplaceLostLeaderReferences = new QuestPart_ReplaceLostLeaderReferences(); questPart_ReplaceLostLeaderReferences.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)); questPart_ReplaceLostLeaderReferences.signalListenMode = signalListenMode.GetValue(slate) ?? QuestPart.SignalListenMode.OngoingOnly; QuestGen.quest.AddPart(questPart_ReplaceLostLeaderReferences); }
public static void Log(this Quest quest, string message, string inSignal = null, QuestPart.SignalListenMode signalListenMode = QuestPart.SignalListenMode.OngoingOnly) { QuestPart_Log questPart_Log = new QuestPart_Log(); questPart_Log.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal"); questPart_Log.signalListenMode = signalListenMode; questPart_Log.message = message; quest.AddPart(questPart_Log); }
private static string RegexMatchEvaluatorAppendPrefix(Match match) { string text = match.Groups[1].Value; if (!tmpPrefix.NullOrEmpty()) { text = tmpPrefix + "/" + text; } text = QuestGenUtility.NormalizeVarPath(text); return("[" + text + "]"); }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { Slate slate = RimWorld.QuestGen.QuestGen.slate; for (int i = 0; i < items.Count; i++) { Pawn pawn = items[i] as Pawn; if (pawn != null) { RimWorld.QuestGen.QuestGen.AddToGeneratedPawns(pawn); if (!pawn.IsWorldPawn()) { Find.WorldPawns.PassToWorld(pawn); } } } if (parms.giveToCaravan) { QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan(); questPart_GiveToCaravan.inSignal = slate.Get <string>("inSignal"); questPart_GiveToCaravan.Things = items; yield return(questPart_GiveToCaravan); } else { QuestPart_DropPods dropPods = new QuestPart_DropPods(); dropPods.inSignal = slate.Get <string>("inSignal"); if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { dropPods.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root")); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { dropPods.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root")); } dropPods.mapParent = slate.Get <Map>("map").Parent; dropPods.useTradeDropSpot = true; dropPods.Things = items; yield return(dropPods); } slate.Set("itemsReward_items", items); slate.Set("itemsReward_totalMarketValue", TotalMarketValue); }
protected override void AddSpawnPawnQuestParts(Quest quest, Map map, Pawn pawn) { this.signalAccept = QuestGenUtility.HardcodedSignalWithQuestID("Accept"); this.signalReject = QuestGenUtility.HardcodedSignalWithQuestID("Reject"); quest.Signal(this.signalAccept, delegate { quest.SetFaction(Gen.YieldSingle <Pawn>(pawn), Faction.OfPlayer, null); quest.PawnsArrive(Gen.YieldSingle <Pawn>(pawn), null, map.Parent, null, false, null, null, null, null, null, false, false, true); quest.End(QuestEndOutcome.Success, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, false); }, null, QuestPart.SignalListenMode.OngoingOnly); quest.Signal(this.signalReject, delegate { quest.GiveDiedOrDownedThoughts(pawn, PawnDiedOrDownedThoughtsKind.DeniedJoining, null); quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, false); }, null, QuestPart.SignalListenMode.OngoingOnly); }
protected override void RunInt() { var pawn = GameComponent.GetRandomAllyForSpawning(); Slate slate = QuestGen.slate; if (storeAs.GetValue(slate) != null) { QuestGen.slate.Set(storeAs.GetValue(slate), pawn, false); } if (addToList.GetValue(slate) != null) { QuestGenUtility.AddToOrMakeList(QuestGen.slate, addToList.GetValue(slate), pawn); } QuestGen.AddToGeneratedPawns(pawn); // Vanilla code: adds the pawn to the World. // For this mod, remove them from the available list and put them in the spawned list instead. }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { Slate slate = RimWorld.QuestGen.QuestGen.slate; RimWorld.QuestGen.QuestGen.AddToGeneratedPawns(pawn); if (!pawn.IsWorldPawn()) { Find.WorldPawns.PassToWorld(pawn); } if (parms.giveToCaravan) { QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan(); questPart_GiveToCaravan.inSignal = slate.Get <string>("inSignal"); questPart_GiveToCaravan.Things = Gen.YieldSingle(pawn); yield return(questPart_GiveToCaravan); yield break; } QuestPart_PawnsArrive pawnsArrive = new QuestPart_PawnsArrive(); pawnsArrive.inSignal = slate.Get <string>("inSignal"); pawnsArrive.pawns.Add(pawn); pawnsArrive.arrivalMode = ((arrivalMode == ArrivalMode.DropPod) ? PawnsArrivalModeDefOf.CenterDrop : PawnsArrivalModeDefOf.EdgeWalkIn); pawnsArrive.joinPlayer = true; pawnsArrive.mapParent = slate.Get <Map>("map").Parent; if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root")); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root")); } yield return(pawnsArrive); }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { Slate slate = RimWorld.QuestGen.QuestGen.slate; QuestPart_GiveRoyalFavor questPart_GiveRoyalFavor = new QuestPart_GiveRoyalFavor(); questPart_GiveRoyalFavor.faction = faction; questPart_GiveRoyalFavor.amount = amount; if (!parms.chosenPawnSignal.NullOrEmpty()) { questPart_GiveRoyalFavor.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(parms.chosenPawnSignal); questPart_GiveRoyalFavor.signalListenMode = QuestPart.SignalListenMode.Always; } else { questPart_GiveRoyalFavor.inSignal = slate.Get <string>("inSignal"); questPart_GiveRoyalFavor.giveToAccepter = true; } yield return(questPart_GiveRoyalFavor); slate.Set("royalFavorReward_amount", amount); }