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 ScrapValueHUD v1.0.1
com.elitemastereric.scrapvaluehud.dll
Decompiled a week agousing System; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using Microsoft.CodeAnalysis; using ScrapValueHUD.Compatibility; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.elitemastereric.scrapvaluehud")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4e59e4707b5253a9710f85c70a7055b22efce179")] [assembly: AssemblyProduct("ScrapValueHUD")] [assembly: AssemblyTitle("com.elitemastereric.scrapvaluehud")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 ScrapValueHUD { internal class ScrapValueHUDUI : MonoBehaviour { private const int NoValue = int.MinValue; private const int LeftOffset = -4; private const int BottomOffset = 0; private static ScrapValueHUDUI? instance; private TextMeshProUGUI[] slotLabels; private void Awake() { HUDManager val = HUDManager.Instance; if ((Object)(object)val == (Object)null || val.itemSlotIconFrames == null) { ((Behaviour)this).enabled = false; return; } ResetItemSlotIconFrames(val); slotLabels = (TextMeshProUGUI[])(object)new TextMeshProUGUI[val.itemSlotIconFrames.Length]; for (int i = 0; i < slotLabels.Length; i++) { slotLabels[i] = CreateLabel(((Component)val.itemSlotIconFrames[i]).transform, "ScrapValueSlot" + i); } instance = this; Refresh(); } private void OnDestroy() { if ((Object)(object)instance == (Object)(object)this) { instance = null; } } private static void ResetItemSlotIconFrames(HUDManager hud) { //IL_001e: 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) if (ScrapValueHUDConfig.FixRotation.Value) { for (int i = 0; i < hud.itemSlotIconFrames.Length; i++) { ((Component)hud.itemSlotIconFrames[i]).transform.rotation = Quaternion.identity; } for (int j = 0; j < hud.itemSlotIcons.Length; j++) { ((Component)hud.itemSlotIcons[j]).transform.rotation = Quaternion.identity; } } } internal static void RefreshLabels(bool updateDisplay = false) { if ((Object)(object)instance != (Object)null) { instance.Refresh(updateDisplay); } } private static TextMeshProUGUI CreateLabel(Transform parent, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyAnchor(component); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); ApplyLabelStyle(val2); ((TMP_Text)val2).text = string.Empty; return val2; } private static void ApplyLabelStyle(TextMeshProUGUI label) { //IL_0067: 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) HUDManager val = HUDManager.Instance; if (!((Object)(object)val == (Object)null) && val.itemSlotIconFrames != null) { if ((Object)(object)val.weightCounter != (Object)null) { ((TMP_Text)label).font = ((TMP_Text)val.weightCounter).font; ((TMP_Text)label).fontSharedMaterial = ((TMP_Text)val.weightCounter).fontSharedMaterial; } else { ((TMP_Text)label).font = TMP_Settings.defaultFontAsset; } ((TMP_Text)label).fontSize = ScrapValueHUDConfig.ScrapValueFontSize.Value; ((TMP_Text)label).alignment = GetAlignment(); ((Graphic)label).color = Color.white; ((TMP_Text)label).enableWordWrapping = false; ((Graphic)label).raycastTarget = false; } } private static void ApplyAnchor(RectTransform rect) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00b5: Unknown result type (might be due to invalid IL or missing references) LabelAnchor value = ScrapValueHUDConfig.ScrapValueAnchor.Value; bool flag = value == LabelAnchor.TopRight || value == LabelAnchor.BottomRight; bool flag2 = value == LabelAnchor.TopLeft || value == LabelAnchor.TopRight; float num = ScrapValueHUDConfig.ScrapValueHorizontalPadding.Value; float value2 = ScrapValueHUDConfig.ScrapValueVerticalPadding.Value; if (!flag) { num += -4f; } if (!flag2) { num += 0f; } rect.anchorMin = new Vector2(0f, 0f); rect.anchorMax = new Vector2(1f, 1f); rect.offsetMin = new Vector2(flag ? 0f : num, flag2 ? 0f : value2); rect.offsetMax = new Vector2(flag ? (0f - num) : 0f, flag2 ? (0f - value2) : 0f); } private static TextAlignmentOptions GetAlignment() { return (TextAlignmentOptions)(ScrapValueHUDConfig.ScrapValueAnchor.Value switch { LabelAnchor.TopLeft => 257, LabelAnchor.TopRight => 260, LabelAnchor.BottomLeft => 1025, _ => 1028, }); } private void Refresh(bool updateDisplay = false) { if (slotLabels == null) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; for (int i = 0; i < slotLabels.Length; i++) { if (updateDisplay) { ApplyLabelStyle(slotLabels[i]); RectTransform component = ((Component)slotLabels[i]).GetComponent<RectTransform>(); ApplyAnchor(component); } GrabbableObject item = (((Object)(object)val != (Object)null && i < val.ItemSlots.Length) ? val.ItemSlots[i] : null); UpdateLabel(slotLabels[i], item); } } private static void UpdateLabel(TextMeshProUGUI? label, GrabbableObject? item) { if (!((Object)(object)label == (Object)null)) { int num = (((Object)(object)item != (Object)null && (Object)(object)item.itemProperties != (Object)null && item.itemProperties.isScrap) ? item.scrapValue : int.MinValue); ((TMP_Text)label).text = ((num == int.MinValue) ? string.Empty : ("$" + num)); } } } [BepInPlugin("com.elitemastereric.scrapvaluehud", "ScrapValueHUD", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ScrapValueHUD : BaseUnityPlugin { public static ScrapValueHUD Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; ScrapValueHUDConfig.Initialize(((BaseUnityPlugin)this).Config); SetupCompatibility(); Patch(); Logger.LogInfo((object)"com.elitemastereric.scrapvaluehud v1.0.0 has loaded!"); } internal static void Patch() { //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_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("com.elitemastereric.scrapvaluehud"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void SetupCompatibility() { if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { Logger.LogInfo((object)"LethalConfig detected, setting up compatibility..."); LethalConfigCompat.Setup(); } } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } internal enum LabelAnchor { TopLeft, TopRight, BottomLeft, BottomRight } internal static class ScrapValueHUDConfig { internal static ConfigEntry<int> ScrapValueFontSize; internal static ConfigEntry<LabelAnchor> ScrapValueAnchor; internal static ConfigEntry<float> ScrapValueVerticalPadding; internal static ConfigEntry<float> ScrapValueHorizontalPadding; internal static ConfigEntry<bool> FixRotation; internal static void Initialize(ConfigFile config) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown ScrapValueFontSize = config.Bind<int>("Scrap Value", "Font Size", 8, new ConfigDescription("Font size of the scrap value label.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 72), Array.Empty<object>())); ScrapValueFontSize.SettingChanged += delegate { ScrapValueHUDUI.RefreshLabels(updateDisplay: true); }; ScrapValueAnchor = config.Bind<LabelAnchor>("Scrap Value", "Anchor", LabelAnchor.BottomRight, "The corner of the slot at which the label is anchored."); ScrapValueAnchor.SettingChanged += delegate { ScrapValueHUDUI.RefreshLabels(updateDisplay: true); }; ScrapValueVerticalPadding = config.Bind<float>("Scrap Value", "Vertical Padding", 2f, new ConfigDescription("Distance from the top or bottom of the slot to the label, depending on the anchor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-64f, 64f), Array.Empty<object>())); ScrapValueVerticalPadding.SettingChanged += delegate { ScrapValueHUDUI.RefreshLabels(updateDisplay: true); }; ScrapValueHorizontalPadding = config.Bind<float>("Scrap Value", "Horizontal Padding", 4f, new ConfigDescription("Distance from the left or right side of the slot to the label, depending on the anchor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-64f, 64f), Array.Empty<object>())); ScrapValueHorizontalPadding.SettingChanged += delegate { ScrapValueHUDUI.RefreshLabels(updateDisplay: true); }; FixRotation = config.Bind<bool>("Misc", "Fix Rotation", true, "Correct the rotation of the slot icon frames."); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.elitemastereric.scrapvaluehud"; public const string PLUGIN_NAME = "ScrapValueHUD"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ScrapValueHUD.Patches { [HarmonyPatch(typeof(HUDManager))] internal static class HUDManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostfix(HUDManager __instance) { if (!((Object)(object)HUDManager.Instance != (Object)(object)__instance) && (Object)(object)((Component)__instance).GetComponent<ScrapValueHUDUI>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<ScrapValueHUDUI>(); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerBPatch { [HarmonyPatch("SwitchToItemSlot")] [HarmonyPostfix] private static void SwitchToItemSlotPostfix() { ScrapValueHUDUI.RefreshLabels(); } [HarmonyPatch("DespawnHeldObjectOnClient")] [HarmonyPostfix] private static void DespawnHeldObjectOnClientPostfix() { ScrapValueHUDUI.RefreshLabels(); } [HarmonyPatch("SetObjectAsNoLongerHeld")] [HarmonyPostfix] private static void SetObjectAsNoLongerHeldPostfix() { ScrapValueHUDUI.RefreshLabels(); } [HarmonyPatch("PlaceObjectServerRpc")] [HarmonyPostfix] private static void PlaceObjectServerRpcPostfix() { ScrapValueHUDUI.RefreshLabels(); } [HarmonyPatch("DropAllHeldItems")] [HarmonyPostfix] private static void DropAllHeldItemsPostfix() { ScrapValueHUDUI.RefreshLabels(); } } } namespace ScrapValueHUD.Compatibility { internal class LethalConfigCompat { internal static void Setup() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ScrapValueHUDConfig.FixRotation, true)); LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(ScrapValueHUDConfig.ScrapValueFontSize, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<LabelAnchor>(ScrapValueHUDConfig.ScrapValueAnchor, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(ScrapValueHUDConfig.ScrapValueVerticalPadding, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(ScrapValueHUDConfig.ScrapValueHorizontalPadding, false)); } } }