using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("JotunnModStub")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JotunnModStub")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] namespace JotunnModStub; [BepInPlugin("com.hejsansvejsan.backpackinfo", "BackpackInfo", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class BackpackInfo : BaseUnityPlugin { [HarmonyPatch(typeof(Inventory), "Changed")] private static class InventoryChangedPatch { private static void Postfix(Inventory __instance) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance == ((Humanoid)localPlayer).GetInventory()) { instance?.UpdateHud(); } } } [HarmonyPatch(typeof(Humanoid), "SetupEquipment")] private static class EquipmentChangedPatch { private static void Postfix(Humanoid __instance) { Logger.LogInfo((object)"EquipmentChangedPatch fired"); if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { instance?.UpdateHud(); } } } public const string PluginGUID = "com.hejsansvejsan.backpackinfo"; public const string PluginName = "BackpackInfo"; public const string PluginVersion = "0.1.0"; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); private GameObject textObject; private Text hudText; private static BackpackInfo instance; private void Awake() { instance = this; Logger.LogInfo((object)"BackpackInfo loaded!"); GUIManager.OnCustomGUIAvailable += CreateHud; Harmony.CreateAndPatchAll(typeof(InventoryChangedPatch), "com.hejsansvejsan.backpackinfo"); Harmony.CreateAndPatchAll(typeof(EquipmentChangedPatch), "com.hejsansvejsan.backpackinfo"); if ((Object)(object)GUIManager.CustomGUIFront != (Object)null) { CreateHud(); } } private void OnDestroy() { GUIManager.OnCustomGUIAvailable -= CreateHud; } private void CreateHud() { //IL_006c: 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_008a: 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_00a1: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) Logger.LogInfo((object)"CreateHud called"); if (GUIManager.Instance == null) { Logger.LogError((object)"GUIManager.Instance is null"); return; } if ((Object)(object)GUIManager.CustomGUIFront == (Object)null) { Logger.LogError((object)"CustomGUIFront is null"); return; } if ((Object)(object)textObject != (Object)null) { Object.Destroy((Object)(object)textObject); } textObject = GUIManager.Instance.CreateText("Loading...", GUIManager.CustomGUIFront.transform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-330f, 0f), GUIManager.Instance.AveriaSerifBold, 18, Color.white, true, Color.black, 300f, 60f, false); hudText = textObject.GetComponent(); hudText.supportRichText = true; RectTransform component = textObject.GetComponent(); component.anchorMin = new Vector2(1f, 0.5f); component.anchorMax = new Vector2(1f, 0.5f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-75f, 0f); hudText.alignment = (TextAnchor)5; UpdateHud(); textObject.SetActive(true); Logger.LogInfo((object)"HUD text created"); } private void UpdateHud() { if ((Object)(object)hudText == (Object)null || (Object)(object)textObject == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { hudText.text = "Loading..."; return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { hudText.text = ""; return; } int num = inventory.GetWidth() * inventory.GetHeight(); int count = inventory.GetAllItems().Count; int num2 = num - count; float totalWeight = inventory.GetTotalWeight(); float num3 = localPlayer.GetMaxCarryWeight() - totalWeight; string text = num3.ToString("0.0"); if (num3 < 0f) { text = "" + text + ""; } hudText.text = $"Free slots: {num2}\n" + "Free weight: " + text; } private void Update() { if (!((Object)(object)textObject == (Object)null)) { textObject.SetActive(!InventoryGui.IsVisible()); } } }