using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Net; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FastLink.Patches; using FastLink.Util; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("089A0531-9441-424D-B144-98C1CE1D4D41")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyProduct("FastLink")] [assembly: AssemblyCompany("Azumatt")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("FastLink")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.4.0")] [assembly: AssemblyConfiguration("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<3395c894-664d-46cb-b899-145d639f8252>Embedded] internal sealed class <3395c894-664d-46cb-b899-145d639f8252>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<3395c894-664d-46cb-b899-145d639f8252>Embedded] internal sealed class <1bcddceb-3426-47e6-a5fc-cf8b5266c913>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <1bcddceb-3426-47e6-a5fc-cf8b5266c913>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <1bcddceb-3426-47e6-a5fc-cf8b5266c913>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<3395c894-664d-46cb-b899-145d639f8252>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContextAttribute : Attribute { public readonly byte Flag; public <92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace FastLink { [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(0)] public class Definition { public string serverName; public ushort port { get; set; } public string address { get; set; } public bool ispvp { get; set; } public bool iscrossplay { get; set; } public string password { get; set; } = ""; public bool iswhitelisted { get; set; } public static IEnumerable Parse(string yaml) { return new DeserializerBuilder().IgnoreFields().Build().Deserialize>(yaml) .Select([<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (KeyValuePair kv) => { Definition value = kv.Value; value.serverName = kv.Key; return value; }); } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(256); stringBuilder.Append(Environment.NewLine); if (FastLinkPlugin.HideIP.Value == FastLinkPlugin.Toggle.On) { stringBuilder.Append("Address: Hidden In Configs"); stringBuilder.Append(Environment.NewLine); stringBuilder.Append("Port: Hidden In Configs"); } else { stringBuilder.Append("Address: " + address); stringBuilder.Append(Environment.NewLine); stringBuilder.Append($"Port: {port}"); } stringBuilder.Append(Environment.NewLine); stringBuilder.Append($"PvP: {ispvp}"); stringBuilder.Append(Environment.NewLine); stringBuilder.Append($"Crossplay Enabled: {iscrossplay}"); if (FastLinkPlugin.ShowPasswordInTooltip.Value == FastLinkPlugin.Toggle.On) { stringBuilder.Append(Environment.NewLine); stringBuilder.Append("Password: " + password); } stringBuilder.Append(Environment.NewLine); stringBuilder.Append($"Uses Whitelisted Player List: {iswhitelisted}"); return stringBuilder.ToString(); } } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(0)] [BepInPlugin("Azumatt.FastLink", "FastLink", "1.4.0")] public class FastLinkPlugin : BaseUnityPlugin { [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] public enum Toggle { Off, On } [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(0)] internal sealed class ConfigurationManagerAttributes { public Action CustomDrawer; public bool? HideDefaultButton; public bool? HideSettingName; public string Description = ""; } internal const string ModName = "FastLink"; internal const string ModVersion = "1.4.0"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.FastLink"; private static string ConfigFileName = "Azumatt.FastLink.cfg"; private static string ConfigFileFullPath; internal static FastLinkPlugin instance; internal readonly Harmony _harmony = new Harmony("Azumatt.FastLink"); public static readonly ManualLogSource FastLinkLogger; public static ConfigEntry UIAnchor; public static ConfigEntry MerchUIAnchor; public static ConfigEntry LocalScale; public static ConfigEntry Sort; public static ConfigEntry HideIP; public static ConfigEntry ShowPasswordPrompt; public static ConfigEntry ShowPasswordInTooltip; private const int WindowId = -70; internal static Rect ScreenRect; internal static string EditorText; internal static Vector2 SettingWindowScrollPos; internal static bool RichTextOn; private Rect ContentWindowRect { get; set; } private void Awake() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown instance = this; ((BaseUnityPlugin)this).Config.Bind("General", "FastLink URL", "https://valheim.thunderstore.io/package/Azumatt/FastLink/", new ConfigDescription("Link to the mod page", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { HideSettingName = true, HideDefaultButton = true, Description = "Edit the " + Servers.ConfigFileName + " directly from the configuration manager.", CustomDrawer = Functions.EditServersButton } })); Sort = ((BaseUnityPlugin)this).Config.Bind("General", "Sort List Alphabetically", Toggle.On, new ConfigDescription("Sorts the Server List Alphabetically. If disabled, the list will be displayed in the same order as the file. NOTE: If you are using colors in your server name, if on, it will still sort but the color you use will have an affect on on the order.", (AcceptableValueBase)null, Array.Empty())); Sort.SettingChanged += [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (object _, EventArgs _) => { ReadNewServers(null, null); }; HideIP = ((BaseUnityPlugin)this).Config.Bind("General", "Hide the IP in the panel", Toggle.Off, new ConfigDescription("Turn on to hide the IP in the connection panel at the main menu. Also hides it in the tooltip", (AcceptableValueBase)null, Array.Empty())); HideIP.SettingChanged += [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (object _, EventArgs _) => { ReadNewServers(null, null); }; UIAnchor = ((BaseUnityPlugin)this).Config.Bind("UI", "Position of the UI", new Vector2(429f, 172f), new ConfigDescription("Sets the anchor position of the UI. You can drag it by left clicking on the title and dragging. Manual setting here is also available.", (AcceptableValueBase)null, Array.Empty())); UIAnchor.SettingChanged += SaveAndReset; MerchUIAnchor = ((BaseUnityPlugin)this).Config.Bind("UI", "Position of the Merch UI", new Vector2(-121f, -89f), new ConfigDescription("Sets the anchor position of the Merch UI. You can drag it by left clicking on the title and dragging. Manual setting here is also available. Vanilla is -200, -155", (AcceptableValueBase)null, Array.Empty())); MerchUIAnchor.SettingChanged += SaveAndReset; LocalScale = ((BaseUnityPlugin)this).Config.Bind("UI", "LocalScale of the UI", new Vector3(1f, 1f, 1f), new ConfigDescription("Sets the local scale the UI. This is overall size of the UI. Defaults to vanilla JoinGame UI size. I prefer 0.85, 0.85, 0.85", (AcceptableValueBase)null, Array.Empty())); LocalScale.SettingChanged += SaveAndReset; ShowPasswordPrompt = ((BaseUnityPlugin)this).Config.Bind("General", "Show Password Prompt", Toggle.Off, new ConfigDescription("Set to true if you want to still show the password prompt to the user. This is for servers that have a password but don't wish to use the file to keep the password.", (AcceptableValueBase)null, Array.Empty())); ShowPasswordInTooltip = ((BaseUnityPlugin)this).Config.Bind("General", "Show Password In Tooltip", Toggle.Off, new ConfigDescription("Set to true if you want to show the password inside the tooltip hover.", (AcceptableValueBase)null, Array.Empty())); ShowPasswordInTooltip.SettingChanged += [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (object _, EventArgs _) => { ReadNewServers(null, null); }; LoadTooltipAsset("fastlink"); _harmony.PatchAll(); SetupWatcher(); } private void Start() { Game.isModded = true; } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; FileSystemWatcher fileSystemWatcher2 = new FileSystemWatcher(Paths.ConfigPath, Servers.ConfigFileName); fileSystemWatcher2.Changed += ReadNewServers; fileSystemWatcher2.Created += ReadNewServers; fileSystemWatcher2.Renamed += ReadNewServers; fileSystemWatcher2.IncludeSubdirectories = true; fileSystemWatcher2.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher2.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { FastLinkLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { FastLinkLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); FastLinkLogger.LogError((object)"Please check your config entries for spelling and format!"); } } private void ReadNewServers(object sender, FileSystemEventArgs e) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(Servers.ConfigPath)) { return; } try { FastLinkLogger.LogDebug((object)"Reloading Server List"); SetupGui.Connecting = null; foreach (GameObject mServerListElement in SetupGui.MServerListElements) { Object.Destroy((Object)(object)mServerListElement); } SetupGui.MServerListElements.Clear(); Servers.Init(); Functions.AbortConnect(); Functions.PopulateServerList(SetupGui.Fastlink); Functions.UpdateServerList(); SetupGui.MJoinServer = null; } catch { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main")) { return; } } FastLinkLogger.LogError((object)("There was an issue loading your " + Servers.ConfigFileName)); FastLinkLogger.LogError((object)"Please check your config entries for spelling and format!"); } } private void SaveAndReset(object sender, EventArgs e) { //IL_001a: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) ((BaseUnityPlugin)this).Config.Save(); SetupGui.FastlinkRootGo.GetComponent().anchoredPosition = new Vector2(UIAnchor.Value.x, UIAnchor.Value.y); SetupGui.MerchRootGo.GetComponent().anchoredPosition = new Vector2(MerchUIAnchor.Value.x, MerchUIAnchor.Value.y); SetupGui.Fastlink.gameObject.transform.localScale = LocalScale.Value; } private void LoadTooltipAsset(string bundleName) { AssetBundle assetBundleFromResources = GetAssetBundleFromResources(bundleName); SetupGui.FastlinkTooltip = assetBundleFromResources.LoadAsset("FastLinkTooltip"); if (assetBundleFromResources != null) { assetBundleFromResources.Unload(false); } } private static AssetBundle GetAssetBundleFromResources(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single([<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (string str) => str.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } private void Update() { Functions.ShouldShowCursor(); } private void LateUpdate() { Functions.ShouldShowCursor(); } private void OnGUI() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (EditorText.Length > 0) { Functions.ShouldShowCursor(); int num = Mathf.Min(Screen.width, 1000); int num2 = ((Screen.height < 560) ? Screen.height : (Screen.height - 200)); int num3 = Mathf.RoundToInt((float)(Screen.width - num) / 2f); int num4 = Mathf.RoundToInt((float)(Screen.height - num2) / 2f); ContentWindowRect = new Rect((float)num3, (float)num4, (float)num, (float)num2); ScreenRect = new Rect(0f, 0f, (float)Screen.width, (float)Screen.height); GUILayout.Window(-70, ContentWindowRect, new WindowFunction(DoServerWindow), "FastLink Servers", Array.Empty()); } } private void DoServerWindow(int id) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_00b0: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 Functions.MakeShitDarkerInABadWay(); bool flag = GUI.GetNameOfFocusedControl() == "FastLinkEditor"; if (flag) { EventType type = Event.current.type; bool flag2 = type - 4 <= 1; flag = flag2; } if (flag && Event.current.isKey) { TextEditor val = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if ((int)Event.current.keyCode == 9) { if ((int)Event.current.type == 5) { val.text += " "; val.MoveLineEnd(); EditorText = val.text; } Event.current.Use(); } } GUILayout.BeginHorizontal(Array.Empty()); GUI.backgroundColor = Color.white; Functions.BuildContentScroller(); GUI.backgroundColor = Color.green; GUI.contentColor = Color.white; Functions.BuildButtons(); GUILayout.EndHorizontal(); } static FastLinkPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; instance = null; FastLinkLogger = Logger.CreateLogSource("FastLink"); UIAnchor = null; MerchUIAnchor = null; LocalScale = null; Sort = null; HideIP = null; ShowPasswordPrompt = null; ShowPasswordInTooltip = null; EditorText = ""; } } } namespace FastLink.Util { public class DragControl : MonoBehaviour, IDragHandler, IEventSystemHandler, IEndDragHandler { [SerializeField] [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(1)] private RectTransform dragRectTransform = new RectTransform(); private void Start() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) dragRectTransform = ((Component)this).GetComponent(); dragRectTransform.anchoredPosition = FastLinkPlugin.UIAnchor.Value; } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] public void OnDrag(PointerEventData eventData) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //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) RectTransform obj = dragRectTransform; obj.anchoredPosition += eventData.delta; } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] public void OnEndDrag(PointerEventData eventData) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FastLinkPlugin.UIAnchor.Value = dragRectTransform.anchoredPosition; } } public class MerchAreaDragControl : MonoBehaviour, IDragHandler, IEventSystemHandler, IEndDragHandler { [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(1)] [SerializeField] private RectTransform dragRectTransform = new RectTransform(); [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(1)] [SerializeField] private Button button; private void Start() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) dragRectTransform = ((Component)this).GetComponent(); button = ((Component)this).GetComponent