From 189fcfc1087764961e61c470ffea642ff46d164d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 25 May 2024 13:11:17 -0400 Subject: You can connect now! --- AnodyneArchipelago/Patches/GameplayPatches.cs | 10 +++++----- AnodyneArchipelago/Patches/StatePatches.cs | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'AnodyneArchipelago/Patches') diff --git a/AnodyneArchipelago/Patches/GameplayPatches.cs b/AnodyneArchipelago/Patches/GameplayPatches.cs index ada4159..9db87a5 100644 --- a/AnodyneArchipelago/Patches/GameplayPatches.cs +++ b/AnodyneArchipelago/Patches/GameplayPatches.cs @@ -69,15 +69,15 @@ namespace AnodyneArchipelago.Patches if (preset.Frame == 0) { - ArchipelagoManager.SendLocation("Temple of the Seeing One - Green Key"); + Plugin.ArchipelagoManager.SendLocation("Temple of the Seeing One - Green Key"); } else if (preset.Frame == 1) { - ArchipelagoManager.SendLocation("Red Grotto - Red Key"); + Plugin.ArchipelagoManager.SendLocation("Red Grotto - Red Key"); } else if (preset.Frame == 2) { - ArchipelagoManager.SendLocation("Mountain Cavern - Blue Key"); + Plugin.ArchipelagoManager.SendLocation("Mountain Cavern - Blue Key"); } } } @@ -134,7 +134,7 @@ namespace AnodyneArchipelago.Patches if (Locations.LocationsByGuid.ContainsKey(preset.EntityID)) { - ArchipelagoManager.SendLocation(Locations.LocationsByGuid[preset.EntityID]); + Plugin.ArchipelagoManager.SendLocation(Locations.LocationsByGuid[preset.EntityID]); } } } @@ -221,7 +221,7 @@ namespace AnodyneArchipelago.Patches if (Locations.LocationsByGuid.ContainsKey(preset.EntityID)) { - ArchipelagoManager.SendLocation(Locations.LocationsByGuid[preset.EntityID]); + Plugin.ArchipelagoManager.SendLocation(Locations.LocationsByGuid[preset.EntityID]); } } } 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; using AnodyneSharp.States.MainMenu; using static AnodyneSharp.AnodyneGame; using AnodyneSharp.Drawing; +using System.IO; namespace AnodyneArchipelago.Patches { @@ -16,7 +17,10 @@ namespace AnodyneArchipelago.Patches { static void Postfix() { - ArchipelagoManager.Update(); + if (Plugin.ArchipelagoManager != null) + { + Plugin.ArchipelagoManager.Update(); + } } } @@ -63,6 +67,17 @@ namespace AnodyneArchipelago.Patches } } + [HarmonyPatch(typeof(GlobalState.Save), nameof(GlobalState.Save.SaveTo))] + class SaveToPatch + { + static bool Prefix(GlobalState.Save __instance) + { + File.WriteAllText(string.Format("{0}Saves/Save_zzAP{1}_{2}.dat", GameConstants.SavePath, Plugin.ArchipelagoManager.GetSeed(), Plugin.ArchipelagoManager.GetPlayer()), __instance.ToString()); + + return false; + } + } + [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))] class PlayStateCreatePatch { @@ -76,11 +91,6 @@ namespace AnodyneArchipelago.Patches GlobalState.events.SetEvent("red_cave_l_ss", 999); GlobalState.events.SetEvent("red_cave_n_ss", 999); GlobalState.events.SetEvent("red_cave_r_ss", 999); - - // Connect to archipelago. - Plugin.Instance.Log.LogInfo("Connecting to Archipelago!"); - - ArchipelagoManager.Connect("localhost:38281", "Anodyne", ""); } } } -- cgit 1.4.1