about summary refs log tree commit diff stats
path: root/AnodyneArchipelago/Patches/StatePatches.cs
diff options
context:
space:
mode:
Diffstat (limited to 'AnodyneArchipelago/Patches/StatePatches.cs')
-rw-r--r--AnodyneArchipelago/Patches/StatePatches.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/AnodyneArchipelago/Patches/StatePatches.cs b/AnodyneArchipelago/Patches/StatePatches.cs new file mode 100644 index 0000000..f6acc62 --- /dev/null +++ b/AnodyneArchipelago/Patches/StatePatches.cs
@@ -0,0 +1,39 @@
1using AnodyneSharp.Entities;
2using AnodyneSharp.Registry;
3using AnodyneSharp.States;
4using AnodyneSharp;
5using HarmonyLib;
6using System.Reflection;
7
8namespace AnodyneArchipelago.Patches
9{
10 [HarmonyPatch(typeof(AnodyneGame), "Update")]
11 class GameUpdatePatch
12 {
13 static void Postfix()
14 {
15 ArchipelagoManager.Update();
16 }
17 }
18
19 [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))]
20 class PlayStateCreatePatch
21 {
22 static void Prefix(PlayState __instance)
23 {
24 // Get player for later access.
25 FieldInfo playerField = typeof(PlayState).GetField("_player", BindingFlags.NonPublic | BindingFlags.Instance);
26 Plugin.Player = (Player)playerField.GetValue(__instance);
27
28 // Handle Red Grotto stuff.
29 GlobalState.events.SetEvent("red_cave_l_ss", 999);
30 GlobalState.events.SetEvent("red_cave_n_ss", 999);
31 GlobalState.events.SetEvent("red_cave_r_ss", 999);
32
33 // Connect to archipelago.
34 Plugin.Instance.Log.LogInfo("Connecting to Archipelago!");
35
36 ArchipelagoManager.Connect("localhost:38281", "Anodyne", "");
37 }
38 }
39}