From 0833419cf848eef11ae18b3321a7b019f0fe14b3 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 30 Nov 2024 08:36:07 +0300 Subject: [PATCH] Disallow Royalty ending quest to be generated for space map --- Source/1.5/HarmonyPatches.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/1.5/HarmonyPatches.cs b/Source/1.5/HarmonyPatches.cs index b5534fad..b7ba1983 100644 --- a/Source/1.5/HarmonyPatches.cs +++ b/Source/1.5/HarmonyPatches.cs @@ -3988,6 +3988,28 @@ public static void Postfix(IncidentParms parms) } } + // Disallow Royalty ending quest to be generated when there are no surface player home maps, + // as it will be attached to player space map, which is not right for quest assuming enemy raids. + [HarmonyPatch(typeof(IncidentWorker_GiveQuest), "TryExecuteWorker")] + public static class NoRoyaltyEndingForSpaceMap + { + public static bool Prefix(IncidentWorker_GiveQuest __instance, IncidentParms parms, ref bool __result) + { + QuestScriptDef quest = __instance.def.questScriptDef ?? parms.questScriptDef; + Map spaceHome = ShipInteriorMod2.FindPlayerShipMap(); + if (quest.defName == "EndGame_RoyalAscent") + { + IEnumerable surfacePlayerMaps = Find.Maps.Where((Map x) => (x.IsPlayerHome && x != spaceHome)); + if (!surfacePlayerMaps.Any()) + { + __result = false; + return false; + } + } + return true; + } + } + [HarmonyPatch(typeof(QuestPart_EndGame), "Notify_QuestSignalReceived")] //change roy ending public static class ReplaceEndGame {