using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [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.7.2", FrameworkDisplayName = "")] [assembly: AssemblyVersion("0.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 HywolfWeightDisplay { [BepInPlugin("hywolf.weightdisplay", "HywolfWeightDisplay", "1.0.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Hud), "Update")] public static class Hud_Update_Patch { public static void Postfix(Hud __instance) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Hud.IsUserHidden()) { if ((Object)(object)weightText != (Object)null) { ((Component)weightText).gameObject.SetActive(false); } return; } if ((Object)(object)weightText == (Object)null) { CreateWeightText(__instance); } if ((Object)(object)weightText != (Object)null) { ((Component)weightText).gameObject.SetActive(true); float num = Mathf.Ceil(((Humanoid)localPlayer).GetInventory().GetTotalWeight()); float maxCarryWeight = localPlayer.GetMaxCarryWeight(); float num2 = ((maxCarryWeight > 0f) ? Mathf.Round(num / maxCarryWeight * 100f) : 0f); float num3 = Mathf.Max(0f, maxCarryWeight - num); try { weightText.text = string.Format(configTextFormat.Value, num, maxCarryWeight, num2, num3); } catch { weightText.text = $"Poids: {num} / {maxCarryWeight}"; } if (num > maxCarryWeight) { ((Graphic)weightText).color = configOverloadColor.Value; } else if (num2 >= configWarningThreshold.Value) { ((Graphic)weightText).color = configWarningColor.Value; } else { ((Graphic)weightText).color = configNormalColor.Value; } } } } public const string PluginGUID = "hywolf.weightdisplay"; public const string PluginName = "HywolfWeightDisplay"; public const string PluginVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("hywolf.weightdisplay"); private static Text weightText; private static ConfigEntry configPositionX; private static ConfigEntry configPositionY; private static ConfigEntry configFontSize; private static ConfigEntry configTextFormat; private static ConfigEntry configWarningThreshold; private static ConfigEntry configNormalColor; private static ConfigEntry configWarningColor; private static ConfigEntry configOverloadColor; private void Awake() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) configPositionX = ((BaseUnityPlugin)this).Config.Bind("1 - Position", "PositionX", 47f, "Position X"); configPositionY = ((BaseUnityPlugin)this).Config.Bind("1 - Position", "PositionY", -8f, "Position Y"); configFontSize = ((BaseUnityPlugin)this).Config.Bind("2 - Text", "FontSize", 20, "Font size"); configTextFormat = ((BaseUnityPlugin)this).Config.Bind("2 - Text", "TextFormat", "{0}/{1} ({2}%)", "({0}=Current weight, {1}=Max, {2}=%, {3}=free weight)"); configWarningThreshold = ((BaseUnityPlugin)this).Config.Bind("3 - Colors", "WarningThreshold", 80f, "Percentage threshold for displaying the warning color"); configNormalColor = ((BaseUnityPlugin)this).Config.Bind("3 - Colors", "NormalColor", Color.white, "Text color"); configWarningColor = ((BaseUnityPlugin)this).Config.Bind("3 - Colors", "WarningColor", new Color(1f, 0.6f, 0f), "Text color when the warning threshold is reached"); configOverloadColor = ((BaseUnityPlugin)this).Config.Bind("3 - Colors", "OverloadColor", Color.red, "Text color for overweight status"); configPositionX.SettingChanged += delegate { UpdateTextPosition(); }; configPositionY.SettingChanged += delegate { UpdateTextPosition(); }; configFontSize.SettingChanged += delegate { UpdateTextProperties(); }; harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"HywolfWeightDisplay chargé avec succès !"); } private static void CreateWeightText(Hud hudInstance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Text componentInChildren = hudInstance.m_rootObject.GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null)) { GameObject val = new GameObject("WeightDisplay_Text"); val.transform.SetParent(hudInstance.m_rootObject.transform, false); weightText = val.AddComponent(); weightText.font = componentInChildren.font; weightText.alignment = (TextAnchor)3; UpdateTextProperties(); UpdateTextPosition(); } } private static void UpdateTextPosition() { //IL_002b: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) if (!((Object)(object)weightText == (Object)null)) { RectTransform component = ((Component)weightText).GetComponent(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(configPositionX.Value, configPositionY.Value); component.sizeDelta = new Vector2(350f, 40f); } } private static void UpdateTextProperties() { if (!((Object)(object)weightText == (Object)null)) { weightText.fontSize = configFontSize.Value; } } } }