using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading; using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.BounceFeatures.DeathLink; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using BendyAndTheArchipelagoMachine.Archipelago; using BendyAndTheArchipelagoMachine.Utils; using BepInEx; using BepInEx.Logging; using HarmonyLib; using InControl; using Newtonsoft.Json; using S13Audio; using TMG.Core; using TMG.Data; using TMG.GamepadControl; using TMG.UI.Controls; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BendyAndTheArchipelagoMachine")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BendyAndTheArchipelagoMachine")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b1f15d8f-0256-4b46-abd0-6c8eeb39d997")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace BendyAndTheArchipelagoMachine { [BepInPlugin("lorecrafter.bendyandtheinkmachine.archipelago", "Bendy and the Archipelago Machine", "1.1.2")] public class BendyAndTheArchipelagoMachine : BaseUnityPlugin { public const string pluginGuid = "lorecrafter.bendyandtheinkmachine.archipelago"; public const string pluginName = "Bendy and the Archipelago Machine"; public const string pluginVersion = "1.1.2"; public const string ModDisplayInfo = "Bendy and the Archipelago Machine v1.1.2"; private const string APDisplayInfo = "Archipelago v0.6.7"; public static ManualLogSource Logger; public static Client ArchipelagoClient; public void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; ArchipelagoClient = new Client(); ArchipelagoConsole.Awake(); new Harmony("lorecrafter.bendyandtheinkmachine.archipelago").PatchAll(); ArchipelagoConsole.LogMessage("Bendy and the Archipelago Machine v1.1.2 loaded!"); } private void Update() { ArchipelagoClient.ProcessItems(); if (GetInputArchipelagoConsole()) { ArchipelagoConsole.ToggleHidden(); } } private static bool GetInputArchipelagoConsole() { bool buttonDown = GamepadInput.GetButtonDown((InputControlType)106); bool keyDown = Input.GetKeyDown((KeyCode)96); if (buttonDown) { return buttonDown; } return keyDown && keyDown; } private void OnGUI() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(16f, 16f, 300f, 20f), "Bendy and the Archipelago Machine v1.1.2"); ArchipelagoConsole.OnGUI(); string text; if (Client.authenticated) { text = " Status: Connected"; GUI.Label(new Rect(16f, 50f, 300f, 20f), "Archipelago v0.6.7" + text); return; } text = " Status: Disconnected"; GUI.Label(new Rect(16f, 50f, 300f, 20f), "Archipelago v0.6.7" + text); GUI.Label(new Rect(16f, 70f, 150f, 20f), "Host: "); GUI.Label(new Rect(16f, 90f, 150f, 20f), "Player Name: "); GUI.Label(new Rect(16f, 110f, 150f, 20f), "Password: "); Client.serverData.Uri = GUI.TextField(new Rect(150f, 70f, 150f, 20f), Client.serverData.Uri); Client.serverData.SlotName = GUI.TextField(new Rect(150f, 90f, 150f, 20f), Client.serverData.SlotName); Client.serverData.Password = GUI.TextField(new Rect(150f, 110f, 150f, 20f), Client.serverData.Password); } } } namespace BendyAndTheArchipelagoMachine.Utils { public static class ArchipelagoConsole { public static bool Hidden = true; private static List logLines = new List(); private static Vector2 scrollView; private static Rect window; private static Rect scroll; private static Rect text; private static Rect hideShowButton; private static GUIStyle textStyle = new GUIStyle(); private static string scrollText = ""; private static float lastUpdateTime = Time.time; private const int MaxLogLines = 80; private const float HideTimeout = 15f; private static string CommandText = "!help"; private static Rect CommandTextRect; private static Rect SendCommandButton; public static void Awake() { UpdateWindow(); } public static void LogMessage(string message) { if (!Utility.IsNullOrWhiteSpace(message)) { if (logLines.Count == 80) { logLines.RemoveAt(0); } logLines.Add(message); BendyAndTheArchipelagoMachine.Logger.LogMessage((object)message); lastUpdateTime = Time.time; UpdateWindow(); } } public static void OnGUI() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (logLines.Count == 0) { return; } if (!Hidden || Time.time - lastUpdateTime < 15f) { scrollView = GUI.BeginScrollView(window, scrollView, scroll); GUI.Box(text, ""); GUI.Box(text, scrollText, textStyle); GUI.EndScrollView(); } if (GUI.Button(hideShowButton, Hidden ? "Show" : "Hide")) { Hidden = !Hidden; UpdateWindow(); } if (!Hidden && Client.authenticated) { CommandText = GUI.TextField(CommandTextRect, CommandText); if (!Utility.IsNullOrWhiteSpace(CommandText) && GUI.Button(SendCommandButton, "Send")) { BendyAndTheArchipelagoMachine.ArchipelagoClient.SendMessage(CommandText); CommandText = ""; } } } public static void ToggleHidden() { BendyAndTheArchipelagoMachine.Logger.LogDebug((object)"Toggle Hidden"); Hidden = !Hidden; UpdateWindow(); } public static void UpdateWindow() { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) scrollText = ""; if (Hidden) { if (logLines.Count > 0) { scrollText = logLines[logLines.Count - 1]; } } else { for (int i = 0; i < logLines.Count; i++) { scrollText += "> "; scrollText += logLines.ElementAt(i); if (i < logLines.Count - 1) { scrollText += "\n\n"; } } } int num = (int)((float)Screen.width * 0.4f); int num3; int num2; if (Hidden) { num2 = (int)((float)Screen.height * 0.03f); num3 = num2; } else { num2 = (int)((float)Screen.height * 0.3f); num3 = num2 * 10; } window = new Rect((float)(Screen.width / 2 - num / 2), 0f, (float)num, (float)num2); scroll = new Rect(0f, 0f, (float)num * 0.9f, (float)num3); scrollView = new Vector2(0f, (float)num3); text = new Rect(0f, 0f, (float)num, (float)num3); textStyle.alignment = (TextAnchor)6; textStyle.fontSize = (Hidden ? ((int)((float)Screen.height * 0.0165f)) : ((int)((float)Screen.height * 0.0185f))); textStyle.normal.textColor = Color.white; textStyle.wordWrap = !Hidden; int num4 = (int)((float)Screen.width * 0.01f); int num5 = (int)((float)Screen.height * 0.01f); textStyle.padding = (Hidden ? new RectOffset(num4 / 2, num4 / 2, num5 / 2, num5 / 2) : new RectOffset(num4, num4, num5, num5)); int num6 = (int)((float)Screen.width * 0.12f); int num7 = (int)((float)Screen.height * 0.03f); hideShowButton = new Rect((float)(Screen.width / 2 + num / 2 + num6 / 3), (float)Screen.height * 0.004f, (float)num6, (float)num7); num = (int)((float)Screen.width * 0.4f); int num8 = (int)((float)Screen.width / 2f - (float)num / 2f); int num9 = (int)((float)Screen.height * 0.307f); num2 = (int)((float)Screen.height * 0.022f); CommandTextRect = new Rect((float)num8, (float)num9, (float)num, (float)num2); num = (int)((float)Screen.width * 0.035f); num9 += (int)((float)Screen.height * 0.03f); SendCommandButton = new Rect((float)num8, (float)num9, (float)num, (float)num2); } } } namespace BendyAndTheArchipelagoMachine.Patches { [HarmonyPatch] internal class AudioLogs { [HarmonyPostfix] [HarmonyPatch(typeof(CH1AudioLogsController), "HandleAudioLogThomas01OnInteracted")] public static void DarkAndColdLog() { Client.SendLocation("CH1 Audio Log Dark and Cold"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH1AudioLogsController), "HandleAudioLogWally01OnInteracted")] public static void ThisMachineLog() { Client.SendLocation("CH1 Audio Log This Machine"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogThePrayerOnInteracted")] public static void CanIGetAnAmenLog() { Client.SendLocation("CH2 Audio Log Can I Get an Amen?"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogDistractionsOnInteracted")] public static void ThePumpSwitchLog() { Client.SendLocation("CH2 Audio Log The Pump Switch"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogTheNewVoiceAcressOnInteracted")] public static void NewActressLog() { Client.SendLocation("CH2 Audio Log New Actress"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogTheProjectionistOnInteracted")] public static void CrazySammyLog() { Client.SendLocation("CH2 Audio Log Crazy Sammy"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogLostKeyOnInteracted")] public static void StupidKeysLog() { Client.SendLocation("CH2 Audio Log Stupid Keys"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogFavoriteSongOnInteracted")] public static void SanctuaryPuzzleLog() { Client.SendLocation("CH2 Audio Log Sanctuary Puzzle"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH2AudioLogsController), "HandleAudioLogJackFainOnInteracted")] public static void QuietAndSmellySewersLog() { Client.SendLocation("CH2 Audio Log Quiet and Smelly Sewers"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogGrantGeniusOnInteracted")] public static void TheGeniusUpstairsLog() { Client.SendLocation("CH3 Audio Log The Genius Upstairs"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogHenryOnInteracted")] public static void ManOfIdeasLog() { Client.SendLocation("CH3 Audio Log Man of Ideas"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogJoeyDrewBeliefOnInteracted")] public static void TimeToBelieveLog() { Client.SendLocation("CH3 Audio Log Time to Believe"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogNormanTroubleOnInteracted")] public static void LookingForTroubleLog() { Client.SendLocation("CH3 Audio Log Looking for Trouble"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogShawnCrookedOnInteracted")] public static void CrookedSmileLog() { Client.SendLocation("CH3 Audio Log Crooked Smile"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogSusieApartOnInteracted")] public static void EverythingIsComingApartLog() { Client.SendLocation("CH3 Audio Log Everything is Coming Apart"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogSusieLunchOnInteracted")] public static void LunchWithJoeyLog() { Client.SendLocation("CH3 Audio Log Lunch with Joey"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogThomasOnInteracted")] public static void CuttingCornersLog() { Client.SendLocation("CH3 Audio Log Cutting Corners"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogWallySmileOnInteracted")] public static void CrackASmileLog() { Client.SendLocation("CH3 Audio Log Crack a Smile"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH3AudioLogController), "HandleAudioLogWallyThomasOnInteracted")] public static void InkPressureLog() { Client.SendLocation("CH3 Audio Log Ink Pressure"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4AudioLogController), "HandleAudioLogBertTransformOnInteracted")] public static void ColossalWondersLog() { Client.SendLocation("CH4 Audio Log Colossal Wonders"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4AudioLogController), "HandleAudioLogGrantTransformOnInteracted")] public static void IndiscernableLog() { Client.SendLocation("CH4 Audio Log Indiscernible"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4AudioLogController), "HandleAudioLogJoeyTransformOnInteracted")] public static void TurnItOffLog() { Client.SendLocation("CH4 Audio Log Turn it Off"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4AudioLogController), "HandleAudioLogLacieTransformOnInteracted")] public static void MechanicalDemonLog() { Client.SendLocation("CH4 Audio Log Mechanical Demon"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4AudioLogController), "HandleAudioLogSusieTransformOnInteracted")] public static void BehindClosedDoorsLog() { Client.SendLocation("CH4 Audio Log Behind Closed Doors"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4AudioLogController), "HandleAudioLogWallyTransformOnInteracted")] public static void PlayingGamesLog() { Client.SendLocation("CH4 Audio Log Playing Games"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH4BertrumController), "HandleAudioLogOnInteracted")] public static void BertrumsRevealLog() { Client.SendLocation("CH4 Audio Log Bertrum's Reveal"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH5AudioLogController), "HandleAudioLogThomasTransformOnInteracted")] public static void OfficeReportLog() { Client.SendLocation("CH5 Audio Log Office Report"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH5AudioLogController), "HandleAudioLogWallyTransformOnInteracted")] public static void ChocolateCakeLog() { Client.SendLocation("CH5 Audio Log Chocolate Cake"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH5AudioLogController), "HandleAudioLogJoeyMemoTransformOnInteracted")] public static void TheBigPictureLog() { Client.SendLocation("CH5 Audio Log The Big Picture"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH5AudioLogController), "HandleAudioLogJoeyTommyTransformOnInteracted")] public static void ThousandsOfSoulsLog() { Client.SendLocation("CH5 Audio Log Thousands of Souls"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH5AudioLogController), "HandleAudioLogJoeySusieTransformOnInteracted")] public static void BringingAliceToLifeLog() { Client.SendLocation("CH5 Audio Log Bringing Alice to Life"); } [HarmonyPostfix] [HarmonyPatch(typeof(CH5ThroneRoom), "HandleAudioLogOnInteracted")] public static void BendysEndLog() { Client.SendLocation("CH5 Audio Log Bendy's End"); } } [HarmonyPatch(typeof(CH4BertrumController))] internal class BertrumFight { public static Interactable BertrumFightAudioLog; [HarmonyPostfix] [HarmonyPatch("HandleDeathOnComplete")] public static void OnBertrumDeath() { Client.SendLocation("CH4 Bertrum Boss"); } [HarmonyPostfix] [HarmonyPatch("Init")] public static void GetAudioLogReference(CH4BertrumController __instance, AudioLog ___m_AudioLog) { BertrumFightAudioLog = (Interactable)(object)___m_AudioLog; } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearAudioLogRef() { BertrumFightAudioLog = null; } public static bool HandleAudioLogInteract() { return Client.HasItem("CH4 Bossfight Bertrum"); } } [HarmonyPatch(typeof(CH4AccountingController))] internal class BookPuzzleDoor { public static List Books = new List(); [HarmonyPostfix] [HarmonyPatch("InitOnComplete")] public static void AddBookRefs(CH4AccountingController __instance, List ___m_BookPuzzle) { foreach (BookPuzzle item in ___m_BookPuzzle) { Books.Add(item.Book); } } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearBookRefs() { Books.Clear(); } public static bool HandleBookOnInteract() { return Client.HasItem("CH4 Books"); } } [HarmonyPatch(typeof(BruteBorisAi))] internal class BruteBorisFight { [HarmonyPostfix] [HarmonyPatch("Death")] public static void OnBruteBorisDeath() { Client.SendLocation("CH4 Brute Boris Boss"); } } [HarmonyPatch(typeof(CH2LostKeysController))] internal class LostKeys { public static Interactable keysReference; [HarmonyPostfix] [HarmonyPatch("InitOnComplete")] public static void RegisterKeys(CH2LostKeysController __instance, Interactable ___m_Keys) { keysReference = ___m_Keys; } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearKeysRef() { keysReference = null; } public static bool HandleKeysPickup() { Client.SendLocation("CH2 Keys"); return Client.HasItem("CH2 Keys"); } } [HarmonyPatch(typeof(CH4LostOneSpecial))] internal class LostOneSpecialErrors { [HarmonyPrefix] [HarmonyPatch("Splash")] public static bool SplashFix(CH4LostOneSpecial __instance, S13ObjectComplex ___m_S13Object) { return (Object)(object)___m_S13Object != (Object)null; } } [HarmonyPatch] internal class Menu { public static TitleScreenController titleScreenController; [HarmonyPostfix] [HarmonyPatch(typeof(TitleScreenController), "InitController")] public static void GetTitleScreenController(TitleScreenController __instance, List ___m_BeginMenuItemButtons) { titleScreenController = __instance; } [HarmonyPrefix] [HarmonyPatch(typeof(BaseUIButton), "OnPointerClick")] public static bool HandleConnect(BaseUIButton __instance) { if (((Object)__instance).name != "BeginBtn") { return true; } if (!Client.authenticated && !Utility.IsNullOrWhiteSpace(Client.serverData.SlotName)) { BendyAndTheArchipelagoMachine.ArchipelagoClient.Connect(); } return Client.authenticated; } [HarmonyPrefix] [HarmonyPatch(typeof(TitleScreenController), "SelectSlot")] public static bool OnSlotSelect(int index) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (!Client.serverData.VerifySlot(index)) { ArchipelagoConsole.LogMessage($"Please Connect to Slot {Client.serverData.GetSlot()}"); return false; } int slot = Client.serverData.GetSlot(); SaveFileData val = new SaveFileData(slot); val.IsNewGamePlus = true; val.HasDied = false; val.PlayTime = 0f; val.CH1Data = new CH1DataVO(); val.CH2Data = new CH2DataVO(); val.CH3Data = new CH3DataVO(); val.CH4Data = new CH4DataVO(); val.CH5Data = new CH5DataVO(); GameManager.Instance.GameData.SaveFiles[slot] = val; return true; } [HarmonyPrefix] [HarmonyPatch(typeof(TitleScreenController), "ShowBeginMenu")] public static void ModifyButtons(TitleScreenController __instance, ref List ___m_BeginMenuItemButtons) { List list = new List(); foreach (MenuItemButton ___m_BeginMenuItemButton in ___m_BeginMenuItemButtons) { if (((Object)___m_BeginMenuItemButton).name != "ChaptersBtn") { ((TMGMonoBehaviour)___m_BeginMenuItemButton).gameObject.SetActive(false); list.Add(___m_BeginMenuItemButton); } } foreach (MenuItemButton item in list) { if (___m_BeginMenuItemButtons.Contains(item)) { ___m_BeginMenuItemButtons.Remove(item); } } } [HarmonyPrefix] [HarmonyPatch(typeof(TitleScreenController), "CheckSelectedBeginMenu")] public static void GoToChapterSelect(TitleScreenController __instance, ref int ___m_SelectedIndex) { ___m_SelectedIndex = 2; } public static void ResetChapterData() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown int slot = Client.serverData.GetSlot(); SaveFileData val = new SaveFileData(slot); val.IsNewGamePlus = true; val.HasDied = false; val.PlayTime = 0f; val.CH1Data = new CH1DataVO(); val.CH2Data = new CH2DataVO(); val.CH3Data = new CH3DataVO(); val.CH4Data = new CH4DataVO(); val.CH5Data = new CH5DataVO(); GameManager.Instance.GameData.SaveFiles[slot] = val; GameManager.Instance.GameData.CurrentSaveFile = val; } [HarmonyPrefix] [HarmonyPatch(typeof(TitleScreenController), "CheckSelectedChapter")] public static bool HandleChapterSelect(TitleScreenController __instance, int ___m_SelectedChapter) { switch (___m_SelectedChapter) { case 0: if (!Client.HasItem("Unlock CH1")) { ArchipelagoConsole.LogMessage("Chapter 1 not yet unlocked"); break; } ResetChapterData(); LoadChapterFromTitle(titleScreenController, "CH1"); break; case 1: if (!Client.HasItem("Unlock CH2")) { ArchipelagoConsole.LogMessage("Chapter 2 not yet unlocked"); break; } ResetChapterData(); LoadChapterFromTitle(titleScreenController, "CH2"); break; case 2: if (!Client.HasItem("Unlock CH3")) { ArchipelagoConsole.LogMessage("Chapter 3 not yet unlocked"); break; } ResetChapterData(); LoadChapterFromTitle(titleScreenController, "CH3"); break; case 3: if (!Client.HasItem("Unlock CH4")) { ArchipelagoConsole.LogMessage("Chapter 4 not yet unlocked"); break; } ResetChapterData(); LoadChapterFromTitle(titleScreenController, "CH4"); break; case 4: { long num = (long)Client.serverData.GetSlotDataOption("bacon_soups_required"); long num2 = (long)Client.serverData.GetSlotDataOption("total_bacon_soups") * num / 100; if (Client.BaconSoupCount() < num2) { ArchipelagoConsole.LogMessage($"Chapter 5 not yet unlocked: {Client.BaconSoupCount()} / {num2} Bacon Soups"); break; } ResetChapterData(); LoadChapterFromTitle(titleScreenController, "CH5"); break; } case 5: ResetChapterData(); LoadChapterFromTitle(titleScreenController, "Archives"); break; default: BendyAndTheArchipelagoMachine.Logger.LogError((object)$"Unrecognized chapter: {___m_SelectedChapter}"); break; } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(TitleScreenController), "OnDisposed")] public static void ClearTitleScreenRef() { titleScreenController = null; } [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(TitleScreenController), "LaunchChapter")] public static void LoadChapterFromTitle(TitleScreenController instance, string chapterName) { throw new NotImplementedException(); } } [HarmonyPatch(typeof(Interactable))] internal class MyInteractible { [HarmonyPrefix] [HarmonyPatch("Interact")] public static bool InteractPatch(Interactable __instance) { if (RitualItems.CH1RitualItemInteractablesToType.ContainsKey(__instance)) { return RitualItems.HandleRitualItemPickup(__instance); } if ((Object)(object)LostKeys.keysReference != (Object)null && (Object)(object)LostKeys.keysReference == (Object)(object)__instance) { return LostKeys.HandleKeysPickup(); } if ((Object)(object)ValvePickup.valveReference != (Object)null && (Object)(object)ValvePickup.valveReference == (Object)(object)__instance) { return ValvePickup.HandleValvePickup(); } if (ToyBlockages.ToysRef.Contains(__instance)) { return ToyBlockages.HandleToyPickup(); } if ((Object)(object)BertrumFight.BertrumFightAudioLog != (Object)null && (Object)(object)BertrumFight.BertrumFightAudioLog == (Object)(object)__instance) { return BertrumFight.HandleAudioLogInteract(); } if (BookPuzzleDoor.Books.Contains(__instance)) { return BookPuzzleDoor.HandleBookOnInteract(); } return true; } } [HarmonyPatch(typeof(BaconSoupController))] internal class BaconSoup { [HarmonyPostfix] [HarmonyPatch("HandleCannedSoupOnInteracted")] private static void PickupBaconSoup(object sender, EventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int iD = ((CannedSoupEdible)sender).GetID(); int chapterNumber = MyChapterController.GetChapterNumber(); BendyAndTheArchipelagoMachine.Logger.LogMessage((object)$"Interacted with CH{chapterNumber} Bacon Soup {iD}"); Client.SendLocation($"CH{chapterNumber} Bacon Soup {iD}"); } [HarmonyPostfix] [HarmonyPatch("Init")] private static void OnInit(BaconSoupController __instance, List ___m_BaconSoups) { BendyAndTheArchipelagoMachine.Logger.LogMessage((object)("Total BaconSoups: " + ___m_BaconSoups.Count)); } } [HarmonyPatch(typeof(ChapterController))] internal class MyChapterController { public static ChapterController currentChapter; public static Chapters currentChapterNumber; [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch("LoadChapter")] public static void MyLoadChapter(ChapterController instance, string chapter) { throw new NotImplementedException(); } [HarmonyPrefix] [HarmonyPatch("CompleteChapter")] public static bool OnChapterComplete(ChapterController __instance, Chapters ___m_Chapter) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected I4, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) switch (___m_Chapter - 1) { case 0: Client.SendLocation("CH1 Complete"); SceneManager.LoadScene("Reset"); return false; case 1: Client.SendLocation("CH2 Complete"); SceneManager.LoadScene("Reset"); return false; case 2: Client.SendLocation("CH3 Complete"); SceneManager.LoadScene("Reset"); return false; case 3: Client.SendLocation("CH4 Complete"); SceneManager.LoadScene("Reset"); return false; case 4: Client.SendLocation("CH5 Complete"); Client.CompleteGoal(); return true; default: BendyAndTheArchipelagoMachine.Logger.LogError((object)$"Unknown Chapter: {___m_Chapter}"); SceneManager.LoadScene("Reset"); return false; } } [HarmonyPostfix] [HarmonyPatch("Init")] public static void ChapterControllerInit(ChapterController __instance, Chapters ___m_Chapter) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) currentChapter = __instance; currentChapterNumber = ___m_Chapter; } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearChapterControllerRef() { currentChapter = null; } public static int GetChapterNumber() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown Chapters val = currentChapterNumber; return (val - 1) switch { 0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, _ => -1, }; } } [HarmonyPatch(typeof(AchievementManager))] internal class PerfectScores { [HarmonyPostfix] [HarmonyPatch("SetAchievement")] public static void BullsEyeAcheivement(AchievementName key, AchievementManager __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown if ((long)Client.serverData.GetSlotDataOption("minigame_sanity") != 0L) { switch (key - 38) { case 1: Client.SendLocation("CH4 Bulls Eye"); break; case 2: Client.SendLocation("CH4 Call the Milk Man"); break; case 0: Client.SendLocation("CH4 Wasting Time"); break; } } } } [HarmonyPatch(typeof(RadioEasterEggController))] internal class Radios { [HarmonyPostfix] [HarmonyPatch("HandleRadioOnInteracted")] public static void OnRadioInteract(RadioEasterEggController __instance, AchievementName ___m_AchievementAssetKey) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0060: Unknown result type (might be due to invalid IL or missing references) if ((int)___m_AchievementAssetKey <= 6) { if ((int)___m_AchievementAssetKey == 2) { Client.SendLocation("CH1 Radio"); return; } if ((int)___m_AchievementAssetKey == 6) { Client.SendLocation("CH2 Radio"); return; } } else { if ((int)___m_AchievementAssetKey == 25) { Client.SendLocation("CH3 Radio"); return; } if ((int)___m_AchievementAssetKey == 33) { Client.SendLocation("CH4 Radio"); return; } if ((int)___m_AchievementAssetKey == 47) { Client.SendLocation("CH5 Radio"); return; } } BendyAndTheArchipelagoMachine.Logger.LogError((object)$"Unrecognized Radio. AchievementName: {___m_AchievementAssetKey}"); } } [HarmonyPatch(typeof(CH1Pedestal))] internal class RitualItems { public static Dictionary CH1RitualItemsTypeToPedestal = new Dictionary(); public static Dictionary CH1RitualItemInteractablesToType = new Dictionary(); [HarmonyPostfix] [HarmonyPatch("Initialize")] public static void OnInit(Transform collectableLocation, CH1Pedestal __instance, CollectableType ___m_CollectableType, Interactable ___m_Collectable) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) CH1RitualItemsTypeToPedestal.Add(___m_CollectableType, __instance); CH1RitualItemInteractablesToType.Add(___m_Collectable, ___m_CollectableType); } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearReferences(CH1Pedestal __instance, CollectableType ___m_CollectableType, Interactable ___m_Collectable) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) CH1RitualItemsTypeToPedestal.Remove(___m_CollectableType); CH1RitualItemInteractablesToType.Remove(___m_Collectable); } public static bool HandleRitualItemPickup(Interactable item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected I4, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) CollectableType val = CH1RitualItemInteractablesToType[item]; switch ((int)val) { case 2: Client.SendLocation("CH1 Book"); return Client.HasItem("CH1 Book"); case 3: Client.SendLocation("CH1 Doll"); return Client.HasItem("CH1 Doll"); case 0: Client.SendLocation("CH1 Gear"); return Client.HasItem("CH1 Gear"); case 5: Client.SendLocation("CH1 Inkwell"); return Client.HasItem("CH1 Inkwell"); case 4: Client.SendLocation("CH1 Record"); return Client.HasItem("CH1 Record"); case 1: Client.SendLocation("CH1 Wrench"); return Client.HasItem("CH1 Wrench"); default: BendyAndTheArchipelagoMachine.Logger.LogError((object)$"Unknown Item Type {CH1RitualItemInteractablesToType[item]}"); return false; } } } [HarmonyPatch(typeof(SammyLawrence_Ai))] internal class SammyLawrenceBoss { [HarmonyPostfix] [HarmonyPatch("TriggerDeath")] public static void OnSammyDeath() { Client.SendLocation("CH5 Sammy Lawrence Boss"); } } [HarmonyPatch(typeof(MeatlyController))] internal class theMeatly { [HarmonyPostfix] [HarmonyPatch("HandleMeatlyAchievementTrigger")] public static void HandleMeatlySighting(MeatlyController __instance, Chapters ___m_Chapter) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected I4, but got Unknown if ((long)Client.serverData.GetSlotDataOption("the_meatly_sanity") != 0L) { switch (___m_Chapter - 1) { case 0: Client.SendLocation("CH1 theMeatly"); break; case 1: Client.SendLocation("CH2 theMeatly"); break; case 2: Client.SendLocation("CH3 theMeatly"); break; case 3: Client.SendLocation("CH4 theMeatly"); break; case 4: Client.SendLocation("CH5 theMeatly"); break; } } } } [HarmonyPatch(typeof(CH3ToyMachine))] internal class ToyBlockages { public static List ToysRef = new List(); [HarmonyPostfix] [HarmonyPatch("InitOnComplete")] public static void RegisterToys(CH3ToyMachine __instance, List ___m_SpinnersLeft, List ___m_SpinnersRight) { foreach (Spinners item in ___m_SpinnersLeft) { foreach (Interactable toy in item.Toys) { ToysRef.Add(toy); } } foreach (Spinners item2 in ___m_SpinnersRight) { foreach (Interactable toy2 in item2.Toys) { ToysRef.Add(toy2); } } } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearToysRef() { ToysRef.Clear(); } public static bool HandleToyPickup() { return Client.HasItem("CH3 Toys"); } } [HarmonyPatch(typeof(CH2SewerController))] internal class ValvePickup { public static Interactable valveReference; [HarmonyPostfix] [HarmonyPatch("InitOnComplete")] public static void RegisterValve(CH2SewerController __instance, Interactable ___m_ValvePickup) { valveReference = ___m_ValvePickup; } [HarmonyPostfix] [HarmonyPatch("OnDisposed")] public static void ClearValveRef() { valveReference = null; } public static bool HandleValvePickup() { Client.SendLocation("CH2 Valve"); return Client.HasItem("CH2 Valve"); } } } namespace BendyAndTheArchipelagoMachine.Archipelago { public class ArchipelagoData { public string Uri; public string SlotName; public string Password; public int Index; private int SaveSlot = -1; public string seed; public Dictionary slotData; public List CheckedLocations { get; private set; } public List ReceivedItems { get; private set; } public bool NeedSlotData => slotData == null; public ArchipelagoData() { Uri = "archipelago.gg:38281"; SlotName = "Bendy"; CheckedLocations = new List(); ReceivedItems = new List(); } public ArchipelagoData(string uri, string slotName, string password) { Uri = uri; SlotName = slotName; Password = password; CheckedLocations = new List(); ReceivedItems = new List(); } public override string ToString() { return JsonConvert.SerializeObject((object)this); } private void SaveData() { BendyAndTheArchipelagoMachine.Logger.LogDebug((object)("Seed: " + seed)); string path = Path.Combine(Paths.PluginPath, "Lorecrafter703-Bendy_and_the_Archipelago_Machine", "BendyAndTheArchipelagoMachine", "savedata", seed + ".json"); string contents = ToString(); File.WriteAllText(path, contents); } public void SetupSession(Dictionary roomSlotData, string roomSeed) { slotData = roomSlotData; seed = roomSeed; SaveData(); } public object GetSlotDataOption(string key) { try { return slotData[key]; } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)ex); return null; } } public bool VerifySlot(int slot) { if (SaveSlot == -1) { SaveSlot = slot; } if (SaveSlot != slot) { return false; } return true; } public int GetSlot() { return SaveSlot; } public void AddItem(long itemID) { ReceivedItems.Add(itemID); Index++; SaveData(); } public void CheckLocation(long itemID) { CheckedLocations.Add(itemID); SaveData(); } } public class DeathLinkHandler { private static bool deathLinkEnabled; private string slotName; private readonly DeathLinkService service; private readonly Queue deathLinks = new Queue(); public DeathLinkHandler(DeathLinkService deathLinkService, string name, bool enableDeathLink = false) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown service = deathLinkService; service.OnDeathLinkReceived += new DeathLinkReceivedHandler(DeathLinkReceived); slotName = name; deathLinkEnabled = enableDeathLink; if (deathLinkEnabled) { service.EnableDeathLink(); } } public void ToggleDeathLink() { deathLinkEnabled = !deathLinkEnabled; if (deathLinkEnabled) { service.EnableDeathLink(); } else { service.DisableDeathLink(); } } private void DeathLinkReceived(DeathLink deathLink) { deathLinks.Enqueue(deathLink); BendyAndTheArchipelagoMachine.Logger.LogDebug((object)(Utility.IsNullOrWhiteSpace(deathLink.Cause) ? ("Received Death Link from " + deathLink.Source) : deathLink.Cause)); } public void KillPlayer() { try { if (deathLinks.Count >= 1) { DeathLink val = deathLinks.Dequeue(); string text = (Utility.IsNullOrWhiteSpace(val.Cause) ? GetDeathLinkCause(val) : val.Cause); BendyAndTheArchipelagoMachine.Logger.LogMessage((object)text); } } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)ex); } } private string GetDeathLinkCause(DeathLink deathLink) { return "Received death from " + deathLink.Source; } public void SendDeathLink() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown try { if (deathLinkEnabled) { BendyAndTheArchipelagoMachine.Logger.LogMessage((object)"sharing your death..."); DeathLink val = new DeathLink(slotName, (string)null); service.SendDeathLink(val); } } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)ex); } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct IDTables { private static readonly Dictionary itemNametoID = new Dictionary { { "Bacon Soup", 1L }, { "Trap", 2L }, { "Filler", 3L }, { "Unlock CH1", 100L }, { "CH1 Book", 101L }, { "CH1 Doll", 102L }, { "CH1 Gear", 103L }, { "CH1 Inkwell", 104L }, { "CH1 Record", 105L }, { "CH1 Wrench", 106L }, { "Unlock CH2", 200L }, { "CH2 Keys", 201L }, { "CH2 Valve", 202L }, { "Unlock CH3", 300L }, { "CH3 Toys", 301L }, { "Unlock CH4", 400L }, { "CH4 Books", 401L }, { "CH4 Bossfight Bertrum", 402L } }; private static readonly Dictionary locationNametoID = new Dictionary { { "CH1 Bacon Soup 0", 100L }, { "CH1 Bacon Soup 1", 101L }, { "CH1 Bacon Soup 2", 102L }, { "CH1 Bacon Soup 3", 103L }, { "CH1 Bacon Soup 4", 104L }, { "CH1 Bacon Soup 5", 105L }, { "CH1 Bacon Soup 6", 106L }, { "CH1 Bacon Soup 7", 107L }, { "CH1 Bacon Soup 8", 108L }, { "CH1 Bacon Soup 9", 109L }, { "CH1 Bacon Soup 10", 110L }, { "CH1 Bacon Soup 11", 111L }, { "CH1 Bacon Soup 12", 112L }, { "CH1 Bacon Soup 13", 113L }, { "CH1 Bacon Soup 14", 114L }, { "CH1 Bacon Soup 15", 115L }, { "CH1 Bacon Soup 16", 116L }, { "CH1 Bacon Soup 17", 117L }, { "CH1 Bacon Soup 18", 118L }, { "CH1 Bacon Soup 19", 119L }, { "CH1 Bacon Soup 20", 120L }, { "CH1 Book", 121L }, { "CH1 Doll", 122L }, { "CH1 Gear", 123L }, { "CH1 Inkwell", 124L }, { "CH1 Record", 125L }, { "CH1 Wrench", 126L }, { "CH1 Audio Log Dark and Cold", 127L }, { "CH1 Audio Log This Machine", 128L }, { "CH1 Radio", 129L }, { "CH1 Complete", 199L }, { "CH2 Bacon Soup 0", 200L }, { "CH2 Bacon Soup 1", 201L }, { "CH2 Bacon Soup 2", 202L }, { "CH2 Bacon Soup 3", 203L }, { "CH2 Bacon Soup 4", 204L }, { "CH2 Bacon Soup 5", 205L }, { "CH2 Bacon Soup 6", 206L }, { "CH2 Bacon Soup 7", 207L }, { "CH2 Bacon Soup 8", 208L }, { "CH2 Bacon Soup 9", 209L }, { "CH2 Bacon Soup 10", 210L }, { "CH2 Bacon Soup 11", 211L }, { "CH2 Bacon Soup 12", 212L }, { "CH2 Bacon Soup 13", 213L }, { "CH2 Bacon Soup 14", 214L }, { "CH2 Bacon Soup 15", 215L }, { "CH2 Bacon Soup 16", 216L }, { "CH2 Bacon Soup 17", 217L }, { "CH2 Bacon Soup 18", 218L }, { "CH2 Bacon Soup 19", 219L }, { "CH2 Bacon Soup 20", 220L }, { "CH2 Bacon Soup 21", 221L }, { "CH2 Bacon Soup 22", 222L }, { "CH2 Bacon Soup 23", 223L }, { "CH2 Bacon Soup 24", 224L }, { "CH2 Bacon Soup 25", 225L }, { "CH2 Bacon Soup 26", 226L }, { "CH2 Bacon Soup 27", 227L }, { "CH2 Bacon Soup 28", 228L }, { "CH2 Bacon Soup 29", 229L }, { "CH2 Bacon Soup 30", 230L }, { "CH2 Keys", 231L }, { "CH2 Valve", 232L }, { "CH2 Audio Log Can I Get an Amen?", 233L }, { "CH2 Audio Log The Pump Switch", 234L }, { "CH2 Audio Log New Actress", 235L }, { "CH2 Audio Log Crazy Sammy", 236L }, { "CH2 Audio Log Stupid Keys", 237L }, { "CH2 Audio Log Sanctuary Puzzle", 238L }, { "CH2 Audio Log Quiet and Smelly Sewers", 239L }, { "CH2 Radio", 240L }, { "CH2 Complete", 299L }, { "CH3 Bacon Soup 0", 300L }, { "CH3 Bacon Soup 1", 301L }, { "CH3 Bacon Soup 2", 302L }, { "CH3 Bacon Soup 3", 303L }, { "CH3 Bacon Soup 4", 304L }, { "CH3 Bacon Soup 5", 305L }, { "CH3 Bacon Soup 6", 306L }, { "CH3 Bacon Soup 7", 307L }, { "CH3 Bacon Soup 8", 308L }, { "CH3 Bacon Soup 9", 309L }, { "CH3 Bacon Soup 10", 310L }, { "CH3 Bacon Soup 11", 311L }, { "CH3 Bacon Soup 12", 312L }, { "CH3 Bacon Soup 13", 313L }, { "CH3 Bacon Soup 14", 314L }, { "CH3 Bacon Soup 15", 315L }, { "CH3 Bacon Soup 16", 316L }, { "CH3 Bacon Soup 17", 317L }, { "CH3 Bacon Soup 18", 318L }, { "CH3 Bacon Soup 19", 319L }, { "CH3 Bacon Soup 20", 320L }, { "CH3 Bacon Soup 21", 321L }, { "CH3 Bacon Soup 22", 322L }, { "CH3 Bacon Soup 23", 323L }, { "CH3 Bacon Soup 24", 324L }, { "CH3 Bacon Soup 25", 325L }, { "CH3 Bacon Soup 26", 326L }, { "CH3 Bacon Soup 27", 327L }, { "CH3 Bacon Soup 28", 328L }, { "CH3 Bacon Soup 29", 329L }, { "CH3 Bacon Soup 30", 330L }, { "CH3 Bacon Soup 31", 331L }, { "CH3 Bacon Soup 32", 332L }, { "CH3 Bacon Soup 33", 333L }, { "CH3 Bacon Soup 34", 334L }, { "CH3 Bacon Soup 35", 335L }, { "CH3 Bacon Soup 36", 336L }, { "CH3 Bacon Soup 37", 337L }, { "CH3 Bacon Soup 38", 338L }, { "CH3 Audio Log Crooked Smile", 350L }, { "CH3 Audio Log Time to Believe", 351L }, { "CH3 Audio Log Everything is Coming Apart", 352L }, { "CH3 Audio Log Ink Pressure", 353L }, { "CH3 Audio Log Cutting Corners", 354L }, { "CH3 Audio Log Lunch with Joey", 355L }, { "CH3 Audio Log Crack a Smile", 356L }, { "CH3 Audio Log The Genius Upstairs", 357L }, { "CH3 Audio Log Looking for Trouble", 358L }, { "CH3 Audio Log Man of Ideas", 359L }, { "CH3 Radio", 360L }, { "CH3 Complete", 399L }, { "CH4 Bacon Soup 0", 400L }, { "CH4 Bacon Soup 1", 401L }, { "CH4 Bacon Soup 2", 402L }, { "CH4 Bacon Soup 3", 403L }, { "CH4 Bacon Soup 4", 404L }, { "CH4 Bacon Soup 5", 405L }, { "CH4 Bacon Soup 6", 406L }, { "CH4 Bacon Soup 7", 407L }, { "CH4 Bacon Soup 8", 408L }, { "CH4 Bacon Soup 9", 409L }, { "CH4 Bacon Soup 10", 410L }, { "CH4 Bacon Soup 11", 411L }, { "CH4 Bacon Soup 12", 412L }, { "CH4 Bacon Soup 13", 413L }, { "CH4 Bacon Soup 14", 414L }, { "CH4 Bacon Soup 15", 415L }, { "CH4 Bacon Soup 16", 416L }, { "CH4 Bacon Soup 17", 417L }, { "CH4 Bacon Soup 18", 418L }, { "CH4 Bulls Eye", 419L }, { "CH4 Call the Milk Man", 420L }, { "CH4 Wasting Time", 421L }, { "CH4 Bertrum Boss", 422L }, { "CH4 Brute Boris Boss", 423L }, { "CH4 Audio Log Indiscernible", 430L }, { "CH4 Audio Log Behind Closed Doors", 431L }, { "CH4 Audio Log Colossal Wonders", 432L }, { "CH4 Audio Log Playing Games", 433L }, { "CH4 Audio Log Mechanical Demon", 434L }, { "CH4 Audio Log Bertrum's Reveal", 435L }, { "CH4 Audio Log Turn it Off", 436L }, { "CH4 Radio", 437L }, { "CH4 Complete", 499L }, { "CH5 Bacon Soup 0", 500L }, { "CH5 Bacon Soup 1", 501L }, { "CH5 Bacon Soup 2", 502L }, { "CH5 Bacon Soup 3", 503L }, { "CH5 Bacon Soup 4", 504L }, { "CH5 Bacon Soup 5", 505L }, { "CH5 Bacon Soup 6", 506L }, { "CH5 Sammy Lawrence Boss", 507L }, { "CH5 Audio Log Office Report", 520L }, { "CH5 Audio Log Chocolate Cake", 521L }, { "CH5 Audio Log The Big Picture", 522L }, { "CH5 Audio Log Thousands of Souls", 523L }, { "CH5 Audio Log Bringing Alice to Life", 524L }, { "CH5 Audio Log Bendy's End", 525L }, { "CH5 Radio", 526L } }; public static long GetItemID(string name) { try { return itemNametoID[name]; } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)("No item with the name " + name + " was found.\n " + ex.Message)); return -1L; } } public static long GetLocationID(string name) { try { return locationNametoID[name]; } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)("No location found with name " + name + ".\n " + ex.Message)); return -1L; } } } public class Client { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static MessageReceivedHandler <>9__13_0; public static Func <>9__15_0; internal void b__13_0(LogMessage message) { ArchipelagoConsole.LogMessage(((object)message).ToString()); } internal string b__15_0(string current, string error) { return current + "\n " + error; } } public const string SERVER = "localhost"; public const int PORT = 38281; public const string SLOT_NAME = "Bendy"; public const string AP_VERSION = "0.6.7"; public const string GAME_NAME = "Bendy and the Ink Machine"; public static bool authenticated; private bool attemptingConnection; public static ArchipelagoData serverData = new ArchipelagoData(); private DeathLinkHandler deathLinkHandler; private static ArchipelagoSession session = ArchipelagoSessionFactory.CreateSession("localhost", 38281); private Queue ItemQueue = new Queue(); private ReceivedItemsHelper Helper; public void Connect() { if (!authenticated && !attemptingConnection) { try { session = ArchipelagoSessionFactory.CreateSession(serverData.Uri, 38281); SetupSession(); attemptingConnection = true; } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)ex); } TryConnect(); } } private void SetupSession() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown IMessageLogHelper messageLog = session.MessageLog; object obj = <>c.<>9__13_0; if (obj == null) { MessageReceivedHandler val = delegate(LogMessage message) { ArchipelagoConsole.LogMessage(((object)message).ToString()); }; <>c.<>9__13_0 = val; obj = (object)val; } messageLog.OnMessageReceived += (MessageReceivedHandler)obj; session.Items.ItemReceived += (ItemReceivedHandler)delegate(ReceivedItemsHelper receivedItemsHelper) { OnItemReceived(receivedItemsHelper); }; session.Socket.ErrorReceived += new ErrorReceivedHandler(OnSessionErrorReceived); session.Socket.SocketClosed += new SocketClosedHandler(OnSessionSocketClosed); } private void TryConnect() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown try { ThreadPool.QueueUserWorkItem(delegate { HandleConnectResult(session.TryConnectAndLogin("Bendy and the Ink Machine", serverData.SlotName, (ItemsHandlingFlags)7, new Version("0.6.7"), (string[])null, (string)null, serverData.Password, serverData.NeedSlotData)); }); } catch (Exception ex) { BendyAndTheArchipelagoMachine.Logger.LogError((object)ex); HandleConnectResult((LoginResult)new LoginFailure(ex.ToString())); attemptingConnection = false; } } private void HandleConnectResult(LoginResult result) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown if (result.Successful) { LoginSuccessful val = (LoginSuccessful)result; string text = Path.Combine(Paths.PluginPath, "Lorecrafter703-Bendy_and_the_Archipelago_Machine", "BendyAndTheArchipelagoMachine", "savedata", session.RoomState.Seed + ".json"); BendyAndTheArchipelagoMachine.Logger.LogDebug((object)text); if (File.Exists(text)) { serverData = JsonConvert.DeserializeObject(File.ReadAllText(text)); } else { serverData.SetupSession(val.SlotData, session.RoomState.Seed); } authenticated = true; deathLinkHandler = new DeathLinkHandler(DeathLinkProvider.CreateDeathLinkService(session), serverData.SlotName); session.Locations.CompleteLocationChecksAsync(serverData.CheckedLocations.ToArray()); string message = "Successfully connected to " + serverData.Uri + " as " + serverData.SlotName + "!"; ArchipelagoConsole.LogMessage(message); } else { LoginFailure val2 = (LoginFailure)result; string message = "Failed to connect to " + serverData.Uri + " as " + serverData.SlotName + "."; message = val2.Errors.Aggregate(message, (string current, string error) => current + "\n " + error); BendyAndTheArchipelagoMachine.Logger.LogError((object)message); authenticated = false; Disconnect(); } attemptingConnection = false; } private void Disconnect() { BendyAndTheArchipelagoMachine.Logger.LogDebug((object)"disconnecting from server.."); ArchipelagoSession obj = session; if (obj != null) { obj.Socket.DisconnectAsync(); } session = null; authenticated = false; } public void SendMessage(string message) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (authenticated) { session.Socket.SendPacketAsync((ArchipelagoPacketBase)new SayPacket { Text = message }); } } private void OnItemReceived(ReceivedItemsHelper helper) { ItemInfo item = helper.DequeueItem(); Helper = helper; ItemQueue.Enqueue(item); } public void ProcessItems() { if (authenticated && !attemptingConnection && Helper != null && !Utility.IsNullOrWhiteSpace(serverData.seed) && ItemQueue.Count > 0) { ItemInfo val = ItemQueue.Dequeue(); if (Helper.Index > serverData.Index) { serverData.AddItem(val.ItemId); ArchipelagoConsole.LogMessage($"Received {val.ItemName} from {val.Player} ({val.LocationName})."); } } } private void OnSessionErrorReceived(Exception e, string message) { BendyAndTheArchipelagoMachine.Logger.LogError((object)e); ArchipelagoConsole.LogMessage(message); if (message.Contains("closed the WebSocket connection")) { Disconnect(); } } private void OnSessionSocketClosed(string reason) { BendyAndTheArchipelagoMachine.Logger.LogError((object)("Connection to Archipelago lost: " + reason)); Disconnect(); } public static void SendLocation(string itemName) { long locationID = IDTables.GetLocationID(itemName); if (locationID != -1) { if (authenticated) { session.Locations.CompleteLocationChecks(new long[1] { locationID }); } serverData.CheckLocation(locationID); } } public static bool HasItem(string itemName) { long itemID = IDTables.GetItemID(itemName); return serverData.ReceivedItems.Contains(itemID); } public static int BaconSoupCount() { int num = 0; foreach (long receivedItem in serverData.ReceivedItems) { if (receivedItem == IDTables.GetItemID("Bacon Soup")) { num++; } } return num; } public static void CompleteGoal() { if (authenticated) { session.SetGoalAchieved(); } } } }