Decompiled source of GuardiansModPack v1.2.0
BepInEx/plugins/Azumatt-FastLink/FastLink.dll
Decompiled 10 months ago
The result has been truncated due to the large size, download it to view full contents!
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<Definition> Parse(string yaml) { return new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, Definition>>(yaml) .Select([<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (KeyValuePair<string, Definition> 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<ConfigEntryBase> 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<Vector2> UIAnchor; public static ConfigEntry<Vector2> MerchUIAnchor; public static ConfigEntry<Vector3> LocalScale; public static ConfigEntry<Toggle> Sort; public static ConfigEntry<Toggle> HideIP; public static ConfigEntry<Toggle> ShowPasswordPrompt; public static ConfigEntry<Toggle> 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<string>("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<Toggle>("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<object>())); Sort.SettingChanged += [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (object _, EventArgs _) => { ReadNewServers(null, null); }; HideIP = ((BaseUnityPlugin)this).Config.Bind<Toggle>("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<object>())); HideIP.SettingChanged += [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(0)] (object _, EventArgs _) => { ReadNewServers(null, null); }; UIAnchor = ((BaseUnityPlugin)this).Config.Bind<Vector2>("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<object>())); UIAnchor.SettingChanged += SaveAndReset; MerchUIAnchor = ((BaseUnityPlugin)this).Config.Bind<Vector2>("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<object>())); MerchUIAnchor.SettingChanged += SaveAndReset; LocalScale = ((BaseUnityPlugin)this).Config.Bind<Vector3>("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<object>())); LocalScale.SettingChanged += SaveAndReset; ShowPasswordPrompt = ((BaseUnityPlugin)this).Config.Bind<Toggle>("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<object>())); ShowPasswordInTooltip = ((BaseUnityPlugin)this).Config.Bind<Toggle>("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<object>())); 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<RectTransform>().anchoredPosition = new Vector2(UIAnchor.Value.x, UIAnchor.Value.y); SetupGui.MerchRootGo.GetComponent<RectTransform>().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<GameObject>("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<GUILayoutOption>()); } } 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<GUILayoutOption>()); 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<RectTransform>(); 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<RectTransform>(); button = ((Component)this).GetComponent<Button>(); dragRectTransform.anchoredPosition = FastLinkPlugin.MerchUIAnchor.Value; } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] public void OnDrag(PointerEventData eventData) { //IL_0013: 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_001e: Unknown result type (might be due to invalid IL or missing references) ((Selectable)button).interactable = false; RectTransform obj = dragRectTransform; obj.anchoredPosition += eventData.delta; } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] public void OnEndDrag(PointerEventData eventData) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) ((Selectable)button).interactable = true; FastLinkPlugin.MerchUIAnchor.Value = dragRectTransform.anchoredPosition; } } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(0)] public static class Functions { internal static void DestroyAll(GameObject thing) { Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("FilterField")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("Refresh")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("Server help")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("Back")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("Join")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("FavoriteTab")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("RecentTab")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("FriendsTab")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("CommunityTab")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("Add server")).gameObject); Object.DestroyImmediate((Object)(object)((Component)thing.transform.Find("FavoriteButton")).gameObject); } internal static void MerchButton() { SetupGui.MerchRootGo = GameObject.Find("GUI/StartGui/Menu/StartGui_MerchButton").gameObject; if ((Object)(object)SetupGui.MerchRootGo != (Object)null) { SetupGui.MerchRootGo.AddComponent<MerchAreaDragControl>(); } } internal static void PopulateServerList(GameObject linkpanel) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00e0: Unknown result type (might be due to invalid IL or missing references) FastLinkPlugin.FastLinkLogger.LogDebug((object)"POPULATE SERVER LIST"); SetupGui.MServerListElement = ((Component)linkpanel.transform.Find("ServerList/ServerElementSteamCrossplay")).gameObject; ((Behaviour)((Component)linkpanel.transform.Find("ServerList")).gameObject.GetComponent<Image>()).enabled = false; GameObject gameObject = GameObject.Find("GuiRoot/GUI/StartGui/FastLink/JoinPanel(Clone)/ServerList/ListRoot").gameObject; gameObject.gameObject.transform.localScale = new Vector3(1f, 0.8f, 1f); SetupGui.MServerListRoot = gameObject.GetComponent<RectTransform>(); gameObject.gameObject.GetComponent<RectTransform>().pivot = new Vector2(gameObject.gameObject.GetComponent<RectTransform>().pivot.x, 1f); SetupGui.MServerCount = ((Component)linkpanel.transform.Find("serverCount")).gameObject.GetComponent<TextMeshProUGUI>(); Rect rect = SetupGui.MServerListRoot.rect; SetupGui.MServerListBaseSize = ((Rect)(ref rect)).height; } internal static void UpdateServerList() { FastLinkPlugin.FastLinkLogger.LogDebug((object)"UPDATE SERVER LIST"); SetupGui.MServerList.Clear(); if (SetupGui.Connecting != null) { FastLinkPlugin.FastLinkLogger.LogDebug((object)"Connecting not null"); AbortConnect(); } else if (Servers.entries.Count > 0) { foreach (Definition entry in Servers.entries) { SetupGui.MServerList.Add(entry); } } else { FastLinkPlugin.FastLinkLogger.LogError((object)"No servers defined"); FastLinkPlugin.FastLinkLogger.LogError((object)("Please create this file " + Servers.ConfigPath)); } if (FastLinkPlugin.Sort.Value == FastLinkPlugin.Toggle.On) { SetupGui.MServerList.Sort((Definition a, Definition b) => string.Compare(a?.serverName, b?.serverName, StringComparison.Ordinal)); } if (SetupGui.MJoinServer != null && !SetupGui.MServerList.Contains(SetupGui.MJoinServer)) { FastLinkPlugin.FastLinkLogger.LogDebug((object)"Server list does not contain selected server, clearing selected server"); SetupGui.MJoinServer = null; } UpdateServerListGui(centerSelection: false); } private static void UpdateServerListGui(bool centerSelection) { //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0101: Expected O, but got Unknown if (SetupGui.MServerList.Count != SetupGui.MServerListElements.Count) { FastLinkPlugin.FastLinkLogger.LogDebug((object)"UPDATE SERVER LIST GUI"); foreach (GameObject mServerListElement in SetupGui.MServerListElements) { Object.DestroyImmediate((Object)(object)mServerListElement); } SetupGui.MServerListElements.Clear(); SetupGui.MServerListRoot.SetSizeWithCurrentAnchors((Axis)1, Mathf.Max(SetupGui.MServerListBaseSize, (float)SetupGui.MServerList.Count * SetupGui.m_serverListElementStep)); for (int i = 0; i < SetupGui.MServerList.Count; i++) { GameObject gameObject = Object.Instantiate<GameObject>(SetupGui.MServerListElement, (Transform)(object)SetupGui.MServerListRoot); gameObject.SetActive(true); Transform transform = gameObject.transform; ((RectTransform)((transform is RectTransform) ? transform : null)).anchoredPosition = new Vector2(0f, (float)i * (0f - SetupGui.m_serverListElementStep)); ((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { OnSelectedServer(gameObject); }); if (!SetupGui.MServerListElements.Contains(gameObject)) { SetupGui.MServerListElements.Add(gameObject); } string text = ((SetupGui.MServerListElements.Count > 1) ? " Servers" : " Server"); if ((Object)(object)SetupGui.MServerCount != (Object)null) { ((TMP_Text)SetupGui.MServerCount).text = SetupGui.MServerListElements.Count + text; } } } FastLinkPlugin.FastLinkLogger.LogDebug((object)$"ServerList count: {SetupGui.MServerList.Count}"); for (int j = 0; j < SetupGui.MServerList.Count; j++) { Definition definition = SetupGui.MServerList[j]; GameObject val = SetupGui.MServerListElements?[j]; if (!((Object)(object)val == (Object)null)) { val.GetComponentInChildren<TMP_Text>().text = j + 1 + ". " + definition.serverName; val.GetComponentInChildren<UITooltip>().Set(definition.serverName, definition.ToString(), (RectTransform)null, default(Vector2)); string text2 = (((Component)val.transform.Find("players")).GetComponent<TMP_Text>().text = string.Empty); TMP_Text component = ((Component)val.transform.Find("modifiers")).GetComponent<TMP_Text>(); TMP_Text component2 = ((Component)val.transform.Find("version")).GetComponent<TMP_Text>(); if (FastLinkPlugin.HideIP.Value == FastLinkPlugin.Toggle.On) { component.text = "Hidden"; component2.text = ""; } else { component.text = definition.address; component2.text = definition.port.ToString(); } ((Component)val.transform.Find("Private")).gameObject.SetActive(definition.password.Length > 1); ((Component)val.transform.Find("PVP")).gameObject.SetActive(definition.ispvp); ((Component)val.transform.Find("crossplay")).gameObject.SetActive(definition.iscrossplay); Transform obj = val.transform.Find("selected"); bool active = SetupGui.MJoinServer != null && SetupGui.MJoinServer.Equals(definition); ((Component)obj).gameObject.SetActive(active); } } } private static void Connect(Definition server) { FastLinkPlugin.FastLinkLogger.LogDebug((object)"DO CONNECT"); SetupGui.Connecting = server; try { if (!JoinServer(IPAddress.Parse(server.address), server.port)) { SetupGui.Connecting = null; FastLinkPlugin.FastLinkLogger.LogError((object)"Server address was not valid"); } } catch (FormatException) { FastLinkPlugin.FastLinkLogger.LogDebug((object)("Resolving: " + server.address)); try { SetupGui.ResolveTask = Dns.GetHostEntryAsync(server.address); FastLinkPlugin.FastLinkLogger.LogDebug((object)("Resolving after task: " + SetupGui.ResolveTask.Result.AddressList[0])); } catch (Exception) { FastLinkPlugin.FastLinkLogger.LogError((object)("You are trying to resolve the IP : " + server.address + ", but something is happening causing it to not work properly.")); } if (SetupGui.ResolveTask == null) { FastLinkPlugin.FastLinkLogger.LogError((object)"Your resolve task was null, fix it you idiot"); } else if (SetupGui.ResolveTask.IsFaulted) { FastLinkPlugin.FastLinkLogger.LogError((object)$"Error resolving IP: {SetupGui.ResolveTask.Exception}"); FastLinkPlugin.FastLinkLogger.LogError((object)((SetupGui.ResolveTask.Exception?.InnerException != null) ? SetupGui.ResolveTask.Exception.InnerException.Message : SetupGui.ResolveTask.Exception?.Message)); SetupGui.ResolveTask = null; SetupGui.Connecting = null; } else if (SetupGui.ResolveTask.IsCanceled) { FastLinkPlugin.FastLinkLogger.LogError((object)("Error CANCELED: " + SetupGui.ResolveTask.Result.HostName)); SetupGui.ResolveTask = null; SetupGui.Connecting = null; } else if (SetupGui.ResolveTask.IsCompleted) { FastLinkPlugin.FastLinkLogger.LogDebug((object)("COMPLETE: " + server.address)); IPAddress[] addressList = SetupGui.ResolveTask.Result.AddressList; int num = 0; if (num < addressList.Length) { IPAddress iPAddress = addressList[num]; FastLinkPlugin.FastLinkLogger.LogDebug((object)$"Resolved Completed: {iPAddress}"); SetupGui.ResolveTask = null; if (!JoinServer(iPAddress, server.port)) { SetupGui.Connecting = null; FastLinkPlugin.FastLinkLogger.LogError((object)"Server DNS resolved to invalid address"); } } } else { SetupGui.ResolveTask = null; SetupGui.Connecting = null; FastLinkPlugin.FastLinkLogger.LogError((object)"Server DNS resolved to no valid addresses"); } } } private static bool JoinServer(IPAddress address, ushort port) { //IL_006c: 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_0097: Expected O, but got Unknown string text = ((address.AddressFamily == AddressFamily.InterNetworkV6) ? $"[{address}]" : $"{address}") + $":{port}"; FastLinkPlugin.FastLinkLogger.LogDebug((object)("Server and Port passed into JoinServer: " + text)); if (address.AddressFamily == AddressFamily.InterNetwork) { address = address.MapToIPv6(); } if (address.AddressFamily != AddressFamily.InterNetworkV6) { return false; } SteamNetworkingIPAddr val = default(SteamNetworkingIPAddr); ((SteamNetworkingIPAddr)(ref val)).SetIPv6(address.GetAddressBytes(), port); ZSteamMatchmaking.instance.m_joinData = (ServerJoinData)new ServerJoinDataDedicated(((SteamNetworkingIPAddr)(ref val)).GetIPv4(), port); return true; } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(2)] public static string CurrentPass() { return SetupGui.Connecting?.password; } public static void AbortConnect() { FastLinkPlugin.FastLinkLogger.LogDebug((object)"ABORT CONNECT"); SetupGui.Connecting = null; SetupGui.ResolveTask = null; } private static void OnSelectedServer(GameObject gameObject) { SetupGui.MJoinServer = SetupGui.MServerList[FindSelectedServer((Object)(object)gameObject)]; Connect(new Definition { serverName = SetupGui.MJoinServer.serverName, address = SetupGui.MJoinServer.address, port = SetupGui.MJoinServer.port, password = SetupGui.MJoinServer.password }); UpdateServerListGui(centerSelection: false); } private static int FindSelectedServer(Object button) { try { FastLinkPlugin.FastLinkLogger.LogDebug((object)"FIND SELECTED"); for (int i = 0; i < SetupGui.MServerListElements.Count; i++) { if (i >= 0 && i < SetupGui.MServerListElements.Count && (Object)(object)SetupGui.MServerListElements[i] == button) { return i; } } return -1; } catch (Exception ex) { FastLinkPlugin.FastLinkLogger.LogDebug((object)("The issues were found here: " + ex)); } return 1; } internal static void ShouldShowCursor() { if (FastLinkPlugin.EditorText.Length > 1) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } internal static void EditServersButton(ConfigEntryBase _) { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); if (File.Exists(Servers.ConfigPath) && Servers.entries.Count > 0 && GUILayout.Button("Edit Servers", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { FastLinkPlugin.EditorText = File.ReadAllText(Servers.ConfigPath); } GUILayout.EndVertical(); } internal static void SaveFromEditor() { try { File.WriteAllText(Servers.ConfigPath, FastLinkPlugin.EditorText); FastLinkPlugin.FastLinkLogger.LogInfo((object)"Saved servers, rebuilding list"); } catch (Exception ex) { FastLinkPlugin.FastLinkLogger.LogError((object)("Error saving servers: " + ex)); } } internal static void MakeShitDarkerInABadWay() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 6; i++) { GUI.Box(FastLinkPlugin.ScreenRect, (Texture)(object)Texture2D.blackTexture); } } internal static void BuildContentScroller() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_004d: Expected O, but got Unknown FastLinkPlugin.SettingWindowScrollPos = GUILayout.BeginScrollView(FastLinkPlugin.SettingWindowScrollPos, false, true, Array.Empty<GUILayoutOption>()); GUI.SetNextControlName("FastLinkEditor"); GUIStyle val = new GUIStyle { richText = true }; val.normal.textColor = Color.white; val.normal.background = Texture2D.blackTexture; GUIStyle val2 = val; if (FastLinkPlugin.RichTextOn) { FastLinkPlugin.EditorText = GUILayout.TextArea(FastLinkPlugin.EditorText, val2, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } else { FastLinkPlugin.EditorText = GUILayout.TextArea(FastLinkPlugin.EditorText, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } GUILayout.EndScrollView(); } internal static void BuildButtons() { //IL_0051: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); if (GUILayout.Button(Localization.instance.Localize("$settings_apply"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { SaveFromEditor(); FastLinkPlugin.EditorText = ""; } GUI.backgroundColor = Color.red; GUI.contentColor = Color.white; if (GUILayout.Button("Discard", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { FastLinkPlugin.EditorText = ""; } GUILayout.Space(20f); GUI.backgroundColor = Color.cyan; GUI.contentColor = Color.white; if (GUILayout.Button(FastLinkPlugin.RichTextOn ? "No Rich Text" : "Use Rich Text", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { FastLinkPlugin.RichTextOn = !FastLinkPlugin.RichTextOn; } GUILayout.EndVertical(); } private static void DoQuickLoad(string fileName, FileSource fileSource) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) string @string = PlayerPrefs.GetString("world"); Game.SetProfile(fileName, fileSource); if (string.IsNullOrEmpty(@string)) { return; } FastLinkPlugin.FastLinkLogger.LogDebug((object)("got world name " + @string)); FejdStartup.instance.UpdateCharacterList(); FejdStartup.instance.UpdateWorldList(true); bool isOn = FejdStartup.instance.m_publicServerToggle.isOn; bool isOn2 = FejdStartup.instance.m_openServerToggle.isOn; string text = ((TMP_InputField)FejdStartup.instance.m_serverPassword).text; World val = FejdStartup.instance.FindWorld(@string); if (val != null) { FastLinkPlugin.FastLinkLogger.LogDebug((object)"got world"); ZNet.SetServer(true, isOn2, isOn, @string, text, val); ZNet.ResetServerHost(); FastLinkPlugin.FastLinkLogger.LogDebug((object)"Set server"); try { string text2 = "open:" + isOn2 + ",public:" + isOn; Gogan.LogEvent("Menu", "WorldStart", text2, 0L); } catch { FastLinkPlugin.FastLinkLogger.LogDebug((object)"Error calling Gogan... oh well"); } FastLinkPlugin.FastLinkLogger.LogDebug((object)"transitioning..."); FejdStartup.instance.TransitionToMainScene(); } } } } namespace FastLink.Patches { [HarmonyPatch(typeof(FejdStartup), "OnSelelectCharacterBack")] internal class PatchCharacterBack { private static void Postfix() { if (Object.op_Implicit((Object)(object)SetupGui.Fastlink)) { Functions.AbortConnect(); } } } [HarmonyPatch(typeof(FejdStartup), "Start")] internal static class FejdStartupStartPatch { [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] private static void Postfix(FejdStartup __instance) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown FastLinkPlugin.instance._harmony.Patch((MethodBase)(((int)ZNet.m_onlineBackend == 1) ? AccessTools.DeclaredMethod(typeof(ZPlayFabMatchmaking), "OnFailed", (Type[])null, (Type[])null) : AccessTools.DeclaredMethod(typeof(ZSteamMatchmaking), "OnJoinServerFailed", (Type[])null, (Type[])null)), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(FejdStartupStartPatch), "Failed", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Failed() { if (Object.op_Implicit((Object)(object)SetupGui.Fastlink)) { JoinServerFailed(); } } private static void JoinServerFailed() { FastLinkPlugin.FastLinkLogger.LogError((object)"Server connection failed"); SetupGui.Connecting = null; } } [HarmonyPatch(typeof(ZNet), "RPC_ClientHandshake")] internal class PatchPasswordPrompt { [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] private static bool Prefix(ZNet __instance, ZRpc rpc, bool needPassword, string serverPasswordSalt) { if (FastLinkPlugin.ShowPasswordPrompt.Value == FastLinkPlugin.Toggle.On) { return true; } string text = Functions.CurrentPass(); if (string.IsNullOrEmpty(text)) { return true; } ZNet.m_serverPasswordSalt = serverPasswordSalt; if (needPassword) { string text2 = text.Aggregate("", (string current, char characters) => current + "*"); FastLinkPlugin.FastLinkLogger.LogDebug((object)("Authenticating with saved password...REDACTED: " + text2)); ((Component)__instance.m_connectingDialog).gameObject.SetActive(false); __instance.SendPeerInfo(rpc, text); return false; } FastLinkPlugin.FastLinkLogger.LogDebug((object)"Server didn't want password?"); return true; } } [HarmonyPatch(typeof(FejdStartup), "LoadMainScene")] internal static class FejdStartup_LoadMainScene_Patch { [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] private static void Postfix(FejdStartup __instance) { if (SetupGui.Fastlink.activeSelf) { SetupGui.Fastlink.SetActive(false); } } } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(0)] [HarmonyPatch(typeof(FejdStartup), "SetupGui")] internal class SetupGui { public static GameObject Fastlink = null; public static GameObject FastlinkTooltip = null; public static GameObject FastlinkRootGo = null; public static GameObject MerchRootGo = null; public static readonly List<Definition> MServerList = new List<Definition>(); [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(2)] public static Definition MJoinServer = new Definition(); public static readonly List<GameObject> MServerListElements = new List<GameObject>(); [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(2)] public static TextMeshProUGUI MServerCount; public static GameObject MServerListElement = new GameObject(); public static float m_serverListElementStep = 28f; public static RectTransform MServerListRoot = new RectTransform(); public static float MServerListBaseSize; [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(new byte[] { 2, 1 })] public static Task<IPHostEntry> ResolveTask; [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(2)] public static Definition Connecting; private static void Postfix(FejdStartup __instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) Connecting = null; foreach (GameObject mServerListElement in MServerListElements) { Object.DestroyImmediate((Object)(object)mServerListElement); } MServerListElements.Clear(); Servers.Init(); FastlinkRootGo = new GameObject("FastLink"); FastlinkRootGo.AddComponent<RectTransform>(); FastlinkRootGo.AddComponent<DragControl>(); FastlinkRootGo.transform.SetParent(GameObject.Find("GuiRoot/GUI/StartGui").transform); Fastlink = Object.Instantiate<GameObject>(GameObject.Find("GUI/StartGui/StartGame/Panel/JoinPanel").gameObject, FastlinkRootGo.transform); Object.DestroyImmediate((Object)(object)Fastlink.gameObject.GetComponent<TabHandler>()); Object.DestroyImmediate((Object)(object)Fastlink.gameObject.GetComponent<ServerList>()); Object.DestroyImmediate((Object)(object)Fastlink.gameObject.GetComponent<UIGamePad>()); Fastlink.transform.SetParent(FastlinkRootGo.transform); Fastlink.gameObject.transform.localScale = FastLinkPlugin.LocalScale.Value; FastlinkRootGo.transform.position = Vector2.op_Implicit(new Vector2(FastLinkPlugin.UIAnchor.Value.x, FastLinkPlugin.UIAnchor.Value.y)); if (!Fastlink.activeSelf) { Fastlink.SetActive(true); } Functions.MerchButton(); ((Component)Fastlink.transform.Find("topic")).GetComponent<TMP_Text>().text = "Fast Link"; FastlinkTooltip.gameObject.SetActive(false); try { Functions.DestroyAll(Fastlink); } catch (Exception ex) { FastLinkPlugin.FastLinkLogger.LogError((object)("Problem in the destroying of things!" + ex)); throw; } Functions.PopulateServerList(Fastlink); Functions.UpdateServerList(); } } [<92adf747-93e3-4ab5-a879-2f24de4e5545>NullableContext(1)] [<1bcddceb-3426-47e6-a5fc-cf8b5266c913>Nullable(0)] internal class Servers { internal static string ConfigFileName = "Azumatt.FastLink_servers.yml"; public static string ConfigPath; public static List<Definition> entries; public static void Init() { entries.Clear(); try { if (!File.Exists(ConfigPath)) { using StreamWriter streamWriter = File.CreateText(ConfigPath); streamWriter.Write((object?)new StringBuilder().AppendLine("# Configure your servers for Azumatt's FastLink mod in this file.").AppendLine("# Servers are automatically sorted alphabetically when shown in the list.").AppendLine("# This file live updates the in-game listing. Feel free to change it while in the main menu.") .AppendLine("") .AppendLine("Example Server:") .AppendLine(" address: example.com") .AppendLine(" port: 1234") .AppendLine(" password: somepassword") .AppendLine("") .AppendLine("Some IPv6 Server:") .AppendLine(" address: 2606:2800:220:1:248:1893:25c8:1946") .AppendLine(" port: 4023") .AppendLine(" password: a password with spaces") .AppendLine("") .AppendLine("Passwordless IPv4 Server:") .AppendLine(" address: 93.184.216.34") .AppendLine(" port: 9999") .AppendLine("") .AppendLine("# You can optionally change the color of your server name. Does not work for the address and port. Also, can show PvP status.") .AppendLine("<color=red>Another IPv4 Server</color>:") .AppendLine(" address: 192.0.2.146") .AppendLine(" port: 9999") .AppendLine(" ispvp: true") .AppendLine("# You can specify if a server is crossplay or not. This will show the crossplay's \"Shuffle\" icon. Please note, this is not fully supported at this time.") .AppendLine("Crossplay Server:") .AppendLine(" address: 92.183.211.42") .AppendLine(" port: 9999") .AppendLine(" password: somepassword") .AppendLine(" iscrossplay: true") .AppendLine(" ispvp: true") .AppendLine("# You can specify if a server uses the whitelist for players or not. This will show in the tooltip only.") .AppendLine("Whitelisted Server:") .AppendLine(" address: 92.183.211.42") .AppendLine(" port: 9999") .AppendLine(" password: somepassword") .AppendLine(" iscrossplay: true") .AppendLine(" ispvp: true") .AppendLine(" iswhitelisted: true")); streamWriter.Close(); } if (File.Exists(ConfigPath)) { entries.AddRange(Definition.Parse(File.ReadAllText(ConfigPath))); FastLinkPlugin.FastLinkLogger.LogDebug((object)$"Loaded {entries.Count} server entries"); } } catch (Exception arg) { FastLinkPlugin.FastLinkLogger.LogError((object)$"Error loading config {arg}"); } } static Servers() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigPath = configPath + directorySeparatorChar + ConfigFileName; entries = new List<Definition>(); } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class IsReadOnlyAttribute : Attribute { } [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; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace YamlDotNet { internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } public override object? GetFormat(Type? formatType) { return provider.GetFormat(formatType); } } internal static class ReflectionExtensions { private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); public static Type? BaseType(this Type type) { return type.BaseType; } public static bool IsValueType(this Type type) { return type.IsValueType; } public static bool IsGenericType(this Type type) { return type.IsGenericType; } public static bool IsGenericTypeDefinition(this Type type) { return type.IsGenericTypeDefinition; } public static bool IsInterface(this Type type) { return type.IsInterface; } public static bool IsEnum(this Type type) { return type.IsEnum; } public static bool IsDbNull(this object value) { return value is DBNull; } public static bool HasDefaultConstructor(this Type type, bool allowPrivateConstructors) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (allowPrivateConstructors) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsValueType) { return type.GetConstructor(bindingFlags, null, Type.EmptyTypes, null) != null; } return true; } public static TypeCode GetTypeCode(this Type type) { return Type.GetTypeCode(type); } public static PropertyInfo? GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } public static FieldInfo? GetPublicStaticField(this Type type, string name) { return type.GetField(name, BindingFlags.Static | BindingFlags.Public); } public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (includeNonPublic) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsInterface) { return type.GetProperties(bindingFlags); } return new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany((Type i) => i.GetProperties(bindingFlags)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return type.GetProperties(includeNonPublic: false); } public static IEnumerable<FieldInfo> GetPublicFields(this Type type) { return type.GetFields(BindingFlags.Instance | BindingFlags.Public); } public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type) { return type.GetMethods(BindingFlags.Static | BindingFlags.Public); } public static MethodInfo GetPrivateStaticMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'."); } public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public); } public static Exception Unwrap(this TargetInvocationException ex) { Exception innerException = ex.InnerException; if (innerException == null) { return ex; } if (RemoteStackTraceField != null) { RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n"); } return innerException; } public static bool IsInstanceOf(this Type type, object o) { return type.IsInstanceOfType(o); } public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute), inherit: true); } } internal static class PropertyInfoExtensions { public static object? ReadValue(this PropertyInfo property, object target) { return property.GetValue(target, null); } } internal static class StandardRegexOptions { public const RegexOptions Compiled = RegexOptions.Compiled; } } namespace YamlDotNet.Serialization { internal abstract class BuilderSkeleton<TBuilder> where TBuilder : BuilderSkeleton<TBuilder> { internal INamingConvention namingConvention = NullNamingConvention.Instance; internal ITypeResolver typeResolver; internal readonly YamlAttributeOverrides overrides; internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories; internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories; internal bool ignoreFields; internal bool includeNonPublicProperties; internal Settings settings; protected abstract TBuilder Self { get; } internal BuilderSkeleton(ITypeResolver typeResolver) { overrides = new YamlAttributeOverrides(); typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter> { { typeof(YamlDotNet.Serialization.Converters.GuidConverter), (Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false) }, { typeof(SystemTypeConverter), (Nothing _) => new SystemTypeConverter() } }; typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); settings = new Settings(); } public TBuilder IgnoreFields() { ignoreFields = true; return Self; } public TBuilder IncludeNonPublicProperties() { includeNonPublicProperties = true; return Self; } public TBuilder EnablePrivateConstructors() { settings.AllowPrivateConstructors = true; return Self; } public TBuilder WithNamingConvention(INamingConvention namingConvention) { this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention"); return Self; } public TBuilder WithTypeResolver(ITypeResolver typeResolver) { this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); return Self; } public abstract TBuilder WithTagMapping(TagName tag, Type type); public TBuilder WithAttributeOverride<TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute) { overrides.Add(propertyAccessor, attribute); return Self; } public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) { overrides.Add(type, member, attribute); return Self; } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) { IYamlTypeConverter typeConverter2 = typeConverter; if (typeConverter2 == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter2.GetType(), (Nothing _) => typeConverter2)); return Self; } public TBuilder WithTypeConverter<TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory2 = typeConverterFactory; if (typeConverterFactory2 == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory2(wrapped))); return Self; } public TBuilder WithoutTypeConverter<TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter { return WithoutTypeConverter(typeof(TYamlTypeConverter)); } public TBuilder WithoutTypeConverter(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } typeConverterFactories.Remove(converterType); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { Func<ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory2(inner))); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory2(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<TTypeInspector>() where TTypeInspector : ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } protected IEnumerable<IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent WrapperFactory<TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<TArgument, TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } internal sealed class Deserializer : IDeserializer { private readonly IValueDeserializer valueDeserializer; public Deserializer() : this(new DeserializerBuilder().BuildValueDeserializer()) { } private Deserializer(IValueDeserializer valueDeserializer) { this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer"); } public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer) { return new Deserializer(valueDeserializer); } public T Deserialize<T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<T>(TextReader input) { return Deserialize<T>(new Parser(input)); } public T Deserialize<T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } public object? Deserialize(string input) { return Deserialize(input, typeof(object)); } public object? Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } public object? Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } public object? Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } public object? Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public object? Deserialize(IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event); YamlDotNet.Core.Events.DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _)) { using SerializerState serializerState = new SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer); serializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.StreamEnd>(); } return result; } } internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder> { private Lazy<IObjectFactory> objectFactory; private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories; private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private readonly ITypeConverter typeConverter; private bool ignoreUnmatched; private bool duplicateKeyChecking; private bool attemptUnknownTypeDeserialization; protected override DeserializerBuilder Self => this; public DeserializerBuilder() : base((ITypeResolver)new StaticTypeResolver()) { typeMappings = new Dictionary<Type, Type>(); objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings, settings), isThreadSafe: true); tagMappings = new Dictionary<TagName, Type> { { FailsafeSchema.Tags.Map, typeof(Dictionary<object, object>) }, { FailsafeSchema.Tags.Str, typeof(string) }, { JsonSchema.Tags.Bool, typeof(bool) }, { JsonSchema.Tags.Float, typeof(double) }, { JsonSchema.Tags.Int, typeof(int) }, { DefaultSchema.Tags.Timestamp, typeof(DateTime) } }; typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner)); typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner); typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner)); typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone())); typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner)); nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer> { { typeof(YamlConvertibleNodeDeserializer), (Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value) }, { typeof(YamlSerializableNodeDeserializer), (Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value) }, { typeof(TypeConverterNodeDeserializer), (Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters()) }, { typeof(NullNodeDeserializer), (Nothing _) => new NullNodeDeserializer() }, { typeof(ScalarNodeDeserializer), (Nothing _) => new ScalarNodeDeserializer(attemptUnknownTypeDeserialization, typeConverter) }, { typeof(ArrayNodeDeserializer), (Nothing _) => new ArrayNodeDeserializer() }, { typeof(DictionaryNodeDeserializer), (Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value, duplicateKeyChecking) }, { typeof(CollectionNodeDeserializer), (Nothing _) => new CollectionNodeDeserializer(objectFactory.Value) }, { typeof(EnumerableNodeDeserializer), (Nothing _) => new EnumerableNodeDeserializer() }, { typeof(ObjectNodeDeserializer), (Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched, duplicateKeyChecking, typeConverter) } }; nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver> { { typeof(MappingNodeTypeResolver), (Nothing _) => new MappingNodeTypeResolver(typeMappings) }, { typeof(YamlConvertibleTypeResolver), (Nothing _) => new YamlConvertibleTypeResolver() }, { typeof(YamlSerializableTypeResolver), (Nothing _) => new YamlSerializableTypeResolver() }, { typeof(TagNodeTypeResolver), (Nothing _) => new TagNodeTypeResolver(tagMappings) }, { typeof(PreventUnknownTagsNodeTypeResolver), (Nothing _) => new PreventUnknownTagsNodeTypeResolver() }, { typeof(DefaultContainersNodeTypeResolver), (Nothing _) => new DefaultContainersNodeTypeResolver() } }; typeConverter = new ReflectionTypeConverter(); } internal ITypeInspector BuildTypeInspector() { ITypeInspector typeInspector = new WritablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); if (!ignoreFields) { typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector); } return typeInspectorFactories.BuildComponentChain(typeInspector); } public DeserializerBuilder WithAttemptingUnquotedStringTypeDeserialization() { attemptUnknownTypeDeserialization = true; return this; } public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory) { IObjectFactory objectFactory2 = objectFactory; if (objectFactory2 == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory2, isThreadSafe: true); return this; } public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new LambdaObjectFactory(objectFactory)); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where) { INodeDeserializer nodeDeserializer2 = nodeDeserializer; if (nodeDeserializer2 == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer2.GetType(), (Nothing _) => nodeDeserializer2)); return this; } public DeserializerBuilder WithNodeDeserializer<TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory2 = nodeDeserializerFactory; if (nodeDeserializerFactory2 == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public DeserializerBuilder WithTypeDiscriminatingNodeDeserializer(Action<ITypeDiscriminatingNodeDeserializerOptions> configureTypeDiscriminatingNodeDeserializerOptions, int maxDepth = -1, int maxLength = -1) { TypeDiscriminatingNodeDeserializerOptions typeDiscriminatingNodeDeserializerOptions = new TypeDiscriminatingNodeDeserializerOptions(); configureTypeDiscriminatingNodeDeserializerOptions(typeDiscriminatingNodeDeserializerOptions); TypeDiscriminatingNodeDeserializer nodeDeserializer = new TypeDiscriminatingNodeDeserializer(nodeDeserializerFactories.BuildComponentList(), typeDiscriminatingNodeDeserializerOptions.discriminators, maxDepth, maxLength); return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> s) { s.Before<DictionaryNodeDeserializer>(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) { INodeTypeResolver nodeTypeResolver2 = nodeTypeResolver; if (nodeTypeResolver2 == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver2.GetType(), (Nothing _) => nodeTypeResolver2)); return this; } public DeserializerBuilder WithNodeTypeResolver<TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver { WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory2 = nodeTypeResolverFactory; if (nodeTypeResolverFactory2 == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeTypeResolver<TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver { return WithoutNodeTypeResolver(typeof(TNodeTypeResolver)); } public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType) { if (nodeTypeResolverType == null) { throw new ArgumentNullException("nodeTypeResolverType"); } nodeTypeResolverFactories.Remove(nodeTypeResolverType); return this; } public override DeserializerBuilder WithTagMapping(TagName tag, Type type) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (type == null) { throw new ArgumentNullException("type"); } if (tagMappings.TryGetValue(tag, out Type value)) { throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag"); } tagMappings.Add(tag, type); return this; } public DeserializerBuilder WithTypeMapping<TInterface, TConcrete>() where TConcrete : TInterface { Type typeFromHandle = typeof(TInterface); Type typeFromHandle2 = typeof(TConcrete); if (!typeFromHandle.IsAssignableFrom(typeFromHandle2)) { throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'."); } if (typeMappings.ContainsKey(typeFromHandle)) { typeMappings[typeFromHandle] = typeFromHandle2; } else { typeMappings.Add(typeFromHandle, typeFromHandle2); } return this; } public DeserializerBuilder WithoutTagMapping(TagName tag) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (!tagMappings.Remove(tag)) { throw new KeyNotFoundException($"Tag '{tag}' is not registered"); } return this; } public DeserializerBuilder IgnoreUnmatchedProperties() { ignoreUnmatched = true; return this; } public DeserializerBuilder WithDuplicateKeyChecking() { duplicateKeyChecking = true; return this; } public IDeserializer Build() { return Deserializer.FromValueDeserializer(BuildValueDeserializer()); } public IValueDeserializer BuildValueDeserializer() { return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList(), typeConverter)); } } internal sealed class EmissionPhaseObjectGraphVisitorArgs { private readonly IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors; public IObjectGraphVisitor<IEmitter> InnerVisitor { get; private set; } public IEventEmitter EventEmitter { get; private set; } public ObjectSerializer NestedObjectSerializer { get; private set; } public IEnumerable<IYamlTypeConverter> TypeConverters { get; private set; } public EmissionPhaseObjectGraphVisitorArgs(IObjectGraphVisitor<IEmitter> innerVisitor, IEventEmitter eventEmitter, IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors, IEnumerable<IYamlTypeConverter> typeConverters, ObjectSerializer nestedObjectSerializer) { InnerVisitor = innerVisitor ?? throw new ArgumentNullException("innerVisitor"); EventEmitter = eventEmitter ?? throw new ArgumentNullException("eventEmitter"); this.preProcessingPhaseVisitors = preProcessingPhaseVisitors ?? throw new ArgumentNullException("preProcessingPhaseVisitors"); TypeConverters = typeConverters ?? throw new ArgumentNullException("typeConverters"); NestedObjectSerializer = nestedObjectSerializer ?? throw new ArgumentNullException("nestedObjectSerializer"); } public T GetPreProcessingPhaseObjectGraphVisitor<T>() where T : IObjectGraphVisitor<Nothing> { return preProcessingPhaseVisitors.OfType<T>().Single(); } } internal abstract class EventInfo { public IObjectDescriptor Source { get; } protected EventInfo(IObjectDescriptor source) { Source = source ?? throw new ArgumentNullException("source"); } } internal class AliasEventInfo : EventInfo { public AnchorName Alias { get; } public bool NeedsExpansion { get; set; } public AliasEventInfo(IObjectDescriptor source, AnchorName alias) : base(source) { if (alias.IsEmpty) { throw new ArgumentNullException("alias"); } Alias = alias; } } internal class ObjectEventInfo : EventInfo { public AnchorName Anchor { get; set; } public TagName Tag { get; set; } protected ObjectEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class ScalarEventInfo : ObjectEventInfo { public string RenderedValue { get; set; } public ScalarStyle Style { get; set; } public bool IsPlainImplicit { get; set; } public bool IsQuotedImplicit { get; set; } public ScalarEventInfo(IObjectDescriptor source) : base(source) { Style = source.ScalarStyle; RenderedValue = string.Empty; } } internal sealed class MappingStartEventInfo : ObjectEventInfo { public bool IsImplicit { get; set; } public MappingStyle Style { get; set; } public MappingStartEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class MappingEndEventInfo : EventInfo { public MappingEndEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class SequenceStartEventInfo : ObjectEventInfo { public bool IsImplicit { get; set; } public SequenceStyle Style { get; set; } public SequenceStartEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class SequenceEndEventInfo : EventInfo { public SequenceEndEventInfo(IObjectDescriptor source) : base(source) { } } internal interface IAliasProvider { AnchorName GetAlias(object target); } internal interface IDeserializer { T Deserialize<T>(string input); T Deserialize<T>(TextReader input); T Deserialize<T>(IParser parser); object? Deserialize(string input); object? Deserialize(TextReader input); object? Deserialize(IParser parser); object? Deserialize(string input, Type type); object? Deserialize(TextReader input, Type type); object? Deserialize(IParser parser, Type type); } internal interface IEventEmitter { void Emit(AliasEventInfo eventInfo, IEmitter emitter); void Emit(ScalarEventInfo eventInfo, IEmitter emitter); void Emit(MappingStartEventInfo eventInfo, IEmitter emitter); void Emit(MappingEndEventInfo eventInfo, IEmitter emitter); void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter); void Emit(SequenceEndEventInfo eventInfo, IEmitter emitter); } internal interface INamingConvention { string Apply(string value); } internal interface INodeDeserializer { bool Deserialize(IParser reader, Type expectedType, Func<IParser, Type, object?> nestedObjectDeserializer, out object? value); } internal interface INodeTypeResolver { bool Resolve(NodeEvent? nodeEvent, ref Type currentType); } internal interface IObjectAccessor { void Set(string name, object target, object value); object? Read(string name, object target); } internal interface IObjectDescriptor { object? Value { get; } Type Type { get; } Type StaticType { get; } ScalarStyle ScalarStyle { get; } } internal static class ObjectDescriptorExtensions { public static object NonNullValue(this IObjectDescriptor objectDescriptor) { return objectDescriptor.Value ?? throw new InvalidOperationException("Attempted to use a IObjectDescriptor of type '" + objectDescriptor.Type.FullName + "' whose Value is null at a point whete it is invalid to do so. This may indicate a bug in YamlDotNet."); } } internal interface IObjectFactory { object Create(Type type); object? CreatePrimitive(Type type); bool GetDictionary(IObjectDescriptor descriptor, out IDictionary? dictionary, out Type[]? genericArguments); Type GetValueType(Type type); } internal interface IObjectGraphTraversalStrategy { void Traverse<TContext>(IObjectDescriptor graph, IObjectGraphVisitor<TContext> visitor, TContext context); } internal interface IObjectGraphVisitor<TContext> { bool Enter(IObjectDescriptor value, TContext context); bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, TContext context); bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, TContext context); void VisitScalar(IObjectDescriptor scalar, TContext context); void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, TContext context); void VisitMappingEnd(IObjectDescriptor mapping, TContext context); void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, TContext context); void VisitSequenceEnd(IObjectDescriptor sequence, TContext context); } internal interface IPropertyDescriptor { string Name { get; } bool CanWrite { get; } Type Type { get; } Type? TypeOverride { get; set; } int Order { get; set; } ScalarStyle ScalarStyle { get; set; } T? GetCustomAttribute<T>() where T : Attribute; IObjectDescriptor Read(object target); void Write(object target, object? value); } internal interface IRegistrationLocationSelectionSyntax<TBaseRegistrationType> { void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType; void Before<TRegistrationType>() where TRegistrationType : TBaseRegistrationType; void After<TRegistrationType>() where TRegistrationType : TBaseRegistrationType; void OnTop(); void OnBottom(); } internal interface ITrackingRegistrationLocationSelectionSyntax<TBaseRegistrationType> { void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType; } internal interface ISerializer { string Serialize(object? graph); string Serialize(object? graph, Type type); void Serialize(TextWriter writer, object? graph); void Serialize(TextWriter writer, object? graph, Type type); void Serialize(IEmitter emitter, object? graph); void Serialize(IEmitter emitter, object? graph, Type type); } internal interface ITypeInspector { IEnumerable<IPropertyDescriptor> GetProperties(Type type, object? container); IPropertyDescriptor GetProperty(Type type, object? container, string name, [MaybeNullWhen(true)] bool ignoreUnmatched); } internal interface ITypeResolver { Type Resolve(Type staticType, object? actualValue); } internal interface IValueDeserializer { object? DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer); } internal interface IValuePromise { event Action<object?> ValueAvailable; } internal interface IValueSerializer { void SerializeValue(IEmitter emitter, object? value, Type? type); } internal interface IYamlConvertible { void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer); void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer); } internal delegate object? ObjectDeserializer(Type type); internal delegate void ObjectSerializer(object? value, Type? type = null); [Obsolete("Please use IYamlConvertible instead")] internal interface IYamlSerializable { void ReadYaml(IParser parser); void WriteYaml(IEmitter emitter); } internal interface IYamlTypeConverter { bool Accepts(Type type); object? ReadYaml(IParser parser, Type type); void WriteYaml(IEmitter emitter, object? value, Type type); } internal sealed class LazyComponentRegistrationList<TArgument, TComponent> : IEnumerable<Func<TArgument, TComponent>>, IEnumerable { public sealed class LazyComponentRegistration { public readonly Type ComponentType; public readonly Func<TArgument, TComponent> Factory; public LazyComponentRegistration(Type componentType, Func<TArgument, TComponent> factory) { ComponentType = componentType; Factory = factory; } } public sealed class TrackingLazyComponentRegistration { public readonly Type ComponentType; public readonly Func<TComponent, TArgument, TComponent> Factory; public TrackingLazyComponentRegistration(Type componentType, Func<TComponent, TArgument, TComponent> factory) { ComponentType = componentType; Factory = factory; } } private class RegistrationLocationSelector : IRegistrationLocationSelectionSyntax<TComponent> { private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations; private readonly LazyComponentRegistration newRegistration; public RegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, LazyComponentRegistration newRegistration) { this.registrations = registrations; this.newRegistration = newRegistration; } void IRegistrationLocationSelectionSyntax<TComponent>.InsteadOf<TRegistrationType>() { if (newRegistration.ComponentType != typeof(TRegistrationType)) { registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); } int index = registrations.EnsureRegistrationExists<TRegistrationType>(); registrations.entries[index] = newRegistration; } void IRegistrationLocationSelectionSyntax<TComponent>.After<TRegistrationType>() { registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); int num = registrations.EnsureRegistrationExists<TRegistrationType>(); registrations.entries.Insert(num + 1, newRegistration); } void IRegistrationLocationSelectionSyntax<TComponent>.Before<TRegistrationType>() { registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); int index = registrations.EnsureRegistrationExists<TRegistrationType>(); registrations.entries.Insert(index, newRegistration); } void IRegistrationLocationSelectionSyntax<TComponent>.OnBottom() { registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); registrations.entries.Add(newRegistration); } void IRegistrationLocationSelectionSyntax<TComponent>.OnTop() { registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); registrations.entries.Insert(0, newRegistration); } } private class TrackingRegistrationLocationSelector : ITrackingRegistrationLocationSelectionSyntax<TComponent> { private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations; private readonly TrackingLazyComponentRegistration newRegistration; public TrackingRegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, TrackingLazyComponentRegistration newRegistration) { this.registrations = registrations; this.newRegistration = newRegistration; } void ITrackingRegistrationLocationSelectionSyntax<TComponent>.InsteadOf<TRegistrationType>() { if (newRegistration.ComponentType != typeof(TRegistrationType)) { registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); } int index = registrations.EnsureRegistrationExists<TRegistrationType>(); Func<TArgument, TComponent> innerComponentFactory = registrations.entries[index].Factory; registrations.entries[index] = new LazyComponentRegistration(newRegistration.ComponentType, (TArgument arg) => newRegistration.Factory(innerComponentFactory(arg), arg)); } } private readonly List<LazyComponentRegistration> entries = new List<LazyComponentRegistration>(); public int Count => entries.Count; public IEnumerable<Func<TArgument, TComponent>> InReverseOrder { get { int i = entries.Count - 1; while (i >= 0) { yield return entries[i].Factory; int num = i - 1; i = num; } } } public LazyComponentRegistrationList<TArgument, TComponent> Clone() { LazyComponentRegistrationList<TArgument, TComponent> lazyComponentRegistrationList = new LazyComponentRegistrationList<TArgument, TComponent>(); foreach (LazyComponentRegistration entry in entries) { lazyComponentRegistrationList.entries.Add(entry); } return lazyComponentRegistrationList; } public void Clear() { entries.Clear(); } public void Add(Type componentType, Func<TArgument, TComponent> factory) { entries.Add(new LazyComponentRegistration(componentType, factory)); } public void Remove(Type componentType) { for (int i = 0; i < entries.Count; i++) { if (entries[i].ComponentType == componentType) { entries.RemoveAt(i); return; } } throw new KeyNotFoundException("A component registration of type '" + componentType.FullName + "' was not found."); } public IRegistrationLocationSelectionSyntax<TComponent> CreateRegistrationLocationSelector(Type componentType, Func<TArgument, TComponent> factory) { return new RegistrationLocationSelector(this, new LazyComponentRegistration(componentType, factory)); } public ITrackingRegistrationLocationSelectionSyntax<TComponent> CreateTrackingRegistrationLocationSelector(Type componentType, Func<TComponent, TArgument, TComponent> factory) { return new TrackingRegistrationLocationSelector(this, new TrackingLazyComponentRegistration(componentType, factory)); } public IEnumerator<Func<TArgument, TComponent>> GetEnumerator() { return entries.Select((LazyComponentRegistration e) => e.Factory).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } private int IndexOfRegistration(Type registrationType) { for (int i = 0; i < entries.Count; i++) { if (registrationType == entries[i].ComponentType) { return i; } } return -1; } private void EnsureNoDuplicateRegistrationType(Type componentType) { if (IndexOfRegistration(componentType) != -1) { throw new InvalidOperationException("A component of type '" + componentType.FullName + "' has already been registered."); } } private int EnsureRegistrationExists<TRegistrationType>() { int num = IndexOfRegistration(typeof(TRegistrationType)); if (num == -1) { throw new InvalidOperationException("A component of type '" + typeof(TRegistrationType).FullName + "' has not been registered."); } return num; } } internal static class LazyComponentRegistrationListExtensions { public static TComponent BuildComponentChain<TComponent>(this LazyComponentRegistrationList<TComponent, TComponent> registrations, TComponent innerComponent) { return registrations.InReverseOrder.Aggregate(innerComponent, (TComponent inner, Func<TComponent, TComponent> factory) => factory(inner)); } public static TComponent BuildComponentChain<TArgument, TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TComponent innerComponent, Func<TComponent, TArgument> argumentBuilder) { Func<TComponent, TArgument> argumentBuilder2 = argumentBuilder; return registrations.InReverseOrder.Aggregate(innerComponent, (TComponent inner, Func<TArgument, TComponent> factory) => factory(argumentBuilder2(inner))); } public static List<TComponent> BuildComponentList<TComponent>(this LazyComponentRegistrationList<Nothing, TComponent> registrations) { return registrations.Select((Func<Nothing, TComponent> factory) => factory(default(Nothing))).ToList(); } public static List<TComponent> BuildComponentList<TArgument, TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TArgument argument) { TArgument argument2 = argument; return registrations.Select((Func<TArgument, TComponent> factory) => factory(argument2)).ToList(); } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct Nothing { } internal sealed class ObjectDescriptor : IObjectDescriptor { public object? Value { get; private set; } public Type Type { get; private set; } public Type StaticType { get; private set; } public ScalarStyle ScalarStyle { get; private set; } public ObjectDescriptor(object? value, Type type, Type staticType) : this(value, type, staticType, ScalarStyle.Any) { } public ObjectDescriptor(object? value, Type type, Type staticType, ScalarStyle scalarStyle) { Value = value; Type = type ?? throw new ArgumentNullException("type"); StaticType = staticType ?? throw new ArgumentNullException("staticType"); ScalarStyle = scalarStyle; } } internal delegate IObjectGraphTraversalStrategy ObjectGraphTraversalStrategyFactory(ITypeInspector typeInspector, ITypeResolver typeResolver, IEnumerable<IYamlTypeConverter> typeConverters, int maximumRecursion); internal sealed class PropertyDescriptor : IPropertyDescriptor { private readonly IPropertyDescriptor baseDescriptor; public string Name { get; set; } public Type Type => baseDescriptor.Type; public Type? TypeOverride { get { return baseDescriptor.TypeOverride; } set { baseDescriptor.TypeOverride = value; } } public int Order { get; set; } public ScalarStyle ScalarStyle { get { return baseDescriptor.ScalarStyle; } set { baseDescriptor.ScalarStyle = value; } } public bool CanWrite => baseDescriptor.CanWrite; public PropertyDescriptor(IPropertyDescriptor baseDescriptor) { this.baseDescriptor = baseDescriptor; Name = baseDescriptor.Name; } public void Write(object target, object? value) { baseDescriptor.Write(target, value); } public T? GetCustomAttribute<T>() where T : Attribute { return baseDescriptor.GetCustomAttribute<T>(); } public IObjectDescriptor Read(object target) { return baseDescriptor.Read(target); } } internal sealed class Serializer : ISerializer { private readonly IValueSerializer valueSerializer; private readonly EmitterSettings emitterSettings; public Serializer() : this(new SerializerBuilder().BuildValueSerializer(), EmitterSettings.Default) { } private Serializer(IValueSerializer valueSerializer, EmitterSettings emitterSettings) { this.valueSerializer = valueSerializer ?? throw new ArgumentNullException("valueSerializer"); this.emitterSettings = emitterSettings ?? throw new ArgumentNullException("emitterSettings"); } public static Serializer FromValueSerializer(IValueSerializer valueSerializer, EmitterSettings emitterSettings) { return new Serializer(valueSerializer, emitterSettings); } public string Serialize(object? graph) { using StringWriter stringWriter = new StringWriter(); Serialize(stringWriter, graph); return stringWriter.ToString(); } public string Serialize(object? graph, Type type) { using StringWriter stringWriter = new StringWriter(); Serialize(stringWriter, graph, type); return stringWriter.ToString(); } public void Serialize(TextWriter writer, object? graph) { Serialize(new Emitter(writer, emitterSettings), graph); } public void Serialize(TextWriter writer, object? graph, Type type) { Serialize(new Emitter(writer, emitterSettings), graph, type); } public void Serialize(IEmitter emitter, object? graph) { if (emitter == null) { throw new ArgumentNullException("emitter"); } EmitDocument(emitter, graph, null); } public void Serialize(IEmitter emitter, object? graph, Type type) { if (emitter == null) { throw new ArgumentNullException("emitter"); } if (type == null) { throw new ArgumentNullException("type"); } EmitDocument(emitter, graph, type); } private void EmitDocument(IEmitter emitter, object? graph, Type? type) { emitter.Emit(new YamlDotNet.Core.Events.StreamStart()); emitter.Emit(new YamlDotNet.Core.Events.DocumentStart()); valueSerializer.SerializeValue(emitter, graph, type); emitter.Emit(new YamlDotNet.Core.Events.DocumentEnd(isImplicit: true)); emitter.Emit(new YamlDotNet.Core.Events.StreamEnd()); } } internal sealed class SerializerBuilder : BuilderSkeleton<SerializerBuilder> { private class ValueSerializer : IValueSerializer { private readonly IObjectGraphTraversalStrategy traversalStrategy; private readonly IEventEmitter eventEmitter; private readonly IEnumerable<IYamlTypeConverter> typeConverters; private readonly LazyComponentRegistrationList<IEnumerable<IYamlTypeConverter>, IObjectGraphVisitor<Nothing>> preProcessingPhaseObjectGraphVisitorFactories; private readonly LazyComponentRegistrationList<EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor<IEmitter>> emissionPhaseObjectGraphVisitorFactories; public ValueSerializer(IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IEnumerable<IYamlTypeConverter> typeConverters, LazyComponentRegistrationList<IEnumerable<IYamlTypeConverter>, IObjectGraphVisitor<Nothing>> preProcessingPhaseObjectGraphVisitorFactories, LazyComponentRegistrationList<EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor<IEmitter>> emissionPhaseObjectGraphVisitorFactories) { this.traversalStrategy = traversalStrategy; this.eventEmitter = eventEmitter; this.typeConverters = typeConverters; this.preProcessingPhaseObjectGraphVisitorFactories = preProcessingPhaseObjectGraphVisitorFactories; this.emissionPhaseObjectGraphVisitorFactories = emissionPhaseObjectGraphVisitorFactories; } public void SerializeValue(IEmitter emitter, object? value, Type? type) { IEmitter emitter2 = emitter; Type type2 = type ?? ((value != null) ? value.GetType() : typeof(object));
BepInEx/plugins/ComfyMods-Chatter/Chatter.dll
Decompiled 10 months ago
The result has been truncated due to the large size, download it to view full contents!
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.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using Fishlabs; using HarmonyLib; 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: AssemblyTitle("Chatter")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Chatter")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("801a13e7-7e13-469e-924d-e74cad364371")] [assembly: AssemblyFileVersion("2.2.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.2.1.0")] [module: UnverifiableCode] namespace ComfyLib { public class DummyIgnoreDrag : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IEndDragHandler, IDragHandler { public void OnBeginDrag(PointerEventData eventData) { } public void OnDrag(PointerEventData eventData) { } public void OnEndDrag(PointerEventData eventData) { } } public static class UIBuilder { private static readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(); public static readonly Color32 ColorWhite = Color32.op_Implicit(Color.white); public static readonly Color32 ColorClear = Color32.op_Implicit(Color.clear); public static Sprite CreateRect(int width, int height, Color32 color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_005c: 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_008b: 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) string text = $"Rectangle-{width}w-{height}h-{color}c"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = new Texture2D(width, height) { name = text, wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)0 }; Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } val.SetPixels32(array); val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)value).name = text; _spriteCache[text] = value; return value; } public static Sprite CreateRoundedCornerSprite(int width, int height, int radius, FilterMode filterMode = 1) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) string text = $"RoundedCorner-{width}w-{height}h-{radius}r"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = Texture2DExtensions.SetName(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode(filterMode); Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { array[i * width + j] = (IsCornerPixel(j, i, width, height, radius) ? ColorClear : ColorWhite); } } val.SetPixels32(array); val.Apply(); int k; for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++) { } int l; for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++) { } value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName(text); _spriteCache[text] = value; return value; } private static bool IsCornerPixel(int x, int y, int w, int h, int rad) { if (rad == 0) { return false; } int num = Math.Min(x, w - x); int num2 = Math.Min(y, h - y); if (num == 0 && num2 == 0) { return true; } if (num > rad || num2 > rad) { return false; } num = rad - num; num2 = rad - num2; return Math.Round(Math.Sqrt(num * num + num2 * num2)) > (double)rad; } public static Sprite CreateSuperellipse(int width, int height, float exponent) { //IL_0042: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) string text = $"Superellipse-{width}w-{height}h-{exponent}e"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = new Texture2D(width, height) { name = text, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)0 }; Color32[] array = (Color32[])(object)new Color32[width * height]; int num = width / 2; int num2 = height / 2; float num3 = 1f * ((float)width / 2f); float num4 = 1f * ((float)height / 2f); for (int i = 0; i < num; i++) { for (int j = 0; j < num2; j++) { Color32 val2 = ((Mathf.Pow(Mathf.Abs((float)i / num3), exponent) + Mathf.Pow(Mathf.Abs((float)j / num4), exponent) > 1f) ? ColorClear : ColorWhite); int x2 = i + num; int x3 = -i + num - 1; int y2 = -j + num2 - 1; int y3 = j + num2; array[XYToIndex(x2, y3)] = val2; array[XYToIndex(x2, y2)] = val2; array[XYToIndex(x3, y2)] = val2; array[XYToIndex(x3, y3)] = val2; } } val.SetPixels32(array); val.Apply(); int k; for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++) { } int l; for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++) { } value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)); ((Object)value).name = text; _spriteCache[text] = value; return value; int XYToIndex(int x, int y) { return x + y * width; } } public static TextMeshProUGUI CreateLabel(Transform parentTransform) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).fontSize = 16f; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).richText = true; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).text = string.Empty; return obj; } } public static class UIResources { public static readonly Dictionary<string, Sprite> SpriteCache = new Dictionary<string, Sprite>(); public static readonly Lazy<Dictionary<string, string>> OsFontMap = new Lazy<Dictionary<string, string>>(delegate { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string[] pathsToOSFonts = Font.GetPathsToOSFonts(); foreach (string text in pathsToOSFonts) { dictionary[Path.GetFileNameWithoutExtension(text)] = text; } return dictionary; }); public static readonly string ValheimAveriaSansLibreFont = "Valheim-AveriaSansLibre"; public static readonly string ValheimNorseFont = "Valheim-Norse"; public static readonly string ValheimNorseboldFont = "Valheim-Norsebold"; public static readonly string FallbackNotoSansNormal = "Fallback-NotoSansNormal"; private static readonly Dictionary<string, TMP_FontAsset> _fontAssetCache = new Dictionary<string, TMP_FontAsset>(); public static TMP_FontAsset ValheimAveriaSansLibreFontAsset => ((TMP_Text)UnifiedPopup.instance.bodyText).font; public static Sprite GetSprite(string spriteName) { if (!SpriteCache.TryGetValue(spriteName, out var value)) { value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => ((Object)sprite).name == spriteName)); SpriteCache[spriteName] = value; } return value; } public static TMP_FontAsset GetFontAssetByName(string fontAssetName) { if (!_fontAssetCache.TryGetValue(fontAssetName, out var value)) { value = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == fontAssetName)); if (fontAssetName != ValheimNorseFont && fontAssetName != ValheimNorseboldFont) { ((TMP_Asset)value).material.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.175f); ((TMP_Asset)value).material.SetFloat(ShaderUtilities.ID_FaceDilate, 0.175f); } _fontAssetCache[fontAssetName] = value; } return value; } } public class CircularQueue<T> : ConcurrentQueue<T> { private readonly int _capacity; private readonly Action<T> _dequeueFunc; private T _lastItem; public T LastItem => _lastItem; public CircularQueue(int capacity, Action<T> dequeueFunc) { _capacity = capacity; _dequeueFunc = dequeueFunc; } public void EnqueueItem(T item) { while (base.Count + 1 > _capacity) { if (TryDequeue(out var result)) { _dequeueFunc(result); } } Enqueue(item); _lastItem = item; } public void ClearItems() { T result; while (TryDequeue(out result)) { _dequeueFunc(result); } _lastItem = default(T); } } public sealed class StringListConfigEntry { private readonly List<string> _valuesCache = new List<string>(); private string _lastFocusedControl; private string _editingValue; private static readonly Lazy<GUIStyle> _richTextLabelStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.label) { richText = true })); private static readonly Lazy<GUIStyle> _labelStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.label) { padding = new RectOffset(5, 5, 5, 5) })); private static readonly Lazy<GUIStyle> _horizontalStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle { padding = new RectOffset(10, 10, 0, 0) })); private static readonly Lazy<GUIStyle> _buttonStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.button) { padding = new RectOffset(10, 10, 5, 5) })); private static readonly Lazy<GUIStyle> _textFieldStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.textField) { padding = new RectOffset(5, 5, 5, 5), wordWrap = false })); public ConfigEntry<string> ConfigEntry { get; } public string[] ValuesSeparator { get; } public List<string> Values => ConfigEntry.Value.Split(ValuesSeparator, StringSplitOptions.RemoveEmptyEntries).ToList(); public List<string> CachedValues { get; } public event EventHandler<List<string>> ValuesChangedEvent; public StringListConfigEntry(ConfigFile configFile, string section, string key, string description, string valuesSeparator) { ConfigEntry = configFile.BindInOrder(section, key, string.Empty, description, Drawer, browsable: true, hideDefaultButton: true, hideSettingName: true); ValuesSeparator = new string[1] { valuesSeparator }; CachedValues = new List<string>(Values); } private void Drawer(ConfigEntryBase entry) { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(_horizontalStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label("<b>" + entry.Definition.Key + "</b>\n<i>" + entry.Description.Description + "</i>", _richTextLabelStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); _valuesCache.Clear(); if (!string.IsNullOrEmpty(entry.BoxedValue.ToString())) { _valuesCache.AddRange(entry.BoxedValue.ToString().Split(ValuesSeparator, StringSplitOptions.None)); } int num = -1; bool flag = false; if (!string.IsNullOrEmpty(entry.BoxedValue.ToString())) { for (int i = 0; i < _valuesCache.Count; i++) { GUILayout.BeginHorizontal(_horizontalStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.Label($"#{i:D2}", _labelStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Space(5f); string name = $"{entry.Definition.Key}.{i}"; string value = _valuesCache[i]; if (ShowTextField(name, ref value) && _valuesCache[i] != value) { _valuesCache[i] = value; flag = true; } GUILayout.Space(10f); if (GUILayout.Button("Delete", _buttonStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { num = i; } GUILayout.EndHorizontal(); } } GUILayout.BeginHorizontal(_horizontalStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); if (GUILayout.Button("Add new entry", _buttonStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _valuesCache.Add("changemeplease"); flag = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (num >= 0 && num < _valuesCache.Count) { _valuesCache.RemoveAt(num); flag = true; } if (flag) { entry.BoxedValue = string.Join(ValuesSeparator[0], _valuesCache); CachedValues.Clear(); CachedValues.AddRange(Values); this.ValuesChangedEvent?.Invoke(this, Values); } } private bool ShowTextField(string name, ref string value) { //IL_009f: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Invalid comparison between Unknown and I4 GUI.SetNextControlName(name); if (GUI.GetNameOfFocusedControl() != name) { if (_lastFocusedControl == name) { value = _editingValue; GUILayout.TextField(value, _textFieldStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return true; } GUILayout.TextField(value, _textFieldStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return false; } if (_lastFocusedControl != name) { _lastFocusedControl = name; _editingValue = value; } bool result = false; if (Event.current.isKey) { KeyCode keyCode = Event.current.keyCode; if ((int)keyCode <= 13) { if ((int)keyCode == 9 || (int)keyCode == 13) { goto IL_00c3; } } else if ((int)keyCode == 27 || (int)keyCode == 271) { goto IL_00c3; } } goto IL_00d7; IL_00c3: value = _editingValue; result = true; Event.current.Use(); goto IL_00d7; IL_00d7: _editingValue = GUILayout.TextField(_editingValue, _textFieldStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return result; } } public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public int? Order; } private static readonly Dictionary<string, int> _sectionToOrderCache = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToOrderCache.TryGetValue(section, out var value)) { value = 0; } _sectionToOrderCache[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Order = GetSettingOrder(section) } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = true, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, Order = GetSettingOrder(section) } })); } public static StringListConfigEntry BindInOrder(this ConfigFile config, string section, string key, string description, string valuesSeparator) { return new StringListConfigEntry(config, section, key, description, valuesSeparator); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(configEntry.Value); }; } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class GameObjectExtensions { public static T SetEnabled<T>(this T behaviour, bool enabled) where T : Behaviour { ((Behaviour)behaviour).enabled = enabled; return behaviour; } public static GameObject SetName(this GameObject gameObject, string name) { ((Object)gameObject).name = name; return gameObject; } public static T SetName<T>(this T component, string name) where T : Component { ((Object)((Component)component).gameObject).name = name; return component; } public static GameObject SetParent(this GameObject gameObject, Transform transform, bool worldPositionStays = false) { gameObject.transform.SetParent(transform, worldPositionStays); return gameObject; } public static IEnumerable<GameObject> Children(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return Enumerable.Empty<GameObject>(); } return from Transform t in (IEnumerable)gameObject.transform select ((Component)t).gameObject; } public static Button Button(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<Button>(); } public static Image Image(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<Image>(); } public static LayoutElement LayoutElement(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<LayoutElement>(); } public static RectTransform RectTransform(this GameObject gameObject) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown return (RectTransform)gameObject.transform; } } public static class GridLayoutGroupExtensions { public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.cellSize = cellSize; return layoutGroup; } public static GridLayoutGroup SetConstraint(this GridLayoutGroup layoutGroup, Constraint constraint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.constraint = constraint; return layoutGroup; } public static GridLayoutGroup SetConstraintCount(this GridLayoutGroup layoutGroup, int constraintCount) { layoutGroup.constraintCount = constraintCount; return layoutGroup; } public static GridLayoutGroup SetStartAxis(this GridLayoutGroup layoutGroup, Axis startAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startAxis = startAxis; return layoutGroup; } public static GridLayoutGroup SetStartCorner(this GridLayoutGroup layoutGroup, Corner startCorner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startCorner = startCorner; return layoutGroup; } public static GridLayoutGroup SetPadding(this GridLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static GridLayoutGroup SetSpacing(this GridLayoutGroup layoutGroup, Vector2 spacing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.spacing = spacing; return layoutGroup; } } public static class HorizontalLayoutGroupExtensions { public static HorizontalLayoutGroup SetChildControl(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static HorizontalLayoutGroup SetChildForceExpand(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static HorizontalLayoutGroup SetChildAlignment(this HorizontalLayoutGroup layoutGroup, TextAnchor alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)layoutGroup).childAlignment = alignment; return layoutGroup; } public static HorizontalLayoutGroup SetPadding(this HorizontalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static HorizontalLayoutGroup SetSpacing(this HorizontalLayoutGroup layoutGroup, float spacing) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static Image SetColor(this Image image, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; return image; } public static Image SetFillAmount(this Image image, float amount) { image.fillAmount = amount; return image; } public static Image SetFillCenter(this Image image, bool fillCenter) { image.fillCenter = fillCenter; return image; } public static Image SetFillMethod(this Image image, FillMethod fillMethod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.fillMethod = fillMethod; return image; } public static Image SetFillOrigin(this Image image, OriginHorizontal origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetFillOrigin(this Image image, OriginVertical origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetMaskable(this Image image, bool maskable) { ((MaskableGraphic)image).maskable = maskable; return image; } public static Image SetPreserveAspect(this Image image, bool preserveAspect) { image.preserveAspect = preserveAspect; return image; } public static Image SetRaycastTarget(this Image image, bool raycastTarget) { ((Graphic)image).raycastTarget = raycastTarget; return image; } public static Image SetSprite(this Image image, Sprite sprite) { image.sprite = sprite; return image; } public static Image SetType(this Image image, Type type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.type = type; return image; } } public static class InputFieldExtensions { public static InputField SetTextComponent(this InputField inputField, Text textComponent) { inputField.textComponent = textComponent; return inputField; } } public static class LayoutElementExtensions { public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.preferredWidth = width.Value; } if (height.HasValue) { layoutElement.preferredHeight = height.Value; } return layoutElement; } public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.flexibleWidth = width.Value; } if (height.HasValue) { layoutElement.flexibleHeight = height.Value; } return layoutElement; } public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.minWidth = width.Value; } if (height.HasValue) { layoutElement.minHeight = height.Value; } return layoutElement; } public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout) { layoutElement.ignoreLayout = ignoreLayout; return layoutElement; } } public static class MaskExtensions { public static Mask SetShowMaskGraphic(this Mask mask, bool showMaskGraphic) { mask.showMaskGraphic = showMaskGraphic; return mask; } } public static class OutlineExtensions { public static Outline SetEffectColor(this Outline outline, Color effectColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Shadow)outline).effectColor = effectColor; return outline; } public static Outline SetEffectDistance(this Outline outline, Vector2 effectDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Shadow)outline).effectDistance = effectDistance; return outline; } public static Outline SetUseGraphicAlpha(this Outline outline, bool useGraphicAlpha) { ((Shadow)outline).useGraphicAlpha = useGraphicAlpha; return outline; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class SelectableExtensions { public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).colors = colors; return selectable; } public static T SetImage<T>(this T selectable, Image image) where T : Selectable { ((Selectable)selectable).image = image; return selectable; } public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable { ((Selectable)selectable).interactable = interactable; return selectable; } public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable { ((Selectable)selectable).targetGraphic = graphic; return selectable; } public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).transition = transition; return selectable; } public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = ((Selectable)selectable).navigation; ((Navigation)(ref navigation)).mode = mode; ((Selectable)selectable).navigation = navigation; return selectable; } } public static class ShadowExtensions { public static Shadow SetEffectColor(this Shadow shadow, Color effectColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) shadow.effectColor = effectColor; return shadow; } public static Shadow SetEffectDistance(this Shadow shadow, Vector2 effectDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) shadow.effectDistance = effectDistance; return shadow; } } public static class ScrollRectExtensions { public static ScrollRect SetScrollSensitivity(this ScrollRect scrollRect, float sensitivity) { scrollRect.scrollSensitivity = sensitivity; return scrollRect; } public static ScrollRect SetVerticalScrollPosition(this ScrollRect scrollRect, float position) { scrollRect.verticalNormalizedPosition = position; return scrollRect; } public static ScrollRect SetViewport(this ScrollRect scrollRect, RectTransform viewport) { scrollRect.viewport = viewport; return scrollRect; } public static ScrollRect SetContent(this ScrollRect scrollRect, RectTransform content) { scrollRect.content = content; return scrollRect; } public static ScrollRect SetHorizontal(this ScrollRect scrollRect, bool horizontal) { scrollRect.horizontal = horizontal; return scrollRect; } public static ScrollRect SetVertical(this ScrollRect scrollRect, bool vertical) { scrollRect.vertical = vertical; return scrollRect; } } public static class SpriteExtensions { public static Sprite SetName(this Sprite sprite, string name) { ((Object)sprite).name = name; return sprite; } } public static class TextExtensions { public static Text SetAlignment(this Text text, TextAnchor alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) text.alignment = alignment; return text; } public static Text SetColor(this Text text, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)text).color = color; return text; } public static Text SetFont(this Text text, Font font) { text.font = font; return text; } public static Text SetFontStyle(this Text text, FontStyle fontStyle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) text.fontStyle = fontStyle; return text; } public static Text SetFontSize(this Text text, int fontSize) { text.fontSize = fontSize; return text; } public static Text SetResizeTextForBestFit(this Text text, bool resizeTextForBestFit) { text.resizeTextForBestFit = resizeTextForBestFit; return text; } public static Text SetSupportRichText(this Text text, bool supportRichText) { text.supportRichText = supportRichText; return text; } public static Text SetText(this Text text, string value) { text.text = value; return text; } } public static class TMPTextExtensions { public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } } public static class Texture2DExtensions { public static Texture2D SetName(this Texture2D texture, string name) { ((Object)texture).name = name; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } } public static class ToggleExtensions { public static Toggle SetIsOn(this Toggle toggle, bool isOn) { toggle.SetIsOnWithoutNotify(isOn); ((UnityEvent<bool>)(object)toggle.onValueChanged)?.Invoke(isOn); return toggle; } } public static class VerticalLayoutGroupExtensions { public static VerticalLayoutGroup SetChildControl(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static VerticalLayoutGroup SetChildForceExpand(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static VerticalLayoutGroup SetChildAlignment(this VerticalLayoutGroup layoutGroup, TextAnchor alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)layoutGroup).childAlignment = alignment; return layoutGroup; } public static VerticalLayoutGroup SetPadding(this VerticalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static VerticalLayoutGroup SetSpacing(this VerticalLayoutGroup layoutGroup, float spacing) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } } namespace Chatter { public static class ChatPanelUtils { public static void ShowOrHideChatPanel(this ChatPanel chatPanel, bool isVisible) { if (isVisible != chatPanel.PanelCanvasGroup.blocksRaycasts) { if (isVisible) { chatPanel.PanelCanvasGroup.SetAlpha(1f).SetBlocksRaycasts(blocksRaycasts: true); return; } chatPanel.PanelCanvasGroup.SetAlpha(Hud.IsUserHidden() ? 0f : PluginConfig.HideChatPanelAlpha.Value).SetBlocksRaycasts(blocksRaycasts: false); chatPanel.SetContentVerticalScrollPosition(0f); } } public static void EnableOrDisableChatPanel(this ChatPanel chatPanel, bool isEnabled) { chatPanel.TextInput.InputField.Ref<GuiInputField>()?.SetEnabled<GuiInputField>(isEnabled); } public static void SetContentSpacing(this ChatPanel chatPanel) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.WithHeaderRow) { chatPanel.ContentLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentSpacing.Value); } else { chatPanel.ContentLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentSingleRowSpacing.Value); } } public static void SetContentFontAsset(this ChatPanel chatPanel, TMP_FontAsset fontAsset) { if (Object.op_Implicit((Object)(object)chatPanel?.Content) && Object.op_Implicit((Object)(object)fontAsset)) { TMP_Text[] componentsInChildren = chatPanel.Content.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].font = fontAsset; } } } public static void SetContentFontSize(this ChatPanel chatPanel, float fontSize) { if (Object.op_Implicit((Object)(object)chatPanel?.Content)) { TMP_Text[] componentsInChildren = chatPanel.Content.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].fontSize = fontSize; } } } public static void SetupContentRowToggles(this ChatPanel chatPanel, ChatMessageType togglesToEnable) { ToggleRow messageTypeToggleRow = chatPanel.MessageTypeToggleRow; ((UnityEvent<bool>)(object)messageTypeToggleRow.SayToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Say); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.ShoutToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Shout); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.PingToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Ping); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.WhisperToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Whisper); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.MessageHudToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.HudCenter); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.TextToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Text); }); messageTypeToggleRow.SayToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Say)); messageTypeToggleRow.ShoutToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Shout)); messageTypeToggleRow.PingToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Ping)); messageTypeToggleRow.WhisperToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Whisper)); messageTypeToggleRow.MessageHudToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.HudCenter)); messageTypeToggleRow.TextToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Text)); } public static bool IsMessageTypeToggleActive(this ChatPanel chatPanel, ChatMessageType messageType) { ToggleRow messageTypeToggleRow = chatPanel.MessageTypeToggleRow; return messageType switch { ChatMessageType.Text => messageTypeToggleRow.TextToggle.Toggle.isOn, ChatMessageType.HudCenter => messageTypeToggleRow.MessageHudToggle.Toggle.isOn, ChatMessageType.Say => messageTypeToggleRow.SayToggle.Toggle.isOn, ChatMessageType.Shout => messageTypeToggleRow.ShoutToggle.Toggle.isOn, ChatMessageType.Whisper => messageTypeToggleRow.WhisperToggle.Toggle.isOn, ChatMessageType.Ping => messageTypeToggleRow.PingToggle.Toggle.isOn, _ => true, }; } } public static class ChatTextInputUtils { public static string ChatTextInputPrefix { get; private set; } = "say "; public static void SetChatTextInputPrefix(this ChatPanel chatPanel, Type talkerType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0042: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_006e: 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_0080: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0053: Unknown result type (might be due to invalid IL or missing references) string chatTextInputPrefix = (((int)talkerType == 0) ? "w " : (((int)talkerType != 2) ? "say " : "s ")); ChatTextInputPrefix = chatTextInputPrefix; chatTextInputPrefix = (((int)talkerType == 0) ? "/whisper" : (((int)talkerType != 2) ? "/say " : "/shout")); string text = chatTextInputPrefix; Color val = (((int)talkerType == 0) ? PluginConfig.ChatMessageTextWhisperColor.Value : (((int)talkerType != 2) ? PluginConfig.ChatMessageTextSayColor.Value : PluginConfig.ChatMessageTextShoutColor.Value)); Color color = val; ((Graphic)((TMP_InputField)chatPanel.TextInput.InputField).textComponent).color = color; ((TMP_Text)chatPanel.TextInput.InputFieldPlaceholder).text = text; ((Graphic)chatPanel.TextInput.InputFieldPlaceholder).color = color.SetAlpha(0.3f); } } public class ChatMessage { public ChatMessageType MessageType { get; set; } = ChatMessageType.Text; public DateTime Timestamp { get; set; } = DateTime.MinValue; public long SenderId { get; set; } public Vector3 Position { get; set; } = Vector3.zero; public Type TalkerType { get; set; } = (Type)1; public string Username { get; set; } = string.Empty; public string Text { get; set; } = string.Empty; } [BepInPlugin("redseiko.valheim.chatter", "Chatter", "2.2.1")] public class Chatter : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.chatter"; public const string PluginName = "Chatter"; public const string PluginVersion = "2.2.1"; private Harmony _harmony; public static CircularQueue<ChatMessage> MessageHistory { get; } = new CircularQueue<ChatMessage>(50, delegate { }); public static bool IsChatMessageQueued { get; set; } public static ChatPanel ChatterChatPanel { get; private set; } public static GuiInputField VanillaInputField { get; set; } private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.chatter"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } public static void ToggleChatter(bool toggleOn) { ToggleChatter(Chat.m_instance, toggleOn); } public static void ToggleChatter(Chat chat, bool toggleOn) { TerminalCommands.ToggleCommands(toggleOn); if (Object.op_Implicit((Object)(object)chat)) { ToggleVanillaChat(chat, !toggleOn); ToggleChatPanel(chat, toggleOn); ((Terminal)chat).m_input = (toggleOn ? ChatterChatPanel.TextInput.InputField : VanillaInputField); } } public static void ToggleVanillaChat(Chat chat, bool toggleOn) { Image[] componentsInChildren = ((Component)((Terminal)chat).m_chatWindow).GetComponentsInChildren<Image>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.SetActive(toggleOn); } ((Behaviour)((Component)((Terminal)chat).m_chatWindow).GetComponent<RectMask2D>()).enabled = toggleOn; ((Component)((Terminal)chat).m_output).gameObject.SetActive(toggleOn); } public static void ToggleChatPanel(Chat chat, bool toggleOn) { //IL_003f: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ChatterChatPanel?.Panel)) { ChatterChatPanel = new ChatPanel(((Transform)((Terminal)chat).m_chatWindow).parent); ((Transform)ChatterChatPanel.Panel.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right) .SetPivot(Vector2.right) .SetPosition(PluginConfig.ChatPanelPosition.Value) .SetSizeDelta(PluginConfig.ChatPanelSizeDelta.Value)).SetAsFirstSibling(); ChatterChatPanel.PanelDragger.OnEndDragEvent += delegate(object _, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) PluginConfig.ChatPanelPosition.Value = Vector2.op_Implicit(position); }; ChatterChatPanel.PanelResizer.OnEndDragEvent += delegate(object _, Vector2 sizeDelta) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PluginConfig.ChatPanelSizeDelta.Value = sizeDelta; }; ((UnityEvent<string>)(object)((TMP_InputField)ChatterChatPanel.TextInput.InputField).onSubmit).AddListener((UnityAction<string>)delegate { Chat.m_instance.SendInput(); }); ChatterChatPanel.SetChatTextInputPrefix(PluginConfig.ChatPanelDefaultMessageTypeToUse.Value); ChatterChatPanel.SetupContentRowToggles(PluginConfig.ChatPanelContentRowTogglesToEnable.Value); ChatterChatPanel.SetContentSpacing(); ContentRowManager.RebuildContentRows(); } ChatterChatPanel.Panel.SetActive(toggleOn); } public static void AddChatMessage(ChatMessage message) { if (ChatMessageUtils.ShouldShowMessage(message)) { MessageHistory.EnqueueItem(message); ContentRowManager.CreateContentRow(message); } } } public static class ChatMessageUtils { public static ChatMessageType GetChatMessageType(Type talkerType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown return (int)talkerType switch { 1 => ChatMessageType.Say, 2 => ChatMessageType.Shout, 0 => ChatMessageType.Whisper, 3 => ChatMessageType.Ping, _ => ChatMessageType.Text, }; } public static string GetContentRowBodyText(ChatMessage message) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { return JoinIgnoringEmpty(PluginConfig.ChatMessageShowTimestamp.Value ? GetTimestampText(message.Timestamp) : string.Empty, GetUsernameText(message.Username), GetMessageText(message)); } return GetMessageText(message); } private static string JoinIgnoringEmpty(params string[] values) { return string.Join(" ", values.Where((string value) => !string.IsNullOrEmpty(value))); } public static string GetUsernameText(string username) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (username.Length == 0) { return string.Empty; } return PluginConfig.ChatMessageLayout.Value switch { MessageLayoutType.WithHeaderRow => PluginConfig.ChatMessageUsernamePrefix.Value + username + PluginConfig.ChatMessageUsernamePostfix.Value, MessageLayoutType.SingleRow => "[ <color=#" + ColorUtility.ToHtmlStringRGBA(PluginConfig.ChatMessageUsernameColor.Value) + ">" + username + "</color> ]", _ => username, }; } public static string GetTimestampText(DateTime timestamp) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { return PluginConfig.ChatMessageShowTimestamp.Value ? $"<color=#{ColorUtility.ToHtmlStringRGBA(PluginConfig.ChatMessageTimestampColor.Value)}>{timestamp:t}</color>" : string.Empty; } return timestamp.ToString("T"); } public static string GetMessageText(ChatMessage message) { //IL_0010: 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) string text = ((message.MessageType != ChatMessageType.Ping) ? message.Text : $"Ping! {message.Position}"); string text2 = text; if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { return "<color=#" + ColorUtility.ToHtmlStringRGBA(GetMessageTextColor(message.MessageType)) + ">" + text2 + "</color>"; } return text2; } public static Color GetMessageTextColor(ChatMessageType messageType) { //IL_0067: 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_0033: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) return (Color)(messageType switch { ChatMessageType.Text => PluginConfig.ChatMessageTextDefaultColor.Value, ChatMessageType.HudCenter => PluginConfig.ChatMessageTextMessageHudColor.Value, ChatMessageType.Say => PluginConfig.ChatMessageTextSayColor.Value, ChatMessageType.Shout => PluginConfig.ChatMessageTextShoutColor.Value, ChatMessageType.Whisper => PluginConfig.ChatMessageTextWhisperColor.Value, ChatMessageType.Ping => PluginConfig.ChatMessageTextPingColor.Value, _ => PluginConfig.ChatMessageTextDefaultColor.Value, }); } public static bool ShouldShowMessage(ChatMessage message) { return message.MessageType switch { ChatMessageType.Say => ShouldShowText(message.Text, PluginConfig.SayTextFilterList.CachedValues), ChatMessageType.Shout => ShouldShowText(message.Text, PluginConfig.ShoutTextFilterList.CachedValues), ChatMessageType.Whisper => ShouldShowText(message.Text, PluginConfig.WhisperTextFilterList.CachedValues), ChatMessageType.HudCenter => ShouldShowText(message.Text, PluginConfig.HudCenterTextFilterList.CachedValues), ChatMessageType.Text => ShouldShowText(message.Text, PluginConfig.OtherTextFilterList.CachedValues), _ => true, }; } private static bool ShouldShowText(string text, List<string> filters) { if (filters.Count == 0) { return true; } return !filters.Any((string f) => text.IndexOf(f, 0, StringComparison.OrdinalIgnoreCase) != -1); } } public static class ContentRowManager { public static CircularQueue<ContentRow> MessageRows { get; } = new CircularQueue<ContentRow>(50, DestroyContentRow); public static void CreateContentRow(ChatMessage message) { if (!Object.op_Implicit((Object)(object)Chatter.ChatterChatPanel?.Content)) { return; } if (ShouldCreateContentRow(message)) { ContentRow contentRow = new ContentRow(message, PluginConfig.ChatMessageLayout.Value, Chatter.ChatterChatPanel.Content.transform); MessageRows.EnqueueItem(contentRow); SetupContentRow(contentRow); bool flag = Chatter.ChatterChatPanel.IsMessageTypeToggleActive(message.MessageType); GameObject obj = contentRow.Divider.Ref<GameObject>(); if (obj != null) { obj.SetActive(flag && PluginConfig.ShowChatPanelMessageDividers.Value); } contentRow.Row.SetActive(flag); } TextMeshProUGUI obj2 = MessageRows.LastItem.AddBodyLabel(message); ((TMP_Text)obj2).font = UIResources.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)obj2).fontSize = PluginConfig.ChatMessageFontSize.Value; } public static bool ShouldCreateContentRow(ChatMessage message) { if (PluginConfig.ChatMessageLayout.Value != MessageLayoutType.SingleRow && !MessageRows.IsEmpty && MessageRows.LastItem != null && MessageRows.LastItem.Message?.MessageType == message.MessageType && MessageRows.LastItem.Message?.SenderId == message.SenderId) { return MessageRows.LastItem.Message?.Username != message.Username; } return true; } public static void DestroyContentRow(ContentRow row) { if (Object.op_Implicit((Object)(object)row.Row)) { Object.Destroy((Object)(object)row.Row); } if (Object.op_Implicit((Object)(object)row.Divider)) { Object.Destroy((Object)(object)row.Divider); } } public static void RebuildContentRows() { MessageRows.ClearItems(); if (!Object.op_Implicit((Object)(object)Chatter.ChatterChatPanel?.Panel)) { return; } foreach (ChatMessage item in Chatter.MessageHistory) { CreateContentRow(item); } } public static void SetupContentRow(ContentRow row) { //IL_0060: 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) if (row.LayoutType == MessageLayoutType.WithHeaderRow) { ((TMP_Text)row.HeaderLeftLabel).font = UIResources.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)row.HeaderLeftLabel).fontSize = PluginConfig.ChatMessageFontSize.Value; ((TMP_Text)row.HeaderLeftLabel).text = ChatMessageUtils.GetUsernameText(row.Message.Username); ((Graphic)row.HeaderLeftLabel).color = PluginConfig.ChatMessageUsernameColor.Value; ((TMP_Text)row.HeaderRightLabel).font = UIResources.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)row.HeaderRightLabel).fontSize = PluginConfig.ChatMessageFontSize.Value; ((TMP_Text)row.HeaderRightLabel).text = ChatMessageUtils.GetTimestampText(row.Message.Timestamp); ((Graphic)row.HeaderRightLabel).color = PluginConfig.ChatMessageTimestampColor.Value; ((Component)row.HeaderRightLabel).gameObject.SetActive(PluginConfig.ChatMessageShowTimestamp.Value); row.RowLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentRowSpacing.Value); } else if (row.LayoutType == MessageLayoutType.SingleRow) { row.RowLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentSingleRowSpacing.Value); } } public static void ToggleContentRows(bool toggleOn, ChatMessageType messageType) { foreach (ContentRow messageRow in MessageRows) { if (messageRow.Message.MessageType == messageType) { GameObject obj = messageRow.Row.Ref<GameObject>(); if (obj != null) { obj.SetActive(toggleOn); } GameObject obj2 = messageRow.Divider.Ref<GameObject>(); if (obj2 != null) { obj2.SetActive(toggleOn); } } } } public static void SetContentRowSpacing(float spacing) { foreach (ContentRow messageRow in MessageRows) { messageRow?.RowLayoutGroup.Ref<VerticalLayoutGroup>()?.SetSpacing(spacing); } } public static void SetMessageTextColor(Color color, ChatMessageType messageType) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (TMP_Text item in from label in MessageRows.Where(delegate(ContentRow row) { ChatMessage message = row.Message; return message != null && message.MessageType == messageType && Object.op_Implicit((Object)(object)row.Row); }).SelectMany((ContentRow row) => row.Row.GetComponentsInChildren<TMP_Text>(true)) where ((Object)label).name == "BodyLabel" select label) { ((Graphic)item).color = color; } } public static void SetUsernameTextColor(Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { messageRow?.HeaderLeftLabel.Ref<TextMeshProUGUI>()?.SetColor<TextMeshProUGUI>(color); } } public static void SetTimestampTextColor(Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { messageRow?.HeaderRightLabel.Ref<TextMeshProUGUI>()?.SetColor<TextMeshProUGUI>(color); } } public static void ToggleShowTimestamp(bool toggleOn) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { TextMeshProUGUI headerRightLabel = messageRow.HeaderRightLabel; if (headerRightLabel != null) { ((Component)headerRightLabel).gameObject.SetActive(toggleOn); } } } } public static void ToggleMessageDividers(bool toggleOn) { foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { GameObject obj = messageRow.Divider.Ref<GameObject>(); if (obj != null) { obj.SetActive(toggleOn); } } } } } [Flags] public enum ChatMessageType { None = 0, Text = 1, HudCenter = 2, Say = 4, Shout = 8, Whisper = 0x10, Ping = 0x20 } public enum MessageLayoutType { WithHeaderRow, SingleRow } public static class WorldTextUtils { public static GameObject CreateWorldTextTemplate(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: 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_004a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown GameObject val = new GameObject("WorldText", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0f)).SetAnchorMax(new Vector2(0.5f, 0f)) .SetPivot(new Vector2(0.5f, 0f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(400f, 100f)); TextMeshProUGUI obj = UIBuilder.CreateLabel(val.transform); ((Object)obj).name = "Text"; ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 18f; return val; } } public static class ObjectExtensions { public static T Ref<T>(this T obj) where T : Object { if (!Object.op_Implicit((Object)(object)obj)) { return default(T); } return obj; } } [HarmonyPatch(typeof(Menu))] internal static class MenuPatch { [HarmonyPostfix] [HarmonyPatch("Show")] private static void ShowPostfix() { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)Chatter.ChatterChatPanel?.Panel)) { Chat.m_instance.m_hideTimer = 0f; Chatter.ChatterChatPanel.EnableOrDisableChatPanel(isEnabled: true); Chatter.ChatterChatPanel.ToggleGrabber(toggleOn: true); } } [HarmonyPostfix] [HarmonyPatch("Hide")] private static void HidePostfix() { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)Chatter.ChatterChatPanel?.Panel)) { Chatter.ChatterChatPanel.SetContentVerticalScrollPosition(0f); Chatter.ChatterChatPanel.ToggleGrabber(toggleOn: false); } } } [HarmonyPatch(typeof(MessageHud))] internal static class MessageHudPatch { [HarmonyPostfix] [HarmonyPatch("ShowMessage")] private static void ShowMessagePostfix(MessageType type, string text) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (PluginConfig.IsModEnabled.Value && (int)type == 2 && PluginConfig.ShowMessageHudCenterMessages.Value) { Chatter.AddChatMessage(new ChatMessage { MessageType = ChatMessageType.HudCenter, Timestamp = DateTime.Now, Text = text }); } } } public class InputFieldCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public GuiInputField InputField { get; private set; } public TextMeshProUGUI InputFieldPlaceholder { get; private set; } public InputFieldCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); InputField = CreateChildInputField(Cell.transform); InputFieldPlaceholder = ((Component)((TMP_InputField)InputField).placeholder).GetComponent<TextMeshProUGUI>(); InputField.SetTargetGraphic<GuiInputField>((Graphic)(object)Background).SetTransition<GuiInputField>((Transition)1).SetNavigationMode<GuiInputField>((Mode)0); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateSuperellipse(128, 128, 10f)) .SetColor(new Color(0.1f, 0.1f, 0.1f, 0.3f)); val.AddComponent<RectMask2D>(); return val; } private GuiInputField CreateChildInputField(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002d: 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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("InputField", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(new Vector2(-16f, -8f)) .SetPosition(Vector2.zero); TextMeshProUGUI val2 = UIBuilder.CreateLabel(val.transform); val2.SetName<TextMeshProUGUI>("Text"); ((TMP_Text)val2).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).overflowMode = (TextOverflowModes)2; ((TMP_Text)val2).richText = false; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; ((Graphic)val2).color = Color.white; ((TMP_Text)val2).text = string.Empty; TextMeshProUGUI val3 = UIBuilder.CreateLabel(val.transform); val3.SetName<TextMeshProUGUI>("Placeholder"); ((TMP_Text)val3).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val3).overflowMode = (TextOverflowModes)2; ((TMP_Text)val3).richText = true; ((TMP_Text)val3).alignment = (TextAlignmentOptions)513; ((Graphic)val3).color = new Color(1f, 1f, 1f, 0.3f); ((TMP_Text)val3).text = "..."; GuiInputField obj = val.AddComponent<GuiInputField>(); ((TMP_InputField)obj).textViewport = val.GetComponent<RectTransform>(); ((TMP_InputField)obj).textComponent = (TMP_Text)(object)val2; ((TMP_InputField)obj).placeholder = (Graphic)(object)val3; ((TMP_InputField)obj).onFocusSelectAll = false; obj.OnInputLayoutChanged(); ((TMP_InputField)obj).MoveToStartOfLine(false, false); return obj; } } public class ContentRow { public ChatMessage Message { get; private set; } public MessageLayoutType LayoutType { get; private set; } public GameObject Row { get; private set; } public VerticalLayoutGroup RowLayoutGroup { get; private set; } public GameObject Divider { get; private set; } public GameObject Header { get; private set; } public TextMeshProUGUI HeaderLeftLabel { get; private set; } public TextMeshProUGUI HeaderRightLabel { get; private set; } public ContentRow(ChatMessage message, MessageLayoutType layoutType, Transform parentTransform) { Message = message; LayoutType = layoutType; if (layoutType == MessageLayoutType.WithHeaderRow) { Divider = CreateDivider(parentTransform); } Row = CreateChildRow(parentTransform); RowLayoutGroup = Row.GetComponent<VerticalLayoutGroup>(); if (layoutType == MessageLayoutType.WithHeaderRow) { (Header, HeaderLeftLabel, HeaderRightLabel) = CreateHeader(Row.transform); } } public TextMeshProUGUI AddBodyLabel(ChatMessage message) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = CreateChildBodyLabel(Row.transform); ((TMP_Text)val).text = ChatMessageUtils.GetContentRowBodyText(message); if (LayoutType == MessageLayoutType.WithHeaderRow) { ((Graphic)val).color = ChatMessageUtils.GetMessageTextColor(message.MessageType); } return val; } private GameObject CreateChildRow(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown GameObject val = new GameObject("Message", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero); val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(true, false) .SetSpacing(2f); return val; } private GameObject CreateDivider(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown GameObject val = new GameObject("Divider", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<Image>().SetSprite(UIBuilder.CreateRect(10, 10, Color32.op_Implicit(Color.white))).SetType((Type)3) .SetColor(new Color(1f, 1f, 1f, 0.0625f)) .SetRaycastTarget(raycastTarget: true) .SetMaskable(maskable: true); LayoutElement layoutElement = val.AddComponent<LayoutElement>().SetFlexible(1f); float? height = 1f; layoutElement.SetPreferred(null, height); return val; } private (GameObject header, TextMeshProUGUI leftCell, TextMeshProUGUI rightCell) CreateHeader(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_00b2: 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_00c4: Expected O, but got Unknown GameObject val = new GameObject("Header", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetPadding(0, 0, 0, 0); TextMeshProUGUI val2 = UIBuilder.CreateLabel(val.transform); ((Object)val2).name = "HeaderLeftLabel"; ((TMP_Text)val2).text = "LeftLabel"; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; GameObject val3 = new GameObject("Spacer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val3, val.transform); val3.AddComponent<LayoutElement>().SetFlexible(1f); TextMeshProUGUI val4 = UIBuilder.CreateLabel(val.transform); ((Object)val4).name = "HeaderRightLabel"; ((TMP_Text)val4).text = "RightLabel"; ((TMP_Text)val4).alignment = (TextAlignmentOptions)516; return (val, val2, val4); } private TextMeshProUGUI CreateChildBodyLabel(Transform parentTransform) { TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((Object)obj).name = "BodyLabel"; ((TMP_Text)obj).alignment = (TextAlignmentOptions)513; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)1; return obj; } } public class ResizeCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public TMP_Text Label { get; private set; } public ResizeCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); Label = CreateChildLabel(Cell.transform); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0036: 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_005e: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown GameObject val = new GameObject("Resizer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); GameObjectExtensions.RectTransform(val).SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)) .SetPivot(new Vector2(0f, 0.5f)) .SetSizeDelta(new Vector2(42.5f, 42.5f)) .SetPosition(new Vector2(5f, 0f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button")) .SetColor(new Color(1f, 1f, 1f, 0.95f)); return val; } private TMP_Text CreateChildLabel(Transform parentTransform) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 24f; ((TMP_Text)obj).text = "<rotate=45>↔</rotate>"; return (TMP_Text)(object)obj; } } public class ToggleCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public TextMeshProUGUI Label { get; private set; } public Toggle Toggle { get; private set; } public ToggleCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.Image(); Label = CreateChildLabel(Cell.transform); Toggle = Cell.AddComponent<Toggle>(); ((UnityEvent<bool>)(object)Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { OnToggleValueChanged(isOn); }); Toggle.SetNavigationMode<Toggle>((Mode)0).SetTargetGraphic<Toggle>((Graphic)(object)Background).SetIsOn(isOn: false); Cell.AddComponent<DummyIgnoreDrag>(); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: 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_0037: 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) //IL_0072: Expected O, but got Unknown GameObject val = new GameObject("Toggle", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button")) .SetColor(new Color(1f, 1f, 1f, 0.95f)); return val; } private TextMeshProUGUI CreateChildLabel(Transform parentTransform) { //IL_0031: 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_0056: 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_006a: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 14f; ((Graphic)obj).color = new Color(1f, 1f, 1f, 0.9f); ((TMP_Text)obj).text = "Toggle"; ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); return obj; } private void OnToggleValueChanged(bool isOn) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_004b: Unknown result type (might be due to invalid IL or missing references) ((Graphic)Background).color = (isOn ? new Color(1f, 1f, 1f, 0.95f) : new Color(0.5f, 0.5f, 0.5f, 0.95f)); ((Graphic)Label).color = (isOn ? Color.white : Color.gray); } } public class ToggleRow { public GameObject Row { get; private set; } public Image Background { get; private set; } public ToggleCell SayToggle { get; private set; } public ToggleCell ShoutToggle { get; private set; } public ToggleCell WhisperToggle { get; private set; } public ToggleCell PingToggle { get; private set; } public ToggleCell MessageHudToggle { get; private set; } public ToggleCell TextToggle { get; private set; } public ToggleRow(Transform parentTransform) { Row = CreateChildRow(parentTransform); Background = Row.Image(); SayToggle = CreateChildToggle(Row.transform, "Say"); ShoutToggle = CreateChildToggle(Row.transform, "Shout"); WhisperToggle = CreateChildToggle(Row.transform, "Whisper"); PingToggle = CreateChildToggle(Row.transform, "Ping"); MessageHudToggle = CreateChildToggle(Row.transform, "Hud"); TextToggle = CreateChildToggle(Row.transform, "Text"); } private GameObject CreateChildRow(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: 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_0036: 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_005e: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0116: Expected O, but got Unknown GameObject val = new GameObject("ToggleRow", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.right) .SetPivot(new Vector2(0.5f, 0f)) .SetPosition(new Vector2(0f, -55f)) .SetSizeDelta(new Vector2(0f, 45f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(256, 256, 16, (FilterMode)1)) .SetColor(new Color(0.5f, 0.5f, 0.5f, 0.25f)); val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetSpacing(5f) .SetPadding(5, 5, 4, 4) .SetChildAlignment((TextAnchor)5); return val; } private ToggleCell CreateChildToggle(Transform parentTransform, string toggleText) { ToggleCell toggleCell = new ToggleCell(parentTransform); ((TMP_Text)toggleCell.Label).text = toggleText; LayoutElement layoutElement = toggleCell.Cell.AddComponent<LayoutElement>().SetPreferred(((TMP_Text)toggleCell.Label).GetPreferredWidth() + 25f); float? height = 0.9f; layoutElement.SetFlexible(null, height); return toggleCell; } } public static class ListExtensions { public static List<T> Add<T>(this List<T> list, params T[] items) { list.AddRange(items); return list; } } [HarmonyPatch(typeof(Chat))] internal static class ChatPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(Chat __instance) { ContentRowManager.MessageRows.ClearItems(); Chatter.VanillaInputField = ((Terminal)__instance).m_input; Chatter.ToggleChatter(__instance, PluginConfig.IsModEnabled.Value); SetupWorldText(__instance); } private static void SetupWorldText(Chat chat) { chat.m_worldTextBase = WorldTextUtils.CreateWorldTextTemplate(chat.m_worldTextBase.transform.parent); chat.m_worldTextBase.SetActive(false); } [HarmonyTranspiler] [HarmonyPatch("InputText")] private static IEnumerable<CodeInstruction> InputTextTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"say ", (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)PrefixSayDelegate) }) .InstructionEnumeration(); } private static string PrefixSayDelegate(string value) { if (PluginConfig.IsModEnabled.Value) { return ChatTextInputUtils.ChatTextInputPrefix; } return value; } [HarmonyPrefix] [HarmonyPatch("OnNewChatMessage")] private static void OnNewChatMessagePrefix(long senderID, Vector3 pos, Type type, UserInfo user, string text) { //IL_0013: 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_0038: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value) { ChatMessage message = new ChatMessage { MessageType = ChatMessageUtils.GetChatMessageType(type), Timestamp = DateTime.Now, SenderId = senderID, Position = pos, TalkerType = type, Username = user.Name, Text = Regex.Replace(text, "(<|>)", " ") }; Chatter.IsChatMessageQueued = true; Chatter.AddChatMessage(message); } } [HarmonyPostfix] [HarmonyPatch("OnNewChatMessage")] private static void OnNewChatMessagePostfix() { if (PluginConfig.IsModEnabled.Value) { Chatter.IsChatMessageQueued = false; } } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_hideTimer"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_hideDelay"), (string)null), new CodeMatch((OpCode?)OpCodes.Clt, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch HideChatPanelDelegate.").InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_hideTimer")), Transpilers.EmitDelegate<Action<float>>((Action<float>)HideChatPanelDelegate) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[8] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Terminal), "m_input"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Component), "get_gameObject", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Terminal), "m_input"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GuiInputField), "ActivateInputField", (Type[])null, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch EnableChatPanelDelegate.") .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action>((Action)EnableChatPanelDelegate) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[7] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Terminal), "m_input"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Component), "get_gameObject", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(Terminal), "m_focused"), (string)null) }) .ThrowIfInvalid("Could not patch DisableChatPanelDelegate.") .Advance(3) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)DisableChatPanelDelegate) }) .InstructionEnumeration(); } private static void HideChatPanelDelegate(float hideTimer) { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)Chatter.ChatterChatPanel?.Panel)) { bool isVisible = (hideTimer < (float)PluginConfig.HideChatPanelDelay.Value || Menu.IsVisible()) && !Hud.IsUserHidden(); Chatter.ChatterChatPanel.ShowOrHideChatPanel(isVisible); } } private static void EnableChatPanelDelegate() { if (PluginConfig.IsModEnabled.Value) { Chatter.ChatterChatPanel?.EnableOrDisableChatPanel(isEnabled: true); } } private static bool DisableChatPanelDelegate(bool active) { if (PluginConfig.IsModEnabled.Value) { if (!Menu.IsVisible()) { Chatter.ChatterChatPanel?.EnableOrDisableChatPanel(isEnabled: false); } return true; } return active; } [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(ref Chat __instance) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to
BepInEx/plugins/ComfyMods-Enhuddlement/Enhuddlement.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Enhuddlement")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Enhuddlement")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("76613fb2-45a2-4253-b205-58d12f10984e")] [assembly: AssemblyFileVersion("1.2.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.0")] [module: UnverifiableCode] namespace UnityEngine.UI { public class VerticalGradient : BaseMeshEffect { public enum Blend { Override, Add, Multiply } private readonly List<UIVertex> _vertices = new List<UIVertex>(); [field: SerializeField] public Gradient EffectGradient { get; set; } = CreateTwoColorGradient(Color.gray, Color.white); [field: SerializeField] public Blend BlendMode { get; set; } = Blend.Multiply; [field: SerializeField] [field: Range(-1f, 1f)] public float EffectOffset { get; set; } public void SetEffectGradient(Color startcolor, Color endColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) EffectGradient = CreateTwoColorGradient(startcolor, endColor); } private static Gradient CreateTwoColorGradient(Color startColor, Color endColor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000f: 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_001a: 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_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) Gradient val = new Gradient(); val.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(startColor, 0f), new GradientColorKey(endColor, 1f) }; return val; } public override void ModifyMesh(VertexHelper helper) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) if (!((UIBehaviour)this).IsActive() || helper.currentVertCount == 0) { return; } _vertices.Clear(); helper.GetUIVertexStream(_vertices); float y = _vertices[0].position.y; float num = y; float num2 = y; for (int num3 = _vertices.Count - 1; num3 > 0; num3--) { y = _vertices[num3].position.y; if (y > num) { num = y; } else if (y < num2) { num2 = y; } } float num4 = 1f / (num - num2); int i = 0; for (int count = _vertices.Count; i < count; i++) { UIVertex val = _vertices[i]; val.color = Color32.op_Implicit(BlendColor(Color32.op_Implicit(val.color), EffectGradient.Evaluate((val.position.y - num2) * num4 - EffectOffset))); _vertices[i] = val; } helper.Clear(); helper.AddUIVertexTriangleStream(_vertices); } private Color BlendColor(Color firstColor, Color secondColor) { //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_0018: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) return (Color)(BlendMode switch { Blend.Add => firstColor + secondColor, Blend.Multiply => firstColor * secondColor, _ => secondColor, }); } } } namespace ComfyLib { public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public int? Order; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = GetSettingOrder(section) } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = customDrawer, Order = GetSettingOrder(section) } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Order = GetSettingOrder(section) } })); } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ComponentExtensions { public static T SetName<T>(this T component, string name) where T : Component { ((Object)((Component)component).gameObject).name = name; return component; } } public static class OutlineExtensions { public static Outline SetEffectColor(this Outline outline, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Shadow)outline).effectColor = color; return outline; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class TextMeshProUGUIExtensions { public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).alignment = alignment; return tmpText; } public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text { ((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing; return tmpText; } public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text { ((TMP_Text)tmpText).font = font; return tmpText; } public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text { ((TMP_Text)tmpText).fontSize = fontSize; return tmpText; } public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text { ((TMP_Text)tmpText).fontMaterial = fontMaterial; return tmpText; } public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).margin = margin; return tmpText; } public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).overflowMode = overflowMode; return tmpText; } public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text { ((TMP_Text)tmpText).richText = richText; return tmpText; } public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).textWrappingMode = textWrappingMode; return tmpText; } } } namespace Enhuddlement { public static class EnemyHudUpdater { private static readonly List<Character> _keysToRemove = new List<Character>(12); public static void UpdateHuds(ref EnemyHud enemyHud, ref Player player, ref Sadle sadle, float dt, ConditionalWeakTable<HudData, TextMeshProUGUI> healthTextCache) { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); if (!Object.op_Implicit((Object)(object)mainCamera)) { return; } Sadle obj = sadle.Ref<Sadle>(); Character val = ((obj != null) ? obj.GetCharacter() : null); Player obj2 = player.Ref<Player>(); Character val2 = ((obj2 != null) ? obj2.GetHoverCreature() : null); _keysToRemove.Clear(); foreach (KeyValuePair<Character, HudData> hud in enemyHud.m_huds) { HudData value = hud.Value; Character character = value.m_character; if (!Object.op_Implicit((Object)(object)character) || !enemyHud.TestShow(character, true) || (Object)(object)character == (Object)(object)val) { _keysToRemove.Add(character); Object.Destroy((Object)(object)value.m_gui); continue; } if ((Object)(object)character == (Object)(object)val2) { value.m_hoverTimer = 0f; } value.m_hoverTimer += dt; if (character.IsPlayer() || character.IsBoss() || value.m_isMount || value.m_hoverTimer < enemyHud.m_hoverShowDuration) { value.m_gui.SetActive(true); ((TMP_Text)value.m_name).text = Localization.m_instance.Localize(character.GetHoverName()); if (character.IsPlayer()) { value.m_name.SetColor<TextMeshProUGUI>(character.IsPVPEnabled() ? PluginConfig.PlayerHudNameTextPvPColor.Value : PluginConfig.PlayerHudNameTextColor.Value); } else if (Object.op_Implicit((Object)(object)character.m_baseAI) && !character.IsBoss()) { bool flag = character.m_baseAI.HaveTarget(); bool flag2 = character.m_baseAI.IsAlerted(); if (PluginConfig.EnemyHudUseNameForStatus.Value) { value.m_name.SetColor<TextMeshProUGUI>((!(flag || flag2)) ? PluginConfig.EnemyHudHealthTextColor.Value : (flag2 ? PluginConfig.EnemyHudNameTextAlertedColor.Value : PluginConfig.EnemyHudNameTextAwareColor.Value)); } else { ((Component)value.m_alerted).gameObject.SetActive(flag2); ((Component)value.m_aware).gameObject.SetActive(flag && !flag2); } } } else { value.m_gui.SetActive(false); } float health = character.GetHealth(); float maxHealth = character.GetMaxHealth(); float value2 = health / maxHealth; if (PluginConfig.ShowEnemyHealthValue.Value && healthTextCache.TryGetValue(value, out var value3)) { ((TMP_Text)value3).SetText($"{health:N0} / {maxHealth:N0}"); } value.m_healthSlow.SetValue(value2); value.m_healthFast.SetValue(value2); if (Object.op_Implicit((Object)(object)value.m_healthFastFriendly)) { value.m_healthFast.SetColor(character.IsTamed() ? PluginConfig.EnemyHudHealthBarTamedColor.Value : ((Object.op_Implicit((Object)(object)player) && !BaseAI.IsEnemy((Character)(object)player, character)) ? PluginConfig.EnemyHudHealthBarFriendlyColor.Value : PluginConfig.EnemyHudHealthBarColor.Value)); } if (value.m_isMount && Object.op_Implicit((Object)(object)sadle)) { float stamina = sadle.GetStamina(); float maxStamina = sadle.GetMaxStamina(); value.m_stamina.SetValue(stamina / maxStamina); ((TMP_Text)value.m_healthText).text = $"{health:N0}"; ((TMP_Text)value.m_staminaText).text = $"{stamina:N0}"; } if (value.m_gui.activeSelf && (PluginConfig.FloatingBossHud.Value || !character.IsBoss())) { Vector3 val3 = (character.IsPlayer() ? (character.GetHeadPoint() + PluginConfig.PlayerHudPositionOffset.Value) : (character.IsBoss() ? (character.GetTopPoint() + PluginConfig.BossHudPositionOffset.Value) : ((!value.m_isMount || !Object.op_Implicit((Object)(object)player)) ? (character.GetTopPoint() + PluginConfig.EnemyHudPositionOffset.Value) : (((Component)((Component)player).transform).transform.position - ((Component)player).transform.up * 0.5f)))); Vector3 val4 = mainCamera.WorldToScreenPoint(val3); if (val4.x < 0f || val4.x > (float)Screen.width || val4.y < 0f || val4.y > (float)Screen.height || val4.z > 0f) { value.m_gui.transform.position = val4; value.m_gui.SetActive(true); } else { value.m_gui.SetActive(false); } } } for (int i = 0; i < _keysToRemove.Count; i++) { enemyHud.m_huds.Remove(_keysToRemove[i]); } _keysToRemove.Clear(); } } [BepInPlugin("redseiko.valheim.enhuddlement", "Enhuddlement", "1.2.1")] public class Enhuddlement : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.enhuddlement"; public const string PluginName = "Enhuddlement"; public const string PluginVersion = "1.2.1"; public static Harmony HarmonyInstance { get; private set; } private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.enhuddlement"); } private void OnDestroy() { Harmony harmonyInstance = HarmonyInstance; if (harmonyInstance != null) { harmonyInstance.UnpatchSelf(); } } } [HarmonyPatch(typeof(EnemyHud))] internal static class EnemyHudPatch { private static readonly ConditionalWeakTable<HudData, TextMeshProUGUI> _healthTextCache = new ConditionalWeakTable<HudData, TextMeshProUGUI>(); [HarmonyPrefix] [HarmonyPatch("ShowHud")] private static void ShowHudPrefix(ref EnemyHud __instance, ref Character c, ref bool __state) { __state = __instance.m_huds.ContainsKey(c); } [HarmonyPostfix] [HarmonyPatch("ShowHud")] private static void ShowHudPostfix(ref EnemyHud __instance, ref Character c, ref bool isMount, ref bool __state) { if (!(!PluginConfig.IsModEnabled.Value | __state) && __instance.m_huds.TryGetValue(c, out var value)) { if (c.IsPlayer()) { SetupPlayerHud(value); } else if (c.IsBoss()) { SetupBossHud(value); } else if (!isMount) { SetupEnemyHud(value); } } } private static void SetupPlayerHud(HudData hudData) { //IL_0010: 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_0053: Unknown result type (might be due to invalid IL or missing references) SetupName(hudData, PluginConfig.PlayerHudNameTextFontSize.Value, PluginConfig.PlayerHudNameTextColor.Value); SetupHud(hudData, PluginConfig.PlayerHudHealthTextFontSize.Value, PluginConfig.PlayerHudHealthTextColor.Value, PluginConfig.PlayerHudHealthBarWidth.Value, PluginConfig.PlayerHudHealthBarHeight.Value); hudData.m_healthFast.SetColor(PluginConfig.PlayerHudHealthBarColor.Value); } private static void SetupBossHud(HudData hudData) { //IL_0010: 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_0053: Unknown result type (might be due to invalid IL or missing references) SetupName(hudData, PluginConfig.BossHudNameTextFontSize.Value, PluginConfig.BossHudNameTextColor.Value); SetupHud(hudData, PluginConfig.BossHudHealthTextFontSize.Value, PluginConfig.BossHudHealthTextFontColor.Value, PluginConfig.BossHudHealthBarWidth.Value, PluginConfig.BossHudHealthBarHeight.Value); hudData.m_healthFast.SetColor(PluginConfig.BossHudHealthBarColor.Value); } private static void SetupEnemyHud(HudData hudData) { //IL_0010: 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_005f: Unknown result type (might be due to invalid IL or missing references) SetupName(hudData, PluginConfig.EnemyHudNameTextFontSize.Value, PluginConfig.EnemyHudNameTextColor.Value); SetupHud(hudData, PluginConfig.EnemyHudHealthTextFontSize.Value, PluginConfig.EnemyHudHealthTextColor.Value, PluginConfig.EnemyHudHealthBarWidth.Value, PluginConfig.EnemyHudHealthBarHeight.Value); SetupAlerted(hudData); SetupAware(hudData); hudData.m_healthFast.SetColor(PluginConfig.EnemyHudHealthBarColor.Value); } private static void SetupName(HudData hudData, int nameTextFontSize, Color nameTextColor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) //IL_006d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) hudData.m_name.SetColor<TextMeshProUGUI>(nameTextColor).SetFontSize<TextMeshProUGUI>((float)nameTextFontSize).SetTextWrappingMode<TextMeshProUGUI>((TextWrappingModes)0) .SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0) .SetAlignment<TextMeshProUGUI>((TextAlignmentOptions)1026) .SetEnableAutoSizing<TextMeshProUGUI>(enableAutoSizing: false); ((Component)hudData.m_name).GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0f)) .SetPosition(new Vector2(0f, 8f)) .SetSizeDelta(new Vector2(((TMP_Text)hudData.m_name).preferredWidth, ((TMP_Text)hudData.m_name).preferredHeight)); } private static void SetupHud(HudData hudData, int healthTextFontSize, Color healthTextFontColor, float healthBarWidth, float healthBarHeight) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) Transform val = hudData.m_gui.transform.Find("Health"); ((Component)val).GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 1f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(healthBarWidth, healthBarHeight)); SetupHealthBars(hudData, healthBarWidth, healthBarHeight); TextMeshProUGUI value = CreateHealthText(hudData, val, healthTextFontSize, healthTextFontColor); _healthTextCache.Add(hudData, value); SetupLevel(hudData, val); } private static void SetupHealthBars(HudData hudData, float healthBarWidth, float healthBarHeight) { //IL_0017: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00e4: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) hudData.m_healthFast.m_width = healthBarWidth; ((Component)hudData.m_healthFast).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); hudData.m_healthFast.m_bar.SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(healthBarWidth, healthBarHeight)); ((Component)hudData.m_healthFast).gameObject.SetActive(true); hudData.m_healthSlow.m_width = healthBarWidth; ((Component)hudData.m_healthSlow).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); hudData.m_healthSlow.m_bar.SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(healthBarWidth, healthBarHeight)); ((Component)hudData.m_healthSlow).gameObject.SetActive(true); GuiBar obj = hudData.m_healthFastFriendly.Ref<GuiBar>(); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } } private static void SetupLevel(HudData hudData, Transform healthTransform) { if (hudData.m_character.m_level > (hudData.m_character.IsBoss() ? 1 : 3)) { CreateEnemyLevelText(hudData, healthTransform); RectTransform obj = hudData.m_level2.Ref<RectTransform>(); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } RectTransform obj2 = hudData.m_level3.Ref<RectTransform>(); if (obj2 != null) { ((Component)obj2).gameObject.SetActive(false); } } else { SetupEnemyLevelStars(hudData, healthTransform); } } private static void SetupAlerted(HudData hudData) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)hudData.m_alerted)) { TextMeshProUGUI component = ((Component)hudData.m_alerted).GetComponent<TextMeshProUGUI>(); ((Transform)hudData.m_alerted).SetParent(((TMP_Text)hudData.m_name).transform, false); hudData.m_alerted.SetAnchorMin(new Vector2(0.5f, 1f)).SetAnchorMax(new Vector2(0.5f, 1f)).SetPivot(new Vector2(0.5f, 0f)) .SetPosition(Vector2.zero) .SetSizeDelta(((TMP_Text)component).GetPreferredValues()); ((Component)hudData.m_alerted).gameObject.SetActive(!PluginConfig.EnemyHudUseNameForStatus.Value); } } private static void SetupAware(HudData hudData) { //IL_0037: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) if (Object.op_Implicit((Object)(object)hudData.m_aware)) { ((Transform)hudData.m_aware).SetParent(((TMP_Text)hudData.m_name).transform, false); hudData.m_aware.SetAnchorMin(new Vector2(0.5f, 1f)).SetAnchorMax(new Vector2(0.5f, 1f)).SetPivot(new Vector2(0.5f, 0f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(30f, 30f)); ((Component)hudData.m_aware).gameObject.SetActive(!PluginConfig.EnemyHudUseNameForStatus.Value); } } private static TextMeshProUGUI CreateHealthText(HudData hudData, Transform parentTransform, int healthTextFontSize, Color healthTextFontColor) { //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_0047: 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_0070: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(hudData.m_name); ((TMP_Text)obj).transform.SetParent(parentTransform, false); ((Object)obj).name = "HealthText"; ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero); ((TMP_Text)obj).text = string.Empty; ((TMP_Text)obj).fontSize = healthTextFontSize; ((Graphic)obj).color = healthTextFontColor; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; return obj; } private static TextMeshProUGUI CreateEnemyLevelText(HudData hudData, Transform healthTransform) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = Object.Instantiate<TextMeshProUGUI>(hudData.m_name); ((Object)val).name = "LevelText"; ((TMP_Text)val).text = string.Empty; ((TMP_Text)val).fontSize = Mathf.Clamp((float)(int)((TMP_Text)hudData.m_name).fontSize, (float)PluginConfig.EnemyLevelTextMinFontSize.Value, 64f); ((Graphic)val).color = new Color(1f, 0.85882f, 0.23137f, 1f); ((TMP_Text)val).enableAutoSizing = false; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; if (PluginConfig.EnemyLevelShowByName.Value) { ((TMP_Text)val).transform.SetParent(((TMP_Text)hudData.m_name).transform, false); ((Component)val).GetComponent<RectTransform>().SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)) .SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(5f, 0f)) .SetSizeDelta(new Vector2(100f, ((TMP_Text)val).GetPreferredValues().y + 5f)); ((TMP_Text)val).alignment = (TextAlignmentOptions)513; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; } else { ((TMP_Text)val).transform.SetParent(healthTransform, false); Vector2 sizeDelta = ((Component)healthTransform).GetComponent<RectTransform>().sizeDelta; sizeDelta.y = ((TMP_Text)val).GetPreferredValues().y * 2f; ((Component)val).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.zero) .SetPivot(Vector2.zero) .SetPosition(new Vector2(0f, 0f - sizeDelta.y - 2f)) .SetSizeDelta(sizeDelta); ((TMP_Text)val).alignment = (TextAlignmentOptions)257; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)1; } int num = hudData.m_character.m_level - 1; ((TMP_Text)val).SetText((num <= PluginConfig.EnemyLevelStarCutoff.Value) ? string.Concat(Enumerable.Repeat(PluginConfig.EnemyLevelStarSymbol.Value, num)) : $"{num}{PluginConfig.EnemyLevelStarSymbol.Value}"); return val; } private static void SetupEnemyLevelStars(HudData hudData, Transform healthTransform) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)hudData.m_level2)) { if (PluginConfig.EnemyLevelShowByName.Value) { ((Transform)hudData.m_level2).SetParent(((TMP_Text)hudData.m_name).transform); hudData.m_level2.SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(12f, 0f)) .SetSizeDelta(Vector2.zero); } else { ((Transform)hudData.m_level2).SetParent(healthTransform, false); hudData.m_level2.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.zero).SetPivot(Vector2.zero) .SetPosition(new Vector2(7.5f, -10f)) .SetSizeDelta(Vector2.zero); } ((Component)hudData.m_level2).gameObject.SetActive(hudData.m_character.GetLevel() == 2); } if (Object.op_Implicit((Object)(object)hudData.m_level3)) { if (PluginConfig.EnemyLevelShowByName.Value) { ((Transform)hudData.m_level3).SetParent(((TMP_Text)hudData.m_name).transform, false); hudData.m_level3.SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(20f, 0f)) .SetSizeDelta(Vector2.zero); } else { ((Transform)hudData.m_level3).SetParent(healthTransform, false); hudData.m_level3.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.zero).SetPivot(Vector2.zero) .SetPosition(new Vector2(15.5f, -10f)) .SetSizeDelta(Vector2.zero); } ((Component)hudData.m_level3).gameObject.SetActive(hudData.m_character.GetLevel() == 3); } } [HarmonyPrefix] [HarmonyPatch("UpdateHuds")] private static bool UpdateHudsPrefix(ref EnemyHud __instance, ref Player player, ref Sadle sadle, float dt) { if (PluginConfig.IsModEnabled.Value) { EnemyHudUpdater.UpdateHuds(ref __instance, ref player, ref sadle, dt, _healthTextCache); return false; } return true; } [HarmonyTranspiler] [HarmonyPatch("LateUpdate")] private static IEnumerable<CodeInstruction> LateUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Stloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null) }).Advance(3).SetInstructionAndAdvance(Transpilers.EmitDelegate<Func<Character, Player, bool>>((Func<Character, Player, bool>)CharacterLocalPlayerEqualityDelegate)) .InstructionEnumeration(); } private static bool CharacterLocalPlayerEqualityDelegate(Character character, Player player) { if (PluginConfig.PlayerHudShowLocalPlayer.Value) { return false; } return (Object)(object)character == (Object)(object)player; } [HarmonyPostfix] [HarmonyPatch("TestShow")] private static void TestShowPostfix(ref EnemyHud __instance, ref Character c, ref bool __result) { if (__result && (Object)(object)c == (Object)(object)Player.m_localPlayer) { __result = PluginConfig.IsModEnabled.Value && PluginConfig.PlayerHudShowLocalPlayer.Value; } } } [HarmonyPatch(typeof(FejdStartup))] internal static class FejdStartupPatch { private static readonly HashSet<string> _targetHarmonyIds = new HashSet<string> { "MK_BetterUI" }; [HarmonyPostfix] [HarmonyPatch("Awake")] [HarmonyPriority(0)] private static void AwakePostfix() { UnpatchIfPatched(typeof(EnemyHud)); } private static void UnpatchIfPatched(Type type) { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)declaredMethod); if (patchInfo == null) { continue; } foreach (string owner in patchInfo.Owners) { if (_targetHarmonyIds.Contains(owner)) { ZLog.Log((object)("Unpatching all '" + owner + "' patches on " + type.FullName + "." + declaredMethod.Name)); Harmony harmonyInstance = Enhuddlement.HarmonyInstance; if (harmonyInstance != null) { harmonyInstance.Unpatch((MethodBase)declaredMethod, (HarmonyPatchType)0, owner); } } } } } } public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<bool> ShowEnemyHealthValue { get; private set; } public static ConfigEntry<bool> PlayerHudShowLocalPlayer { get; private set; } public static ConfigEntry<Vector3> PlayerHudPositionOffset { get; private set; } public static ConfigEntry<int> PlayerHudNameTextFontSize { get; private set; } public static ConfigEntry<Color> PlayerHudNameTextColor { get; private set; } public static ConfigEntry<Color> PlayerHudNameTextPvPColor { get; private set; } public static ConfigEntry<int> PlayerHudHealthTextFontSize { get; private set; } public static ConfigEntry<Color> PlayerHudHealthTextColor { get; private set; } public static ConfigEntry<float> PlayerHudHealthBarWidth { get; private set; } public static ConfigEntry<float> PlayerHudHealthBarHeight { get; private set; } public static ConfigEntry<Color> PlayerHudHealthBarColor { get; private set; } public static ConfigEntry<bool> FloatingBossHud { get; private set; } public static ConfigEntry<Vector3> BossHudPositionOffset { get; private set; } public static ConfigEntry<int> BossHudNameTextFontSize { get; private set; } public static ConfigEntry<Color> BossHudNameTextColor { get; private set; } public static ConfigEntry<int> BossHudHealthTextFontSize { get; private set; } public static ConfigEntry<Color> BossHudHealthTextFontColor { get; private set; } public static ConfigEntry<float> BossHudHealthBarWidth { get; private set; } public static ConfigEntry<float> BossHudHealthBarHeight { get; private set; } public static ConfigEntry<Color> BossHudHealthBarColor { get; private set; } public static ConfigEntry<Vector3> EnemyHudPositionOffset { get; private set; } public static ConfigEntry<int> EnemyHudNameTextFontSize { get; private set; } public static ConfigEntry<Color> EnemyHudNameTextColor { get; private set; } public static ConfigEntry<bool> EnemyHudUseNameForStatus { get; private set; } public static ConfigEntry<Color> EnemyHudNameTextAlertedColor { get; private set; } public static ConfigEntry<Color> EnemyHudNameTextAwareColor { get; private set; } public static ConfigEntry<Color> EnemyHudHealthTextColor { get; private set; } public static ConfigEntry<int> EnemyHudHealthTextFontSize { get; private set; } public static ConfigEntry<float> EnemyHudHealthBarWidth { get; private set; } public static ConfigEntry<float> EnemyHudHealthBarHeight { get; private set; } public static ConfigEntry<Color> EnemyHudHealthBarColor { get; private set; } public static ConfigEntry<Color> EnemyHudHealthBarFriendlyColor { get; private set; } public static ConfigEntry<Color> EnemyHudHealthBarTamedColor { get; private set; } public static ConfigEntry<bool> EnemyLevelShowByName { get; private set; } public static ConfigEntry<string> EnemyLevelStarSymbol { get; private set; } public static ConfigEntry<int> EnemyLevelStarCutoff { get; private set; } public static ConfigEntry<int> EnemyLevelTextMinFontSize { get; private set; } public static void BindConfig(ConfigFile config) { IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod."); ShowEnemyHealthValue = config.BindInOrder("EnemyHud", "showEnemyHealthValue", defaultValue: true, "Show enemy health values."); BindPlayerHudConfig(config); BindBossHudConfig(config); BindEnemyHudConfig(config); BindEnemyLevelConfig(config); } public static void BindPlayerHudConfig(ConfigFile config) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_017d: Unknown result type (might be due to invalid IL or missing references) PlayerHudShowLocalPlayer = config.BindInOrder("PlayerHud", "showLocalPlayer", defaultValue: false, "If true, shows a PlayerHud for the local player."); PlayerHudPositionOffset = config.BindInOrder<Vector3>("PlayerHud.Position", "positionOffset", new Vector3(0f, 0.3f, 0f), "PlayerHud position offset from head point."); PlayerHudNameTextFontSize = config.BindInOrder("PlayerHud.Name", "nameTextFontSize", 20, "PlayerHud.Name text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); PlayerHudNameTextColor = config.BindInOrder<Color>("PlayerHud.Name", "nameTextColor", new Color(1f, 0.7176f, 0.3603f, 1f), "PlayerHud.Name text color."); PlayerHudNameTextPvPColor = config.BindInOrder<Color>("PlayerHud.Name", "nameTextPvPColor", Color.red, "PlayerHud.Name text color when player has PvP enabled."); PlayerHudHealthTextFontSize = config.BindInOrder("PlayerHud.HealthText", "healthTextFontSize", 16, "PlayerHud.HealthText text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); PlayerHudHealthTextColor = config.BindInOrder<Color>("PlayerHud.HealthText", "healthTextColor", Color.white, "PlayerHud.HealthText text color."); PlayerHudHealthBarWidth = config.BindInOrder("PlayerHud.HealthBar", "healthBarWidth", 125f, "PlayerHud.HealthBar width (vanilla: 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f)); PlayerHudHealthBarHeight = config.BindInOrder("PlayerHud.HealthBar", "healthBarHeight", 22f, "PlayerHud.HealthBar height (vanilla: 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f)); PlayerHudHealthBarColor = config.BindInOrder<Color>("PlayerHud.HealthBar", "healthBarColor", new Color(0.2638f, 1f, 0.125f, 1f), "PlayerHud.HealthBar fast color for regular players."); } public static void BindBossHudConfig(ConfigFile config) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) FloatingBossHud = config.BindInOrder("BossHud", "floatingBossHud", defaultValue: true, "If set, each BossHud will float over the target enemy."); BossHudPositionOffset = config.BindInOrder<Vector3>("BossHud.Position", "positionOffset", new Vector3(0f, 1f, 0f), "BossHud position offset from top point."); BossHudNameTextFontSize = config.BindInOrder("BossHud.Name", "nameTextFontSize", 32, "BossHud.Name text font size (vanilla: 32).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 64)); BossHudNameTextColor = config.BindInOrder<Color>("BossHud.Name", "nameTextColor", Color.white, "BossHud.Name text color."); BossHudHealthTextFontSize = config.BindInOrder("BossHud.HealthText", "healthTextFontSize", 24, "BossHud.HealthText font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 64)); BossHudHealthTextFontColor = config.BindInOrder<Color>("BossHud.HealthText", "healthTextColor", Color.white, "BossHud.HealthText text color."); BossHudHealthBarWidth = config.BindInOrder("BossHud.HealthBar", "healthBarWidth", 300f, "BossHud.HealthBar width (vanilla: 600).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f)); BossHudHealthBarHeight = config.BindInOrder("BossHud.HealthBar", "healthBarHeight", 30f, "BossHud.HealthBar height (vanilla: 15).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f)); BossHudHealthBarColor = config.BindInOrder<Color>("BossHud.HealthBar", "healthBarColor", new Color(1f, 0f, 0.3931f, 1f), "BossHud.HealthBar fast color."); } public static void BindEnemyHudConfig(ConfigFile config) { //IL_001a: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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) //IL_01da: Unknown result type (might be due to invalid IL or missing references) EnemyHudPositionOffset = config.BindInOrder<Vector3>("EnemyHud.Position", "positionOffset", new Vector3(0f, 0.1f, 0f), "EnemyHud position offset from top point."); EnemyHudNameTextFontSize = config.BindInOrder("EnemyHud.Name", "nameTextFontSize", 16, "EnemyHud.Name text font size (vanilla: 16).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); EnemyHudNameTextColor = config.BindInOrder<Color>("EnemyHud.Name", "nameTextColor", Color.white, "EnemyHud.Name text color (vanilla: white)."); EnemyHudUseNameForStatus = config.BindInOrder("EnemyHud.Name.Status", "useNameForStatus", defaultValue: true, "Use the EnemyHud.Name text color for alerted/aware status."); EnemyHudNameTextAlertedColor = config.BindInOrder<Color>("EnemyHud.Name.Status", "nameTextAlertedColor", Color.red, "EnemyHud.Name text color for alerted status."); EnemyHudNameTextAwareColor = config.BindInOrder<Color>("EnemyHud.Name.Status", "nameTextAwareColor", Color.yellow, "EnemyHud.Name text color for aware status."); EnemyHudHealthTextFontSize = config.BindInOrder("EnemyHud.HealthText", "healthTextFontSize", 14, "EnemyHud.HealthText text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); EnemyHudHealthTextColor = config.BindInOrder<Color>("EnemyHud.HealthText", "healthTextColor", Color.white, "EnemyHud.HealthText text color."); EnemyHudHealthBarWidth = config.BindInOrder("EnemyHud.HealthBar", "healthBarWidth", 125f, "EnemyHud.HealthBar width (vanilla: 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f)); EnemyHudHealthBarHeight = config.BindInOrder("EnemyHud.HealthBar", "healthBarHeight", 22f, "EnemyHud.HealthBar height (vanilla: 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f)); EnemyHudHealthBarColor = config.BindInOrder<Color>("EnemyHud.HealthBar", "healthBarColor", new Color(1f, 0.333f, 0.333f, 1f), "EnemyHud.HealthBar fast color for regular mobs."); EnemyHudHealthBarFriendlyColor = config.BindInOrder<Color>("EnemyHud.HealthBar", "healthBarFriendlyColor", new Color(0.2638f, 1f, 0.125f, 1f), "EnemyHud.HealthBar fast color for friendly (but not tamed) mobs."); EnemyHudHealthBarTamedColor = config.BindInOrder<Color>("EnemyHud.HealthBar", "healthBarTamedColor", Color.green, "EnemyHud.HealthBar fast color for tamed mobs."); } public static void BindEnemyLevelConfig(ConfigFile config) { EnemyLevelShowByName = config.BindInOrder("EnemyLevel", "enemyLevelShowByName", defaultValue: false, "If true, shows the enemy level after the name, otherwise below healthbar."); EnemyLevelStarSymbol = config.BindInOrder("EnemyLevel", "enemyLevelStarSymbol", "★", "Symbol to use for 'star' for enemy levels above vanilla 2*.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[5] { "★", "✪", "✵", "✭", "✫" })); EnemyLevelStarCutoff = config.BindInOrder("EnemyLevel", "enemyLevelStarCutoff", 2, "When showing enemy levels using stars, max stars to show before switching to 'X★' format.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10)); EnemyLevelTextMinFontSize = config.BindInOrder("EnemyLevel", "enemyLevelMinFontSize", 20, "Sets a minimum font size for the enemy level text which is inherited from enemy name text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); } } public static class CodeMatcherExtensions { public static CodeMatcher SaveOperand(this CodeMatcher matcher, out object operand) { operand = matcher.Operand; return matcher; } } public static class ObjectExtensions { public static T Ref<T>(this T o) where T : Object { if (!Object.op_Implicit((Object)(object)o)) { return default(T); } return o; } } }