using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; 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.Threading.Tasks; using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ContentWarningArchipelago.Core; using ContentWarningArchipelago.Data; using ContentWarningArchipelago.Patches; using ContentWarningArchipelago.UI; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using MyceliumNetworking; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using Zorro.Core; using pworld.Scripts.Extensions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ContentWarningArchipelago")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Archipelago Randomizer for Content Warning")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+7a8fe43c6a672dcf7da9254c9a58671e13d29218")] [assembly: AssemblyProduct("Content Warning Archipelago")] [assembly: AssemblyTitle("ContentWarningArchipelago")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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; } } } namespace ContentWarningArchipelago { [BepInPlugin("automagic.cw-archipelago", "Content Warning Archipelago", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; public static ArchipelagoClient connection; internal const uint MyceliumModId = 2718281828u; public static APConfig APConfig { get; private set; } public static string apAddress => APConfig?.address.Value ?? "archipelago.gg"; public static int apPort => APConfig?.port.Value ?? 38281; public static string apPassword => APConfig?.password.Value ?? ""; public static string apSlot => APConfig?.slot.Value ?? ""; public static Plugin Instance { get; private set; } public static bool isConnecting { get; private set; } private void Awake() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"[CWArch] automagic.cw-archipelago v0.1.0 loading…"); APConfig = new APConfig(((BaseUnityPlugin)this).Config); Logger.LogInfo((object)$"[CWArch] Config loaded. AP address: {apAddress}:{APConfig.port.Value}"); ItemData.Init(); LocationData.Init(); new Harmony("automagic.cw-archipelago").PatchAll(); MyceliumNetwork.RegisterNetworkObject((object)this, 2718281828u, 0); Logger.LogInfo((object)"[CWArch] Harmony patches applied."); } private void Start() { connection = new ArchipelagoClient(); Logger.LogInfo((object)"[CWArch] ArchipelagoClient created. Waiting for connection."); } private void OnDestroy() { MyceliumNetwork.DeregisterNetworkObject((object)this, 2718281828u, 0); } private void Update() { if (connection.connected) { connection.checkItemsReceived?.MoveNext(); connection.incomingItemHandler?.MoveNext(); connection.outgoingCheckHandler?.MoveNext(); } } [CustomRPC] internal void LocationFound(string locName, RPCInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (info.SenderSteamID != SteamUser.GetSteamID()) { Logger.LogDebug((object)("[CWArch] Received remote location-found notification: '" + locName + "'")); APNotificationUI.ShowLocationFound(locName); } } public static async void Connect() { if (isConnecting || connection.connected) { return; } isConnecting = true; try { await connection.TryConnect(apAddress, apPort, apPassword, apSlot); } finally { isConnecting = false; } } public static void Disconnect() { connection.TryDisconnect(); } public static void SendCheck(long locationId) { connection.ActivateCheck(locationId); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "automagic.cw-archipelago"; public const string PLUGIN_NAME = "Content Warning Archipelago"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace ContentWarningArchipelago.UI { public class APConnectionPanelUI : MonoBehaviour { private TMP_InputField _addressField; private TMP_InputField _slotField; private TMP_InputField _passwordField; private Button _connectButton; private Button _disconnectButton; private TextMeshProUGUI _statusLabel; private static readonly Color ColDisconnected = new Color(0.9f, 0.22f, 0.22f); private static readonly Color ColConnecting = new Color(1f, 0.85f, 0.1f); private static readonly Color ColConnected = new Color(0.2f, 0.88f, 0.2f); private void Awake() { BuildUI(); PopulateFromConfig(); } private void Update() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (_statusLabel != null) { if (Plugin.isConnecting) { ((TMP_Text)_statusLabel).text = "○ Connecting…"; ((Graphic)_statusLabel).color = ColConnecting; } else if (Plugin.connection != null && Plugin.connection.connected) { ((TMP_Text)_statusLabel).text = "● Connected!"; ((Graphic)_statusLabel).color = ColConnected; } else { ((TMP_Text)_statusLabel).text = "● Disconnected"; ((Graphic)_statusLabel).color = ColDisconnected; } } } public void PopulateFromConfig() { if (Plugin.APConfig != null) { if (_addressField != null) { _addressField.text = $"{Plugin.APConfig.address.Value}:{Plugin.APConfig.port.Value}"; } if (_slotField != null) { _slotField.text = Plugin.APConfig.slot.Value; } if (_passwordField != null) { _passwordField.text = Plugin.APConfig.password.Value; } } } private void OnAddressChanged(string value) { if (Plugin.APConfig == null) { return; } int num = value.LastIndexOf(':'); if (num > 0 && num < value.Length - 1) { string value2 = value.Substring(0, num); string s = value.Substring(num + 1); Plugin.APConfig.address.Value = value2; if (int.TryParse(s, out var result) && result > 0 && result <= 65535) { Plugin.APConfig.port.Value = result; } } else if (num < 0) { Plugin.APConfig.address.Value = value.Trim(); } Plugin.Logger.LogDebug((object)$"[APPanel] Address updated: {Plugin.APConfig.address.Value}:{Plugin.APConfig.port.Value}"); } private void OnSlotChanged(string value) { if (Plugin.APConfig != null) { Plugin.APConfig.slot.Value = value; Plugin.Logger.LogDebug((object)("[APPanel] Slot updated: " + value)); } } private void OnPasswordChanged(string value) { if (Plugin.APConfig != null) { Plugin.APConfig.password.Value = value; Plugin.Logger.LogDebug((object)"[APPanel] Password updated."); } } private void OnConnectClicked() { if (!Plugin.isConnecting) { ArchipelagoClient connection = Plugin.connection; if (connection == null || !connection.connected) { Plugin.Logger.LogInfo((object)"[APPanel] Connect button clicked."); Plugin.Connect(); } } } private void OnDisconnectClicked() { Plugin.Logger.LogInfo((object)"[APPanel] Disconnect button clicked."); Plugin.Disconnect(); } private void BuildUI() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (((Component)this).gameObject.GetComponent() == null) { ((Component)this).gameObject.AddComponent(); } ContentSizeFitter obj = ((Component)this).gameObject.AddComponent(); obj.verticalFit = (FitMode)2; obj.horizontalFit = (FitMode)0; VerticalLayoutGroup obj2 = ((Component)this).gameObject.AddComponent(); ((LayoutGroup)obj2).padding = new RectOffset(10, 10, 8, 8); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 5f; ((LayoutGroup)obj2).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((Graphic)((Component)this).gameObject.AddComponent()).color = new Color(0.05f, 0.05f, 0.05f, 0.72f); CreateLabel(((Component)this).transform, "── Archipelago Connection ──", 16f, (FontStyles)1, (TextAlignmentOptions)514, 26f, new Color(1f, 0.92f, 0.016f)); _addressField = CreateLabeledField(((Component)this).transform, "Address : Port", $"{Plugin.apAddress}:{Plugin.apPort}", isPassword: false); _slotField = CreateLabeledField(((Component)this).transform, "Slot Name", Plugin.apSlot, isPassword: false); _passwordField = CreateLabeledField(((Component)this).transform, "Password", Plugin.apPassword, isPassword: true); ((UnityEvent)(object)_addressField.onEndEdit).AddListener((UnityAction)OnAddressChanged); ((UnityEvent)(object)_slotField.onEndEdit).AddListener((UnityAction)OnSlotChanged); ((UnityEvent)(object)_passwordField.onEndEdit).AddListener((UnityAction)OnPasswordChanged); CreateButtonRow(((Component)this).transform); } private static TMP_InputField CreateLabeledField(Transform parent, string labelText, string initialValue, bool isPassword) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("APRow_" + labelText); val.transform.SetParent(parent, false); val.AddComponent().preferredHeight = 28f; HorizontalLayoutGroup obj = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 6f; ((LayoutGroup)obj).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; GameObject val2 = new GameObject("Label"); val2.transform.SetParent(val.transform, false); LayoutElement obj2 = val2.AddComponent(); obj2.preferredWidth = 110f; obj2.preferredHeight = 28f; TextMeshProUGUI obj3 = val2.AddComponent(); ((TMP_Text)obj3).text = labelText; ((TMP_Text)obj3).fontSize = 13f; ((TMP_Text)obj3).alignment = (TextAlignmentOptions)4100; ((Graphic)obj3).color = new Color(0.85f, 0.85f, 0.85f); TMP_InputField val3 = CreateInputField(val.transform, labelText, isPassword); LayoutElement obj4 = ((Component)val3).gameObject.GetComponent() ?? ((Component)val3).gameObject.AddComponent(); obj4.flexibleWidth = 1f; obj4.preferredHeight = 28f; val3.text = initialValue; return val3; } private void CreateButtonRow(Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("APButtonRow"); val.transform.SetParent(parent, false); val.AddComponent().preferredHeight = 32f; HorizontalLayoutGroup obj = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((LayoutGroup)obj).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; _connectButton = CreateButton(val.transform, "Connect", new Color(0.16f, 0.56f, 0.16f), 88f); _disconnectButton = CreateButton(val.transform, "Disconnect", new Color(0.5f, 0.13f, 0.13f), 100f); ((UnityEvent)_connectButton.onClick).AddListener(new UnityAction(OnConnectClicked)); ((UnityEvent)_disconnectButton.onClick).AddListener(new UnityAction(OnDisconnectClicked)); GameObject val2 = new GameObject("StatusLabel"); val2.transform.SetParent(val.transform, false); LayoutElement obj2 = val2.AddComponent(); obj2.flexibleWidth = 1f; obj2.preferredHeight = 32f; _statusLabel = val2.AddComponent(); ((TMP_Text)_statusLabel).fontSize = 13f; ((TMP_Text)_statusLabel).alignment = (TextAlignmentOptions)4097; ((TMP_Text)_statusLabel).text = "● Disconnected"; ((Graphic)_statusLabel).color = ColDisconnected; } private static TextMeshProUGUI CreateLabel(Transform parent, string text, float fontSize, FontStyles style, TextAlignmentOptions alignment, float height, Color color = default(Color)) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0059: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("APLabel"); val.transform.SetParent(parent, false); val.AddComponent().preferredHeight = height; TextMeshProUGUI obj = val.AddComponent(); ((TMP_Text)obj).text = text; ((TMP_Text)obj).fontSize = fontSize; ((TMP_Text)obj).fontStyle = style; ((TMP_Text)obj).alignment = alignment; ((Graphic)obj).color = ((color == default(Color)) ? Color.white : color); return obj; } private static TMP_InputField CreateInputField(Transform parent, string placeholder, bool isPassword) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0039: 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_0055: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("InputField"); val.transform.SetParent(parent, false); val.AddComponent(); ((Graphic)val.AddComponent()).color = new Color(0.12f, 0.12f, 0.12f, 0.95f); TMP_InputField val2 = val.AddComponent(); GameObject val3 = new GameObject("Text Area"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = new Vector2(5f, 2f); val4.offsetMax = new Vector2(-5f, -2f); val3.AddComponent(); GameObject val5 = new GameObject("Placeholder"); val5.transform.SetParent(val3.transform, false); RectTransform obj = val5.AddComponent(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; TextMeshProUGUI val6 = val5.AddComponent(); ((TMP_Text)val6).text = placeholder; ((TMP_Text)val6).fontSize = 13f; ((Graphic)val6).color = new Color(0.65f, 0.65f, 0.65f, 0.65f); ((TMP_Text)val6).alignment = (TextAlignmentOptions)4097; ((TMP_Text)val6).fontStyle = (FontStyles)2; ((Graphic)val6).raycastTarget = false; GameObject val7 = new GameObject("Text"); val7.transform.SetParent(val3.transform, false); RectTransform obj2 = val7.AddComponent(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; TextMeshProUGUI val8 = val7.AddComponent(); ((TMP_Text)val8).fontSize = 13f; ((Graphic)val8).color = Color.white; ((TMP_Text)val8).alignment = (TextAlignmentOptions)4097; ((Graphic)val8).raycastTarget = false; val2.textViewport = val4; val2.textComponent = (TMP_Text)(object)val8; val2.placeholder = (Graphic)(object)val6; if (isPassword) { val2.contentType = (ContentType)7; val2.inputType = (InputType)2; } else { val2.contentType = (ContentType)0; } return val2; } private static Button CreateButton(Transform parent, string label, Color bgColor, float width) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Btn_" + label); val.transform.SetParent(parent, false); LayoutElement obj = val.AddComponent(); obj.preferredWidth = width; obj.preferredHeight = 28f; Image val2 = val.AddComponent(); ((Graphic)val2).color = bgColor; Button obj2 = val.AddComponent