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.cs22
1 files changed, 16 insertions, 6 deletions
diff --git a/AnodyneArchipelago/Patches/StatePatches.cs b/AnodyneArchipelago/Patches/StatePatches.cs index 4b29295..40b30fe 100644 --- a/AnodyneArchipelago/Patches/StatePatches.cs +++ b/AnodyneArchipelago/Patches/StatePatches.cs
@@ -8,6 +8,7 @@ using AnodyneSharp.Drawing.Effects;
8using AnodyneSharp.States.MainMenu; 8using AnodyneSharp.States.MainMenu;
9using static AnodyneSharp.AnodyneGame; 9using static AnodyneSharp.AnodyneGame;
10using AnodyneSharp.Drawing; 10using AnodyneSharp.Drawing;
11using System.IO;
11 12
12namespace AnodyneArchipelago.Patches 13namespace AnodyneArchipelago.Patches
13{ 14{
@@ -16,7 +17,10 @@ namespace AnodyneArchipelago.Patches
16 { 17 {
17 static void Postfix() 18 static void Postfix()
18 { 19 {
19 ArchipelagoManager.Update(); 20 if (Plugin.ArchipelagoManager != null)
21 {
22 Plugin.ArchipelagoManager.Update();
23 }
20 } 24 }
21 } 25 }
22 26
@@ -63,6 +67,17 @@ namespace AnodyneArchipelago.Patches
63 } 67 }
64 } 68 }
65 69
70 [HarmonyPatch(typeof(GlobalState.Save), nameof(GlobalState.Save.SaveTo))]
71 class SaveToPatch
72 {
73 static bool Prefix(GlobalState.Save __instance)
74 {
75 File.WriteAllText(string.Format("{0}Saves/Save_zzAP{1}_{2}.dat", GameConstants.SavePath, Plugin.ArchipelagoManager.GetSeed(), Plugin.ArchipelagoManager.GetPlayer()), __instance.ToString());
76
77 return false;
78 }
79 }
80
66 [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))] 81 [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))]
67 class PlayStateCreatePatch 82 class PlayStateCreatePatch
68 { 83 {
@@ -76,11 +91,6 @@ namespace AnodyneArchipelago.Patches
76 GlobalState.events.SetEvent("red_cave_l_ss", 999); 91 GlobalState.events.SetEvent("red_cave_l_ss", 999);
77 GlobalState.events.SetEvent("red_cave_n_ss", 999); 92 GlobalState.events.SetEvent("red_cave_n_ss", 999);
78 GlobalState.events.SetEvent("red_cave_r_ss", 999); 93 GlobalState.events.SetEvent("red_cave_r_ss", 999);
79
80 // Connect to archipelago.
81 Plugin.Instance.Log.LogInfo("Connecting to Archipelago!");
82
83 ArchipelagoManager.Connect("localhost:38281", "Anodyne", "");
84 } 94 }
85 } 95 }
86} 96}