|
3 | 3 | using InscryptionAPI.Guid; |
4 | 4 | using InscryptionAPI.Masks; |
5 | 5 | using InscryptionAPI.Saves; |
| 6 | +using System.Collections; |
6 | 7 | using System.Collections.ObjectModel; |
7 | 8 | using System.Reflection; |
8 | 9 | using System.Reflection.Emit; |
@@ -89,10 +90,49 @@ public static FullOpponent Add(string guid, string opponentName, string sequence |
89 | 90 | NewOpponents.Add(opp); |
90 | 91 | return opp; |
91 | 92 | } |
| 93 | + public static List<Opponent.Type> RunStateOpponents |
| 94 | + { |
| 95 | + get |
| 96 | + { |
| 97 | + List<Opponent.Type> previousBosses = new List<Opponent.Type>(); |
| 98 | + |
| 99 | + string value = ModdedSaveManager.RunState.GetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses"); // 2,0,1 |
| 100 | + if (value == null) |
| 101 | + { |
| 102 | + // Do nothing |
| 103 | + } |
| 104 | + else if (!value.Contains(',')) |
| 105 | + { |
| 106 | + // Single boss encounter |
| 107 | + previousBosses.Add((Opponent.Type)int.Parse(value)); |
| 108 | + } |
| 109 | + else |
| 110 | + { |
| 111 | + // Multiple boss encounters |
| 112 | + IEnumerable<Opponent.Type> ids = value.Split(',').Select(static (a) => (Opponent.Type)int.Parse(a)); |
| 113 | + previousBosses.AddRange(ids); |
| 114 | + } |
| 115 | + |
| 116 | + return previousBosses; |
| 117 | + } |
| 118 | + set |
| 119 | + { |
| 120 | + string result = ""; // 2,0,1 |
| 121 | + for (int i = 0; i < value.Count; i++) |
| 122 | + { |
| 123 | + if (i > 0) |
| 124 | + { |
| 125 | + result += ","; |
| 126 | + } |
| 127 | + result += (int)value[i]; |
| 128 | + |
| 129 | + } |
| 130 | + ModdedSaveManager.RunState.SetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses", result); |
| 131 | + } |
| 132 | + } |
92 | 133 |
|
93 | 134 | #region Patches |
94 | | - [HarmonyPatch(typeof(Opponent), nameof(Opponent.SpawnOpponent))] |
95 | | - [HarmonyPrefix] |
| 135 | + [HarmonyPrefix, HarmonyPatch(typeof(Opponent), nameof(Opponent.SpawnOpponent))] |
96 | 136 | private static bool ReplaceSpawnOpponent(EncounterData encounterData, ref Opponent __result) |
97 | 137 | { |
98 | 138 | if (encounterData.opponentType == Opponent.Type.Default || !ProgressionData.LearnedMechanic(MechanicsConcept.OpponentQueue)) |
@@ -124,27 +164,19 @@ private static bool ReplaceSpawnOpponent(EncounterData encounterData, ref Oppone |
124 | 164 | [MethodImpl(MethodImplOptions.NoInlining)] |
125 | 165 | public static string OriginalGetSequencerIdForBoss(Opponent.Type bossType) { throw new NotImplementedException(); } |
126 | 166 |
|
127 | | - [HarmonyPatch(typeof(BossBattleSequencer), nameof(BossBattleSequencer.GetSequencerIdForBoss))] |
128 | | - [HarmonyPrefix] |
| 167 | + [HarmonyPrefix, HarmonyPatch(typeof(BossBattleSequencer), nameof(BossBattleSequencer.GetSequencerIdForBoss))] |
129 | 168 | private static bool ReplaceGetSequencerId(Opponent.Type bossType, ref string __result) |
130 | 169 | { |
131 | 170 | __result = AllOpponents.First(o => o.Id == bossType).SpecialSequencerId; |
132 | 171 | return false; |
133 | 172 | } |
134 | 173 |
|
135 | | - [HarmonyPatch(typeof(BossBattleNodeData), nameof(BossBattleNodeData.PrefabPath), MethodType.Getter)] |
136 | | - [HarmonyPrefix] |
| 174 | + [HarmonyPrefix, HarmonyPatch(typeof(BossBattleNodeData), nameof(BossBattleNodeData.PrefabPath), MethodType.Getter)] |
137 | 175 | private static bool ReplacePrefabPath(ref string __result, Opponent.Type ___bossType) |
138 | 176 | { |
139 | | - GameObject obj = ResourceBank.Get<GameObject>("Prefabs/Map/MapNodesPart1/MapNode_" + ___bossType); |
140 | | - if (obj != null) |
141 | | - { |
142 | | - __result = "Prefabs/Map/MapNodesPart1/MapNode_" + ___bossType; |
143 | | - } |
144 | | - else |
145 | | - { |
146 | | - __result = "Prefabs/Map/MapNodesPart1/MapNode_ProspectorBoss"; |
147 | | - } |
| 177 | + string fullPath = "Prefabs/Map/MapNodesPart1/MapNode_" + ___bossType; |
| 178 | + GameObject obj = ResourceBank.Get<GameObject>(fullPath); |
| 179 | + __result = obj != null ? fullPath : "Prefabs/Map/MapNodesPart1/MapNode_ProspectorBoss"; |
148 | 180 | return false; |
149 | 181 | } |
150 | 182 |
|
@@ -220,47 +252,20 @@ public static void ProcessBossType(NodeData nodeData) |
220 | 252 | } |
221 | 253 | } |
222 | 254 |
|
223 | | - public static List<Opponent.Type> RunStateOpponents |
| 255 | + [HarmonyPostfix, HarmonyPatch(typeof(CardDrawPiles), nameof(CardDrawPiles.ExhaustedSequence))] |
| 256 | + private static IEnumerator CustomBossExhaustionSequence(IEnumerator enumerator, CardDrawPiles __instance) |
224 | 257 | { |
225 | | - get |
| 258 | + if (TurnManager.Instance.Opponent is ICustomExhaustSequence exhaustSeq && exhaustSeq != null) |
226 | 259 | { |
227 | | - List<Opponent.Type> previousBosses = new List<Opponent.Type>(); |
228 | | - |
229 | | - string value = ModdedSaveManager.RunState.GetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses"); // 2,0,1 |
230 | | - if (value == null) |
231 | | - { |
232 | | - // Do nothing |
233 | | - } |
234 | | - else if (!value.Contains(',')) |
235 | | - { |
236 | | - // Single boss encounter |
237 | | - previousBosses.Add((Opponent.Type)int.Parse(value)); |
238 | | - } |
239 | | - else |
240 | | - { |
241 | | - // Multiple boss encounters |
242 | | - IEnumerable<Opponent.Type> ids = value.Split(',').Select(static (a) => (Opponent.Type)int.Parse(a)); |
243 | | - previousBosses.AddRange(ids); |
244 | | - } |
245 | | - |
246 | | - return previousBosses; |
| 260 | + Singleton<ViewManager>.Instance.SwitchToView(View.CardPiles, immediate: false, lockAfter: true); |
| 261 | + yield return new WaitForSeconds(1f); |
| 262 | + yield return exhaustSeq.DoCustomExhaustSequence(__instance); |
247 | 263 | } |
248 | | - set |
| 264 | + else |
249 | 265 | { |
250 | | - string result = ""; // 2,0,1 |
251 | | - for (int i = 0; i < value.Count; i++) |
252 | | - { |
253 | | - if (i > 0) |
254 | | - { |
255 | | - result += ","; |
256 | | - } |
257 | | - result += (int)value[i]; |
258 | | - |
259 | | - } |
260 | | - ModdedSaveManager.RunState.SetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses", result); |
| 266 | + yield return enumerator; |
261 | 267 | } |
262 | 268 | } |
263 | | - |
264 | 269 | #endregion |
265 | 270 |
|
266 | 271 | #region Optimization Patches |
|
0 commit comments