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 ModHub v1.0.1
ModHub.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ModHub")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ModHub")] [assembly: AssemblyTitle("ModHub")] [assembly: AssemblyVersion("1.0.0.0")] [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 ModHub { public static class HubNet { private static bool _warned; private static MethodInfo _listContainsId; private static FieldInfo _adminListField; public static bool IsServer => (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer(); public static bool IsRemoteClient => (Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer(); public static ZRpc ServerRpc() { if (!IsRemoteClient) { return null; } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer != null && peer.m_rpc != null) { return peer.m_rpc; } } return null; } public static ZNetPeer FindPeer(ZRpc rpc) { if ((Object)(object)ZNet.instance == (Object)null || rpc == null) { return null; } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer != null && peer.m_rpc == rpc) { return peer; } } return null; } public static bool IsAdmin(ZNetPeer peer) { if (peer == null || peer.m_socket == null || (Object)(object)ZNet.instance == (Object)null) { return false; } try { string hostName = peer.m_socket.GetHostName(); if (_adminListField == null) { _adminListField = AccessTools.Field(typeof(ZNet), "m_adminList"); } if (_listContainsId == null) { _listContainsId = AccessTools.Method(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); } object obj = _adminListField?.GetValue(ZNet.instance); if (obj != null && _listContainsId != null && hostName != null) { return (bool)_listContainsId.Invoke(ZNet.instance, new object[2] { obj, hostName }); } } catch (Exception ex) { if (!_warned) { _warned = true; ModHubPlugin.LogError("Admin check failed: " + ex.Message); } return false; } if (!_warned) { _warned = true; ModHubPlugin.LogError("Admin check is not available on this game version."); } return false; } } public static class HubUI { public static readonly Color Background = Color32.op_Implicit(new Color32((byte)18, (byte)17, (byte)16, (byte)245)); public static readonly Color SlotFill = Color32.op_Implicit(new Color32((byte)42, (byte)36, (byte)30, byte.MaxValue)); public static readonly Color SlotHover = Color32.op_Implicit(new Color32((byte)56, (byte)46, (byte)34, byte.MaxValue)); public static readonly Color SlotActive = Color32.op_Implicit(new Color32((byte)62, (byte)49, (byte)28, byte.MaxValue)); public static readonly Color SlotBorder = Color32.op_Implicit(new Color32((byte)92, (byte)74, (byte)50, byte.MaxValue)); public static readonly Color Gold = Color32.op_Implicit(new Color32((byte)201, (byte)164, (byte)92, byte.MaxValue)); public static readonly Color GoldBright = Color32.op_Implicit(new Color32((byte)232, (byte)195, (byte)106, byte.MaxValue)); public static readonly Color GoldDim = Color32.op_Implicit(new Color32((byte)110, (byte)88, (byte)56, byte.MaxValue)); public static readonly Color Text = Color32.op_Implicit(new Color32((byte)230, (byte)216, (byte)184, byte.MaxValue)); public static readonly Color TextDim = Color32.op_Implicit(new Color32((byte)150, (byte)138, (byte)116, byte.MaxValue)); public static readonly Color Danger = Color32.op_Implicit(new Color32((byte)176, (byte)58, (byte)52, byte.MaxValue)); public static GUIStyle WindowStyle; public static GUIStyle InnerFrameStyle; public static GUIStyle SlotStyle; public static GUIStyle SlotHoverStyle; public static GUIStyle SlotActiveStyle; public static GUIStyle TitleStyle; public static GUIStyle HeaderStyle; public static GUIStyle LabelStyle; public static GUIStyle LabelDimStyle; public static GUIStyle LabelCenterStyle; public static GUIStyle TileLabelStyle; public static GUIStyle TileLabelHoverStyle; public static GUIStyle ButtonStyle; public static GUIStyle TextFieldStyle; public static GUIStyle ThumbStyle; private static bool _ready; private static Texture2D _trackTex; private static Texture2D _trackFillTex; private static Texture2D _checkOn; private static Texture2D _checkOff; private static readonly Dictionary<Color, Texture2D> _dots = new Dictionary<Color, Texture2D>(); private static Matrix4x4 _savedMatrix; private static Texture2D _gear; public static Font Font { get; private set; } public static float Scale => Mathf.Clamp((float)Screen.height / 1080f, 0.5f, 4f) * (ModHubPlugin.UiScale?.Value ?? 1f); public static Texture2D GearIcon { get { //IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_gear != (Object)null) { return _gear; } _gear = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[4096]; float num = 32f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num2 = (float)j + 0.5f - num; float num3 = (float)i + 0.5f - num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Atan2(num3, num2); float num6 = Mathf.Clamp01((Mathf.Cos(num5 * 8f) + 0.15f) * 3f); float num7 = 21f + 8f * num6; float a = Mathf.Clamp01(num7 - num4 + 0.5f) * Mathf.Clamp01(num4 - 9f + 0.5f); Color goldBright = GoldBright; goldBright.a = a; array[i * 64 + j] = goldBright; } } _gear.SetPixels(array); _gear.Apply(); return _gear; } } public static void Ensure() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0091: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_01ea: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Expected O, but got Unknown //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Expected O, but got Unknown //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Expected O, but got Unknown //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) if (_ready) { GUIStyle windowStyle = WindowStyle; if ((Object)(object)((windowStyle != null) ? windowStyle.normal.background : null) != (Object)null) { return; } } _ready = true; _dots.Clear(); Font = FindValheimFont(); WindowStyle = Panel(RoundedRect(64, 20, 3, Background, Gold), 24); InnerFrameStyle = Panel(RoundedRect(64, 14, 1, Color.clear, GoldDim), 16); SlotStyle = Panel(RoundedRect(48, 10, 2, SlotFill, SlotBorder), 12); SlotHoverStyle = Panel(RoundedRect(48, 10, 2, SlotHover, GoldDim), 12); SlotActiveStyle = Panel(RoundedRect(48, 10, 3, SlotActive, GoldBright), 12); TitleStyle = Text_(40, Gold, (TextAnchor)4, (FontStyle)1); HeaderStyle = Text_(20, Gold, (TextAnchor)3, (FontStyle)1); LabelStyle = Text_(16, Text, (TextAnchor)3, (FontStyle)0); LabelStyle.wordWrap = true; LabelDimStyle = Text_(14, TextDim, (TextAnchor)3, (FontStyle)0); LabelDimStyle.wordWrap = true; LabelCenterStyle = Text_(14, TextDim, (TextAnchor)4, (FontStyle)0); LabelCenterStyle.wordWrap = true; TileLabelStyle = Text_(15, Text, (TextAnchor)4, (FontStyle)1); TileLabelHoverStyle = Text_(15, GoldBright, (TextAnchor)4, (FontStyle)1); ButtonStyle = new GUIStyle { font = Font, fontSize = 16, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, border = new RectOffset(12, 12, 12, 12), padding = new RectOffset(12, 12, 6, 6) }; ButtonStyle.normal.background = SlotStyle.normal.background; ButtonStyle.normal.textColor = Text; ButtonStyle.hover.background = SlotHoverStyle.normal.background; ButtonStyle.hover.textColor = GoldBright; ButtonStyle.active.background = SlotActiveStyle.normal.background; ButtonStyle.active.textColor = GoldBright; TextFieldStyle = new GUIStyle { font = Font, fontSize = 16, alignment = (TextAnchor)3, border = new RectOffset(8, 8, 8, 8), padding = new RectOffset(10, 10, 4, 4), clipping = (TextClipping)1 }; TextFieldStyle.normal.background = RoundedRect(32, 6, 1, Color32.op_Implicit(new Color32((byte)12, (byte)11, (byte)10, byte.MaxValue)), SlotBorder); TextFieldStyle.normal.textColor = Text; TextFieldStyle.hover.background = TextFieldStyle.normal.background; TextFieldStyle.hover.textColor = Text; TextFieldStyle.focused.background = RoundedRect(32, 6, 1, Color32.op_Implicit(new Color32((byte)12, (byte)11, (byte)10, byte.MaxValue)), Gold); TextFieldStyle.focused.textColor = GoldBright; ThumbStyle = new GUIStyle { fixedWidth = 18f, fixedHeight = 18f }; ThumbStyle.normal.background = RoundedRect(36, 18, 3, GoldBright, GoldDim); ThumbStyle.hover.background = ThumbStyle.normal.background; ThumbStyle.active.background = ThumbStyle.normal.background; _trackTex = RoundedRect(16, 3, 0, SlotBorder, SlotBorder); _trackFillTex = RoundedRect(16, 3, 0, Gold, Gold); _checkOff = RoundedRect(32, 6, 2, SlotFill, SlotBorder); _checkOn = RoundedRect(32, 6, 2, Gold, GoldBright); } public static Vector2 BeginScaled() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0046: Unknown result type (might be due to invalid IL or missing references) Ensure(); _savedMatrix = GUI.matrix; float scale = Scale; GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, 1f)); return new Vector2((float)Screen.width / scale, (float)Screen.height / scale); } public static void EndScaled() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.matrix = _savedMatrix; } public static Rect Centered(Vector2 screen, float w, float h) { //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_001e: Unknown result type (might be due to invalid IL or missing references) return new Rect((screen.x - w) * 0.5f, (screen.y - h) * 0.5f, w, h); } public static void Window(Rect r, string title = null, bool titleAtBottom = false) { //IL_0001: 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_00b1: 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) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) GUI.Box(r, GUIContent.none, WindowStyle); GUI.Box(new Rect(((Rect)(ref r)).x + 12f, ((Rect)(ref r)).y + 12f, ((Rect)(ref r)).width - 24f, ((Rect)(ref r)).height - 24f), GUIContent.none, InnerFrameStyle); if (!string.IsNullOrEmpty(title)) { Rect val = (titleAtBottom ? new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 84f, ((Rect)(ref r)).width, 52f) : new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 22f, ((Rect)(ref r)).width, 52f)); GUI.Label(val, title.ToUpperInvariant(), TitleStyle); } } public static bool CloseButton(Rect window) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) return GUI.Button(new Rect(((Rect)(ref window)).xMax - 52f, ((Rect)(ref window)).y + 22f, 30f, 30f), "X", ButtonStyle); } public static bool Button(Rect r, string text) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GUI.Button(r, text, ButtonStyle); } public static void Label(Rect r, string text) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.Label(r, text, LabelStyle); } public static void LabelDim(Rect r, string text) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.Label(r, text, LabelDimStyle); } public static void Header(Rect r, string text) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.Label(r, text, HeaderStyle); } public static string TextField(Rect r, string value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GUI.TextField(r, value ?? "", TextFieldStyle); } public static float FloatField(Rect r, float value, string format = "0.##") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = GUI.TextField(r, value.ToString(format, CultureInfo.InvariantCulture), TextFieldStyle); float result; return float.TryParse(text.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : value; } public static bool Toggle(Rect r, bool value, string text) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 22f) * 0.5f, 22f, 22f); GUI.DrawTexture(val, (Texture)(object)(value ? _checkOn : _checkOff)); GUI.Label(new Rect(((Rect)(ref val)).xMax + 10f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 32f, ((Rect)(ref r)).height), text, LabelStyle); if (GUI.Button(r, GUIContent.none, GUIStyle.none)) { value = !value; } return value; } public static float Slider(Rect r, string label, float value, float min, float max, string format = "0.##") { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return SliderText(r, label, value, min, max, null, format); } public static float SliderText(Rect r, string label, float value, float min, float max, string valueText, string format = "0.##", float labelWidth = -1f) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) float num = (string.IsNullOrEmpty(label) ? 0f : ((labelWidth >= 0f) ? labelWidth : (((Rect)(ref r)).width * 0.35f))); if (num > 0f) { GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), label, LabelStyle); } Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x + num + 8f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 18f) * 0.5f, ((Rect)(ref r)).width - num - 64f - 20f, 18f); float num2 = Mathf.InverseLerp(min, max, value); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).center.y - 3f, ((Rect)(ref val)).width, 6f), (Texture)(object)_trackTex); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).center.y - 3f, ((Rect)(ref val)).width * num2, 6f), (Texture)(object)_trackFillTex); value = GUI.HorizontalSlider(val, value, min, max, GUIStyle.none, ThumbStyle); GUI.Label(new Rect(((Rect)(ref r)).xMax - 64f, ((Rect)(ref r)).y, 64f, ((Rect)(ref r)).height), valueText ?? value.ToString(format), LabelCenterStyle); return value; } public static bool LayoutToggle(bool value, string text, float height = 28f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return Toggle(GUILayoutUtility.GetRect(100f, height, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), value, text); } public static float LayoutSlider(string label, float value, float min, float max, string valueText = null, float height = 28f, float labelWidth = -1f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return SliderText(GUILayoutUtility.GetRect(100f, height, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), label, value, min, max, valueText, "0.##", labelWidth); } public static void LayoutDivider(float space = 8f) { //IL_0021: 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_0041: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(space); Rect rect = GUILayoutUtility.GetRect(1f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)_trackTex); GUILayout.Space(space); } public static GUIStyle NoWrap(GUIStyle st) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown return new GUIStyle(st) { wordWrap = false }; } public static void Slot(Rect r, bool hover = false, bool active = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.Box(r, GUIContent.none, active ? SlotActiveStyle : (hover ? SlotHoverStyle : SlotStyle)); } public static void DrawSprite(Rect r, Sprite sprite) { //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_0085: 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_011e: 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) if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null)) { Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height); float num = ((Rect)(ref textureRect)).width / ((Rect)(ref textureRect)).height; Rect val2 = r; if (num > 1f) { float num2 = ((Rect)(ref r)).width / num; ((Rect)(ref val2))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + (((Rect)(ref r)).height - num2) * 0.5f, ((Rect)(ref r)).width, num2); } else if (num < 1f) { float num3 = ((Rect)(ref r)).height * num; ((Rect)(ref val2))..ctor(((Rect)(ref r)).x + (((Rect)(ref r)).width - num3) * 0.5f, ((Rect)(ref r)).y, num3, ((Rect)(ref r)).height); } GUI.DrawTextureWithTexCoords(val2, (Texture)(object)texture, val); } } public static void Dot(Vector2 center, float size, Color color) { //IL_0006: 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_0048: 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_0024: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (!_dots.TryGetValue(color, out var value) || (Object)(object)value == (Object)null) { value = RoundedRect(64, 32, 0, color, color); _dots[color] = value; } GUI.DrawTexture(new Rect(center.x - size * 0.5f, center.y - size * 0.5f, size, size), (Texture)(object)value); } public static float Stepper(Rect r, string label, float value, float step, float min, float max, string format = "0.##") { //IL_0025: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref r)).width * 0.5f; GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), label, LabelStyle); float num2 = ((Rect)(ref r)).x + num; float height = ((Rect)(ref r)).height; if (GUI.Button(new Rect(num2, ((Rect)(ref r)).y, height, ((Rect)(ref r)).height), "-", ButtonStyle)) { value -= step; } GUI.Label(new Rect(num2 + height, ((Rect)(ref r)).y, ((Rect)(ref r)).xMax - num2 - height * 2f, ((Rect)(ref r)).height), value.ToString(format), TileLabelStyle); if (GUI.Button(new Rect(((Rect)(ref r)).xMax - height, ((Rect)(ref r)).y, height, ((Rect)(ref r)).height), "+", ButtonStyle)) { value += step; } return Mathf.Clamp((float)Math.Round(value, 3), min, max); } public static Texture2D RoundedRect(int size, int radius, int borderWidth, 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_0012: 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_0024: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Mathf.Abs((float)j + 0.5f - num) - (num - (float)radius); float num3 = Mathf.Abs((float)i + 0.5f - num) - (num - (float)radius); Vector2 val2 = new Vector2(Mathf.Max(num2, 0f), Mathf.Max(num3, 0f)); float magnitude = ((Vector2)(ref val2)).magnitude; float num4 = magnitude + Mathf.Min(Mathf.Max(num2, num3), 0f) - (float)radius; float num5 = Mathf.Clamp01(0.5f - num4); Color val3 = ((borderWidth <= 0) ? fill : Color.Lerp(border, fill, Mathf.Clamp01(0f - num4 - (float)borderWidth + 0.5f))); val3.a *= num5; array[i * size + j] = val3; } } val.SetPixels(array); val.Apply(); return val; } private static GUIStyle Panel(Texture2D tex, int border) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0017: Expected O, but got Unknown GUIStyle val = new GUIStyle { border = new RectOffset(border, border, border, border) }; val.normal.background = tex; return val; } private static GUIStyle Text_(int size, Color color, TextAnchor anchor, FontStyle style) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle { font = Font, fontSize = size, alignment = anchor, fontStyle = style, richText = true }; val.normal.textColor = color; return val; } private static Font FindValheimFont() { Font val = null; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val2 in array) { if (!((Object)(object)val2 == (Object)null)) { if (((Object)val2).name.StartsWith("AveriaSerifLibre-Bold")) { return val2; } if ((Object)(object)val == (Object)null && ((Object)val2).name.StartsWith("AveriaSerifLibre")) { val = val2; } } } return val; } } internal class HubWindow { private const string BlockOwner = "modhub"; private const float Tile = 124f; private const float Gap = 18f; private const float PadX = 56f; private const float PadTop = 62f; private const float BottomH = 120f; private const float SettingsW = 600f; private const float SettingsH = 640f; private const float RowH = 34f; private const float RowGap = 10f; private Vector2 _scroll; private Vector2 _settingsScroll; public bool IsOpen { get; private set; } public bool InSettings { get; private set; } public bool IsRebinding { get; private set; } public void Open() { IsOpen = true; InSettings = false; IsRebinding = false; HubState.Set("modhub", on: true); } public void Close() { IsOpen = false; InSettings = false; IsRebinding = false; HubState.Set("modhub", on: false); } public void ShowGrid() { InSettings = false; IsRebinding = false; } public void Draw() { //IL_0024: 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_0044: 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) if (!IsOpen) { return; } if (IsRebinding) { CaptureKey(); } Vector2 screen = HubUI.BeginScaled(); HubEntry hubEntry = null; try { if (InSettings) { DrawSettings(screen); } else { hubEntry = DrawGrid(screen); } } finally { HubUI.EndScaled(); } if (hubEntry == null) { return; } Close(); try { hubEntry.Open?.Invoke(); } catch (Exception arg) { ModHubPlugin.LogError($"[{hubEntry.Id}] open failed: {arg}"); } } private HubEntry DrawGrid(Vector2 screen) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) HubEntry result = null; List<HubEntry> list = ModHubAPI.VisibleEntries(); int num = Mathf.Max(1, ModHubPlugin.Columns.Value); int num2 = Mathf.Max(1, Mathf.CeilToInt((float)list.Count / (float)num)); int num3 = Mathf.Min(num2, Mathf.Max(1, ModHubPlugin.MaxRows.Value)); float num4 = (float)num * 124f + (float)(num - 1) * 18f; float num5 = (float)num3 * 124f + (float)(num3 - 1) * 18f; float num6 = (float)num2 * 124f + (float)(num2 - 1) * 18f; Rect val = HubUI.Centered(screen, num4 + 112f, 62f + num5 + 120f); HubUI.Window(val, ModHubPlugin.HubTitle.Value, titleAtBottom: true); if (HubUI.CloseButton(val)) { Close(); return null; } if (GearButton(val)) { InSettings = true; return null; } string text = $"{ModHubPlugin.HubKey.Value} / Esc — закрыть"; if (list.Count == 0) { GUI.Label(new Rect(((Rect)(ref val)).x + 56f, ((Rect)(ref val)).y + 62f, num4, num5), (ModHubAPI.Entries.Count == 0) ? "Пока ни один мод не подключён к хабу" : "Все плитки скрыты — включи их в настройках", HubUI.LabelCenterStyle); } else { Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + 56f, ((Rect)(ref val)).y + 62f, num4, num5); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(0f, 0f, num4, num6); _scroll = GUI.BeginScrollView(val2, _scroll, val3, false, false, GUIStyle.none, GUIStyle.none); Rect val4 = default(Rect); for (int i = 0; i < list.Count; i++) { HubEntry hubEntry = list[i]; ((Rect)(ref val4))..ctor((float)(i % num) * 142f, (float)(i / num) * 142f, 124f, 124f); bool flag = ((Rect)(ref val4)).Contains(Event.current.mousePosition); DrawTile(val4, hubEntry, flag); if (flag && !string.IsNullOrEmpty(hubEntry.Description)) { text = hubEntry.Description; } if (GUI.Button(val4, GUIContent.none, GUIStyle.none)) { result = hubEntry; } } GUI.EndScrollView(); } GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).yMax - 40f, ((Rect)(ref val)).width - 48f, 22f), text, HubUI.LabelCenterStyle); return result; } private static void DrawTile(Rect r, HubEntry e, bool hover) { //IL_0001: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) HubUI.Slot(r, hover: false, hover); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref r)).center.x - 28f, ((Rect)(ref r)).y + 18f, 56f, 56f); Sprite val = e.ResolveIcon(); if ((Object)(object)val != (Object)null) { HubUI.DrawSprite(r2, val); } else { HubUI.Dot(((Rect)(ref r2)).center, 30f, e.DotColor); } GUI.Label(new Rect(((Rect)(ref r)).x + 6f, ((Rect)(ref r)).yMax - 42f, ((Rect)(ref r)).width - 12f, 32f), e.Title, hover ? HubUI.TileLabelHoverStyle : HubUI.TileLabelStyle); } private static bool GearButton(Rect win) { //IL_002c: 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) Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref win)).x + 22f, ((Rect)(ref win)).y + 22f, 30f, 30f); bool result = GUI.Button(val, GUIContent.none, HubUI.ButtonStyle); GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 4f, ((Rect)(ref val)).y + 4f, 22f, 22f), (Texture)(object)HubUI.GearIcon); return result; } private void DrawSettings(Vector2 screen) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) Rect val = HubUI.Centered(screen, 600f, 640f); HubUI.Window(val, "Settings", titleAtBottom: true); if (HubUI.CloseButton(val)) { Close(); return; } if (GUI.Button(new Rect(((Rect)(ref val)).x + 22f, ((Rect)(ref val)).y + 22f, 30f, 30f), "<", HubUI.ButtonStyle)) { ShowGrid(); return; } List<HubEntry> list = ModHubAPI.AllAvailableEntries(); float innerW = 488f; int num = 8 + Mathf.Max(1, list.Count) + 1; float num2 = (float)num * 44f + 20f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + 56f, ((Rect)(ref val)).y + 62f, innerW, 458f); _settingsScroll = GUI.BeginScrollView(val2, _settingsScroll, new Rect(0f, 0f, innerW, num2), false, false, GUIStyle.none, GUIStyle.none); float y = 0f; HubUI.Header(Row(), "Основное"); Rect val3 = Row(); GUI.Label(new Rect(((Rect)(ref val3)).x, ((Rect)(ref val3)).y, innerW * 0.5f, 34f), "Клавиша хаба", HubUI.LabelStyle); string text = (IsRebinding ? "Нажми клавишу..." : ((object)ModHubPlugin.HubKey.Value/*cast due to .constrained prefix*/).ToString()); if (GUI.Button(new Rect(((Rect)(ref val3)).x + innerW * 0.5f, ((Rect)(ref val3)).y, innerW * 0.5f, 34f), text, HubUI.ButtonStyle)) { IsRebinding = !IsRebinding; } Rect val4 = Row(); GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y, innerW * 0.5f, 34f), "Надпись окна", HubUI.LabelStyle); string text2 = HubUI.TextField(new Rect(((Rect)(ref val4)).x + innerW * 0.5f, ((Rect)(ref val4)).y, innerW * 0.5f, 34f), ModHubPlugin.HubTitle.Value); if (text2 != ModHubPlugin.HubTitle.Value && text2.Length <= 24) { ModHubPlugin.HubTitle.Value = text2; } int num3 = (int)HubUI.Stepper(Row(), "Плиток в ряду", ModHubPlugin.Columns.Value, 1f, 2f, 6f, "0"); if (num3 != ModHubPlugin.Columns.Value) { ModHubPlugin.Columns.Value = num3; } int num4 = (int)HubUI.Stepper(Row(), "Рядов без прокрутки", ModHubPlugin.MaxRows.Value, 1f, 1f, 6f, "0"); if (num4 != ModHubPlugin.MaxRows.Value) { ModHubPlugin.MaxRows.Value = num4; } float num5 = HubUI.Stepper(Row(), "Масштаб меню", ModHubPlugin.UiScale.Value, 0.1f, 0.6f, 2f, "0.0"); if (!Mathf.Approximately(num5, ModHubPlugin.UiScale.Value)) { ModHubPlugin.UiScale.Value = num5; } Row(); HubUI.Header(Row(), "Плитки в хабе"); if (list.Count == 0) { HubUI.LabelDim(Row(), "Пока ни один мод не подключён"); } else { foreach (HubEntry item in list) { bool flag = !ModHubAPI.IsHidden(item.Id); bool flag2 = HubUI.Toggle(Row(), flag, item.Title); if (flag2 != flag) { ModHubAPI.SetHidden(item.Id, !flag2); } } } Rect val5 = Row(); if (GUI.Button(new Rect(((Rect)(ref val5)).x, ((Rect)(ref val5)).y, innerW * 0.5f, 34f), "Сбросить всё", HubUI.ButtonStyle)) { ResetToDefaults(); } GUI.EndScrollView(); string text3 = (IsRebinding ? "Нажми новую клавишу (можно с Ctrl/Shift/Alt). Esc — отмена" : "Изменения сохраняются сразу. Esc — назад"); GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).yMax - 40f, ((Rect)(ref val)).width - 48f, 22f), text3, HubUI.LabelCenterStyle); Rect Row() { //IL_0030: 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_0034: Unknown result type (might be due to invalid IL or missing references) Rect result = default(Rect); ((Rect)(ref result))..ctor(0f, y, innerW, 34f); y += 44f; return result; } } private void CaptureKey() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0046: 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_00bc: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current == null || (int)current.type != 4 || (int)current.keyCode == 0) { return; } if ((int)current.keyCode == 27) { IsRebinding = false; } else if (!IsModifier(current.keyCode)) { List<KeyCode> list = new List<KeyCode>(); if (current.control) { list.Add((KeyCode)306); } if (current.shift) { list.Add((KeyCode)304); } if (current.alt) { list.Add((KeyCode)308); } ModHubPlugin.HubKey.Value = new KeyboardShortcut(current.keyCode, list.ToArray()); IsRebinding = false; } current.Use(); } private static bool IsModifier(KeyCode k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 return (int)k == 306 || (int)k == 305 || (int)k == 304 || (int)k == 303 || (int)k == 308 || (int)k == 307 || (int)k == 310 || (int)k == 309; } private static void ResetToDefaults() { ConfigEntryBase[] array = (ConfigEntryBase[])(object)new ConfigEntryBase[6] { (ConfigEntryBase)ModHubPlugin.HubKey, (ConfigEntryBase)ModHubPlugin.HubTitle, (ConfigEntryBase)ModHubPlugin.Columns, (ConfigEntryBase)ModHubPlugin.MaxRows, (ConfigEntryBase)ModHubPlugin.UiScale, (ConfigEntryBase)ModHubPlugin.HiddenTiles }; ConfigEntryBase[] array2 = array; foreach (ConfigEntryBase val in array2) { val.BoxedValue = val.DefaultValue; } } } public static class ModHubAPI { public const string GUID = "kaefchik.modhub"; private static readonly List<HubEntry> _entries = new List<HubEntry>(); public static IReadOnlyList<HubEntry> Entries => _entries; public static KeyboardShortcut HubKey => (ModHubPlugin.HubKey != null) ? ModHubPlugin.HubKey.Value : KeyboardShortcut.Empty; public static bool IsHubOpen => ModHubPlugin.Window != null && ModHubPlugin.Window.IsOpen; public static bool IsInputBlocked => HubState.Blocked; public static HubEntry Register(string id, string title, Action open, string itemIcon = null, Sprite icon = null, Color? dotColor = null, string description = null, int order = 100, Func<bool> visible = null, Action close = null, Func<bool> isOpen = null) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(id)) { throw new ArgumentException("id is empty"); } HubEntry hubEntry = new HubEntry { Id = id, Title = (string.IsNullOrEmpty(title) ? id : title), Open = open, ItemIconPrefab = itemIcon, Icon = icon, DotColor = (Color)(((??)dotColor) ?? HubUI.Gold), Description = description, Order = order, Visible = visible, Close = close, IsOpen = isOpen }; _entries.RemoveAll((HubEntry e) => e.Id == id); _entries.Add(hubEntry); _entries.Sort(delegate(HubEntry a, HubEntry b) { int num = a.Order.CompareTo(b.Order); return (num != 0) ? num : string.Compare(a.Title, b.Title, StringComparison.OrdinalIgnoreCase); }); ModHubPlugin.Log("Registered hub entry '" + id + "'"); return hubEntry; } internal static bool CloseOpenModMenu() { foreach (HubEntry entry in _entries) { if (entry.IsOpen == null || entry.Close == null) { continue; } bool flag; try { flag = entry.IsOpen(); } catch { continue; } if (!flag) { continue; } try { entry.Close(); } catch (Exception arg) { ModHubPlugin.LogError($"[{entry.Id}] close failed: {arg}"); } return true; } return false; } public static void Unregister(string id) { _entries.RemoveAll((HubEntry e) => e.Id == id); } public static void OpenHub() { if (ModHubPlugin.Window != null && (Object)(object)Player.m_localPlayer != (Object)null) { ModHubPlugin.Window.Open(); } } public static void CloseHub() { ModHubPlugin.Window?.Close(); } public static void SetInputBlock(string owner, bool blocked) { HubState.Set(owner, blocked); } public static bool CanOpenMenu() { return (Object)(object)Player.m_localPlayer != (Object)null && ModHubPlugin.CanOpen(); } internal static bool IsHidden(string id) { string text = ModHubPlugin.HiddenTiles?.Value; if (string.IsNullOrEmpty(text)) { return false; } string[] array = text.Split(new char[1] { ',' }); foreach (string text2 in array) { if (text2.Trim() == id) { return true; } } return false; } internal static void SetHidden(string id, bool hidden) { HashSet<string> hashSet = new HashSet<string>(); string value = ModHubPlugin.HiddenTiles.Value; if (!string.IsNullOrEmpty(value)) { string[] array = value.Split(new char[1] { ',' }); foreach (string text in array) { if (text.Trim().Length > 0) { hashSet.Add(text.Trim()); } } } if (hidden) { hashSet.Add(id); } else { hashSet.Remove(id); } ModHubPlugin.HiddenTiles.Value = string.Join(",", new List<string>(hashSet).ToArray()); } internal static List<HubEntry> VisibleEntries() { return Filter(skipHidden: true); } internal static List<HubEntry> AllAvailableEntries() { return Filter(skipHidden: false); } private static List<HubEntry> Filter(bool skipHidden) { List<HubEntry> list = new List<HubEntry>(_entries.Count); foreach (HubEntry entry in _entries) { if (skipHidden && IsHidden(entry.Id)) { continue; } bool flag = true; if (entry.Visible != null) { try { flag = entry.Visible(); } catch (Exception arg) { ModHubPlugin.LogError($"[{entry.Id}] visible() failed: {arg}"); } } if (flag) { list.Add(entry); } } return list; } } public class HubEntry { public string Id; public string Title; public string Description; public Action Open; public Sprite Icon; public string ItemIconPrefab; public Color DotColor; public int Order; public Func<bool> Visible; public Action Close; public Func<bool> IsOpen; private bool _iconResolved; private Sprite _itemIcon; internal Sprite ResolveIcon() { if ((Object)(object)Icon != (Object)null) { return Icon; } if (_iconResolved || string.IsNullOrEmpty(ItemIconPrefab)) { return _itemIcon; } ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null) { return null; } _iconResolved = true; GameObject itemPrefab = instance.GetItemPrefab(ItemIconPrefab); if ((Object)(object)itemPrefab == (Object)null) { return null; } ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null && component.m_itemData?.m_shared?.m_icons != null && component.m_itemData.m_shared.m_icons.Length != 0) { _itemIcon = component.m_itemData.GetIcon(); } return _itemIcon; } } internal static class HubState { private static readonly HashSet<string> _blockers = new HashSet<string>(); public static int LastReleaseFrame = -1; public static bool Blocked => _blockers.Count > 0; public static bool SuppressPauseMenu => Blocked || Time.frameCount == LastReleaseFrame; public static void Set(string owner, bool on) { if (!string.IsNullOrEmpty(owner)) { if (on) { _blockers.Add(owner); } else if (_blockers.Remove(owner) && _blockers.Count == 0) { LastReleaseFrame = Time.frameCount; } } } public static void Clear() { _blockers.Clear(); } } [BepInPlugin("kaefchik.modhub", "ModHub", "1.0.0")] public class ModHubPlugin : BaseUnityPlugin { public const string GUID = "kaefchik.modhub"; public const string NAME = "ModHub"; public const string VERSION = "1.0.0"; internal static ModHubPlugin Instance; internal static HubWindow Window; internal static ConfigEntry<KeyboardShortcut> HubKey; internal static ConfigEntry<string> HubTitle; internal static ConfigEntry<int> Columns; internal static ConfigEntry<int> MaxRows; internal static ConfigEntry<float> UiScale; internal static ConfigEntry<string> HiddenTiles; private Harmony _harmony; private bool _closeAtLateUpdate; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown Instance = this; HubKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "HubKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Клавиша, открывающая общее меню модов"); HubTitle = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "Title", "MODS", "Надпись внизу окна хаба"); Columns = ((BaseUnityPlugin)this).Config.Bind<int>("UI", "Columns", 3, new ConfigDescription("Плиток в ряду", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 6), Array.Empty<object>())); MaxRows = ((BaseUnityPlugin)this).Config.Bind<int>("UI", "MaxRows", 3, new ConfigDescription("Сколько рядов видно без прокрутки", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>())); UiScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Scale", 1f, new ConfigDescription("Масштаб всех меню, использующих ModHub", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 2f), Array.Empty<object>())); HiddenTiles = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "HiddenTiles", "", "id плиток через запятую, которые скрыты в хабе (удобнее менять в самом хабе через шестерёнку)"); Window = new HubWindow(); _harmony = new Harmony("kaefchik.modhub"); _harmony.PatchAll(typeof(ModHubPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ModHub 1.0.0 loaded"); } private void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { if (Window.IsOpen) { Window.Close(); } } else { if (Window.IsRebinding) { return; } KeyboardShortcut value = HubKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (Window.IsOpen) { Window.Close(); } else if (!ModHubAPI.CloseOpenModMenu() && CanOpen()) { Window.Open(); } } else if (Window.IsOpen && Input.GetKeyDown((KeyCode)27)) { if (Window.InSettings) { Window.ShowGrid(); } else { _closeAtLateUpdate = true; } } } } private void LateUpdate() { if (_closeAtLateUpdate) { _closeAtLateUpdate = false; Window.Close(); } if (HubState.Blocked) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void OnGUI() { Window?.Draw(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static bool CanOpen() { if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if (Console.IsVisible()) { return false; } if (TextInput.IsVisible()) { return false; } if (Menu.IsVisible()) { return false; } if (InventoryGui.IsVisible()) { return false; } if (StoreGui.IsVisible()) { return false; } if (Minimap.IsOpen()) { return false; } return true; } internal static void Log(string msg) { ModHubPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)msg); } } internal static void LogError(string msg) { ModHubPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogError((object)msg); } } } [HarmonyPatch] internal static class PlayerTakeInputPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static void Postfix(ref bool __result) { if (HubState.Blocked) { __result = false; } } } [HarmonyPatch] internal static class PlayerControllerTakeInputPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(PlayerController), "TakeInput", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static void Postfix(ref bool __result) { if (HubState.Blocked) { __result = false; } } } [HarmonyPatch] internal static class GameCameraMouseCapturePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(GameCamera), "UpdateMouseCapture", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static bool Prefix() { if (!HubState.Blocked) { return true; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return false; } } [HarmonyPatch] internal static class MenuUpdatePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Menu), "Update", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static bool Prefix() { return !HubState.SuppressPauseMenu; } } }