Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValheimProfiler v1.1.13
ValheimProfiler.dll
Decompiled 2 weeks 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.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using ValheimProfiler.Configuration; using ValheimProfiler.Core; using ValheimProfiler.Core.Logging; using ValheimProfiler.Core.Profiling; using ValheimProfiler.Server; using ValheimProfiler.Tools.GeneralMethodProfiler; using ValheimProfiler.Tools.LogMonitor; using ValheimProfiler.Tools.MonoBehaviourCallProfiler; using ValheimProfiler.Tools.MonoBehaviourProfiler; using ValheimProfiler.Tools.NetworkProfiler; using ValheimProfiler.Tools.PatchProfiler; using ValheimProfiler.Tools.ServerLogMonitor; using ValheimProfiler.Tools.ValheimUpdateProfiler; using ValheimProfiler.UI; using ValheimProfiler.Valheim; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyFileVersion("1.1.13")] [assembly: AssemblyInformationalVersion("1.1.13")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ValheimProfiler")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyProduct("ValheimProfiler")] [assembly: AssemblyTitle("ValheimProfiler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.13.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ValheimProfiler { [BepInPlugin("shudnal.ValheimProfiler", "Valheim Profiler", "1.1.13")] public sealed class ValheimProfilerPlugin : BaseUnityPlugin { public const string PluginGuid = "shudnal.ValheimProfiler"; public const string PluginName = "Valheim Profiler"; public const string PluginVersion = "1.1.13"; internal const string CoreHarmonyId = "shudnal.ValheimProfiler.Core"; private Harmony _coreHarmony; private bool _headlessServerBackend; internal static ValheimProfilerPlugin Instance { get; private set; } internal ValheimProfilerApp App { get; private set; } internal ServerLogService ServerLogService { get; private set; } internal NetworkProfilerService NetworkProfilerService { get; private set; } private void Awake() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 Instance = this; ValheimProfilerConfig config = new ValheimProfilerConfig(((BaseUnityPlugin)this).Config); _coreHarmony = new Harmony("shudnal.ValheimProfiler.Core"); _headlessServerBackend = (int)SystemInfo.graphicsDeviceType == 4; if (_headlessServerBackend) { ServerLogService = new ServerLogService(config); NetworkProfilerService = new NetworkProfilerService(); PatchHeadlessNetworkBridges(); ServerLogRpcBridge.RegisterForCurrentNetwork(); NetworkProfilerRpcBridge.RegisterForCurrentNetwork(); } else { App = new ValheimProfilerApp(config, ((BaseUnityPlugin)this).Logger); _coreHarmony.PatchAll(typeof(ValheimProfilerPlugin).Assembly); App.Initialize(); ServerLogRpcBridge.RegisterForCurrentNetwork(); NetworkProfilerRpcBridge.RegisterForCurrentNetwork(); } } private void PatchHeadlessNetworkBridges() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown _coreHarmony.Patch((MethodBase)AccessTools.Method(typeof(ZNet), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ZNetAwakeServerLogPatch), "Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _coreHarmony.Patch((MethodBase)AccessTools.Method(typeof(ZNet), "OnDestroy", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(ZNetOnDestroyServerLogPatch), "Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private void Start() { App?.MarkGameWindowReady(); } private void Update() { if (_headlessServerBackend) { ServerLogService?.Update(); NetworkProfilerService?.Update(); } else { App?.Update(); } } private void LateUpdate() { App?.LateUpdate(); } private void OnGUI() { App?.OnGUI(); } private void OnApplicationFocus(bool focused) { App?.OnApplicationFocus(focused); } private void OnDisable() { App?.SetUiVisible(visible: false); App?.ReleaseCursorAndPause(); } private void OnDestroy() { try { App?.Shutdown(); ServerLogService?.Shutdown(); NetworkProfilerService?.Shutdown(); } finally { Harmony coreHarmony = _coreHarmony; if (coreHarmony != null) { coreHarmony.UnpatchSelf(); } _coreHarmony = null; App = null; ServerLogService = null; NetworkProfilerService = null; ServerLogTransport.Clear(); NetworkProfilerTransport.Clear(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } } } namespace ValheimProfiler.Valheim { [HarmonyPatch] internal static class GuiPointScalingPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(GUIUtility), "ScreenToGUIPoint", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(GUIUtility), "GUIToScreenPoint", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static void Prefix(ref Matrix4x4 __state) { //IL_003d: 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_0047: Unknown result type (might be due to invalid IL or missing references) ValheimProfilerPlugin instance = ValheimProfilerPlugin.Instance; if (instance != null && instance.App?.IsDrawingUi == true) { __state = GUI.matrix; GUI.matrix = Matrix4x4.identity; } } [HarmonyPriority(800)] private static void Postfix(Matrix4x4 __state) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) ValheimProfilerPlugin instance = ValheimProfilerPlugin.Instance; if (instance != null && instance.App?.IsDrawingUi == true) { GUI.matrix = __state; } } } internal sealed class ValheimCursorController { private bool _acquired; private CursorLockMode _savedLockState; private bool _savedRequested; private bool _savedVisible; private bool _savedHardwareVisible; internal void Update(bool active) { if (active) { Acquire(); } else { Release(); } } internal void LateUpdate(bool active) { if (active) { ApplyWindowCursor(); } } internal void OnGUI(bool active) { if (active) { ApplyWindowCursor(); } } internal void OnApplicationFocus(bool focused, bool active) { if (focused && active) { ApplyWindowCursor(); } } internal void ApplyWindowCursor() { ValheimProfilerPlugin instance = ValheimProfilerPlugin.Instance; if (instance != null && instance.App?.HasVisibleWindows == true && Application.isFocused) { ZCursor.LockState = (CursorLockMode)0; if (ZInput.instance != null) { ZCursor.Show(); } else { Cursor.visible = true; } } } internal void Release() { //IL_00d9: 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) if (!_acquired) { return; } _acquired = false; if (ZInput.instance != null) { if (Object.op_Implicit((Object)(object)GameCamera.instance)) { GameCamera.instance.UpdateMouseCapture(); if (Object.op_Implicit((Object)(object)Menu.instance) && Menu.IsActive()) { Menu.instance.UpdateCursor(); } } else if (Object.op_Implicit((Object)(object)FejdStartup.instance)) { FejdStartup.instance.UpdateCursor(); } else if (Object.op_Implicit((Object)(object)Menu.instance) && Menu.IsActive()) { Menu.instance.UpdateCursor(); } else { ZCursor.LockState = _savedLockState; ZCursor.SetRequested(_savedRequested); ZCursor.SetVisible(_savedVisible); } } else { ZCursor.LockState = _savedLockState; Cursor.visible = _savedHardwareVisible; } } private void Acquire() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!_acquired) { _savedLockState = ZCursor.LockState; _savedRequested = ZCursor.IsRequested; _savedVisible = ZCursor.IsVisible; _savedHardwareVisible = Cursor.visible; _acquired = true; } ApplyWindowCursor(); } } [HarmonyPatch] internal static class NativeCursorWindowOverridePatch { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo gameCamera = AccessTools.DeclaredMethod(typeof(GameCamera), "UpdateMouseCapture", (Type[])null, (Type[])null); MethodInfo menu = AccessTools.DeclaredMethod(typeof(Menu), "UpdateCursor", (Type[])null, (Type[])null); MethodInfo fejd = AccessTools.DeclaredMethod(typeof(FejdStartup), "UpdateCursor", (Type[])null, (Type[])null); if (gameCamera != null) { yield return gameCamera; } if (menu != null) { yield return menu; } if (fejd != null) { yield return fejd; } } [HarmonyPriority(800)] private static bool Prefix() { ValheimProfilerApp valheimProfilerApp = ValheimProfilerPlugin.Instance?.App; if (valheimProfilerApp == null || !valheimProfilerApp.HasVisibleWindows || !Application.isFocused) { return true; } valheimProfilerApp.ApplyCursorOverride(); return false; } } internal enum ValheimInputBlockMode { Off, Mouse, All } internal static class ValheimInputState { private static int _releaseUntilFrame = -1; private static ValheimInputBlockMode _releasedMode; private static ValheimInputBlockMode _lastLiveMode; private static readonly List<Vector2> NoTouchPoints = new List<Vector2>(); internal static bool ShouldBlockAll => CurrentMode == ValheimInputBlockMode.All; internal static bool ShouldBlockMouse => CurrentMode != ValheimInputBlockMode.Off; internal static List<Vector2> EmptyTouchPoints { get { NoTouchPoints.Clear(); return NoTouchPoints; } } private static ValheimInputBlockMode CurrentMode { get { ValheimProfilerApp valheimProfilerApp = ValheimProfilerPlugin.Instance?.App; if (valheimProfilerApp != null && valheimProfilerApp.HasVisibleWindows) { return ResolveLiveMode(valheimProfilerApp); } return (Time.frameCount <= _releaseUntilFrame) ? _releasedMode : ValheimInputBlockMode.Off; } } internal static void Synchronize() { ValheimProfilerApp valheimProfilerApp = ValheimProfilerPlugin.Instance?.App; ValheimInputBlockMode valheimInputBlockMode = ((valheimProfilerApp != null && valheimProfilerApp.HasVisibleWindows) ? ResolveLiveMode(valheimProfilerApp) : ValheimInputBlockMode.Off); if (valheimInputBlockMode == _lastLiveMode) { return; } ValheimInputBlockMode lastLiveMode = _lastLiveMode; _lastLiveMode = valheimInputBlockMode; if (valheimInputBlockMode != ValheimInputBlockMode.Off) { _releaseUntilFrame = -1; _releasedMode = ValheimInputBlockMode.Off; CancelInventoryDrag(); ResetGameButtonStates(); } else if (lastLiveMode != ValheimInputBlockMode.Off) { _releasedMode = lastLiveMode; _releaseUntilFrame = Time.frameCount + 1; ResetGameButtonStates(); if (lastLiveMode == ValheimInputBlockMode.All) { PlayerController.SetTakeInputDelay(Mathf.Max(PlayerController.takeInputDelay, 0.1f)); } } } internal static void Reset() { _releaseUntilFrame = -1; _releasedMode = ValheimInputBlockMode.Off; _lastLiveMode = ValheimInputBlockMode.Off; } private static ValheimInputBlockMode ResolveLiveMode(ValheimProfilerApp app) { if (app == null) { return ValheimInputBlockMode.Off; } if (app.Config.BlockGameInput.Value) { return ValheimInputBlockMode.All; } if (app.Config.BlockMouseInput.Value) { return ValheimInputBlockMode.Mouse; } return ValheimInputBlockMode.Off; } private static void CancelInventoryDrag() { if (Object.op_Implicit((Object)(object)InventoryGui.instance)) { InventoryGui.instance.SetupDragItem((ItemData)null, (Inventory)null, 0); } } private static void ResetGameButtonStates() { if (ZInput.instance != null) { ZInput.ResetAllButtonStates(); } } } internal static class ZInputPatchMethods { private const BindingFlags AllMethods = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; internal static IEnumerable<MethodBase> FindBooleanMethods(params string[] names) { HashSet<string> acceptedNames = new HashSet<string>(names ?? Array.Empty<string>(), StringComparer.Ordinal); return (from method in typeof(ZInput).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where method.ReturnType == typeof(bool) && acceptedNames.Contains(method.Name) select method).Cast<MethodBase>().Distinct(); } internal static IEnumerable<MethodBase> FindStringButtonMethods() { return FindBooleanMethods("GetButton", "GetButtonDown", "GetButtonUp").Where(delegate(MethodBase method) { ParameterInfo[] parameters = method.GetParameters(); return parameters.Length != 0 && parameters[0].ParameterType == typeof(string); }); } } internal static class ZInputMouseBindingResolver { private sealed class CachedMouseBindings { public bool DefinitionFound; public bool BindingSourceResolved; public object ButtonAction; public object[] MouseControls = Array.Empty<object>(); public int MouseButtonMask; } private const BindingFlags InstanceMembers = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly Dictionary<string, CachedMouseBindings> BindingCache = new Dictionary<string, CachedMouseBindings>(StringComparer.Ordinal); internal static void ClearCache() { BindingCache.Clear(); } internal static void Invalidate(string action) { if (!string.IsNullOrWhiteSpace(action)) { BindingCache.Remove(action); } } internal static bool IsMouseBindingActive(string action, string queryMethodName, bool actionResultIsKnownTrue = false) { if (string.IsNullOrWhiteSpace(action)) { return false; } CachedMouseBindings configuredMouseBindings = GetConfiguredMouseBindings(action); if (configuredMouseBindings.DefinitionFound) { object memberValue = GetMemberValue(configuredMouseBindings.ButtonAction, "activeControl"); if (memberValue != null) { bool flag = IsMouseControl(memberValue); bool flag2 = IsControlActive(memberValue, queryMethodName); if (flag && (actionResultIsKnownTrue || flag2)) { return true; } if (!flag && (actionResultIsKnownTrue || flag2)) { return false; } } for (int i = 0; i < configuredMouseBindings.MouseControls.Length; i++) { if (IsControlActive(configuredMouseBindings.MouseControls[i], queryMethodName)) { return true; } } int num = configuredMouseBindings.MouseButtonMask; int num2 = 0; while (num != 0 && num2 < 31) { if ((num & 1) != 0 && IsMouseButtonActive(num2, queryMethodName)) { return true; } num2++; num >>= 1; } if (configuredMouseBindings.BindingSourceResolved) { return false; } } if (1 == 0) { } int num3; switch (action) { case "Attack": num3 = 0; break; case "Block": case "BuildMenu": num3 = 1; break; case "SecondaryAttack": case "Remove": num3 = 2; break; default: num3 = -1; break; } if (1 == 0) { } int num4 = num3; return num4 >= 0 && IsMouseButtonActive(num4, queryMethodName); } private static CachedMouseBindings GetConfiguredMouseBindings(string action) { if (BindingCache.TryGetValue(action, out var value)) { return value; } CachedMouseBindings cachedMouseBindings = ResolveConfiguredMouseBindings(action); BindingCache[action] = cachedMouseBindings; return cachedMouseBindings; } private static CachedMouseBindings ResolveConfiguredMouseBindings(string action) { CachedMouseBindings cachedMouseBindings = new CachedMouseBindings(); try { ZInput instance = ZInput.instance; if (instance?.m_buttons == null || !instance.m_buttons.TryGetValue(action, out var value)) { return cachedMouseBindings; } cachedMouseBindings.DefinitionFound = true; ResolveDirectButtonDefinition(value, cachedMouseBindings); object memberValue = GetMemberValue(value, "ButtonAction"); if (memberValue == null) { memberValue = GetMemberValue(value, "m_buttonAction"); } if (memberValue == null) { return cachedMouseBindings; } cachedMouseBindings.BindingSourceResolved = true; cachedMouseBindings.ButtonAction = memberValue; object memberValue2 = GetMemberValue(memberValue, "bindings"); if (memberValue2 is IEnumerable enumerable) { foreach (object item in enumerable) { string text = GetMemberValue(item, "effectivePath") as string; if (string.IsNullOrWhiteSpace(text)) { text = GetMemberValue(item, "path") as string; } if (TryParseMouseButton(text, out var mouseButton) && mouseButton < 31) { cachedMouseBindings.MouseButtonMask |= 1 << mouseButton; } } } object memberValue3 = GetMemberValue(memberValue, "controls"); if (memberValue3 is IEnumerable enumerable2) { List<object> list = new List<object>(); foreach (object item2 in enumerable2) { if (item2 != null && IsMouseControl(item2)) { list.Add(item2); } } cachedMouseBindings.MouseControls = list.ToArray(); } } catch { return new CachedMouseBindings(); } return cachedMouseBindings; } private static void ResolveDirectButtonDefinition(object definition, CachedMouseBindings resolved) { if (definition == null || resolved == null) { return; } bool value; bool flag = TryGetBooleanMember(definition, "m_bMouseButtonSet", out value) || TryGetBooleanMember(definition, "m_mouseButtonSet", out value); object memberValue = GetMemberValue(definition, "m_mouseButton"); int mouseButton2; if (flag) { resolved.BindingSourceResolved = true; if (value && TryConvertMouseButton(memberValue, out var mouseButton)) { resolved.MouseButtonMask |= 1 << mouseButton; } } else if (memberValue != null && TryConvertMouseButton(memberValue, out mouseButton2)) { string text = memberValue.ToString() ?? string.Empty; if (!text.Equals("None", StringComparison.OrdinalIgnoreCase) && !text.Equals("Back", StringComparison.OrdinalIgnoreCase)) { resolved.BindingSourceResolved = true; resolved.MouseButtonMask |= 1 << mouseButton2; } } object memberValue2 = GetMemberValue(definition, "m_key"); if (memberValue2 != null) { string text2 = memberValue2.ToString() ?? string.Empty; if (TryParseLegacyMouseKeyName(text2, out var mouseButton3)) { resolved.BindingSourceResolved = true; resolved.MouseButtonMask |= 1 << mouseButton3; } else if (!text2.Equals("None", StringComparison.OrdinalIgnoreCase)) { resolved.BindingSourceResolved = true; } } } private static bool TryConvertMouseButton(object value, out int mouseButton) { mouseButton = -1; if (value == null) { return false; } string text = value.ToString() ?? string.Empty; if (text.Equals("Left", StringComparison.OrdinalIgnoreCase) || text.Equals("LeftButton", StringComparison.OrdinalIgnoreCase)) { mouseButton = 0; return true; } if (text.Equals("Right", StringComparison.OrdinalIgnoreCase) || text.Equals("RightButton", StringComparison.OrdinalIgnoreCase)) { mouseButton = 1; return true; } if (text.Equals("Middle", StringComparison.OrdinalIgnoreCase) || text.Equals("MiddleButton", StringComparison.OrdinalIgnoreCase)) { mouseButton = 2; return true; } if (text.Equals("Forward", StringComparison.OrdinalIgnoreCase) || text.Equals("ForwardButton", StringComparison.OrdinalIgnoreCase)) { mouseButton = 3; return true; } if (text.Equals("Back", StringComparison.OrdinalIgnoreCase) || text.Equals("BackButton", StringComparison.OrdinalIgnoreCase)) { mouseButton = 4; return true; } try { int num = Convert.ToInt32(value); if (num >= 0 && num < 31) { mouseButton = num; return true; } } catch { } return false; } private static bool TryParseLegacyMouseKeyName(string keyName, out int mouseButton) { mouseButton = -1; if (string.IsNullOrWhiteSpace(keyName) || !keyName.StartsWith("Mouse", StringComparison.OrdinalIgnoreCase)) { return false; } return int.TryParse(keyName.Substring(5), out mouseButton) && mouseButton >= 0 && mouseButton < 31; } private static object GetMemberValue(object instance, string memberName) { if (instance == null || string.IsNullOrEmpty(memberName)) { return null; } try { Type type = instance.GetType(); PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.GetIndexParameters().Length == 0) { return property.GetValue(instance, null); } return type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance); } catch { return null; } } private static bool TryGetBooleanMember(object instance, string memberName, out bool value) { value = false; if (!(GetMemberValue(instance, memberName) is bool flag) || 1 == 0) { return false; } value = flag; return true; } private static bool IsMouseControl(object control) { if (control == null) { return false; } string text = GetMemberValue(control, "path") as string; if (!string.IsNullOrWhiteSpace(text) && text.IndexOf("/Mouse/", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } object memberValue = GetMemberValue(control, "device"); string text2 = memberValue?.GetType().FullName ?? string.Empty; if (text2.EndsWith(".Mouse", StringComparison.Ordinal) || string.Equals(memberValue?.GetType().Name, "Mouse", StringComparison.Ordinal)) { return true; } string a = GetMemberValue(memberValue, "displayName") as string; return string.Equals(a, "Mouse", StringComparison.OrdinalIgnoreCase); } private static bool IsControlActive(object control, string queryMethodName) { if (control == null) { return false; } if (1 == 0) { } string text = ((queryMethodName == "GetButtonDown") ? "wasPressedThisFrame" : ((!(queryMethodName == "GetButtonUp")) ? "isPressed" : "wasReleasedThisFrame")); if (1 == 0) { } string memberName = text; if (TryGetBooleanMember(control, memberName, out var value)) { return value; } MethodInfo method = control.GetType().GetMethod("ReadValueAsButton", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null && method.ReturnType == typeof(bool)) { try { return (bool)method.Invoke(control, null); } catch { } } return false; } private static bool TryParseMouseButton(string path, out int mouseButton) { mouseButton = -1; if (string.IsNullOrWhiteSpace(path) || path.IndexOf("<Mouse>", StringComparison.OrdinalIgnoreCase) < 0) { return false; } string text = path.Replace(" ", string.Empty).ToLowerInvariant(); if (text.EndsWith("/leftbutton", StringComparison.Ordinal)) { mouseButton = 0; } else if (text.EndsWith("/rightbutton", StringComparison.Ordinal)) { mouseButton = 1; } else if (text.EndsWith("/middlebutton", StringComparison.Ordinal)) { mouseButton = 2; } else if (text.EndsWith("/forwardbutton", StringComparison.Ordinal)) { mouseButton = 3; } else if (text.EndsWith("/backbutton", StringComparison.Ordinal)) { mouseButton = 4; } else { int num = text.LastIndexOf("/button", StringComparison.Ordinal); if (num < 0 || !int.TryParse(text.Substring(num + 7), out mouseButton)) { return false; } } return mouseButton >= 0; } private static bool IsMouseButtonActive(int mouseButton, string queryMethodName) { if (TryGetInputSystemMouseButton(mouseButton, out var control) && IsControlActive(control, queryMethodName)) { return true; } try { if (1 == 0) { } bool result = ((queryMethodName == "GetButtonDown") ? Input.GetMouseButtonDown(mouseButton) : ((!(queryMethodName == "GetButtonUp")) ? Input.GetMouseButton(mouseButton) : Input.GetMouseButtonUp(mouseButton))); if (1 == 0) { } return result; } catch { return false; } } private static bool TryGetInputSystemMouseButton(int mouseButton, out object control) { control = null; try { object obj = Type.GetType("UnityEngine.InputSystem.Mouse, Unity.InputSystem", throwOnError: false)?.GetProperty("current", BindingFlags.Static | BindingFlags.Public)?.GetValue(null, null); if (obj == null) { return false; } if (1 == 0) { } string text = mouseButton switch { 0 => "leftButton", 1 => "rightButton", 2 => "middleButton", 3 => "forwardButton", 4 => "backButton", _ => null, }; if (1 == 0) { } string text2 = text; if (text2 == null) { return false; } control = GetMemberValue(obj, text2); return control != null; } catch { return false; } } } [HarmonyPatch] internal static class ZInputMouseBindingCachePatch { private static IEnumerable<MethodBase> TargetMethods() { return typeof(ZInput).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where(delegate(MethodInfo method) { if (method.Name == "Load") { return true; } if (method.Name != "AddButton") { return false; } ParameterInfo[] parameters = method.GetParameters(); return parameters.Length != 0 && parameters[0].ParameterType == typeof(string); }).Cast<MethodBase>() .Distinct(); } private static void Postfix(MethodBase __originalMethod, object[] __args) { if (__originalMethod?.Name == "Load") { ZInputMouseBindingResolver.ClearCache(); return; } string action = ((__args != null && __args.Length != 0) ? (__args[0] as string) : null); ZInputMouseBindingResolver.Invalidate(action); } } [HarmonyPatch(typeof(PlayerController), "TakeInput", new Type[] { typeof(bool) })] [HarmonyPriority(0)] internal static class PlayerControllerTakeInputPatch { private static void Postfix(ref bool __result) { if (ValheimInputState.ShouldBlockAll) { __result = false; } } } [HarmonyPatch(typeof(TextInput), "IsVisible")] [HarmonyPriority(0)] internal static class TextInputIsVisiblePatch { private static void Postfix(ref bool __result) { if (ValheimInputState.ShouldBlockAll) { __result = true; } } } internal static class ValheimInputPatchUtilities { internal static MethodInfo InputMethod(Type type, string name) { return AccessTools.DeclaredMethod(type, name, (Type[])null, (Type[])null); } internal static MethodInfo AnalogInputMethod(Type valueType) { return InputMethod(typeof(ZInput), "ReadValueDef")?.MakeGenericMethod(valueType); } internal static MethodInfo OptionalMethod(string typeName, string methodName) { Type type = AccessTools.TypeByName(typeName); return (type == null) ? null : AccessTools.Method(type, methodName, (Type[])null, (Type[])null); } } [HarmonyPatch] internal static class ZInputAllBooleanQueriesPatch { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] source = new MethodInfo[5] { ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "TryGetButtonState"), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "TryGetKeyStateLowLevel"), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "GetRadialTap"), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "GetRadialMultiTap"), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "HasDoubleTapped") }; return source.Where((MethodInfo method) => method != null).Cast<MethodBase>(); } [HarmonyPriority(800)] private static bool Prefix(ref bool __result) { if (!ValheimInputState.ShouldBlockAll) { return true; } __result = false; return false; } } [HarmonyPatch] internal static class ZInputAllFloatQueriesPatch { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] source = new MethodInfo[4] { ValheimInputPatchUtilities.AnalogInputMethod(typeof(float)), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "GetButtonPressedTimer"), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "GetButtonLastPressedTimer"), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "GetLongPressProgress") }; return source.Where((MethodInfo method) => method != null).Cast<MethodBase>(); } [HarmonyPriority(0)] private static void Postfix(ref float __result) { if (ValheimInputState.ShouldBlockAll) { __result = 0f; } } } [HarmonyPatch] internal static class ZInputAllVectorQueriesPatch { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] source = new MethodInfo[2] { ValheimInputPatchUtilities.AnalogInputMethod(typeof(Vector2)), ValheimInputPatchUtilities.InputMethod(typeof(ZInput), "GetGyro") }; return source.Where((MethodInfo method) => method != null).Cast<MethodBase>(); } [HarmonyPriority(0)] private static void Postfix(ref Vector2 __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (ValheimInputState.ShouldBlockAll) { __result = Vector2.zero; } } } [HarmonyPatch(typeof(ZInput), "GetTouchPinchPoints")] internal static class ZInputTouchPinchBlockPatch { [HarmonyPriority(0)] private static void Postfix(ref List<Vector2> __result) { if (ValheimInputState.ShouldBlockAll) { __result = ValheimInputState.EmptyTouchPoints; } } } [HarmonyPatch] internal static class ValheimPointerInteractionBlockPatch { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] source = new MethodInfo[30] { AccessTools.Method(typeof(InventoryGrid), "OnLeftClick", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGrid), "OnLeftDown", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGrid), "OnRightDown", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGrid), "OnBeginDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGrid), "OnReleasedOn", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGrid), "OnDragEnd", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGui), "OnSelectedItem", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGui), "OnReleasedItem", (Type[])null, (Type[])null), AccessTools.Method(typeof(InventoryGui), "OnRightClickItem", (Type[])null, (Type[])null), AccessTools.Method(typeof(UIInputHandler), "OnPointerDown", (Type[])null, (Type[])null), AccessTools.Method(typeof(UIInputHandler), "OnPointerClick", (Type[])null, (Type[])null), AccessTools.Method(typeof(UIDragHandler), "OnBeginDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(UIDragHandler), "OnDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(UIDragHandler), "OnEndDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(UIDragHandler), "OnReleasedOn", (Type[])null, (Type[])null), AccessTools.Method(typeof(Button), "OnPointerClick", (Type[])null, (Type[])null), AccessTools.Method(typeof(Toggle), "OnPointerClick", (Type[])null, (Type[])null), AccessTools.Method(typeof(Selectable), "OnPointerDown", (Type[])null, (Type[])null), AccessTools.Method(typeof(Slider), "OnPointerDown", (Type[])null, (Type[])null), AccessTools.Method(typeof(Slider), "OnDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(Scrollbar), "OnPointerDown", (Type[])null, (Type[])null), AccessTools.Method(typeof(Scrollbar), "OnDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(Scrollbar), "OnBeginDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(ScrollRect), "OnScroll", (Type[])null, (Type[])null), AccessTools.Method(typeof(ScrollRect), "OnBeginDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(ScrollRect), "OnDrag", (Type[])null, (Type[])null), AccessTools.Method(typeof(InputField), "OnPointerClick", (Type[])null, (Type[])null), AccessTools.Method(typeof(Dropdown), "OnPointerClick", (Type[])null, (Type[])null), ValheimInputPatchUtilities.OptionalMethod("TMPro.TMP_InputField", "OnPointerClick"), ValheimInputPatchUtilities.OptionalMethod("TMPro.TMP_Dropdown", "OnPointerClick") }; return source.Where((MethodInfo method) => method != null).Cast<MethodBase>().Distinct(); } [HarmonyPriority(800)] private static bool Prefix() { return !ValheimInputState.ShouldBlockMouse; } } [HarmonyPatch(typeof(UIInputHandler), "OnPointerUp")] internal static class UIInputHandlerPointerUpBlockPatch { [HarmonyPriority(800)] private static bool Prefix(UIInputHandler __instance) { if (!ValheimInputState.ShouldBlockMouse) { return true; } InventoryGrid componentInParent = ((Component)__instance).GetComponentInParent<InventoryGrid>(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.OnLeftRelease(__instance); } return false; } } [HarmonyPatch] internal static class ValheimAllInputInteractionBlockPatch { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] source = new MethodInfo[14] { AccessTools.Method(typeof(InventoryGrid), "EquipHovered", (Type[])null, (Type[])null), AccessTools.Method(typeof(Player), "UseHotbarItem", (Type[])null, (Type[])null), AccessTools.Method(typeof(Button), "OnSubmit", (Type[])null, (Type[])null), AccessTools.Method(typeof(Button), "Press", (Type[])null, (Type[])null), AccessTools.Method(typeof(Toggle), "OnSubmit", (Type[])null, (Type[])null), AccessTools.Method(typeof(Selectable), "OnMove", (Type[])null, (Type[])null), AccessTools.Method(typeof(Slider), "OnMove", (Type[])null, (Type[])null), AccessTools.Method(typeof(Scrollbar), "OnMove", (Type[])null, (Type[])null), AccessTools.Method(typeof(InputField), "OnUpdateSelected", (Type[])null, (Type[])null), AccessTools.Method(typeof(InputField), "OnSubmit", (Type[])null, (Type[])null), AccessTools.Method(typeof(Dropdown), "OnSubmit", (Type[])null, (Type[])null), ValheimInputPatchUtilities.OptionalMethod("TMPro.TMP_InputField", "OnUpdateSelected"), ValheimInputPatchUtilities.OptionalMethod("TMPro.TMP_InputField", "OnSubmit"), ValheimInputPatchUtilities.OptionalMethod("TMPro.TMP_Dropdown", "OnSubmit") }; return source.Where((MethodInfo method) => method != null).Cast<MethodBase>().Distinct(); } [HarmonyPriority(800)] private static bool Prefix() { return !ValheimInputState.ShouldBlockAll; } } [HarmonyPatch] internal static class ZInputMouseMappedButtonBlockPatch { private static IEnumerable<MethodBase> TargetMethods() { return ZInputPatchMethods.FindStringButtonMethods(); } [HarmonyPriority(0)] private static Exception Finalizer(Exception __exception, MethodBase __originalMethod, object[] __args, ref bool __result) { if (__exception != null || !__result || ValheimInputState.ShouldBlockAll || !ValheimInputState.ShouldBlockMouse) { return __exception; } string action = ((__args != null && __args.Length != 0) ? (__args[0] as string) : null); if (ZInputMouseBindingResolver.IsMouseBindingActive(action, __originalMethod?.Name, actionResultIsKnownTrue: true)) { __result = false; } return __exception; } } [HarmonyPatch] internal static class PlayerSetControlsMouseBlockPatch { private const BindingFlags AllMethods = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static IEnumerable<MethodBase> TargetMethods() { string[] requiredNames = new string[6] { "attack", "attackHold", "secondaryAttack", "secondaryAttackHold", "block", "blockHold" }; return (from method in typeof(Player).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where method.Name == "SetControls" select method).Where(delegate(MethodInfo method) { HashSet<string> hashSet = new HashSet<string>(from parameter in method.GetParameters() select parameter.Name, StringComparer.Ordinal); return requiredNames.All(hashSet.Contains); }).Cast<MethodBase>().Distinct(); } [HarmonyPriority(0)] private static void Prefix(ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold) { if (ValheimInputState.ShouldBlockMouse && !ValheimInputState.ShouldBlockAll) { if ((attack | attackHold) && ZInputMouseBindingResolver.IsMouseBindingActive("Attack", "GetButton", actionResultIsKnownTrue: true)) { attack = false; attackHold = false; } if ((secondaryAttack | secondaryAttackHold) && ZInputMouseBindingResolver.IsMouseBindingActive("SecondaryAttack", "GetButton", actionResultIsKnownTrue: true)) { secondaryAttack = false; secondaryAttackHold = false; } if ((block | blockHold) && ZInputMouseBindingResolver.IsMouseBindingActive("Block", "GetButton", actionResultIsKnownTrue: true)) { block = false; blockHold = false; } } } } [HarmonyPatch] internal static class ZInputMouseBooleanBlockPatch { private static IEnumerable<MethodBase> TargetMethods() { return ZInputPatchMethods.FindBooleanMethods("GetMouseButton", "GetMouseButtonDown", "GetMouseButtonUp"); } [HarmonyPriority(800)] private static bool Prefix(ref bool __result) { if (!ValheimInputState.ShouldBlockMouse) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] internal static class ZInputMouseScrollBlockPatch { [HarmonyPriority(0)] private static void Postfix(ref float __result) { if (ValheimInputState.ShouldBlockMouse) { __result = 0f; } } } [HarmonyPatch(typeof(ZInput), "GetMouseDelta")] internal static class ZInputMouseDeltaBlockPatch { [HarmonyPriority(0)] private static void Postfix(ref Vector2 __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (ValheimInputState.ShouldBlockMouse) { __result = Vector2.zero; } } } internal sealed class ValheimPauseController { private readonly ValheimProfilerConfig _config; private bool _pausedByProfiler; internal ValheimPauseController(ValheimProfilerConfig config) { _config = config; } internal void Update(bool hasVisibleWindows) { if (!_config.PauseGame.Value || !Object.op_Implicit((Object)(object)Game.instance)) { if (_pausedByProfiler) { Release(); } } else if (hasVisibleWindows) { if (!_pausedByProfiler && !Game.IsPaused() && Game.CanPause()) { Game.Pause(); _pausedByProfiler = true; } } else if (_pausedByProfiler) { Release(); } } internal void Release() { if (_pausedByProfiler && Object.op_Implicit((Object)(object)Game.instance) && !Menu.IsActive() && Game.IsPaused()) { Game.Unpause(); } _pausedByProfiler = false; } } } namespace ValheimProfiler.UI { internal sealed class GuiScaleController { private readonly ValheimProfilerConfig _config; private bool _temporaryUnity6000Window = true; internal float ScaleFactor { get { float num = Mathf.Clamp(_config.UiScale.Value, 0.25f, 4f); if (_config.UseValheimGuiScale.Value) { num *= GetValheimGuiScale(); } return Mathf.Max(0.01f, num); } } internal int PhysicalWidth => _temporaryUnity6000Window ? GetDisplayWidth() : Mathf.Max(1, Screen.width); internal int PhysicalHeight => _temporaryUnity6000Window ? GetDisplayHeight() : Mathf.Max(1, Screen.height); internal float LogicalWidth => (float)PhysicalWidth / ScaleFactor; internal float LogicalHeight => (float)PhysicalHeight / ScaleFactor; internal Matrix4x4 Matrix => Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(ScaleFactor, ScaleFactor, 1f)); internal GuiScaleController(ValheimProfilerConfig config) { _config = config; } internal void MarkGameWindowReady() { _temporaryUnity6000Window = false; } internal Vector2 GetLogicalMousePosition() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 val = Matrix; val = ((Matrix4x4)(ref val)).inverse; Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyPoint(UnityInput.Current.mousePosition); return new Vector2(val2.x, LogicalHeight - val2.y); } private float GetValheimGuiScale() { try { float num = (float)PhysicalWidth / (float)GuiScaler.m_minWidth; float num2 = (float)PhysicalHeight / (float)GuiScaler.m_minHeight; return Mathf.Max(0.01f, Mathf.Min(num, num2) * GuiScaler.m_largeGuiScale); } catch { return 1f; } } private static int GetDisplayWidth() { try { return (Display.main != null) ? Mathf.Max(1, Display.main.systemWidth) : Mathf.Max(1, Screen.width); } catch { return Mathf.Max(1, Screen.width); } } private static int GetDisplayHeight() { try { return (Display.main != null) ? Mathf.Max(1, Display.main.systemHeight) : Mathf.Max(1, Screen.height); } catch { return Mathf.Max(1, Screen.height); } } } internal sealed class InstrumentationReportView { internal readonly InstrumentationReport Report = new InstrumentationReport(); private List<InstrumentationReport.Entry> _filtered = new List<InstrumentationReport.Entry>(); private Vector2 _scroll; private string _search = string.Empty; private bool _failuresOnly; private bool _dirty = true; private int _revision = -1; private float _contentWidth = 1200f; private GUISkin _skin; private GUIStyle _rowStyle; private GUIStyle _warningStyle; private GUIStyle _warningTabStyle; private GUIStyle _bannerStyle; private static readonly Color WarningColor = new Color(1f, 0.84f, 0.25f, 1f); internal int Count => Report.Entries.Count; internal bool HasFailures => Report.HasFailures; internal void Clear() { //IL_000e: 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) Report.BeginCapture(); _scroll = Vector2.zero; _dirty = true; } internal void Add(MethodBase method, string reason) { Report.Skip(method, reason); } internal void Failure(MethodBase method, string stage, Exception exception, bool restartRequired = false) { Report.Failure(method, stage, exception, restartRequired); } internal int DrawTabs(int selected, string selectionCaption, float width, bool recoveryRequired) { //IL_00cb: 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_0076: 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_00c5: Expected O, but got Unknown EnsureStyles(); string[] array = new string[4] { "Profiler", selectionCaption, "Help", "Skipped methods" }; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); for (int i = 0; i < array.Length; i++) { bool flag = i == 3 && (HasFailures || recoveryRequired); string text = ((i == 3) ? "Installation and removal failures are shown first. Expected exclusions are not errors. Failures remain visible after Reset stats." : array[i]); Color contentColor = GUI.contentColor; if (flag) { GUI.contentColor = Color.white; } bool flag2; try { flag2 = GUILayout.Toggle(selected == i, new GUIContent(array[i], text), flag ? _warningTabStyle : GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width / 4f - 2f) }); } finally { GUI.contentColor = contentColor; } if (flag2 && selected != i) { selected = i; } } GUILayout.EndHorizontal(); return selected; } internal void DrawRecoveryBanner(InstrumentationSafety safety) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (!safety.RestartRequired) { return; } EnsureStyles(); Color contentColor = GUI.contentColor; GUI.contentColor = Color.white; try { GUILayout.Label(new GUIContent("RECOVERY UNCERTAIN - " + safety.RestartMessage, "Measurement is disabled. Resetting statistics or reopening the window cannot repair an uncertain detour or undo game-state changes."), _bannerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } finally { GUI.contentColor = contentColor; } } internal void Draw(float windowHeight) { //IL_0409: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: 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_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: 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_0404: Expected O, but got Unknown //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Expected O, but got Unknown EnsureStyles(); GUILayout.Label("Failed methods: " + Report.FailureCount + " | Other exclusions: " + Report.OtherSkipCount, Array.Empty<GUILayoutOption>()); GUILayout.Label("Failures are retained for this process. Expected exclusions did not disable the original methods.", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); bool flag = GUILayout.Toggle(_failuresOnly, "Failures only", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(115f) }); if (flag != _failuresOnly) { _failuresOnly = flag; _dirty = true; _scroll = Vector2.zero; } GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) }); string text = GUILayout.TextField(_search, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(180f), GUILayout.ExpandWidth(true) }); if (!string.Equals(text, _search, StringComparison.Ordinal)) { _search = text; _dirty = true; _scroll = Vector2.zero; } if (GUILayout.Button("Clear filter", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { _search = string.Empty; _dirty = true; _scroll = Vector2.zero; GUI.FocusControl((string)null); } GUILayout.EndHorizontal(); if (_dirty || _revision != Report.Revision) { _dirty = false; _revision = Report.Revision; _filtered = (from entry2 in Report.Entries where (!_failuresOnly || entry2.HasFailure) && (entry2.Assembly + " " + entry2.Method + " " + entry2.Details).IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0 orderby entry2.SortPriority select entry2).ThenBy<InstrumentationReport.Entry, string>((InstrumentationReport.Entry entry2) => entry2.Assembly, StringComparer.Ordinal).ThenBy<InstrumentationReport.Entry, string>((InstrumentationReport.Entry entry2) => entry2.Method, StringComparer.Ordinal).ToList(); _contentWidth = Math.Max(1200f, (_filtered.Count == 0) ? 0f : _filtered.Max((InstrumentationReport.Entry entry2) => Math.Max((entry2.HasFailure ? _warningStyle : _rowStyle).CalcSize(new GUIContent(Identity(entry2))).x, _rowStyle.CalcSize(new GUIContent(entry2.Details)).x) + 20f)); } float num = Mathf.Max(20f, _rowStyle.lineHeight + 4f); float num2 = num * 2f + 6f; _scroll = GUILayout.BeginScrollView(_scroll, false, true, Array.Empty<GUILayoutOption>()); float num3 = Mathf.Max(num2, (float)_filtered.Count * num2); Rect rect = GUILayoutUtility.GetRect(_contentWidth, num3, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(_contentWidth), GUILayout.Height(num3) }); int num4 = Mathf.Max(0, Mathf.FloorToInt(_scroll.y / num2) - 2); int num5 = Mathf.Min(_filtered.Count, num4 + Mathf.CeilToInt(windowHeight / num2) + 5); Rect val = default(Rect); for (int num6 = num4; num6 < num5; num6++) { InstrumentationReport.Entry entry = _filtered[num6]; string text2 = Identity(entry); string text3 = text2 + "\n" + string.Join("\n", entry.Messages); ((Rect)(ref val))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + (float)num6 * num2, ((Rect)(ref rect)).width, num); Color contentColor = GUI.contentColor; if (entry.HasFailure) { GUI.contentColor = Color.white; } try { GUI.Label(val, new GUIContent(text2, text3), entry.HasFailure ? _warningStyle : _rowStyle); } finally { GUI.contentColor = contentColor; } ((Rect)(ref val)).y = ((Rect)(ref val)).y + num; GUI.Label(val, new GUIContent(entry.Details, text3), _rowStyle); } if (_filtered.Count == 0) { GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, num), "No diagnostics match the current filter.", _rowStyle); } GUILayout.EndScrollView(); } private static string Identity(InstrumentationReport.Entry entry) { return (entry.RequiresRestart ? "[RESTART REQUIRED] " : (entry.HasFailure ? "[FAILURE] " : "[SKIPPED] ")) + entry.Assembly + " | " + entry.Method; } private void EnsureStyles() { //IL_003e: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0078: 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_008a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_skin == (Object)(object)GUI.skin) || _rowStyle == null) { _skin = GUI.skin; _rowStyle = new GUIStyle(GUI.skin.label) { wordWrap = false, richText = false }; _warningStyle = new GUIStyle(_rowStyle) { fontStyle = (FontStyle)1 }; _bannerStyle = new GUIStyle(_warningStyle) { wordWrap = true }; _warningTabStyle = new GUIStyle(GUI.skin.button); GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[3] { _warningStyle, _warningTabStyle, _bannerStyle }; foreach (GUIStyle val in array) { val.normal.textColor = WarningColor; val.hover.textColor = WarningColor; val.active.textColor = WarningColor; val.focused.textColor = WarningColor; val.onNormal.textColor = WarningColor; val.onHover.textColor = WarningColor; val.onActive.textColor = WarningColor; val.onFocused.textColor = WarningColor; } _dirty = true; } } } internal static class ProfilerGui { internal static bool ToggleLayout(ThemeManager theme, bool value, GUIContent content, float width, GUIStyle labelStyle = null, float verticalOffset = 1f) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) GUIStyle val = labelStyle ?? GUI.skin.label; float num = Mathf.Max(18f, val.lineHeight + 4f); Rect rect = GUILayoutUtility.GetRect(width, num, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(width), GUILayout.Height(num) }); return Toggle(theme, rect, value, content, val, verticalOffset); } internal static bool Toggle(ThemeManager theme, Rect rect, bool value, GUIContent content, GUIStyle labelStyle = null, float verticalOffset = 1f) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown GUIStyle val = labelStyle ?? GUI.skin.label; string text = ((content != null) ? content.tooltip : null) ?? string.Empty; GUIContent val2 = new GUIContent(string.Empty, text); bool flag = GUI.Toggle(rect, value, val2, GUIStyle.none); float num = theme?.CompactToggleSize ?? 10f; float num2 = Mathf.Ceil(Mathf.Max(0f, (((Rect)(ref rect)).height - num) * 0.5f)); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + num2 + verticalOffset, num, num); GUI.Box(val3, new GUIContent(string.Empty, text), flag ? theme.CompactToggleOnStyle : theme.CompactToggleOffStyle); string text2 = ((content != null) ? content.text : null) ?? string.Empty; if (!string.IsNullOrEmpty(text2)) { float num3 = ((Rect)(ref val3)).xMax + 4f; GUI.Label(new Rect(num3, ((Rect)(ref rect)).y, Mathf.Max(0f, ((Rect)(ref rect)).xMax - num3), ((Rect)(ref rect)).height), new GUIContent(text2, text), val); } return flag; } internal static void ProgressBar(ThemeManager theme, float progress, string text, float height = 22f) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_0061: 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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) progress = Mathf.Clamp01(progress); Rect rect = GUILayoutUtility.GetRect(1f, height, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(height) }); GUI.Box(rect, GUIContent.none); if (progress > 0f) { Rect val = rect; ((Rect)(ref val)).width = ((Rect)(ref val)).width * progress; Color color = GUI.color; GUI.color = theme?.AccentColor ?? color; GUI.Box(val, GUIContent.none); GUI.color = color; } if (!string.IsNullOrEmpty(text)) { GUI.Label(rect, text, GUI.skin.label); } } } internal sealed class ProfilerWindow : IDisposable { private readonly ConfigEntry<Vector2> _positionConfig; private readonly ConfigEntry<Vector2> _sizeConfig; private readonly object _layoutSync = new object(); private bool _layoutChangePending; private Vector2 _pendingPosition; private Vector2 _pendingSize; internal string Key { get; } internal string Title { get; set; } internal int WindowId { get; } internal Rect DefaultRect { get; } internal Vector2 MinimumSize { get; } internal bool Resizable { get; } internal bool CenterWhenPositionIsNegative { get; } internal bool AllowTooltipOverflow { get; } internal Action<int> DrawContents { get; } internal WindowFunction WindowFunction { get; set; } internal bool RequestedVisible { get; set; } internal Rect Rect { get; set; } internal bool LayoutDirty { get; set; } internal float SaveAfterRealtime { get; set; } internal ProfilerWindow(string key, string title, Rect defaultRect, Vector2 minimumSize, bool resizable, bool requestedVisible, Action<int> drawContents, ConfigEntry<Vector2> positionConfig = null, ConfigEntry<Vector2> sizeConfig = null, bool centerWhenPositionIsNegative = false, bool allowTooltipOverflow = false) { //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_0081: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_009b: 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_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_00a9: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00c6: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) Key = key; Title = title; MinimumSize = minimumSize; Resizable = resizable; RequestedVisible = requestedVisible; DrawContents = drawContents ?? throw new ArgumentNullException("drawContents"); _positionConfig = positionConfig; _sizeConfig = sizeConfig; CenterWhenPositionIsNegative = centerWhenPositionIsNegative; AllowTooltipOverflow = allowTooltipOverflow; Vector2 val = positionConfig?.Value ?? ((Rect)(ref defaultRect)).position; Vector2 val2 = ResolveConfiguredSize(sizeConfig?.Value ?? ((Rect)(ref defaultRect)).size, ((Rect)(ref defaultRect)).size); DefaultRect = new Rect(((Rect)(ref defaultRect)).position, ((Rect)(ref defaultRect)).size); Rect = new Rect(val, val2); WindowId = StableHash(key); if (_sizeConfig != null && (_sizeConfig.Value.x <= 0f || _sizeConfig.Value.y <= 0f)) { _sizeConfig.Value = val2; } if (_positionConfig != null) { _positionConfig.SettingChanged += OnLayoutConfigChanged; } if (_sizeConfig != null) { _sizeConfig.SettingChanged += OnLayoutConfigChanged; } } internal void ApplyPendingLayoutChanges() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Vector2 pendingPosition; Vector2 pendingSize; lock (_layoutSync) { if (!_layoutChangePending) { return; } pendingPosition = _pendingPosition; pendingSize = _pendingSize; _layoutChangePending = false; } Rect rect = Rect; if (_positionConfig != null) { ((Rect)(ref rect)).position = pendingPosition; } if (_sizeConfig != null) { Rect defaultRect = DefaultRect; ((Rect)(ref rect)).size = ResolveConfiguredSize(pendingSize, ((Rect)(ref defaultRect)).size); } Rect = rect; LayoutDirty = false; } internal void ResetLayoutToDefault() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_001d: 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) Rect defaultRect = DefaultRect; if (_sizeConfig == null) { Rect rect = Rect; ((Rect)(ref defaultRect)).size = ((Rect)(ref rect)).size; } Rect = defaultRect; LayoutDirty = false; } internal void SaveLayout() { //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_001d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Rect rect; if (_positionConfig != null) { ConfigEntry<Vector2> positionConfig = _positionConfig; rect = Rect; positionConfig.Value = ((Rect)(ref rect)).position; } if (_sizeConfig != null) { ConfigEntry<Vector2> sizeConfig = _sizeConfig; rect = Rect; sizeConfig.Value = ((Rect)(ref rect)).size; } LayoutDirty = false; } public void Dispose() { if (_positionConfig != null) { _positionConfig.SettingChanged -= OnLayoutConfigChanged; } if (_sizeConfig != null) { _sizeConfig.SettingChanged -= OnLayoutConfigChanged; } } private void OnLayoutConfigChanged(object sender, EventArgs e) { //IL_002f: 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_0028: 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_0054: 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_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references) lock (_layoutSync) { ConfigEntry<Vector2> positionConfig = _positionConfig; Rect rect; Vector2 pendingPosition; if (positionConfig == null) { rect = Rect; pendingPosition = ((Rect)(ref rect)).position; } else { pendingPosition = positionConfig.Value; } _pendingPosition = pendingPosition; ConfigEntry<Vector2> sizeConfig = _sizeConfig; Vector2 pendingSize; if (sizeConfig == null) { rect = Rect; pendingSize = ((Rect)(ref rect)).size; } else { pendingSize = sizeConfig.Value; } _pendingSize = pendingSize; _layoutChangePending = true; } } private static Vector2 ResolveConfiguredSize(Vector2 configured, Vector2 fallback) { //IL_0001: 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_000e: 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_0031: 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_0037: 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_003f: Unknown result type (might be due to invalid IL or missing references) return new Vector2((configured.x > 0f) ? configured.x : fallback.x, (configured.y > 0f) ? configured.y : fallback.y); } private static int StableHash(string value) { uint num = 2166136261u; string text = value ?? string.Empty; foreach (char c in text) { num ^= c; num *= 16777619; } int num2 = (int)(num & 0x7FFFFFFF); return (num2 == 0) ? 1 : num2; } } internal sealed class ThemeManager { private readonly ValheimProfilerConfig _config; private GUISkin _sourceSkin; private GUISkin _runtimeSkin; private bool _dirty = true; private Texture2D _windowTexture; private Texture2D _borderTexture; private Texture2D _entryTexture; private Texture2D _buttonTexture; private Texture2D _buttonHoverTexture; private Texture2D _buttonActiveTexture; private Texture2D _accentTexture; private Texture2D _accentHoverTexture; private Texture2D _scrollbarTrackTexture; private Texture2D _tooltipTexture; private Texture2D _toggleOffTexture; private Texture2D _toggleOnTexture; private Texture2D _toggleOffHoverTexture; private Texture2D _toggleOnHoverTexture; private GUIStyle _accentButtonStyle; private GUIStyle _accentLabelStyle; private GUIStyle _tooltipStyle; private GUIStyle _resizeHandleStyle; private GUIStyle _compactToggleOffStyle; private GUIStyle _compactToggleOnStyle; internal Color TextColor => _config.TextColor.Value; internal Color HeaderTextColor => _config.HeaderTextColor.Value; internal Color AccentColor => _config.AccentColor.Value; internal GUISkin Skin { get { EnsureStyles(); return _runtimeSkin ?? GUI.skin; } } internal Texture2D WindowTexture { get { EnsureStyles(); return _windowTexture; } } internal Texture2D BorderTexture { get { EnsureStyles(); return _borderTexture; } } internal GUIStyle AccentButtonStyle { get { EnsureStyles(); return _accentButtonStyle ?? GUI.skin.button; } } internal GUIStyle AccentLabelStyle { get { EnsureStyles(); return _accentLabelStyle ?? GUI.skin.label; } } internal GUIStyle TooltipStyle { get { EnsureStyles(); return _tooltipStyle ?? GUI.skin.box; } } internal GUIStyle ResizeHandleStyle { get { EnsureStyles(); return _resizeHandleStyle ?? GUI.skin.box; } } internal GUIStyle CompactToggleOffStyle { get { EnsureStyles(); return _compactToggleOffStyle ?? GUI.skin.box; } } internal GUIStyle CompactToggleOnStyle { get { EnsureStyles(); return _compactToggleOnStyle ?? GUI.skin.box; } } internal float CompactToggleSize { get { EnsureStyles(); return Mathf.Clamp((float)_config.FontSize.Value - 2f, 9f, 16f); } } internal ThemeManager(ValheimProfilerConfig config) { _config = config; _config.FontSize.SettingChanged += OnThemeChanged; _config.WindowBackground.SettingChanged += OnThemeChanged; _config.WindowBorder.SettingChanged += OnThemeChanged; _config.EntryBackground.SettingChanged += OnThemeChanged; _config.TextColor.SettingChanged += OnThemeChanged; _config.HeaderTextColor.SettingChanged += OnThemeChanged; _config.ButtonBackground.SettingChanged += OnThemeChanged; _config.ButtonTextColor.SettingChanged += OnThemeChanged; _config.AccentColor.SettingChanged += OnThemeChanged; } internal void EnsureStyles() { GUISkin skin = GUI.skin; if (_dirty || !((Object)(object)_runtimeSkin != (Object)null) || (!((Object)(object)_sourceSkin == (Object)(object)skin) && !((Object)(object)_runtimeSkin == (Object)(object)skin))) { Rebuild(((Object)(object)skin == (Object)(object)_runtimeSkin) ? _sourceSkin : skin); } } internal void Shutdown() { _config.FontSize.SettingChanged -= OnThemeChanged; _config.WindowBackground.SettingChanged -= OnThemeChanged; _config.WindowBorder.SettingChanged -= OnThemeChanged; _config.EntryBackground.SettingChanged -= OnThemeChanged; _config.TextColor.SettingChanged -= OnThemeChanged; _config.HeaderTextColor.SettingChanged -= OnThemeChanged; _config.ButtonBackground.SettingChanged -= OnThemeChanged; _config.ButtonTextColor.SettingChanged -= OnThemeChanged; _config.AccentColor.SettingChanged -= OnThemeChanged; DestroyResources(); } private void OnThemeChanged(object sender, EventArgs e) { _dirty = true; } private void Rebuild(GUISkin baseSkin) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007d: 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_0099: 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_00ab: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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) //IL_010f: 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_0120: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Expected O, but got Unknown //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Expected O, but got Unknown //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Expected O, but got Unknown //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Expected O, but got Unknown //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Expected O, but got Unknown //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Expected O, but got Unknown //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Expected O, but got Unknown //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Expected O, but got Unknown //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Expected O, but got Unknown //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Expected O, but got Unknown //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Expected O, but got Unknown //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Expected O, but got Unknown //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Expected O, but got Unknown //IL_05d3: Expected O, but got Unknown //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Expected O, but got Unknown //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Expected O, but got Unknown //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Expected O, but got Unknown //IL_0647: Expected O, but got Unknown //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Expected O, but got Unknown //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Expected O, but got Unknown //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Expected O, but got Unknown //IL_06d9: Expected O, but got Unknown //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Expected O, but got Unknown //IL_0746: Expected O, but got Unknown DestroyResources(); _sourceSkin = baseSkin; if (!((Object)(object)baseSkin == (Object)null)) { Color value = _config.WindowBackground.Value; Color value2 = _config.EntryBackground.Value; Color value3 = _config.ButtonBackground.Value; Color value4 = _config.AccentColor.Value; _windowTexture = CreateTexture(value); _borderTexture = CreateTexture(_config.WindowBorder.Value); _entryTexture = CreateTexture(value2); _buttonTexture = CreateTexture(value3); _buttonHoverTexture = CreateTexture(Lighten(value3, 0.12f)); _buttonActiveTexture = CreateTexture(Darken(value4, 0.1f)); _accentTexture = CreateTexture(value4); _accentHoverTexture = CreateTexture(Lighten(value4, 0.12f)); _scrollbarTrackTexture = CreateTexture(Darken(value2, 0.08f)); _tooltipTexture = CreateTexture(new Color(value2.r, value2.g, value2.b, 1f)); Color val = CreateNeutralToggleColor(value2, value3); Color value5 = _config.WindowBorder.Value; _toggleOffTexture = CreateBorderedTexture(val, value5); _toggleOnTexture = CreateBorderedTexture(value4, value5); _toggleOffHoverTexture = CreateBorderedTexture(Lighten(val, 0.12f), Lighten(value5, 0.2f)); _toggleOnHoverTexture = CreateBorderedTexture(Lighten(value4, 0.12f), Lighten(value5, 0.2f)); _runtimeSkin = Object.Instantiate<GUISkin>(baseSkin); ((Object)_runtimeSkin).name = "ValheimProfilerSkin"; ((Object)_runtimeSkin).hideFlags = (HideFlags)61; int fontSize = Mathf.Clamp(_config.FontSize.Value, 9, 28); Color value6 = _config.TextColor.Value; Color value7 = _config.HeaderTextColor.Value; Color value8 = _config.ButtonTextColor.Value; ConfigureTextStyle(_runtimeSkin.label, value6, fontSize); ConfigureTextStyle(_runtimeSkin.box, value6, fontSize); ConfigureTextStyle(_runtimeSkin.window, value7, fontSize); ConfigureTextStyle(_runtimeSkin.button, value8, fontSize); ConfigureTextStyle(_runtimeSkin.toggle, value6, fontSize); ConfigureTextStyle(_runtimeSkin.textField, value6, fontSize); ConfigureTextStyle(_runtimeSkin.textArea, value6, fontSize); SetAllBackgrounds(_runtimeSkin.window, _windowTexture); _runtimeSkin.window.padding = new RectOffset(4, 4, 21, 4); _runtimeSkin.window.margin = new RectOffset(0, 0, 0, 0); _runtimeSkin.window.border = new RectOffset(0, 0, 0, 0); SetAllBackgrounds(_runtimeSkin.box, _entryTexture); _runtimeSkin.box.padding = new RectOffset(4, 4, 3, 3); _runtimeSkin.box.margin = new RectOffset(1, 1, 1, 1); _runtimeSkin.box.border = new RectOffset(0, 0, 0, 0); SetAllBackgrounds(_runtimeSkin.textField, _entryTexture); _runtimeSkin.textField.padding = new RectOffset(4, 4, 1, 1); _runtimeSkin.textField.margin = new RectOffset(1, 1, 1, 1); _runtimeSkin.textField.border = new RectOffset(0, 0, 0, 0); _runtimeSkin.button.padding = new RectOffset(5, 5, 2, 2); _runtimeSkin.button.margin = new RectOffset(2, 2, 1, 1); _runtimeSkin.button.border = new RectOffset(0, 0, 0, 0); _runtimeSkin.toggle.margin = new RectOffset(1, 1, 1, 1); _runtimeSkin.label.margin = new RectOffset(1, 1, 0, 0); SetButtonBackgrounds(_runtimeSkin.button); ConfigureSquareScrollbars(_runtimeSkin); _accentButtonStyle = new GUIStyle(_runtimeSkin.button) { name = "ValheimProfilerAccentButton" }; SetAllBackgrounds(_accentButtonStyle, _accentTexture); _accentButtonStyle.hover.background = _accentHoverTexture; _accentButtonStyle.onHover.background = _accentHoverTexture; _accentButtonStyle.active.background = _buttonActiveTexture; _accentButtonStyle.onActive.background = _buttonActiveTexture; _accentLabelStyle = new GUIStyle(_runtimeSkin.label) { name = "ValheimProfilerAccentLabel", fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; ConfigureTextStyle(_accentLabelStyle, Lighten(value4, 0.35f), fontSize); _tooltipStyle = new GUIStyle(_runtimeSkin.box) { name = "ValheimProfilerTooltip", wordWrap = true, richText = false, alignment = (TextAnchor)3, padding = new RectOffset(10, 10, 5, 5), margin = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0) }; ConfigureTextStyle(_tooltipStyle, value6, fontSize); SetAllBackgrounds(_tooltipStyle, _tooltipTexture); _resizeHandleStyle = new GUIStyle(_runtimeSkin.box) { name = "ValheimProfilerResizeHandle", padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0) }; SetAllBackgrounds(_resizeHandleStyle, _accentTexture); _resizeHandleStyle.hover.background = _accentHoverTexture; _resizeHandleStyle.active.background = _buttonActiveTexture; _compactToggleOffStyle = new GUIStyle(_runtimeSkin.box) { name = "ValheimProfilerCompactToggleOff", padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0), border = new RectOffset(1, 1, 1, 1) }; SetAllBackgrounds(_compactToggleOffStyle, _toggleOffTexture); _compactToggleOffStyle.hover.background = _toggleOffHoverTexture; _compactToggleOffStyle.active.background = _toggleOffHoverTexture; _compactToggleOnStyle = new GUIStyle(_compactToggleOffStyle) { name = "ValheimProfilerCompactToggleOn", border = new RectOffset(1, 1, 1, 1) }; SetAllBackgrounds(_compactToggleOnStyle, _toggleOnTexture); _compactToggleOnStyle.hover.background = _toggleOnHoverTexture; _compactToggleOnStyle.active.background = _toggleOnHoverTexture; _dirty = false; } } private void ConfigureSquareScrollbars(GUISkin skin) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if (skin.scrollView != null) { RectOffset padding = skin.scrollView.padding; skin.scrollView.padding = new RectOffset((padding != null) ? padding.left : 0, Mathf.Max(1, (padding != null) ? padding.right : 0), (padding != null) ? padding.top : 0, (padding != null) ? padding.bottom : 0); } ConfigureScrollbarTrack(skin.horizontalScrollbar, horizontal: true, 13f); ConfigureScrollbarTrack(skin.verticalScrollbar, horizontal: false, 13f); ConfigureScrollbarThumb(skin.horizontalScrollbarThumb, horizontal: true, 13f); ConfigureScrollbarThumb(skin.verticalScrollbarThumb, horizontal: false, 13f); HideScrollbarButton(skin.horizontalScrollbarLeftButton); HideScrollbarButton(skin.horizontalScrollbarRightButton); HideScrollbarButton(skin.verticalScrollbarUpButton); HideScrollbarButton(skin.verticalScrollbarDownButton); } private void ConfigureScrollbarTrack(GUIStyle style, bool horizontal, float size) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_003b: 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_0045: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown if (style != null) { SetAllBackgrounds(style, _scrollbarTrackTexture); style.border = new RectOffset(0, 0, 0, 0); style.margin = (horizontal ? new RectOffset(0, 0, 0, 0) : new RectOffset(0, 1, 0, 0)); style.padding = new RectOffset(0, 0, 0, 0); if (horizontal) { style.fixedHeight = size; } else { style.fixedWidth = size; } } } private void ConfigureScrollbarThumb(GUIStyle style, bool horizontal, float size) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if (style != null) { SetAllBackgrounds(style, _accentTexture); style.hover.background = _accentHoverTexture; style.active.background = _buttonActiveTexture; style.border = new RectOffset(0, 0, 0, 0); style.margin = new RectOffset(1, 1, 1, 1); style.padding = new RectOffset(0, 0, 0, 0); if (horizontal) { style.fixedHeight = Mathf.Max(1f, size - 2f); } else { style.fixedWidth = Mathf.Max(1f, size - 2f); } } } private static void HideScrollbarButton(GUIStyle style) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if (style != null) { SetAllBackgrounds(style, null); style.border = new RectOffset(0, 0, 0, 0); style.margin = new RectOffset(0, 0, 0, 0); style.padding = new RectOffset(0, 0, 0, 0); style.fixedWidth = 0f; style.fixedHeight = 0f; style.stretchWidth = false; style.stretchHeight = false; } } private void SetButtonBackgrounds(GUIStyle style) { if (style != null) { style.normal.background = _buttonTexture; style.onNormal.background = _accentTexture; style.hover.background = _buttonHoverTexture; style.onHover.background = _buttonHoverTexture; style.active.background = _buttonActiveTexture; style.onActive.background = _buttonActiveTexture; style.focused.background = _buttonTexture; style.onFocused.background = _accentTexture; } } private static void SetAllBackgrounds(GUIStyle style, Texture2D texture) { if (style != null) { style.normal.background = texture; style.hover.background = texture; style.active.background = texture; style.focused.background = texture; style.onNormal.background = texture; style.onHover.background = texture; style.onActive.background = texture; style.onFocused.background = texture; } } private static void ConfigureTextStyle(GUIStyle style, Color color, int fontSize) { //IL_0019: 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_0033: 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_004d: 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_0067: 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) if (style != null) { style.fontSize = fontSize; SetTextColor(style.normal, color); SetTextColor(style.hover, color); SetTextColor(style.active, color); SetTextColor(style.focused, color); SetTextColor(style.onNormal, color); SetTextColor(style.onHover, color); SetTextColor(style.onActive, color); SetTextColor(style.onFocused, color); } } private static void SetTextColor(GUIStyleState state, Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (state != null) { state.textColor = color; } } private static Texture2D CreateTexture(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61, name = "ValheimProfilerColor" }; val.SetPixel(0, 0, color); val.Apply(false, true); return val; } private static Texture2D CreateBorderedTexture(Color fill, Color border) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003d: 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) Texture2D val = new Texture2D(3, 3, (TextureFormat)4, false) { hideFlags = (HideFlags)61, name = "ValheimProfilerBorderedColor" }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { val.SetPixel(j, i, (j == 0 || i == 0 || j == 2 || i == 2) ? border : fill); } } val.Apply(false, true); return val; } private static Color Lighten(Color color, float amount) { //IL_0000: 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_0022: 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_0039: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Lerp(color.r, 1f, amount), Mathf.Lerp(color.g, 1f, amount), Mathf.Lerp(color.b, 1f, amount), color.a); } private static Color Darken(Color color, float amount) { //IL_0000: 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_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r * (1f - amount), color.g * (1f - amount), color.b * (1f - amount), color.a); } private static Color CreateNeutralToggleColor(Color entry, Color button) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (mi