using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.Converters; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.MessageLog.Parts; using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using Global; using Global.Online; using HarmonyLib; using KeyWe.Profile.ProfileDataClasses; using KeyWe.Stats; using KeyWe.Tournament; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("KeyWe_AP_Client")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a079b433f20323f781ed5f206427ef487b5d2ab0")] [assembly: AssemblyProduct("KeyWe_AP_Client")] [assembly: AssemblyTitle("KeyWe_AP_Client")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class CosmeticSyncHandler : MonoBehaviourPunCallbacks { public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { string text = default(string); if (targetPlayer != PhotonNetwork.LocalPlayer && OnlineExtensions.TryGetValue(changedProps, (object)Properties.Customization, ref text)) { uint[] itemIDs = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(uint.Parse).ToArray(); ApplyRemoteCosmetics(itemIDs); } } private void ApplyRemoteCosmetics(uint[] itemIDs) { Kiwi[] array = Object.FindObjectsOfType(); foreach (Kiwi val in array) { if (!val.IsLocalPlayer) { val.Customization.Init(itemIDs, true); } } } } namespace TemplatePlugin { internal static class TemplatePluginInfo { public const string PLUGIN_GUID = "keywe_ap_client"; public const string PLUGIN_NAME = "KeyWe_AP_Client"; public const string GAME_NAME = "KeyWe"; } } namespace KeyWe_AP_Client { public class APConsole : MonoBehaviour { private enum ConsoleAnchorCorner { BottomLeft, BottomRight, TopLeft, TopRight } [Serializable] public class LogEntry { public enum State { SlideIn, Hold, FadeOut } public State state; public float stateTimer; public float offsetY; public float baseY; public float animatedY; public TextMeshProUGUI? text; public Image? background; public string message; public string colorizedMessage; public float height; public LogEntry(string msg) { message = msg; colorizedMessage = msg; height = 28f; } } private static readonly Dictionary KeywordColors = new Dictionary { { "summer", "#00ff00" }, { "fall", "#ff6600" }, { "winter", "#3399ff" }, { "warning", "#ff0000" }, { "movement+", "#ffff00" }, { "respawn+", "#ffff00" }, { "dash+", "#ffff00" }, { "jump+", "#ffff00" }, { "swim+", "#ffff00" }, { "chirp+", "#ffff00" }, { "peck+", "#ffff00" }, { "random facewear", "#ff00ff" }, { "random hat", "#ff00ff" }, { "random skin", "#ff00ff" }, { "random footwear", "#ff00ff" }, { "random backwear", "#ff00ff" }, { "random hairstyle", "#ff00ff" }, { "random arms", "#ff00ff" } }; private const string FontName = "BlackHanSans-Regular SDF"; private readonly Color _textColor = Color.white; private readonly Color _backColor = new Color(0f, 0f, 0f, 0.8f); private const int MaxHistoryEntries = 1000; private const KeyCode LogToggleKey = 288; private const KeyCode HistoryToggleKey = 289; private const CursorLockMode DefaultCursorMode = 0; private const bool DefaultCursorVisible = false; private const float DefaultMessageHeight = 28f; private const float DefaultConsoleHeight = 250f; private const float DefaultConsoleWidth = 600f; private float _slideInTime = 0.25f; private float _holdTime = 3f; private float _fadeOutTime = 0.5f; private const float SlideInOffset = -50f; private const float FadeUpOffset = 20f; private const float PaddingX = 25f; private const float PaddingY = 25f; private const float MessageSpacing = 2.5f; private const ConsoleAnchorCorner AnchorCorner = ConsoleAnchorCorner.BottomLeft; private const float ConsoleWidth = 600f; private const float ConsoleHeight = 250f; private const float MessageHeight = 28f; private bool _rebuildHistoryDirty; private int _historyBuiltCount; private static TMP_FontAsset _font; private readonly ConcurrentQueue _backgroundPool = new ConcurrentQueue(); private ConcurrentQueue _cachedEntries = new ConcurrentQueue(); private readonly ConcurrentQueue _textPool = new ConcurrentQueue(); private readonly List _visibleEntries = new List(); private readonly List _historyEntries = new List(); private GameObject? _historyPanel; private RectTransform? _historyContent; private bool _showHistory; private ScrollRect? _historyScrollRect; private RectTransform? _historyViewport; private Transform? _messageParent; private bool _showConsole = true; private static APConsole? _instance; public static APConsole Instance { get { if ((Object)(object)_instance == (Object)null) { Create(); } return _instance; } } private static void Create() { //IL_0062: 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_006d: Expected O, but got Unknown if ((Object)(object)_instance != (Object)null) { return; } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { Console.WriteLine(((Object)array[i]).name); } _font = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((TMP_FontAsset x) => ((Object)x).name == "BlackHanSans-Regular SDF")); GameObject val = new GameObject("ArchipelagoConsoleUI"); Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent(); _instance.BuildUI(); if (PluginMain.MessageInTime != null) { _instance._slideInTime = PluginMain.MessageInTime.Value; } if (PluginMain.MessageHoldTime != null) { _instance._holdTime = PluginMain.MessageHoldTime.Value; } if (PluginMain.MessageOutTime != null) { _instance._fadeOutTime = PluginMain.MessageOutTime.Value; } _instance.Log("by xMcacutt"); _instance.Log($"Press {(object)(KeyCode)288} to Toggle log & {(object)(KeyCode)289} to toggle history"); _instance.DebugLog("Colour Test"); foreach (string key in KeywordColors.Keys) { _instance.DebugLog(key); } } private void Update() { UpdateMessages(Time.deltaTime); TryAddNewMessages(); if (Input.GetKeyDown((KeyCode)288)) { ToggleConsole(); } if (Input.GetKeyDown((KeyCode)289)) { ToggleHistory(); } if (_showHistory) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (_showHistory && _rebuildHistoryDirty) { _rebuildHistoryDirty = false; RebuildHistory(); } } private void UpdateMessages(float delta) { for (int num = _visibleEntries.Count - 1; num >= 0; num--) { LogEntry entry = _visibleEntries[num]; if (AnimateEntry(entry, delta)) { RecycleEntry(entry); _visibleEntries.RemoveAt(num); RecalculateBaseY(); } else { UpdateEntryVisual(entry); } } } private void RecalculateBaseY() { float num = 0f; for (int num2 = _visibleEntries.Count - 1; num2 >= 0; num2--) { LogEntry logEntry = _visibleEntries[num2]; logEntry.baseY = num; num += logEntry.height + 2.5f; } } private bool AnimateEntry(LogEntry entry, float delta) { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) entry.stateTimer += delta; switch (entry.state) { case LogEntry.State.SlideIn: { float num3 = Mathf.Clamp01(entry.stateTimer / _slideInTime); entry.offsetY = Mathf.Lerp(-50f, 0f, EaseOutQuad(num3)); if (num3 >= 1f) { entry.state = LogEntry.State.Hold; entry.stateTimer = 0f; } break; } case LogEntry.State.Hold: entry.offsetY = 0f; if (entry.stateTimer >= _holdTime) { entry.state = LogEntry.State.FadeOut; entry.stateTimer = 0f; } break; case LogEntry.State.FadeOut: { float num = Mathf.Clamp01(entry.stateTimer / _fadeOutTime); entry.offsetY = Mathf.Lerp(0f, 20f, num); float num2 = 1f - num; if ((Object)(object)entry.text != (Object)null) { ((Graphic)entry.text).color = new Color(_textColor.r, _textColor.g, _textColor.b, num2); } if ((Object)(object)entry.background != (Object)null) { ((Graphic)entry.background).color = new Color(_backColor.r, _backColor.g, _backColor.b, num2); } if (num >= 1f) { return true; } break; } } return false; } private static float EaseOutQuad(float x) { return 1f - (1f - x) * (1f - x); } private void TryAddNewMessages() { if (_showHistory || !_cachedEntries.Any()) { return; } int num = Mathf.FloorToInt(8.928572f); if (_visibleEntries.Count < num) { _cachedEntries.TryDequeue(out LogEntry result); if (result != null) { result.state = LogEntry.State.SlideIn; result.stateTimer = 0f; result.offsetY = -50f; result.animatedY = result.baseY + result.offsetY; CreateEntryVisual(result); _visibleEntries.Add(result); RecalculateBaseY(); result.animatedY = result.baseY + result.offsetY; } } } private void ApplyRectSettings(RectTransform rt, Vector2 min, Vector2 max, Vector2 pivot, Vector2 pos, Vector2 size) { //IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = min; rt.anchorMax = max; rt.pivot = pivot; rt.anchoredPosition = pos; rt.sizeDelta = size; } private void PositionMessageContainer(RectTransform rect) { //IL_0011: 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) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0036: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 0f); Vector2 max; Vector2 min = (max = val); Vector2 pos = default(Vector2); ((Vector2)(ref pos))..ctor(25f, 25f); ApplyRectSettings(rect, min, max, val, pos, new Vector2(600f, 250f)); } private void PositionHistoryPanel(RectTransform rect) { PositionMessageContainer(rect); } private void AddHistoryEntryVisual(LogEntry entry) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Image background = GetBackground(); ((Component)background).transform.SetParent((Transform)(object)_historyContent, false); RectTransform rectTransform = ((Graphic)background).rectTransform; ApplyRectSettings(rectTransform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(600f, 28f)); TextMeshProUGUI text = GetText(); RectTransform rectTransform2 = ((TMP_Text)text).rectTransform; ((Transform)rectTransform2).SetParent(((Component)background).transform, false); rectTransform2.anchorMin = new Vector2(0f, 0f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0f, 0.5f); rectTransform2.offsetMin = new Vector2(8f, 4f); rectTransform2.offsetMax = new Vector2(-8f, -4f); entry.text = text; entry.background = background; ((Graphic)text).color = _textColor; ((Graphic)background).color = _backColor; ((TMP_Text)text).text = entry.colorizedMessage; Canvas.ForceUpdateCanvases(); LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform2); float preferredHeight = Mathf.Max(28f, ((TMP_Text)text).preferredHeight + 8f); (((Component)background).GetComponent() ?? ((Component)background).gameObject.AddComponent()).preferredHeight = preferredHeight; } private void CreateEntryVisual(LogEntry entry) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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) Image background = GetBackground(); ((Component)background).transform.SetParent(_messageParent, false); RectTransform rectTransform = ((Graphic)background).rectTransform; ApplyRectSettings(rectTransform, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero, new Vector2(600f, 28f)); TextMeshProUGUI text = GetText(); RectTransform rectTransform2 = ((TMP_Text)text).rectTransform; ((Transform)rectTransform2).SetParent(((Component)background).transform, false); rectTransform2.anchorMin = new Vector2(0f, 0f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0f, 0.5f); rectTransform2.offsetMin = new Vector2(8f, 4f); rectTransform2.offsetMax = new Vector2(-8f, -4f); entry.text = text; entry.background = background; ((Graphic)text).color = _textColor; ((Graphic)background).color = _backColor; UpdateEntryVisual(entry); } private void UpdateEntryVisual(LogEntry entry) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)entry.text != (Object)null) { ((TMP_Text)entry.text).text = entry.colorizedMessage; float preferredHeight = ((TMP_Text)entry.text).preferredHeight; entry.height = Mathf.Max(28f, preferredHeight + 8f); if ((Object)(object)entry.background != (Object)null) { ((Graphic)entry.background).rectTransform.sizeDelta = new Vector2(600f, entry.height); } } float num = entry.baseY + entry.offsetY; entry.animatedY = Mathf.Lerp(entry.animatedY, num, Time.deltaTime * 12f); if ((Object)(object)entry.background != (Object)null) { ((Graphic)entry.background).rectTransform.anchoredPosition = new Vector2(0f, entry.animatedY); } } private TextMeshProUGUI GetText() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (_textPool.TryDequeue(out TextMeshProUGUI result) && (Object)(object)result != (Object)null) { ((Component)result).gameObject.SetActive(true); return result; } TextMeshProUGUI component = new GameObject("LogText", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }).GetComponent(); ((TMP_Text)component).fontSize = 19f; ((Graphic)component).color = _textColor; ((TMP_Text)component).font = _font; ((TMP_Text)component).wordSpacing = 20f; ((TMP_Text)component).alignment = (TextAlignmentOptions)4097; return component; } private Image GetBackground() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (_backgroundPool.TryDequeue(out Image result) && (Object)(object)result != (Object)null) { ((Component)result).gameObject.SetActive(true); return result; } Image obj = new GameObject("LogBG").AddComponent(); ((Graphic)obj).color = _backColor; obj.type = (Type)1; return obj; } private void RecycleEntry(LogEntry entry) { if ((Object)(object)entry.text != (Object)null) { ((Component)entry.text).gameObject.SetActive(false); _textPool.Enqueue(entry.text); entry.text = null; } if ((Object)(object)entry.background != (Object)null) { ((Component)entry.background).gameObject.SetActive(false); _backgroundPool.Enqueue(entry.background); entry.background = null; } } private string Colorize(string input) { if (string.IsNullOrEmpty(input)) { return input; } List list = Tokenize(input); ApplyMultiWordColoring(list); ApplySingleWordColoring(list); return string.Concat(list); } private List Tokenize(string input) { if (!string.IsNullOrEmpty(input)) { return Regex.Split(input, "(\\s+)").ToList(); } return new List(); } private void ApplySingleWordColoring(List tokens) { Dictionary dictionary = KeywordColors.Where>((KeyValuePair kvp) => !kvp.Key.Contains(" ")).ToDictionary((KeyValuePair k) => k.Key.ToLowerInvariant(), (KeyValuePair v) => v.Value); for (int i = 0; i < tokens.Count; i++) { string text = tokens[i]; if (IsWord(text)) { string key = Regex.Replace(text.ToLowerInvariant(), "[^a-z0-9]", ""); if (dictionary.TryGetValue(key, out var value)) { tokens[i] = "" + text + ""; } } } } private void ApplyMultiWordColoring(List tokens) { List> list = (from kvp in KeywordColors where kvp.Key.Contains(" ") select kvp into k orderby k.Key.Length descending select k).ToList(); if (list.Count == 0) { return; } for (int i = 0; i < tokens.Count; i++) { if (!IsWord(tokens[i])) { continue; } string text = string.Concat(tokens.Skip(i)).ToLowerInvariant(); foreach (KeyValuePair item in list) { if (!text.StartsWith(item.Key.ToLowerInvariant())) { continue; } int num = 0; string text2 = ""; for (int j = i; j < tokens.Count; j++) { if (text2.Length >= item.Key.Length) { break; } text2 += tokens[j]; num++; } tokens[i] = "" + text2 + ""; for (int l = 1; l < num; l++) { tokens[i + l] = ""; } i += num - 1; break; } } } private bool IsWord(string token) { return !string.IsNullOrWhiteSpace(token); } public void Log(string text) { string colorizedMessage = Colorize(text); LogEntry item = new LogEntry(text) { colorizedMessage = colorizedMessage }; _historyEntries.Add(item); if (_historyEntries.Count > 1000) { _historyEntries.RemoveAt(0); _historyBuiltCount = Mathf.Max(0, _historyBuiltCount - 1); } if (_showHistory) { _rebuildHistoryDirty = true; } else { _cachedEntries.Enqueue(item); } } public void DebugLog(string text) { if (PluginMain.EnableDebugLogging != null && PluginMain.EnableDebugLogging.Value) { Log(text); } } private void ToggleHistory() { _showHistory = !_showHistory; if ((Object)(object)_messageParent == (Object)null || (Object)(object)_historyPanel == (Object)null) { return; } ((Component)_messageParent).gameObject.SetActive(!_showHistory); _historyPanel.SetActive(_showHistory); if (_showHistory) { foreach (LogEntry visibleEntry in _visibleEntries) { if ((Object)(object)visibleEntry.text != (Object)null) { ((Component)visibleEntry.text).gameObject.SetActive(false); _textPool.Enqueue(visibleEntry.text); } if ((Object)(object)visibleEntry.background != (Object)null) { ((Component)visibleEntry.background).gameObject.SetActive(false); _backgroundPool.Enqueue(visibleEntry.background); } } _visibleEntries.Clear(); _cachedEntries = new ConcurrentQueue(); RebuildHistory(); } else { Cursor.lockState = (CursorLockMode)0; Cursor.visible = false; ((Component)_messageParent).gameObject.SetActive(_showConsole); } } private void ToggleConsole() { _showConsole = !_showConsole; if ((Object)(object)_messageParent == (Object)null || (Object)(object)_historyPanel == (Object)null) { return; } foreach (LogEntry visibleEntry in _visibleEntries) { if ((Object)(object)visibleEntry.background != (Object)null) { ((Component)visibleEntry.background).gameObject.SetActive(_showConsole); } if ((Object)(object)visibleEntry.text != (Object)null) { ((Component)visibleEntry.text).gameObject.SetActive(_showConsole); } } ((Component)_messageParent).gameObject.SetActive(_showConsole); if (!_showConsole) { _showHistory = false; _historyPanel.SetActive(false); } } private void BuildUI() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("APConsoleCanvas", new Type[3] { typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); val.transform.SetParent(((Component)this).transform); Canvas component = val.GetComponent(); component.renderMode = (RenderMode)0; component.sortingOrder = 2000; CanvasScaler component2 = val.GetComponent(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); GameObject val2 = new GameObject("Messages", new Type[1] { typeof(RectTransform) }); RectTransform component3 = val2.GetComponent(); ((Transform)component3).SetParent(val.transform, false); _messageParent = val2.transform; PositionMessageContainer(component3); _historyPanel = new GameObject("HistoryPanel", new Type[1] { typeof(RectTransform) }); RectTransform component4 = _historyPanel.GetComponent(); ((Transform)component4).SetParent(val.transform, false); PositionHistoryPanel(component4); _historyPanel.SetActive(false); _historyScrollRect = _historyPanel.AddComponent(); _historyScrollRect.horizontal = false; _historyScrollRect.vertical = true; _historyScrollRect.scrollSensitivity = 5f; _historyScrollRect.movementType = (MovementType)2; GameObject val3 = new GameObject("Viewport", new Type[3] { typeof(RectTransform), typeof(Image), typeof(Mask) }); _historyViewport = val3.GetComponent(); val3.transform.SetParent(_historyPanel.transform, false); _historyViewport.anchorMin = Vector2.zero; _historyViewport.anchorMax = Vector2.one; RectTransform? historyViewport = _historyViewport; Vector2 offsetMin = (_historyViewport.offsetMax = Vector2.zero); historyViewport.offsetMin = offsetMin; Image component5 = val3.GetComponent(); ((Graphic)component5).color = _backColor; component5.type = (Type)0; ((Graphic)component5).raycastTarget = true; val3.GetComponent().showMaskGraphic = false; _historyScrollRect.viewport = _historyViewport; GameObject val4 = new GameObject("Content", new Type[3] { typeof(RectTransform), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter) }); RectTransform component6 = val4.GetComponent(); ((Transform)component6).SetParent(val3.transform, false); component6.anchorMin = new Vector2(0f, 1f); component6.anchorMax = new Vector2(1f, 1f); component6.pivot = new Vector2(0.5f, 1f); component6.anchoredPosition = Vector2.zero; component6.sizeDelta = new Vector2(0f, 0f); VerticalLayoutGroup component7 = val4.GetComponent(); ((HorizontalOrVerticalLayoutGroup)component7).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component7).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component7).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component7).spacing = 8f; ((LayoutGroup)component7).childAlignment = (TextAnchor)0; ContentSizeFitter component8 = val4.GetComponent(); component8.verticalFit = (FitMode)2; component8.horizontalFit = (FitMode)0; _historyScrollRect.content = component6; _historyContent = component6; } private void RebuildHistory() { if (!((Object)(object)_historyContent == (Object)null)) { for (int i = _historyBuiltCount; i < _historyEntries.Count; i++) { AddHistoryEntryVisual(_historyEntries[i]); } _historyBuiltCount = _historyEntries.Count; Canvas.ForceUpdateCanvases(); LayoutRebuilder.ForceRebuildLayoutImmediate(_historyContent); Canvas.ForceUpdateCanvases(); if ((Object)(object)_historyScrollRect != (Object)null) { _historyScrollRect.verticalNormalizedPosition = 0f; } } } } public class ArchipelagoHandler { private const string GameName = "KeyWe"; public static bool IsConnected; public static bool IsConnecting; public static Action OnConnect; private readonly string[] _deathMessages = new string[26] { "had a skill issue (died)", "forgot to dash (died)", "didn't see the edge of the table (died)", "thought kiwis could fly (died)", "forgot their floatie (died)", "got spooked to death by Zoey", "slept on the job (died)", "got left out in the cold (died)", "got abducted by the mailflies (died)", "had an argument with a cassowary (died)", "popped too much bubblewrap (died)", "fell into a shipping crate (died)", "called Papa Moon an ape (died)", "lost the snowball fight (died)", "was struck by lightning", "got trapped in the bungalow basin oven (died)", "swallowed a button (died)", "got hit by a cannonball (died)", "lost Herbert (died)", "was swallowed by a pitcher plant (died)", "tried to hitch a ride on Bartleby (died)", "got toasted (died)", "sank in quicksand (died)", "didn't try hard enough (died)", "made a typo (died)", "forgot the 'We' (died)" }; private readonly ConcurrentQueue _locationsToCheck = new ConcurrentQueue(); private readonly Random _random = new Random(); private string _lastDeath; private LoginSuccessful _loginSuccessful; private ArchipelagoSession _session; public SlotData SlotData; private static DateTime LastDeathLinkTime = DateTime.Now; private string Server { get; } private int Port { get; } private string Slot { get; } private string Password { get; } private string Seed { get; set; } private double SlotInstance { get; set; } public ArchipelagoHandler(string server, int port, string slot, string password) { Server = server; Port = port; Slot = slot; Password = password; base..ctor(); } private void HandleDeathLink(string source, string cause) { if (SlotData.DeathLink) { APConsole.Instance.Log(cause ?? ""); if (!(source == Slot)) { GameHandler.SomeoneElseDied = true; PluginMain.GameHandler.Kill(); } } } private void CreateSession() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown SlotInstance = UnixTimeConverter.ToUnixTimeStamp(DateTime.Now); _session = ArchipelagoSessionFactory.CreateSession(Server, Port); _session.MessageLog.OnMessageReceived += new MessageReceivedHandler(OnMessageReceived); _session.Socket.SocketClosed += new SocketClosedHandler(OnSocketClosed); _session.Socket.PacketReceived += new PacketReceivedHandler(PacketReceived); _session.Items.ItemReceived += new ItemReceivedHandler(ItemReceived); } private void OnSocketClosed(string reason) { APConsole.Instance.Log("Connection closed (" + reason + ") Attempting reconnect..."); IsConnected = false; } public void InitConnect() { IsConnecting = true; CreateSession(); IsConnected = Connect(); IsConnecting = false; } private bool Connect() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown Task task = _session.ConnectAsync(); object seed; if (task == null) { seed = null; } else { RoomInfoPacket result = task.Result; seed = ((result != null) ? result.SeedName : null); } Seed = (string)seed; if (Seed != null) { PluginMain.SaveDataHandler.LoadProfile(Seed, Slot); } LoginResult result2 = _session.LoginAsync("KeyWe", Slot, (ItemsHandlingFlags)7, new Version(6, 0, 0), Array.Empty(), (string)null, Password, true).Result; if (result2.Successful) { _loginSuccessful = (LoginSuccessful)result2; SlotData = new SlotData(_loginSuccessful.SlotData); PluginMain.GameHandler.InitOnConnect(); new Thread(RunCheckLocationsFromList).Start(); OnConnect(); return true; } LoginFailure val = (LoginFailure)result2; string text = Enumerable.Aggregate(seed: Enumerable.Aggregate(seed: $"Failed to Connect to {Server}:{Port} as {Slot}:", source: val.Errors, func: (string current, string error) => current + "\n " + error), source: val.ErrorCodes, func: (string current, ConnectionRefusedError error) => current + $"\n {error}"); APConsole.Instance.Log(text); APConsole.Instance.Log("Attempting reconnect..."); return false; } private void ItemReceived(ReceivedItemsHelper helper) { try { while (helper.Any()) { int index = helper.Index; ItemInfo item = helper.DequeueItem(); PluginMain.ItemHandler.HandleItem(index, item); } } catch (Exception arg) { APConsole.Instance.Log($"[ItemReceived ERROR] {arg}"); throw; } } public void Release() { _session.SetGoalAchieved(); _session.SetClientState((ArchipelagoClientState)30); } public void CheckLocations(long[] ids) { ids.ToList().ForEach(delegate(long id) { _locationsToCheck.Enqueue(id); }); } public void CheckLocation(long id) { _locationsToCheck.Enqueue(id); } private void RunCheckLocationsFromList() { while (true) { if (_locationsToCheck.TryDequeue(out var result)) { _session.Locations.CompleteLocationChecks(new long[1] { result }); } else { Thread.Sleep(100); } } } public bool IsLocationChecked(long id) { return _session.Locations.AllLocationsChecked.Contains(id); } public int CountLocationsCheckedInRange(long start, long end) { return _session.Locations.AllLocationsChecked.Count((long loc) => loc >= start && loc < end); } public void UpdateTags(List tags) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown ConnectUpdatePacket val = new ConnectUpdatePacket { Tags = tags.ToArray(), ItemsHandling = (ItemsHandlingFlags)7 }; _session.Socket.SendPacket((ArchipelagoPacketBase)(object)val); } private void OnMessageReceived(LogMessage message) { if (message.Parts.Any((MessagePart x) => (int)x.Type == 1) && PluginMain.FilterLog != null && PluginMain.FilterLog.Value && !message.Parts.Any((MessagePart x) => x.Text.Contains(_session.Players.GetPlayerName(_session.ConnectionInfo.Slot)))) { return; } string text; if (message.Parts.Length == 1) { text = message.Parts[0].Text; } else { StringBuilder stringBuilder = new StringBuilder(); MessagePart[] parts = message.Parts; foreach (MessagePart val in parts) { stringBuilder.Append(val.Text ?? ""); } text = stringBuilder.ToString(); } APConsole.Instance.Log(text); } private void PacketReceived(ArchipelagoPacketBase packet) { BouncePacket val = (BouncePacket)(object)((packet is BouncePacket) ? packet : null); if (val != null) { BouncePacketReceived(val); } } public void SendDeath() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown BouncePacket val = new BouncePacket(); DateTime now = DateTime.Now; if (now - LastDeathLinkTime < TimeSpan.FromSeconds(2.0)) { return; } val.Tags = new List(1) { "DeathLink" }; val.Data = new Dictionary { { "time", JToken.op_Implicit(UnixTimeConverter.ToUnixTimeStamp(now)) }, { "source", JToken.op_Implicit(Slot) }, { "cause", JToken.op_Implicit(Slot + " " + _deathMessages[_random.Next(_deathMessages.Length)]) } }; if (val.Data.TryGetValue("source", out var value)) { ((object)value)?.ToString(); if (val.Data.TryGetValue("cause", out var value2)) { ((object)value2)?.ToString(); if (val.Data.TryGetValue("time", out var value3)) { ((object)value3)?.ToString(); } } } LastDeathLinkTime = now; _session.Socket.SendPacket((ArchipelagoPacketBase)(object)val); } private void BouncePacketReceived(BouncePacket packet) { if (SlotData.DeathLink) { ProcessBouncePacket(packet, "DeathLink", ref _lastDeath, delegate(string source, Dictionary data) { HandleDeathLink(source, ((object)data["cause"])?.ToString() ?? "Unknown"); }); } } private static void ProcessBouncePacket(BouncePacket packet, string tag, ref string lastTime, Action> handler) { if (!packet.Tags.Contains(tag) || !packet.Data.TryGetValue("time", out var value) || lastTime == ((object)value).ToString()) { return; } lastTime = ((object)value).ToString(); if (packet.Data.TryGetValue("source", out var value2)) { string arg = ((object)value2)?.ToString() ?? "Unknown"; if (packet.Data.TryGetValue("cause", out var value3)) { ((object)value3)?.ToString(); } handler(arg, packet.Data); } } public bool IsFinalLocked() { if (SaveDataHandler.ArchipelagoSaveData.CollectiblesChecked.Count((KeyValuePair x) => x.Value) < PluginMain.ArchipelagoHandler.SlotData.RequiredCollectibleChecks) { return true; } if (SaveDataHandler.ArchipelagoSaveData.LevelCompletions.Count((KeyValuePair x) => x.Value) < PluginMain.ArchipelagoHandler.SlotData.RequiredLevelCompletions) { return true; } if (Enumerable.Range(0, 9).Any((int week) => Enumerable.Range(0, 4).Count((int day) => SaveDataHandler.ArchipelagoSaveData.LevelCompletions[week * 4 + day]) < PluginMain.ArchipelagoHandler.SlotData.RequiredLevelCompletionsPerWeek)) { return true; } if (SaveDataHandler.ArchipelagoSaveData.Collectibles.Count((KeyValuePair x) => x.Value) < PluginMain.ArchipelagoHandler.SlotData.RequiredCollectibles) { return true; } if (SaveDataHandler.ArchipelagoSaveData.OvertimeLevelCompletions.Count((KeyValuePair x) => x.Value) < PluginMain.ArchipelagoHandler.SlotData.RequiredOvertimeCompletions) { return true; } if (SaveDataHandler.ArchipelagoSaveData.TournamentCourseCompletions.Count((KeyValuePair x) => x.Value) < PluginMain.ArchipelagoHandler.SlotData.RequiredTournamentCompletions) { return true; } return false; } public string GetRequirementsString() { int num = SaveDataHandler.ArchipelagoSaveData.LevelCompletions.Count((KeyValuePair x) => x.Value); int requiredLevelCompletions = PluginMain.ArchipelagoHandler.SlotData.RequiredLevelCompletions; int num2 = Enumerable.Range(0, 9).Count((int week) => Enumerable.Range(0, 4).Count((int day) => SaveDataHandler.ArchipelagoSaveData.LevelCompletions[week * 4 + day]) >= PluginMain.ArchipelagoHandler.SlotData.RequiredLevelCompletionsPerWeek); int num3 = SaveDataHandler.ArchipelagoSaveData.Collectibles.Count((KeyValuePair x) => x.Value); int requiredCollectibles = PluginMain.ArchipelagoHandler.SlotData.RequiredCollectibles; int num4 = SaveDataHandler.ArchipelagoSaveData.CollectiblesChecked.Count((KeyValuePair x) => x.Value); int requiredCollectibleChecks = PluginMain.ArchipelagoHandler.SlotData.RequiredCollectibleChecks; int num5 = SaveDataHandler.ArchipelagoSaveData.OvertimeLevelCompletions.Count((KeyValuePair x) => x.Value); int requiredOvertimeCompletions = PluginMain.ArchipelagoHandler.SlotData.RequiredOvertimeCompletions; int num6 = SaveDataHandler.ArchipelagoSaveData.TournamentCourseCompletions.Count((KeyValuePair x) => x.Value); int requiredTournamentCompletions = PluginMain.ArchipelagoHandler.SlotData.RequiredTournamentCompletions; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Stand Your Post Requirements:"); if (requiredLevelCompletions > 0) { stringBuilder.AppendLine($"{num}/{requiredLevelCompletions} levels complete"); } if (PluginMain.ArchipelagoHandler.SlotData.RequiredLevelCompletionsPerWeek > 0) { stringBuilder.AppendLine($"{num2}/{9} weeks with {PluginMain.ArchipelagoHandler.SlotData.RequiredLevelCompletionsPerWeek} level(s) complete"); } if (requiredCollectibles > 0) { stringBuilder.AppendLine($"{num3}/{requiredCollectibles} collectibles received"); } if (requiredCollectibleChecks > 0) { stringBuilder.AppendLine($"{num4}/{requiredCollectibleChecks} collectible locations checked"); } if (requiredOvertimeCompletions > 0) { stringBuilder.AppendLine($"{num5}/{requiredOvertimeCompletions} overtime shifts complete"); } if (requiredTournamentCompletions > 0) { stringBuilder.AppendLine($"{num6}/{requiredTournamentCompletions} tournament courses complete"); } return stringBuilder.ToString(); } } public class ConnectionInfo { public string Server { get; set; } public ushort Port { get; set; } public string Slot { get; set; } public string Password { get; set; } } public class ConnectionInfoHandler { private static readonly string path = SaveSystem.DataRoot + "connection_info.json"; public static void Save(string server, ushort port, string slot, string password) { string contents = JsonConvert.SerializeObject((object)new ConnectionInfo { Server = server, Port = port, Slot = slot, Password = password }); File.WriteAllText(path, contents); } public static void Load(ref string server, ref ushort port, ref string slotName, ref string password) { if (!File.Exists(path)) { Save("archipelago.gg", ushort.MaxValue, "Player1", ""); } ConnectionInfo connectionInfo = JsonConvert.DeserializeObject(File.ReadAllText(path)); server = connectionInfo.Server; port = connectionInfo.Port; slotName = connectionInfo.Slot; password = connectionInfo.Password; } } public class Data { public static float MaxWalkSpeed = 16f; public static float MaxJumpHeight = 33f; public static float MaxSwimSpeed = 12.4f; public static float MaxRespawnFallSpeed = 10f; public static float MaxRespawnFallMoveSpeed = 13f; public static float MaxDashForce = 37.5f; public static float MaxChirpCooldown = 5f; public static float MinDashCooldown = 0.3f; public static float MinPeckCooldown = 0f; public static float MinChirpCooldown = 0f; public static float InitialWalkSpeed = 10f; public static float InitialDashForce = 20f; public static float InitialSwimSpeed = 5f; public static float InitialJumpHeight = 22f; public static float InitialRespawnFallMoveSpeed = 5f; public static float InitialRespawnFallSpeed = 4f; public static float InitialChirpCooldown = 0.6f; public static float InitialPeckCooldown = 0.6f; public static float InitialDashCooldown = 0.6f; public static Dictionary OvertimeLevelNameToId = new Dictionary { { "Kiwis in Harmony", 0 }, { "Conveyer Belt Chaos", 1 }, { "Lunch Break", 2 }, { "Tank Trouble", 3 }, { "Cassowary Courier Course", 4 }, { "Bubble Wrap Testing", 5 }, { "Snowball Fight!", 6 }, { "The Sorting Room", 7 }, { "Cashing Out", 8 } }; public static Dictionary TournamentLevelNameToId = new Dictionary { { "Gumtree Grove", 0 }, { "Painted Cliffs", 1 }, { "Lake Bessy", 2 } }; public static List ExcludedLevels = new List(4) { 16, 18, 19, 17 }; public static List ExcludedOvertimeShifts = new List(1) { 3 }; public static List ExcludedTournamentCourses = new List(2) { 1, 2 }; public static Dictionary LevelNameToId = new Dictionary { { "The Telegraph Desk", 0 }, { "The Transcription Room", 1 }, { "The Shipping Floor", 2 }, { "The Dropoff Depot", 3 }, { "Marauding Mailflies", 4 }, { "Covert Decoders", 5 }, { "Postal Pest Problems", 6 }, { "Vegetation Vexation", 7 }, { "Devilish Dust-Up", 8 }, { "A Sinking Feeling", 9 }, { "Bouncing Boxes (and Blimps)", 10 }, { "Creepin’ Kudzu", 11 }, { "Shipping Shake-Up", 12 }, { "Transcription Turmoil", 13 }, { "Keyboard Commotion", 14 }, { "Parcel Panel Puzzle", 15 }, { "The Night Post", 16 }, { "Electrical Interference", 17 }, { "Bobbing for Boxes", 18 }, { "Mechanical Mayhem", 19 }, { "Tricks and Telegrams", 20 }, { "Zoey’s Tracks of Terror", 21 }, { "Casso-scary", 22 }, { "Mail from Beyond", 23 }, { "Trapdoors and Tentacles", 24 }, { "Assembly-Line Scramble", 25 }, { "Dueling Crates", 26 }, { "Switchboard Synchrony", 27 }, { "Bungalow Basin Bake-Off", 28 }, { "Parts and Crafts", 29 }, { "The Hollyjostle Tinkertrack", 30 }, { "That’s a Wrap", 31 }, { "An Approaching Storm", 32 }, { "Bitter Cold", 33 }, { "Emergency Relief", 34 }, { "Stand Your Post", 35 } }; } public class GameHandler : MonoBehaviour { [HarmonyPatch(typeof(Overmap))] public class Overmap_Patch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void OnStart(Overmap __instance) { OvermapMenuOption? obj = ((IEnumerable)__instance.options).FirstOrDefault((Func)((OvermapMenuOption o) => ((Object)o).name == "SwitchProfile")); if (obj != null) { ((Component)obj).transform.Translate(-10000f, 0f, 0f); } OvermapMenuOption? obj2 = ((IEnumerable)__instance.options).FirstOrDefault((Func)((OvermapMenuOption o) => (int)o.option == 2)); if (obj2 != null) { KeyWeExtensions.SetActive((MonoBehaviour)(object)obj2, false); } OvermapMenuOption? obj3 = ((IEnumerable)__instance.options).FirstOrDefault((Func)((OvermapMenuOption o) => (int)o.option == 3)); if (obj3 != null) { KeyWeExtensions.SetActive((MonoBehaviour)(object)obj3, false); } } } [HarmonyPatch(typeof(Kiwi))] public class Kiwi_Patch { private static readonly ConditionalWeakTable handlers = new ConditionalWeakTable(); [HarmonyPatch("Init")] [HarmonyPostfix] public static void OnInit(Kiwi __instance) { Kiwi __instance2 = __instance; UpdateKiwiMovement(__instance2); Action value = delegate { UpdateKiwiMovement(__instance2); }; handlers.Add(__instance2, value); onReceivedMovementUpgrade = (Action)Delegate.Combine(onReceivedMovementUpgrade, (Action)delegate { UpdateKiwiMovement(__instance2); }); } [HarmonyPatch("OnDestroy")] [HarmonyPrefix] public static void OnDestroy(Kiwi __instance) { if (handlers.TryGetValue(__instance, out Action value)) { onReceivedMovementUpgrade = (Action)Delegate.Remove(onReceivedMovementUpgrade, value); handlers.Remove(__instance); } } [HarmonyPatch("Respawn")] [HarmonyPrefix] public static void OnRespawn(Kiwi __instance, bool inWater) { try { if (!((PauseObject)__instance).IsPaused && PluginMain.ArchipelagoHandler.SlotData.DeathLink) { PluginMain.ArchipelagoHandler.SendDeath(); } } catch (Exception ex) { APConsole.Instance.Log(ex.Message); } } } [HarmonyPatch(typeof(CourseButton))] public class CourseButton_Patch { [HarmonyPatch("SetData")] [HarmonyPrefix] private static void OnSetData(ref bool isLocked, int index, TournamentRecord record, TournamentLevelData data) { bool tournamentUnlocked = SaveDataHandler.ArchipelagoSaveData.TournamentUnlocked; if (SystemHandler.Get().Profile.CheckProgress((ProgressFlag)8192)) { isLocked = !tournamentUnlocked; } else if (tournamentUnlocked) { APConsole.Instance.Log("Warning: You have made an attempt to DLC protection measures. Please support the devs. They worked hard on this game. Thank you - xMcacutt"); } } } [HarmonyPatch(typeof(OvertimeShiftBoard))] public class OvertimeShiftBoard_Patch { [HarmonyPatch("Overmap_OnRefreshScene")] [HarmonyPostfix] private static void Overmap_OnRefreshScene(OvertimeShiftBoard __instance) { KeyWeExtensions.ForEachItem((IEnumerable)__instance.topRow, (Action)delegate(ShiftDisplay d) { KeyWeExtensions.SetActive((MonoBehaviour)(object)d, SaveDataHandler.ArchipelagoSaveData.OvertimeSummerUnlocked); }); KeyWeExtensions.ForEachItem((IEnumerable)__instance.middleRow, (Action)delegate(ShiftDisplay d) { KeyWeExtensions.SetActive((MonoBehaviour)(object)d, SaveDataHandler.ArchipelagoSaveData.OvertimeFallUnlocked); }); KeyWeExtensions.ForEachItem((IEnumerable)__instance.bottomRow, (Action)delegate(ShiftDisplay d) { KeyWeExtensions.SetActive((MonoBehaviour)(object)d, SaveDataHandler.ArchipelagoSaveData.OvertimeWinterUnlocked); }); } } [HarmonyPatch(typeof(OvermapSubMenu))] public class OvermapSubMenu_Patch { [HarmonyPatch("SetUIShowing")] [HarmonyPostfix] private static void SetUIShowing(OvermapSubMenu __instance, bool activate) { if (SaveDataHandler.ArchipelagoSaveData == null) { return; } OvertimeShiftBoard val = (OvertimeShiftBoard)(object)((__instance is OvertimeShiftBoard) ? __instance : null); if (val != null) { KeyWeExtensions.ForEachItem((IEnumerable)val.topRow, (Action)delegate(ShiftDisplay d) { KeyWeExtensions.SetActive((MonoBehaviour)(object)d, SaveDataHandler.ArchipelagoSaveData.OvertimeSummerUnlocked); }); KeyWeExtensions.ForEachItem((IEnumerable)val.middleRow, (Action)delegate(ShiftDisplay d) { KeyWeExtensions.SetActive((MonoBehaviour)(object)d, SaveDataHandler.ArchipelagoSaveData.OvertimeFallUnlocked); }); KeyWeExtensions.ForEachItem((IEnumerable)val.bottomRow, (Action)delegate(ShiftDisplay d) { KeyWeExtensions.SetActive((MonoBehaviour)(object)d, SaveDataHandler.ArchipelagoSaveData.OvertimeWinterUnlocked); }); } } } [HarmonyPatch(typeof(Calendar))] public class Calendar_Patch { [HarmonyPatch("Day_OnSelected")] [HarmonyPostfix] public static void OnDaySelected(DayButton button) { if (!(SystemHandler.Get().Levels[(int)button.DataIndex].Name != "Stand Your Post") && button.IsLocked) { APConsole.Instance.Log(PluginMain.ArchipelagoHandler.GetRequirementsString()); } } [HarmonyPatch("InitRewards")] [HarmonyPrefix] private static bool InitRewards(Calendar __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) LevelResults results = __instance.results; if (((results != null) ? results.BestResults : null) == null || !KeyWeExtensions.IsPassed(__instance.results.BestResults.Grade) || !__instance.results.BestResults.NewGrade) { return false; } LevelResults results2 = __instance.results; if (results2 != null) { results2.ResetData(); } __instance.OnAwardsDone(); return false; } [HarmonyPatch("SetUpButtons")] [HarmonyPrefix] public static bool OnSetUpButtons(Calendar __instance, SeasonRange range, int numLevels) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < __instance.dayButtons.Length; i++) { DayButton val = __instance.dayButtons[i]; int num = range.StartIndex + i; int key = range.StartIndex / 12 * 3 + i / 4; bool flag = !SaveDataHandler.ArchipelagoSaveData.WeeksUnlocked[key]; if (num == 35) { flag = PluginMain.ArchipelagoHandler.IsFinalLocked(); } if (i < numLevels) { LevelData val2 = __instance.dataKeeper.Levels[num]; Sprite modeIcon = __instance.modeInfo.GetModeIcon(val2.Mode); bool? challengesStatus = __instance.GetChallengesStatus(num, val2); val.Init(((RecordBase)__instance.dataKeeper.Profile.LevelRecords[num]).HighestGrade, modeIcon, flag, (short)num, (short)i, challengesStatus); } else { val.Init((Grade)(-2), (Sprite)null, true, (short)(-1), (short)i, (bool?)null); } } __instance.FocusButton(range); return false; } [HarmonyPatch("UpdateSeason")] [HarmonyPrefix] public static bool OnUpdateSeason(Calendar __instance) { __instance.details.Hide(); if ((Object)(object)__instance.pcFields.StartButton != (Object)null) { __instance.pcFields.StartButton.interactable = false; } DataKeeper dataKeeper = __instance.dataKeeper; SeasonRange val = ((dataKeeper != null) ? dataKeeper.Levels.SeasonsIndices[__instance.seasonIndex] : null); __instance.SetUpButtons(val, val.Count); __instance.isNextSeasonLocked = false; __instance.UpdateSeasonPlates(); __instance.UpdatePCButtons(); __instance.RefreshHighlightedDay(); __instance.UpdateIntroButton(); return false; } } [HarmonyPatch(typeof(ProfileData))] public class ProfileData_Patch { [HarmonyPatch("ChallengesCompleted")] [HarmonyPrefix] public static bool OnChallengesCompleted(ProfileData __instance, ref ushort __result, Mode mode, int levelID, ushort[] challengeIDs, ushort reward) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) ushort num = 0; if (challengeIDs == null) { __result = num; return false; } RecordBase val = default(RecordBase); foreach (ushort num2 in challengeIDs) { if (!__instance.IsChallengeCompleted(mode, levelID, num2, ref val) && val != null) { RecordBase val2 = val; if (val2.CompletedChallengeIndices == null) { val2.CompletedChallengeIndices = new List(); } val?.CompletedChallengeIndices.Add(num2); num += reward; } } __result = num; return false; } } [HarmonyPatch(typeof(DataKeeper))] public class DataKeeper_Patch { [HarmonyPatch("GiveReward")] [HarmonyPrefix] public static bool OnGiveReward(Grade grade, ref ushort extraStamps, LevelData levelData) { extraStamps = 0; return true; } [HarmonyPatch("CheckForCinematicTrigger")] [HarmonyPrefix] private static bool OnCheckForCinematicTrigger(ref Cinematics __result) { __result = (Cinematics)(-1); return false; } [HarmonyPatch("GetActiveSeason")] [HarmonyPrefix] public static bool GetActiveSeason(ref Season __result) { __result = (Season)2; return false; } } public static bool IsUnlocking; public static bool SomeoneElseDied; public static Action onReceivedMovementUpgrade; public void InitOnConnect() { ((Component)this).gameObject.AddComponent(); } public void LogWearables() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) string text = ""; for (int i = 0; i < 7; i++) { text = text + "Category " + i + " \n"; Customizable[] items = SystemHandler.Get().GetWearables((Categories)i).Items; foreach (Customizable val in items) { text = text + val.Id + " " + val.Name + "\n"; text = text + val.Description + "\n"; text = text + ((object)(CategoryMask)(ref val.incompatibleCategories)).ToString() + "\n"; string text2 = text; RewardCategory rewardCategory = val.RewardCategory; text = text2 + ((object)(RewardCategory)(ref rewardCategory)).ToString() + "\n\n"; } text += "\n"; } File.WriteAllText(SaveSystem.DataRoot + "Help.txt", text); } public void Kill() { ((MonoBehaviour)this).StartCoroutine(KillDelayed()); } private IEnumerator KillDelayed() { yield return null; Kiwi[] array = Object.FindObjectsOfType(); foreach (Kiwi val in array) { if (val.IsLocalPlayer) { Respawn(val, inWater: false); } } SomeoneElseDied = false; } public void Respawn(Kiwi kiwi, bool inWater) { kiwi.ShowRespawnEffect(inWater); if (OnlineEventRelay.Instance.IsInRoom) { kiwi.photonView.RPC("Kiwi_Respawn_RPC", (RpcTarget)1, new object[1] { inWater }); } ((CommonKiwi)kiwi).ChangeState((StateID)1); } public void EquipRandom(Categories category) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) DataKeeper val = SystemHandler.Get(); if ((Object)(object)val == (Object)null || Data.ExcludedLevels == null || Data.LevelNameToId == null || (Object)(object)val.CurrentLevelData == (Object)null) { APConsole.Instance.Log("Failed to equip a cosmetic (this is a failsafe, don't panic)"); return; } State currentState = val.CurrentState; if ((int)currentState != 2) { if ((int)currentState != 3) { if ((int)currentState == 7 && Data.ExcludedTournamentCourses.Contains(Data.TournamentLevelNameToId[val.CurrentLevelData.Name])) { goto IL_00b7; } } else if (Data.ExcludedOvertimeShifts.Contains(Data.OvertimeLevelNameToId[val.CurrentLevelData.Name])) { goto IL_00b7; } } else if (Data.ExcludedLevels.Contains(Data.LevelNameToId[val.CurrentLevelData.Name])) { goto IL_00b7; } ((MonoBehaviour)this).StartCoroutine(EquipRandomDelayed(category)); return; IL_00b7: APConsole.Instance.Log("Cannot equip cosmetics in this level"); } private IEnumerator EquipRandomDelayed(Categories category) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return null; DataKeeper dataKeeper = SystemHandler.Get(); Kiwi[] array = Object.FindObjectsOfType(); if (array.Length == 0) { yield break; } Kiwi[] array2 = array; foreach (Kiwi val in array2) { if (!val.IsLocalPlayer) { continue; } int num = ((!PhotonNetwork.IsConnected) ? ((CommonKiwi)val).playerIndex : dataKeeper.OnlineSelectedKiwi); Customization customization = dataKeeper.Profile.GetCustomization(num); List list = dataKeeper.GetWearables(category).Items.Where((Customizable x) => (dataKeeper.Profile.CheckProgress((ProgressFlag)8192) || (int)x.RewardCategory != 7) && (dataKeeper.Profile.CheckProgress((ProgressFlag)256) || (int)x.RewardCategory != 3) && (int)x.RewardCategory != 5).ToList(); if (list.Count == 0) { continue; } Customizable random = KeyWeExtensions.GetRandom((IEnumerable)list); int num2 = 1; for (int j = 0; j < 7; j++) { if (FlagsHelper.IsSet(random.IncompatibleCategories, (CategoryMask)num2)) { ((Customization)(ref customization)).EquipItem((Categories)j, 0u); } num2 <<= 1; } UnequipIncompatibleItems(random, num, category); ((Customization)(ref customization)).EquipItem(category, random.Id); dataKeeper.SaveProfile(); val.Customization.InitAll(); if (PhotonNetwork.IsConnected) { Player localPlayer = PhotonNetwork.LocalPlayer; Hashtable val2 = new Hashtable(); string customization2 = Properties.Customization; Customization customization3 = dataKeeper.Profile.GetCustomization(dataKeeper.OnlineSelectedKiwi); ((Dictionary)(object)val2).Add((object)customization2, (object)((Customization)(ref customization3)).GetItemIDsString()); localPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); } } } private void UnequipIncompatibleItems(Customizable wearable, int playerIndex, Categories category) { //IL_000d: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) DataKeeper val = SystemHandler.Get(); Customization customization = val.Profile.GetCustomization(playerIndex); CategoryMask val2 = (CategoryMask)(1 << (int)category); for (int i = 0; i < 7; i++) { Categories val3 = (Categories)i; bool num = val3 != category && FlagsHelper.IsSet(wearable.IncompatibleCategories, (CategoryMask)(1 << i)); uint num2 = customization.ItemIDs[i]; Customizable wearable2 = val.GetWearable(val3, num2); bool flag = wearable2 != null && FlagsHelper.IsSet(wearable2.IncompatibleCategories, val2); if (num || flag) { ((Customization)(ref customization)).EquipItem(val3, 0u); } } } public static void UpdateKiwiMovement(Kiwi kiwi) { kiwi.walkSpeed = SaveDataHandler.ArchipelagoSaveData.WalkSpeed; kiwi.swimSpeed = SaveDataHandler.ArchipelagoSaveData.SwimSpeed; kiwi.dashing.dashForce = SaveDataHandler.ArchipelagoSaveData.DashForce; kiwi.dashing.DashCooldownTimer.maxTime = SaveDataHandler.ArchipelagoSaveData.DashCooldown; kiwi.dashing.dashCooldownTimer.Length = SaveDataHandler.ArchipelagoSaveData.DashCooldown; kiwi.jumping.initialSpeed = SaveDataHandler.ArchipelagoSaveData.JumpHeight; kiwi.jumping.maxJumpForce = SaveDataHandler.ArchipelagoSaveData.JumpHeight; kiwi.fallSpeed = SaveDataHandler.ArchipelagoSaveData.RespawnFallSpeed; kiwi.fallMovementSpeed = SaveDataHandler.ArchipelagoSaveData.RespawnFallMoveSpeed; kiwi.vocalTimer.maxTime = SaveDataHandler.ArchipelagoSaveData.ChirpCooldown; kiwi.vocalTimer.Length = SaveDataHandler.ArchipelagoSaveData.ChirpCooldown; kiwi.peckTimer.maxTime = SaveDataHandler.ArchipelagoSaveData.PeckCooldown; kiwi.peckTimer.Length = SaveDataHandler.ArchipelagoSaveData.PeckCooldown; } } public enum KWItem { SummerWeek1 = 1, SummerWeek2 = 2, SummerWeek3 = 3, FallWeek1 = 4, FallWeek2 = 5, FallWeek3 = 6, WinterWeek1 = 7, WinterWeek2 = 8, WinterWeek3 = 9, OvertimeSummer = 10, OvertimeFall = 11, OvertimeWinter = 12, Tournament = 13, Facewear = 256, Hat = 257, Skin = 258, Backwear = 259, Hairstyle = 260, Footwear = 261, Arms = 262, DashUp = 512, MoveUp = 513, SwimUp = 514, JumpUp = 515, RespawnUp = 516, ChirpUp = 517, PeckUp = 518, SecretSpiceShaker = 768, GlimmeringShell = 769, EmptyChrysalis = 770, TemperedLens = 771, WayfarersCompass = 772, PricklySeedPod = 773, AncientTooth = 774, CosmicFriendshipRock = 775, ChargedFeather = 776, SaltyScale = 777, GlowingWishbone = 778, Z39SoaringAuk = 779, PapaMoonFigurine = 780, MountaineersPiton = 781, LostLetter = 782 } public class ItemHandler { public void HandleItem(int index, ItemInfo item) { try { if (index < SaveDataHandler.ArchipelagoSaveData.ItemIndex) { return; } SaveDataHandler.ArchipelagoSaveData.ItemIndex++; long itemId = item.ItemId; if (itemId > 767) { if (itemId < 783) { SaveDataHandler.ArchipelagoSaveData.Collectibles[(int)item.ItemId - 768] = true; } } else if (itemId > 0) { if (itemId >= 10) { long num = itemId - 10; if ((ulong)num <= 3uL) { switch (num) { case 0L: goto IL_0105; case 1L: goto IL_0115; case 2L: goto IL_0125; case 3L: goto IL_0135; } } long num2 = itemId - 256; if ((ulong)num2 <= 6uL) { switch (num2) { case 0L: goto IL_016f; case 1L: goto IL_017f; case 2L: goto IL_018f; case 3L: goto IL_019f; case 4L: goto IL_01af; case 5L: goto IL_01bf; case 6L: goto IL_01cf; } } long num3 = itemId - 512; if ((ulong)num3 <= 6uL) { switch (num3) { case 0L: { float dashCooldown = SaveDataHandler.ArchipelagoSaveData.DashCooldown; float num10 = (Data.InitialDashCooldown - Data.MinDashCooldown) / 5f; SaveDataHandler.ArchipelagoSaveData.DashCooldown = Math.Max(dashCooldown - num10, Data.MinDashCooldown); float dashForce = SaveDataHandler.ArchipelagoSaveData.DashForce; num10 = (Data.MaxDashForce - Data.InitialDashForce) / 5f; SaveDataHandler.ArchipelagoSaveData.DashForce = Math.Min(dashForce + num10, Data.MaxDashForce); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } case 1L: { float walkSpeed = SaveDataHandler.ArchipelagoSaveData.WalkSpeed; float num5 = (Data.MaxWalkSpeed - Data.InitialWalkSpeed) / 5f; SaveDataHandler.ArchipelagoSaveData.WalkSpeed = Math.Min(walkSpeed + num5, Data.MaxWalkSpeed); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } case 2L: { float swimSpeed = SaveDataHandler.ArchipelagoSaveData.SwimSpeed; float num7 = (Data.MaxSwimSpeed - Data.InitialSwimSpeed) / 5f; SaveDataHandler.ArchipelagoSaveData.SwimSpeed = Math.Min(swimSpeed + num7, Data.MaxSwimSpeed); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } case 3L: { float jumpHeight = SaveDataHandler.ArchipelagoSaveData.JumpHeight; float num11 = (Data.MaxJumpHeight - Data.InitialJumpHeight) / 5f; SaveDataHandler.ArchipelagoSaveData.JumpHeight = Math.Min(jumpHeight + num11, Data.MaxJumpHeight); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } case 4L: { float respawnFallSpeed = SaveDataHandler.ArchipelagoSaveData.RespawnFallSpeed; float num8 = (Data.MaxRespawnFallSpeed - Data.InitialRespawnFallSpeed) / 5f; SaveDataHandler.ArchipelagoSaveData.RespawnFallSpeed = Math.Min(respawnFallSpeed + num8, Data.MaxRespawnFallSpeed); float respawnFallMoveSpeed = SaveDataHandler.ArchipelagoSaveData.RespawnFallMoveSpeed; float num9 = (Data.MaxRespawnFallMoveSpeed - Data.InitialRespawnFallMoveSpeed) / 5f; SaveDataHandler.ArchipelagoSaveData.RespawnFallMoveSpeed = Math.Min(respawnFallMoveSpeed + num9, Data.MaxRespawnFallMoveSpeed); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } case 5L: { float chirpCooldown = SaveDataHandler.ArchipelagoSaveData.ChirpCooldown; float num6 = (Data.InitialChirpCooldown - Data.MinChirpCooldown) / 5f; SaveDataHandler.ArchipelagoSaveData.ChirpCooldown = Math.Max(chirpCooldown - num6, Data.MinChirpCooldown); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } case 6L: { float peckCooldown = SaveDataHandler.ArchipelagoSaveData.PeckCooldown; float num4 = (Data.InitialPeckCooldown - Data.MinPeckCooldown) / 5f; SaveDataHandler.ArchipelagoSaveData.PeckCooldown = Math.Max(peckCooldown - num4, Data.MinPeckCooldown); GameHandler.onReceivedMovementUpgrade?.Invoke(); break; } } } } else { PluginMain.SaveDataHandler.UnlockWeek((int)item.ItemId - 1); } } goto IL_0486; IL_0135: if (SystemHandler.Get().Profile.CheckProgress((ProgressFlag)8192)) { SaveDataHandler.ArchipelagoSaveData.TournamentUnlocked = true; } else { APConsole.Instance.Log("Warning: You do not own the Telepost Tournament DLC but have its checks enabled."); } goto IL_0486; IL_0105: SaveDataHandler.ArchipelagoSaveData.OvertimeSummerUnlocked = true; goto IL_0486; IL_0125: SaveDataHandler.ArchipelagoSaveData.OvertimeWinterUnlocked = true; goto IL_0486; IL_0115: SaveDataHandler.ArchipelagoSaveData.OvertimeFallUnlocked = true; goto IL_0486; IL_019f: PluginMain.GameHandler.EquipRandom((Categories)3); goto IL_0486; IL_018f: PluginMain.GameHandler.EquipRandom((Categories)1); goto IL_0486; IL_017f: PluginMain.GameHandler.EquipRandom((Categories)0); goto IL_0486; IL_016f: PluginMain.GameHandler.EquipRandom((Categories)2); goto IL_0486; IL_01bf: PluginMain.GameHandler.EquipRandom((Categories)5); goto IL_0486; IL_01af: PluginMain.GameHandler.EquipRandom((Categories)4); goto IL_0486; IL_01cf: PluginMain.GameHandler.EquipRandom((Categories)6); goto IL_0486; IL_0486: SystemHandler.Get().SaveProfile(); } catch (Exception arg) { APConsole.Instance.Log($"[HandleItem ERROR] {arg}"); throw; } } } public class LocationHandler { [HarmonyPatch(typeof(DataKeeper))] public class DataKeeper_Patch { [HarmonyPatch("CalenderLevelComplete")] [HarmonyPrefix] public static bool OnCalenderLevelComplete(DataKeeper __instance, LevelData levelData, LevelCompletionInfo info, ref Grade grade, ref ushort reward, ref ushort challengeReward, ref bool shouldSave) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between I4 and Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) int value; bool flag = Data.LevelNameToId.TryGetValue(levelData.Name, out value); if (flag && value == 35) { PluginMain.ArchipelagoHandler.Release(); } else if ((int)grade < (int)PluginMain.ArchipelagoHandler.SlotData.GradeCheckThreshold) { grade = (Grade)(-1); } else if (flag) { PluginMain.ArchipelagoHandler.CheckLocation(256 + 16 * value); ushort[] challengesCompleted = info.ChallengesCompleted; if (challengesCompleted != null && challengesCompleted.Length > 0) { PluginMain.ArchipelagoHandler.CheckLocation(256 + 16 * value + 11); } SaveDataHandler.ArchipelagoSaveData.LevelCompletions[value] = true; } reward = 0; challengeReward = 0; LevelResults val = SystemHandler.Get(); LevelRecord val2 = null; bool flag2 = false; if (KeyWeExtensions.IsValidIndex(__instance.ActiveLevelIndex, (IEnumerable)__instance.profile.LevelRecords, (short)0)) { val2 = __instance.Profile.LevelRecords[__instance.ActiveLevelIndex]; flag2 = __instance.Profile.CurrentLevelIndex == __instance.ActiveLevelIndex; } val.StoreMatchResults(levelData, val2, grade, flag2, __instance.activeLevelIndex, (int)info.GoalsCleared, info.Duration, reward, (short)(-1), info.CollectibleID, challengeReward); __instance.Profile.LevelAttempted(val.LastResults.NewRecord || val.LastResults.NewGrade, (int)__instance.ActiveLevelIndex, grade, info.GoalsCleared, info.Duration, info.TutorialDuration); shouldSave = true; return false; } [HarmonyPatch("OvertimeShiftComplete")] [HarmonyPrefix] public static bool OnOvertimeShiftComplete(DataKeeper __instance, ref bool __result, ref OvertimeShiftLevelData levelData, ref LevelCompletionInfo info, ref Grade grade, ref ushort reward, ref ushort challengeReward, ref bool shouldSave) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between I4 and Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected I4, but got Unknown File.AppendAllText(SaveSystem.DataRoot + "Levels.txt", ((LevelData)levelData).Name ?? ""); int value; if ((int)grade < (int)PluginMain.ArchipelagoHandler.SlotData.GradeCheckThreshold) { grade = (Grade)(-1); } else if (Data.OvertimeLevelNameToId.TryGetValue(((LevelData)levelData).Name, out value)) { PluginMain.ArchipelagoHandler.CheckLocation(1024 + 4 * value); ushort[] challengesCompleted = info.ChallengesCompleted; if (challengesCompleted != null && challengesCompleted.Length > 0) { PluginMain.ArchipelagoHandler.CheckLocation(1024 + 4 * value + 2); } SaveDataHandler.ArchipelagoSaveData.OvertimeLevelCompletions[value] = true; } reward = 0; challengeReward = 0; OvertimeShiftRecord overtimeShiftRecord = __instance.Profile.GetOvertimeShiftRecord((ushort)levelData.ID); float num = overtimeShiftRecord.WearableProgress; float num2 = 0f; if ((int)grade > -1) { num2 = __instance.OvertimeShifts.WearableUnlockThreshold / 3f * (float)((int)grade + 1); num = overtimeShiftRecord.WearableProgress + num2; shouldSave = true; if ((double)num >= (double)__instance.OvertimeShifts.WearableUnlockThreshold && !__instance.Profile.IsUnlocked(levelData.WearableCategory, 0, (int)(ushort)levelData.WearableID)) { if (Data.OvertimeLevelNameToId.TryGetValue(((LevelData)levelData).Name, out var value2)) { PluginMain.ArchipelagoHandler.CheckLocation(1024 + 4 * value2 + 1); } Utility.UnsignedClamp(ref num, __instance.OvertimeShifts.WearableUnlockThreshold); __instance.Profile.AddNotification((Type)2, (int)levelData.WearableCategory, (int)levelData.WearableID); } } float num3 = overtimeShiftRecord.WearableProgress / __instance.OvertimeShifts.WearableUnlockThreshold; float num4 = num / __instance.OvertimeShifts.WearableUnlockThreshold; SystemHandler.Get().StoreOvertimeResults((LevelData)(object)levelData, grade, (ushort)__instance.ActiveLevelIndex, info.GoalsCleared, info.Duration, reward, num3, num4, challengeReward); __result = __instance.Profile.OvertimeAttempted(__instance.ActiveLevelIndex, grade, (int)info.GoalsCleared, info.Duration, num2, __instance.OvertimeShifts.WearableUnlockThreshold); return false; } [HarmonyPatch("TournamentCourseComplete")] [HarmonyPrefix] public static bool OnTournamentCourseComplete(LevelData levelData, LevelCompletionInfo info, ref Grade grade, ref ushort reward, ref bool shouldSave) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between I4 and Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((int)grade < (int)PluginMain.ArchipelagoHandler.SlotData.GradeCheckThreshold) { grade = (Grade)(-1); reward = 0; return true; } int value; bool flag = Data.TournamentLevelNameToId.TryGetValue(levelData.Name, out value); if (flag) { for (int i = 0; i < 3; i++) { if (flag && (int)info.TournyChallengeStates[i] == 1) { PluginMain.ArchipelagoHandler.CheckLocation(1280 + 4 * value + 1 + i); } } PluginMain.ArchipelagoHandler.CheckLocation(1280 + 4 * value); SaveDataHandler.ArchipelagoSaveData.TournamentCourseCompletions[value] = true; } reward = 0; return true; } } [HarmonyPatch(typeof(ProfileData))] public class Collectible_Patch { [HarmonyPatch("HasCollectibleBeenFound")] [HarmonyPrefix] public static void HasCollectibleBeenFound(ushort id) { string name = SystemHandler.Get().CurrentLevelData.Name; if (Data.LevelNameToId.TryGetValue(name, out var value)) { PluginMain.ArchipelagoHandler.CheckLocation(256 + 16 * value + 10); } SaveDataHandler.ArchipelagoSaveData.CollectiblesChecked[value] = true; } } [HarmonyPatch(typeof(MatchGameMode))] public class MatchGameMode_Patch { [HarmonyPatch("GoalCompleted")] [HarmonyPrefix] protected static void OnGoalCompleted(MatchGameMode __instance) { if (Data.LevelNameToId.TryGetValue(((GameMode)__instance).LevelData.Name, out var value)) { PluginMain.ArchipelagoHandler.CheckLocation(256 + 16 * value + 1 + ((GameMode)__instance).NumGoalsCleared); } } } [HarmonyPatch(typeof(DropoffWickertideGM))] public class ResetCartTracker { [HarmonyPatch("StartNextGoal")] [HarmonyPostfix] private static void Reset() { _wickertideCartCount = 0; } } [HarmonyPatch(typeof(PuzzlePackage))] public class PuzzlePackage_EndReached_Patch { [HarmonyPatch("EndReached")] [HarmonyPostfix] private static void EndReached_Postfix(PuzzlePackage __instance) { if (__instance is WickertideOctoCart) { LevelData currentLevelData = SystemHandler.Get().CurrentLevelData; if (Data.LevelNameToId.TryGetValue(currentLevelData.Name, out var value)) { PluginMain.ArchipelagoHandler.CheckLocation(256 + 16 * value + 1 + _wickertideCartCount); } _wickertideCartCount++; } } } private static int _wickertideCartCount; } public class LoginMenuHandler : MonoBehaviour { [HarmonyPatch(typeof(Menu))] public class Menu_Patch { [HarmonyPatch("Focus")] [HarmonyPrefix] public static bool Focus(Menu __instance, bool isFocused, GameObject control = null) { return !IsTyping; } } [HarmonyPatch(typeof(MessageWindow))] public class MessageWindow_Patch { [HarmonyPatch("Opened")] [HarmonyPostfix] public static void Opened_Postfix(MessageWindow __instance) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) if (!ArchipelagoHandler.IsConnected && !ArchipelagoHandler.IsConnecting) { Transform transform = ((Component)__instance.textDisplay).gameObject.transform; __instance.textDisplay.text = ""; ((Component)((Menu)__instance).canvas).GetComponentInChildren().text = "Archipelago"; ((Component)((DialogBox)__instance).loneYupButton).GetComponentInChildren().text = "Connect"; TextMeshProUGUI componentInChildren = ((Component)((Menu)__instance).canvas).GetComponentInChildren(); AddLabel(transform, "Server", new Vector3(-2.15f, 1.5f, 0f), (TMP_Text)(object)componentInChildren); AddLabel(transform, "Port", new Vector3(-2.38f, 0.75f, 0f), (TMP_Text)(object)componentInChildren); AddLabel(transform, "Slot", new Vector3(-2.45f, 0f, 0f), (TMP_Text)(object)componentInChildren); AddLabel(transform, "Password", new Vector3(-2f, -0.75f, 0f), (TMP_Text)(object)componentInChildren); TMP_InputField val = AddInputField(transform, "ServerInput", new Vector3(1f, 1.5f, 0f), (TMP_Text)(object)componentInChildren, delegate(string text) { _server = text; }); ((Menu)__instance).FirstSelected = ((Component)val).gameObject; EventSystem.current.SetSelectedGameObject(((Component)val).gameObject); val.text = _server; AddInputField(transform, "PortInput", new Vector3(1f, 0.75f, 0f), (TMP_Text)(object)componentInChildren, delegate(string text) { ushort.TryParse(text, out _port); }).text = _port.ToString(); AddInputField(transform, "SlotInput", new Vector3(1f, 0f, 0f), (TMP_Text)(object)componentInChildren, delegate(string text) { _slotName = text; }).text = _slotName; AddInputField(transform, "PasswordInput", new Vector3(1f, -0.75f, 0f), (TMP_Text)(object)componentInChildren, delegate(string text) { _password = text; }, isPassword: true).text = _password; } } private static void AddLabel(Transform reference, string label, Vector3 localPosition, TMP_Text template) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("AP " + label + " Label"); val.transform.SetParent(reference, false); TextMeshProUGUI val2 = val.AddComponent(); ((TMP_Text)val2).text = label; SetTextSettings(template, (TMP_Text)(object)val2); ((Transform)((Component)val2).GetComponent()).localPosition = localPosition; } private static TMP_InputField AddInputField(Transform parent, string name, Vector3 localPosition, TMP_Text template, Action onValueChanged, bool isPassword = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.AddComponent(); RectTransform obj = val.AddComponent(); obj.sizeDelta = new Vector2(4f, 0.5f); ((Transform)obj).localPosition = localPosition; Image val2 = val.AddComponent(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.4f); TMP_InputField val3 = val.AddComponent(); GameObject val4 = new GameObject("TextViewport", new Type[1] { typeof(RectTransform) }); val4.transform.SetParent(val.transform, false); RectTransform component = val4.GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; val3.textViewport = component; ((Selectable)val3).targetGraphic = (Graphic)(object)val2; ((UnityEvent)(object)val3.onSelect).AddListener((UnityAction)delegate { IsTyping = true; }); ((UnityEvent)(object)val3.onDeselect).AddListener((UnityAction)delegate { IsTyping = false; }); GameObject val5 = new GameObject("Text"); val5.transform.SetParent(val4.transform, false); TextMeshProUGUI val6 = val5.AddComponent(); SetTextSettings(template, (TMP_Text)(object)val6); ((TMP_Text)val6).enableWordWrapping = false; ((TMP_Text)val6).alignment = (TextAlignmentOptions)4097; RectTransform component2 = ((Component)val6).GetComponent(); component2.anchorMin = new Vector2(0.025f, 0f); component2.anchorMax = new Vector2(0.975f, 1f); component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; val3.textComponent = (TMP_Text)(object)val6; if (isPassword) { val3.inputType = (InputType)2; val3.contentType = (ContentType)7; } else { val3.contentType = (ContentType)0; } ((UnityEvent)(object)val3.onValueChanged).AddListener((UnityAction)onValueChanged.Invoke); return val3; } private static void SetTextSettings(TMP_Text template, TMP_Text text) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0058: Expected O, but got Unknown text.font = template.font; text.fontSize = 0.35f; ((Graphic)text).color = ((Graphic)template).color; text.alignment = template.alignment; text.enableWordWrapping = template.enableWordWrapping; text.margin = template.margin; text.fontMaterial = new Material(template.fontMaterial); } [HarmonyPatch("OnYupSelected")] [HarmonyPrefix] public static bool Yup_Prefix(MessageWindow __instance) { MessageWindow __instance2 = __instance; if (ArchipelagoHandler.IsConnected) { return true; } ArchipelagoHandler.OnConnect = (Action)Delegate.Combine(ArchipelagoHandler.OnConnect, (Action)delegate { ((Menu)__instance2).CloseAnimationStart(); }); Connect(); return false; } } [HarmonyPatch(typeof(StartScreen))] public class StartScreen_Patch { [HarmonyPatch(typeof(StartScreen), "Opened")] [HarmonyPostfix] private static void Postfix(StartScreen __instance) { if (!ArchipelagoHandler.IsConnected && !ArchipelagoHandler.IsConnecting) { MessageWindow val = Resources.FindObjectsOfTypeAll().FirstOrDefault(); messageWindow = SystemHandler.Get().OpenMenu(val, (Action)delegate { }, false, (Menu)null); } } [HarmonyPatch("GetInput")] [HarmonyPrefix] private static bool OnGetInput() { return false; } } private static MessageWindow messageWindow; private static string _password = ""; private static ushort _port; private static string _server = "archipelago.gg"; private static bool _showLogin; private static string _slotName = ""; private static string _status = ""; public static bool IsTyping; private GameObject _introClipboard; private Rect _windowRect = new Rect(100f, 100f, 600f, 500f); private void Start() { ((MonoBehaviour)this).StartCoroutine(CheckProfileSelect()); ConnectionInfoHandler.Load(ref _server, ref _port, ref _slotName, ref _password); } private IEnumerator CheckProfileSelect() { while (true) { yield return (object)new WaitForSeconds(0.5f); _introClipboard = GameObject.Find("/Director/Attract/Clipboard"); if ((Object)(object)_introClipboard == (Object)null || _showLogin) { yield return null; } _showLogin = true; Object.Destroy((Object)(object)_introClipboard); } } private static void Connect() { ConnectionInfoHandler.Save(_server, _port, _slotName, _password); PluginMain.ArchipelagoHandler = new ArchipelagoHandler(_server, _port, _slotName, _password); PluginMain.ArchipelagoHandler.InitConnect(); _status = "Connecting..."; } } [BepInPlugin("keywe_ap_client", "KeyWe_AP_Client", "1.1.0")] public class PluginMain : BaseUnityPlugin { public const string GameName = "KeyWe"; private const string Version = "1.1.0"; public static ConfigEntry? EnableDebugLogging; public static ConfigEntry? FilterLog; public static ConfigEntry? MessageInTime; public static ConfigEntry? MessageHoldTime; public static ConfigEntry? MessageOutTime; public static LoginMenuHandler LoginHandler; public static SaveDataHandler SaveDataHandler; public static ArchipelagoHandler ArchipelagoHandler; public static ItemHandler ItemHandler; public static LocationHandler LocationHandler; public static GameHandler GameHandler; private readonly Harmony _harmony = new Harmony("keywe_ap_client"); private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0044: 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) //IL_0059: Expected O, but got Unknown _harmony.PatchAll(); GameObject val = new GameObject("ArchipelagoLoginHandler"); LoginHandler = val.AddComponent(); Object.DontDestroyOnLoad((Object)val); GameObject val2 = new GameObject("ArchipelagoSaveDataHandler"); SaveDataHandler = val2.AddComponent(); Object.DontDestroyOnLoad((Object)val2); GameObject val3 = new GameObject("ArchipelagoGameHandler"); GameHandler = val3.AddComponent(); Object.DontDestroyOnLoad((Object)val3); ItemHandler = new ItemHandler(); LocationHandler = new LocationHandler(); APConsole.Instance.Log("Welcome to KeyWe Archipelago!"); EnableDebugLogging = ((BaseUnityPlugin)this).Config.Bind("Logging", "EnableDebugLogging", false, "Enables or disables debug logging in the Archipelago Console."); FilterLog = ((BaseUnityPlugin)this).Config.Bind("Logging", "FilterLog", false, "Filter the archipelago log to only show messages relevant to you."); MessageInTime = ((BaseUnityPlugin)this).Config.Bind("Logging", "MessageInTime", 0.25f, "How long messages take to animate in."); MessageHoldTime = ((BaseUnityPlugin)this).Config.Bind("Logging", "MessageHoldTime", 3f, "How long messages stay in the log before animating out."); MessageOutTime = ((BaseUnityPlugin)this).Config.Bind("Logging", "MessageOutTime", 0.5f, "How long messages stay in the log before animating out."); } private void Start() { Cursor.visible = true; ((Behaviour)ControllerVibrationHandler.Instance).enabled = false; } } public class CustomSaveData { public int ItemIndex = 1; public float WalkSpeed = 10f; public float DashForce = 20f; public float SwimSpeed = 5f; public float JumpHeight = 22f; public float RespawnFallMoveSpeed = 5f; public float RespawnFallSpeed = 4f; public float ChirpCooldown = 0.6f; public float PeckCooldown = 0.6f; public float DashCooldown = 0.6f; public Dictionary WeeksUnlocked { get; set; } = new Dictionary { { 0, false }, { 1, false }, { 2, false }, { 3, false }, { 4, false }, { 5, false }, { 6, false }, { 7, false }, { 8, false } }; public bool OvertimeSummerUnlocked { get; set; } public bool OvertimeFallUnlocked { get; set; } public bool OvertimeWinterUnlocked { get; set; } public bool TournamentUnlocked { get; set; } public Dictionary Collectibles { get; set; } = new Dictionary { { 0, false }, { 1, false }, { 2, false }, { 3, false }, { 4, false }, { 5, false }, { 6, false }, { 7, false }, { 8, false }, { 9, false }, { 10, false }, { 11, false }, { 12, false }, { 13, false }, { 14, false } }; public Dictionary LevelCompletions { get; set; } = new Dictionary { { 0, false }, { 1, false }, { 2, false }, { 3, false }, { 4, false }, { 5, false }, { 6, false }, { 7, false }, { 8, false }, { 9, false }, { 10, false }, { 11, false }, { 12, false }, { 13, false }, { 14, false }, { 15, false }, { 16, false }, { 17, false }, { 18, false }, { 19, false }, { 20, false }, { 21, false }, { 22, false }, { 23, false }, { 24, false }, { 25, false }, { 26, false }, { 27, false }, { 28, false }, { 29, false }, { 30, false }, { 31, false }, { 32, false }, { 33, false }, { 34, false }, { 35, false } }; public Dictionary OvertimeLevelCompletions { get; set; } = new Dictionary { { 0, false }, { 1, false }, { 2, false }, { 3, false }, { 4, false }, { 5, false }, { 6, false }, { 7, false }, { 8, false } }; public Dictionary TournamentCourseCompletions { get; set; } = new Dictionary { { 0, false }, { 1, false }, { 2, false } }; public Dictionary CollectiblesChecked { get; set; } = new Dictionary { { 0, false }, { 1, false }, { 2, false }, { 3, false }, { 4, false }, { 5, false }, { 6, false }, { 7, false }, { 8, false }, { 9, false }, { 10, false }, { 11, false }, { 12, false }, { 13, false }, { 14, false } }; } public class SaveDataHandler : MonoBehaviour { [HarmonyPatch(typeof(SaveSystem))] private class DataRootPatch { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static bool OnGetDataRoot(ref string __result) { string text = Path.Combine(Directory.GetParent(Application.dataPath).FullName, "ArchipelagoSaves/"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } __result = text; return false; } [HarmonyPatch("LoadProfile")] [HarmonyPrefix] public static bool LoadProfile(ref ProfileData __result, int index) { ProfileData val = null; string path = SaveSystem.DataRoot + "APProfile" + _seed + _slot + ".kiwi"; if (File.Exists(path)) { ArchipelagoSaveData = JsonConvert.DeserializeObject(File.ReadAllText(SaveSystem.DataRoot + "APSave" + _seed + _slot + ".json")); try { using BinaryReader binaryReader = new BinaryReader(File.Open(path, FileMode.Open)); val = JsonUtility.FromJson(StringEncryption.Decrypt(binaryReader.ReadString(), "TallKikiIsCursed_967f2d41-a0a0-42fa-a7ed-79b2c5977569")); } catch (Exception arg) { Debug.LogError((object)$"[KEYWE][SaveSystem] LoadData - Exception thrown while loading data:\n{arg}"); } } __result = val; return false; } [HarmonyPatch("SaveProfile")] [HarmonyPrefix] public static bool SaveProfile(ProfileData profile, string profileName = "Profile") { string contents = JsonConvert.SerializeObject((object)ArchipelagoSaveData); File.WriteAllText(SaveSystem.DataRoot + "APSave" + _seed + _slot + ".json", contents); SaveSystem.TryCreateFolderDemo(); string path = SaveSystem.DataRoot + "APProfile" + _seed + _slot + ".kiwi"; if (profile == null) { return false; } try { using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(path, FileMode.Create))) { string value = StringEncryption.Encrypt(JsonUtility.ToJson((object)profile), "TallKikiIsCursed_967f2d41-a0a0-42fa-a7ed-79b2c5977569"); binaryWriter.Write(value); } SaveSystem.BackupSave(profile); } catch (Exception ex) { Debug.LogError((object)ex.Message); } return false; } } private static DataKeeper dataKeeper; private static string _seed; private static string _slot; public static CustomSaveData ArchipelagoSaveData; private void Start() { dataKeeper = SystemHandler.Get(); } public void LoadProfile(string seed, string slot) { _seed = seed; _slot = slot; ushort num = (ushort)(ulong.Parse(seed.Substring(1, 15)) % 65535); ((SystemBase)dataKeeper).Initialize(); ProfileData val = dataKeeper.LoadProfile((int)num); if (val == null) { ArchipelagoSaveData = new CustomSaveData(); val = dataKeeper.CreateProfile(num, SystemHandler.Get().GetNewPlaythroughID()); val.MarkProgress((ProgressFlag)1); val.MarkProgress((ProgressFlag)64); val.MarkProgress((ProgressFlag)512); val.MarkProgress((ProgressFlag)4); val.MarkProgress((ProgressFlag)2); val.MarkProgress((ProgressFlag)2048); val.MarkProgress((ProgressFlag)32); val.MarkProgress((ProgressFlag)4096); val.MarkProgress((ProgressFlag)1024); val.MarkProgress((ProgressFlag)16); val.MarkProgress((ProgressFlag)8); val.CurrentLevelIndex = 35; } dataKeeper.SaveProfile(val); dataKeeper.HasSelectedSaveProfile = true; dataKeeper.SelectProfile(val); ((OvermapMenuOption)Object.FindObjectOfType()).RefreshScene(); } public void UnlockWeek(int weekIndex) { ArchipelagoSaveData.WeeksUnlocked[weekIndex] = true; } } public class ShopHandler { [HarmonyPatch(typeof(Wardrobe))] public class Wardrobe_Patch { [HarmonyPatch("ShowDisplayHalves")] [HarmonyPostfix] public static void OnShowDisplayHalves(Wardrobe __instance) { KeyWeExtensions.SetActive((MonoBehaviour)(object)__instance.itemDisplays[1], false); } } [HarmonyPatch(typeof(PlayerItemDisplay))] public class PlayerItemDisplay_Patch { public static void AddCategory(PlayerItemDisplay __instance, string categoryName, Categories category, int index) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) MethodInfo methodInfo = AccessTools.Method(typeof(CategoryDisplay), "add_OnSelected", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CategoryDisplay), "add_OnHighlighted", (Type[])null, (Type[])null); CategoryDisplay val = Object.Instantiate(__instance.categoryDisplayPrefab, __instance.categoryParent); __instance.categories[index] = val; val.Init(categoryName, category); Delegate @delegate = Delegate.CreateDelegate(methodInfo.GetParameters()[0].ParameterType, __instance, "Category_OnSelected"); Delegate delegate2 = Delegate.CreateDelegate(methodInfo2.GetParameters()[0].ParameterType, __instance, "Category_OnHighlighted"); methodInfo.Invoke(val, new object[1] { @delegate }); methodInfo2.Invoke(val, new object[1] { delegate2 }); } [HarmonyPatch("PopulateCategoryUI")] [HarmonyPrefix] public static bool OnPopulateCategoryUI(PlayerItemDisplay __instance) { __instance.categories = (CategoryDisplay[])(object)new CategoryDisplay[2]; AddCategory(__instance, "Stamp Shop", (Categories)2, 0); AddCategory(__instance, "Coin Shop", (Categories)0, 1); return false; } } [HarmonyPatch(typeof(CategoryDisplay))] public class CategoryDisplay_Patch { [HarmonyPatch("Init")] [HarmonyPrefix] public static bool Init(CategoryDisplay __instance, string text, Categories category) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if ((int)category != 2 && (int)category != 0) { KeyWeExtensions.SetActive((MonoBehaviour)(object)__instance, false); return false; } __instance.CategoryName = (((int)category == 0) ? "Coin Shop" : "Stamp Shop"); __instance.Category = (Categories)(-1); ((TMP_Text)__instance.textMesh).text = __instance.CategoryName; return false; } } } public class SlotData { public readonly int RequiredCollectibleChecks; public readonly int RequiredCollectibles; public readonly int RequiredLevelCompletions; public readonly int RequiredLevelCompletionsPerWeek; public readonly int RequiredOvertimeCompletions; public readonly int RequiredTournamentCompletions; public readonly bool TournamentIncluded; public readonly bool OvertimeIncluded; public bool DeathLink; public Grade GradeCheckThreshold; public SlotData(Dictionary slotDict) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair item in slotDict) { Console.WriteLine($"{item.Key} {item.Value}"); } TournamentIncluded = (long)slotDict["TournamentIncluded"] == 1; OvertimeIncluded = (long)slotDict["TournamentIncluded"] == 1; RequiredLevelCompletions = (int)(long)slotDict["RequiredLevelCompletions"]; RequiredLevelCompletionsPerWeek = (int)(long)slotDict["RequiredLevelCompletionsPerWeek"]; RequiredCollectibles = (int)(long)slotDict["RequiredCollectibles"]; RequiredCollectibleChecks = (int)(long)slotDict["RequiredCollectibleChecks"]; RequiredOvertimeCompletions = (int)(long)slotDict["RequiredOvertimeCompletions"]; RequiredTournamentCompletions = (int)(long)slotDict["RequiredTournamentCompletions"]; int num = (int)(long)slotDict["StartingWeek"]; GradeCheckThreshold = (Grade)((int)(long)slotDict["LevelCompletionCheckThreshold"] switch { 1 => 0, 2 => 1, 3 => 2, _ => GradeCheckThreshold, }); DeathLink = (long)slotDict["DeathLink"] == 1; if (DeathLink) { PluginMain.ArchipelagoHandler.UpdateTags(new List(1) { "DeathLink" }); } SaveDataHandler.ArchipelagoSaveData.WeeksUnlocked[num - 1] = true; if (!SystemHandler.Get().Profile.CheckProgress((ProgressFlag)8192) && TournamentIncluded) { APConsole.Instance.Log("Warning: You do not own the Telepost Tournament DLC but have its checks enabled."); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }