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 CompactStatusEffects v1.1.2
CompactStatusEffects.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("CompactStatusEffects")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CompactStatusEffects")] [assembly: AssemblyTitle("CompactStatusEffects")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 CompactStatusEffects { [BepInPlugin("com.ttolg.compactstatuseffects", "CompactStatusEffects", "1.1.2")] [BepInProcess("valheim.exe")] public class CompactStatusEffectsPlugin : BaseUnityPlugin { public const string ModGUID = "com.ttolg.compactstatuseffects"; public const string ModName = "CompactStatusEffects"; public const string ModVersion = "1.1.2"; internal static ManualLogSource Logger; private Harmony _harmony; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<KeyCode> ToggleGuiKey; public static ConfigEntry<float> RootX; public static ConfigEntry<float> RootY; public static ConfigEntry<float> Scale; public static ConfigEntry<float> SpacingY; public const float IconSize = 36f; public const float FontSize = 13.5f; public static bool IsGuiOpen; private Rect _windowRect = new Rect(40f, 100f, 380f, 470f); private GUIStyle _windowStyle; private GUIStyle _headerStyle; private GUIStyle _buttonStyle; private GUIStyle _sliderLabelStyle; private bool _stylesInitialized; private void Awake() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; InitConfig(); if (!ModEnabled.Value) { Logger.LogInfo((object)"CompactStatusEffects is disabled in config."); return; } _harmony = new Harmony("com.ttolg.compactstatuseffects"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Logger.LogInfo((object)string.Format("{0} v{1} loaded successfully! Settings shortcut: {2}", "CompactStatusEffects", "1.1.2", ToggleGuiKey.Value)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void InitConfig() { ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, "Enables or disables the mod."); ToggleGuiKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1 - General", "ToggleGuiKey", (KeyCode)289, "Key shortcut to open/close the in-game settings panel."); RootX = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Position", "RootX", -180f, "Horizontal root position relative to the top-right screen anchor."); RootY = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Position", "RootY", -290f, "Vertical root position relative to the top-right screen anchor (default: -290 directly under minimap)."); Scale = ((BaseUnityPlugin)this).Config.Bind<float>("3 - Sizing", "Scale", 1f, "Overall scale multiplier for status effects (default: 1.0)."); SpacingY = ((BaseUnityPlugin)this).Config.Bind<float>("3 - Sizing", "SpacingY", 55f, "Vertical spacing between status effect rows in pixels (default: 55px)."); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(ToggleGuiKey.Value)) { IsGuiOpen = !IsGuiOpen; } if (IsGuiOpen && Input.GetKeyDown((KeyCode)27)) { IsGuiOpen = false; } if (IsGuiOpen) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } private void OnGUI() { //IL_0085: 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_00a6: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (ModEnabled.Value && IsGuiOpen) { InitStyles(); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); _windowRect = GUI.Window(94821, _windowRect, new WindowFunction(DrawSettingsWindow), "Compact Status Effects - Settings", _windowStyle); } } private void DrawSettingsWindow(int windowId) { //IL_0020: 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) GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width - 30f, 26f)); if (GUI.Button(new Rect(((Rect)(ref _windowRect)).width - 26f, 4f, 22f, 20f), "X", _buttonStyle)) { IsGuiOpen = false; } GUILayout.Space(8f); GUILayout.Label("Changes apply live on screen.", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Horizontal Position (X): {RootX.Value:F0} px", _sliderLabelStyle, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("-5", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(20f) })) { ConfigEntry<float> rootX = RootX; rootX.Value -= 5f; } if (GUILayout.Button("+5", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(20f) })) { ConfigEntry<float> rootX2 = RootX; rootX2.Value += 5f; } GUILayout.EndHorizontal(); RootX.Value = GUILayout.HorizontalSlider(RootX.Value, -800f, 0f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) }); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Vertical Position (Y): {RootY.Value:F0} px", _sliderLabelStyle, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("-5", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(20f) })) { ConfigEntry<float> rootY = RootY; rootY.Value -= 5f; } if (GUILayout.Button("+5", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(20f) })) { ConfigEntry<float> rootY2 = RootY; rootY2.Value += 5f; } GUILayout.EndHorizontal(); RootY.Value = GUILayout.HorizontalSlider(RootY.Value, -800f, 0f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) }); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Scale: {Scale.Value:F2}x", _sliderLabelStyle, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("-0.05", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(45f), GUILayout.Height(20f) })) { Scale.Value = (float)Math.Round(Math.Max(0.3f, Scale.Value - 0.05f), 2); } if (GUILayout.Button("+0.05", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(45f), GUILayout.Height(20f) })) { Scale.Value = (float)Math.Round(Math.Min(2f, Scale.Value + 0.05f), 2); } GUILayout.EndHorizontal(); Scale.Value = (float)Math.Round(GUILayout.HorizontalSlider(Scale.Value, 0.4f, 1.6f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) }), 2); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Vertical Spacing: {SpacingY.Value:F0} px", _sliderLabelStyle, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("-2", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(20f) })) { ConfigEntry<float> spacingY = SpacingY; spacingY.Value -= 2f; } if (GUILayout.Button("+2", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(20f) })) { ConfigEntry<float> spacingY2 = SpacingY; spacingY2.Value += 2f; } GUILayout.EndHorizontal(); SpacingY.Value = (float)Math.Round(GUILayout.HorizontalSlider(SpacingY.Value, 30f, 90f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) }), 0); GUILayout.Space(14f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Reset (Under Minimap)", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { ResetToMinimapPreset(); } if (GUILayout.Button("Save Settings", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { ((BaseUnityPlugin)this).Config.Save(); Logger.LogInfo((object)"CompactStatusEffects settings saved."); } GUILayout.EndHorizontal(); GUILayout.Space(6f); if (GUILayout.Button("Close (F8 / ESC)", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { IsGuiOpen = false; } } private void ResetToMinimapPreset() { RootX.Value = -180f; RootY.Value = -290f; Scale.Value = 1f; SpacingY.Value = 55f; ((BaseUnityPlugin)this).Config.Save(); } private void InitStyles() { //IL_0020: 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_0064: 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_007f: 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_0091: 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_00a7: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00de: Expected O, but got Unknown //IL_00e9: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown if (!_stylesInitialized) { Texture2D background = MakeTex(2, 2, new Color(0.1f, 0.11f, 0.13f, 0.95f)); Texture2D background2 = MakeTex(2, 2, new Color(0.2f, 0.22f, 0.26f, 0.95f)); Texture2D background3 = MakeTex(2, 2, new Color(0.28f, 0.32f, 0.38f, 1f)); GUIStyle val = new GUIStyle(GUI.skin.window); val.normal.background = background; val.normal.textColor = Color.white; val.onNormal.background = background; val.onNormal.textColor = Color.white; val.fontSize = 13; val.fontStyle = (FontStyle)1; val.padding = new RectOffset(14, 14, 28, 14); _windowStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.button); val2.normal.background = background2; val2.normal.textColor = new Color(0.92f, 0.92f, 0.92f); val2.hover.background = background3; val2.hover.textColor = Color.white; val2.fontSize = 12; val2.fontStyle = (FontStyle)1; _buttonStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)1 }; val3.normal.textColor = new Color(0.9f, 0.85f, 0.75f); _sliderLabelStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 11, fontStyle = (FontStyle)2 }; val4.normal.textColor = new Color(0.7f, 0.7f, 0.7f); _headerStyle = val4; _stylesInitialized = true; } } private Texture2D MakeTex(int width, int height, Color col) { //IL_000f: 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) //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } } [HarmonyPatch(typeof(Hud), "UpdateStatusEffects", new Type[] { typeof(List<StatusEffect>) })] public static class Hud_UpdateStatusEffects_Patch { [HarmonyPostfix] public static void Postfix(List<StatusEffect> statusEffects, List<RectTransform> ___m_statusEffects, RectTransform ___m_statusEffectListRoot) { //IL_0028: 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_0052: 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_0100: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: 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_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) if (!CompactStatusEffectsPlugin.ModEnabled.Value || statusEffects == null || ___m_statusEffects == null) { return; } if ((Object)(object)___m_statusEffectListRoot != (Object)null) { ___m_statusEffectListRoot.anchorMin = new Vector2(1f, 1f); ___m_statusEffectListRoot.anchorMax = new Vector2(1f, 1f); ___m_statusEffectListRoot.pivot = new Vector2(1f, 1f); ___m_statusEffectListRoot.anchoredPosition = new Vector2(CompactStatusEffectsPlugin.RootX.Value, CompactStatusEffectsPlugin.RootY.Value); } float value = CompactStatusEffectsPlugin.Scale.Value; float num = 36f; float value2 = CompactStatusEffectsPlugin.SpacingY.Value; float num2 = 13.5f; int num3 = Math.Min(statusEffects.Count, ___m_statusEffects.Count); for (int i = 0; i < num3; i++) { RectTransform val = ___m_statusEffects[i]; if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeSelf) { continue; } StatusEffect val2 = statusEffects[i]; float num4 = 0f - (float)i * value2; ((Transform)val).localPosition = new Vector3(0f, num4, 0f); ((Transform)val).localScale = new Vector3(value, value, 1f); Transform obj = ((Transform)val).Find("Icon"); RectTransform val3 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)val3 != (Object)null) { val3.anchorMin = new Vector2(0f, 0.5f); val3.anchorMax = new Vector2(0f, 0.5f); val3.pivot = new Vector2(0.5f, 0.5f); val3.anchoredPosition = new Vector2(num * 0.5f, 0f); val3.SetSizeWithCurrentAnchors((Axis)0, num); val3.SetSizeWithCurrentAnchors((Axis)1, num); } Transform obj2 = ((Transform)val).Find("Cooldown"); RectTransform val4 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val4 != (Object)null) { val4.anchorMin = new Vector2(0f, 0.5f); val4.anchorMax = new Vector2(0f, 0.5f); val4.pivot = new Vector2(0.5f, 0.5f); val4.anchoredPosition = new Vector2(num * 0.5f, 0f); val4.SetSizeWithCurrentAnchors((Axis)0, num); val4.SetSizeWithCurrentAnchors((Axis)1, num); } Transform obj3 = ((Transform)val).Find("TimeText"); RectTransform val5 = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null); if ((Object)(object)val5 != (Object)null) { TMP_Text component = ((Component)val5).GetComponent<TMP_Text>(); if ((Object)(object)component != (Object)null) { string iconText = val2.GetIconText(); if (string.IsNullOrEmpty(iconText)) { ((Component)val5).gameObject.SetActive(false); } else { ((Component)val5).gameObject.SetActive(true); component.fontSize = num2 * 0.88f; component.text = iconText; component.alignment = (TextAlignmentOptions)514; component.textWrappingMode = (TextWrappingModes)0; val5.anchorMin = new Vector2(0f, 0.5f); val5.anchorMax = new Vector2(0f, 0.5f); val5.pivot = new Vector2(0.5f, 1f); val5.anchoredPosition = new Vector2(num * 0.5f, 0f - (num * 0.5f + 2f)); val5.SetSizeWithCurrentAnchors((Axis)0, num + 20f); val5.SetSizeWithCurrentAnchors((Axis)1, 18f); } } } Transform obj4 = ((Transform)val).Find("Name"); RectTransform val6 = (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null); if ((Object)(object)val6 != (Object)null) { TMP_Text component2 = ((Component)val6).GetComponent<TMP_Text>(); if ((Object)(object)component2 != (Object)null) { ((Component)val6).gameObject.SetActive(true); component2.fontSize = num2; component2.alignment = (TextAlignmentOptions)4097; component2.textWrappingMode = (TextWrappingModes)0; component2.overflowMode = (TextOverflowModes)1; val6.anchorMin = new Vector2(0f, 0.5f); val6.anchorMax = new Vector2(0f, 0.5f); val6.pivot = new Vector2(0f, 0.5f); val6.anchoredPosition = new Vector2(num + 10f, 0f); val6.SetSizeWithCurrentAnchors((Axis)0, 240f); val6.SetSizeWithCurrentAnchors((Axis)1, num + 8f); } } } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] public static class GameCamera_UpdateMouseCapture_Patch { [HarmonyPrefix] public static bool Prefix() { if (CompactStatusEffectsPlugin.IsGuiOpen) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); return false; } return true; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] public static class PlayerController_TakeInput_Patch { [HarmonyPostfix] public static void Postfix(ref bool __result) { if (CompactStatusEffectsPlugin.IsGuiOpen) { __result = false; } } } }