about summary refs log tree commit diff stats
path: root/AnodyneArchipelago/Patches
diff options
context:
space:
mode:
Diffstat (limited to 'AnodyneArchipelago/Patches')
-rw-r--r--AnodyneArchipelago/Patches/GameplayPatches.cs96
1 files changed, 96 insertions, 0 deletions
diff --git a/AnodyneArchipelago/Patches/GameplayPatches.cs b/AnodyneArchipelago/Patches/GameplayPatches.cs index 9db87a5..ba33457 100644 --- a/AnodyneArchipelago/Patches/GameplayPatches.cs +++ b/AnodyneArchipelago/Patches/GameplayPatches.cs
@@ -10,6 +10,11 @@ using System;
10using System.Collections.Generic; 10using System.Collections.Generic;
11using System.Reflection; 11using System.Reflection;
12using Microsoft.Xna.Framework; 12using Microsoft.Xna.Framework;
13using AnodyneSharp.Entities.Interactive.Npc.RunningTradeNPCs;
14using AnodyneSharp.Dialogue;
15using AnodyneSharp.Sounds;
16using AnodyneSharp.States;
17using AnodyneSharp.Entities.Interactive.Npc;
13 18
14namespace AnodyneArchipelago.Patches 19namespace AnodyneArchipelago.Patches
15{ 20{
@@ -225,4 +230,95 @@ namespace AnodyneArchipelago.Patches
225 } 230 }
226 } 231 }
227 } 232 }
233
234 [HarmonyPatch(typeof(Box), nameof(Box.PlayerInteraction))]
235 class BoxOpenPatch
236 {
237 static bool Prefix(Box __instance, ref bool __result)
238 {
239 if (!GlobalState.events.SpookedMonster)
240 {
241 __result = false;
242 return false;
243 }
244
245 __instance.Play("open");
246 SoundManager.PlaySoundEffect("broom_hit");
247 GlobalState.StartCutscene = OnOpened(__instance);
248 __result = true;
249 return false;
250 }
251
252 static IEnumerator<CutsceneState.CutsceneEvent> OnOpened(Box box)
253 {
254 MethodInfo openedMethod = typeof(Box).GetMethod("OnOpened", BindingFlags.NonPublic | BindingFlags.Instance);
255 IEnumerator<CutsceneState.CutsceneEvent> subCutscene = (IEnumerator<CutsceneState.CutsceneEvent>)openedMethod.Invoke(box, new object[] { });
256
257 yield return subCutscene.Current;
258 while (subCutscene.MoveNext())
259 {
260 yield return subCutscene.Current;
261 }
262
263 GlobalState.inventory.tradeState = InventoryManager.TradeState.NONE;
264
265 Plugin.ArchipelagoManager.SendLocation("Fields - Cardboard Box");
266 }
267 }
268
269 [HarmonyPatch(typeof(ShopKeep), nameof(ShopKeep.PlayerInteraction))]
270 class ShopKeepTalkPatch
271 {
272 static bool Prefix(ShopKeep __instance)
273 {
274 if (GlobalState.events.GetEvent("ReceivedCardboardBox") == 1 && GlobalState.events.GetEvent("UsedCardboardBox") == 0)
275 {
276 GlobalState.Dialogue = GetDiag(2) + " " + GetDiag(4);
277 GlobalState.events.SetEvent("UsedCardboardBox", 1);
278
279 EntityPreset preset = PatchHelper.GetEntityPreset(typeof(ShopKeep), __instance);
280 preset.Activated = true;
281
282 Plugin.ArchipelagoManager.SendLocation("Fields - Shopkeeper Trade");
283
284 return false;
285 }
286
287 return true;
288 }
289
290 static string GetDiag(int i) => DialogueManager.GetDialogue("misc", "any", "tradenpc", i);
291 }
292
293 [HarmonyPatch(typeof(MitraFields), "GetInteractionText")]
294 class MitraFieldsTextPatch
295 {
296 static bool Prefix(ref string __result)
297 {
298 if (GlobalState.events.GetEvent("ReceivedBikingShoes") == 1 && GlobalState.events.GetEvent("UsedBikingShoes") == 0)
299 {
300 __result = DialogueManager.GetDialogue("misc", "any", "mitra", 1);
301
302 GlobalState.events.SetEvent("UsedBikingShoes", 1);
303
304 Plugin.ArchipelagoManager.SendLocation("Fields - Mitra Trade");
305
306 return false;
307 }
308
309 return true;
310 }
311 }
312
313 [HarmonyPatch("AnodyneSharp.Entities.Interactive.Npc.Windmill.Console", "PlayerInteraction")]
314 class WindmillInteractPatch
315 {
316 static void Prefix(object __instance)
317 {
318 if ((__instance as Entity).CurAnimName == "active")
319 {
320 Plugin.ArchipelagoManager.SendLocation("Windmill - Activation");
321 }
322 }
323 }
228} 324}