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 TMPro; using UnityEngine; using UnityEngine.Events; 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("Estonia")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Prevents weapons from being sold in How to Fish.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WeaponSaleLock")] [assembly: AssemblyTitle("WeaponSaleLock")] [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 WeaponSaleLock { [BepInPlugin("estonia.howtofish.weaponsalelock", "Weapon Sale Lock", "1.0.0")] [BepInProcess("How to Fish.exe")] public sealed class WeaponSaleLockPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(NPC), "CanEat")] private static class NpcCanEatPatch { private static bool Prefix(NPCQuest quest, Item item, ref bool __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)quest) && (int)quest.Type == 1 && ShouldBlock(item)) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(MoneyManager), "SellItem")] private static class MoneyManagerSellItemPatch { private static bool Prefix(Item item) { return !ShouldBlock(item); } } private const string PluginGuid = "estonia.howtofish.weaponsalelock"; private const string PluginName = "Weapon Sale Lock"; private const string PluginVersion = "1.0.0"; private const string Author = "Estonia"; private static readonly BindingFlags PrivateStatic = BindingFlags.Static | BindingFlags.NonPublic; private static readonly BindingFlags PrivateInstance = BindingFlags.Instance | BindingFlags.NonPublic; private static WeaponSaleLockPlugin _instance; private ConfigEntry _blockWeaponSales; private Harmony _harmony; private PauseManager _pauseManager; private ButtonManager _buttonManager; private GameObject _optionsScreen; private GameObject _settingsRow; private Toggle _settingsToggle; private TextMeshProUGUI _settingsText; private bool BlockWeaponSales { get { return _blockWeaponSales.Value; } set { _blockWeaponSales.Value = value; RefreshSettingsUi(); } } private void Awake() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown _instance = this; _blockWeaponSales = ((BaseUnityPlugin)this).Config.Bind("General", "BlockWeaponSales", true, "Yes blocks weapons from being sold. No allows weapon selling."); _harmony = new Harmony("estonia.howtofish.weaponsalelock"); _harmony.PatchAll(typeof(WeaponSaleLockPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Weapon Sale Lock 1.0.0 loaded. Author: Estonia."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } if (Object.op_Implicit((Object)(object)_settingsRow)) { Object.Destroy((Object)(object)_settingsRow); } } private void Update() { EnsureSettingsUi(); RefreshSettingsUi(); } private void EnsureSettingsUi() { PauseManager pauseManager = GetPauseManager(); ButtonManager buttonManager = GetButtonManager(); if (!Object.op_Implicit((Object)(object)pauseManager) || !Object.op_Implicit((Object)(object)buttonManager)) { return; } GameObject privateField = GetPrivateField(pauseManager, "_optionsScreen"); if (Object.op_Implicit((Object)(object)privateField) && (!((Object)(object)pauseManager == (Object)(object)_pauseManager) || !((Object)(object)buttonManager == (Object)(object)_buttonManager) || !((Object)(object)privateField == (Object)(object)_optionsScreen) || !Object.op_Implicit((Object)(object)_settingsRow))) { _pauseManager = pauseManager; _buttonManager = buttonManager; _optionsScreen = privateField; if (Object.op_Implicit((Object)(object)_settingsRow)) { Object.Destroy((Object)(object)_settingsRow); } BuildSettingsToggle(); } } private void BuildSettingsToggle() { Toggle val = GetPrivateField(_buttonManager, "_damageNumbersToggle") ?? GetPrivateField(_buttonManager, "_itemDotsToggle") ?? _optionsScreen.GetComponentInChildren(true); if (Object.op_Implicit((Object)(object)val)) { BuildClonedToggle(val); } else { BuildFallbackButton(); } } private void BuildClonedToggle(Toggle templateToggle) { Transform val = (Object.op_Implicit((Object)(object)((Component)templateToggle).transform.parent) ? ((Component)templateToggle).transform.parent : ((Component)templateToggle).transform); Transform val2 = (Object.op_Implicit((Object)(object)val.parent) ? val.parent : _optionsScreen.transform); _settingsRow = Object.Instantiate(((Component)val).gameObject, val2); ((Object)_settingsRow).name = "WeaponSaleLock_SettingsToggle"; _settingsRow.SetActive(true); _settingsRow.transform.SetAsLastSibling(); RemoveRelabelComponents(_settingsRow); _settingsToggle = _settingsRow.GetComponentInChildren(true); if (Object.op_Implicit((Object)(object)_settingsToggle)) { ((UnityEventBase)_settingsToggle.onValueChanged).RemoveAllListeners(); _settingsToggle.isOn = BlockWeaponSales; ((UnityEvent)(object)_settingsToggle.onValueChanged).AddListener((UnityAction)SetFromToggle); } _settingsText = FindBestText(_settingsRow); RefreshSettingsUi(); } private void BuildFallbackButton() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_008b: 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_00d0: 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_0109: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0169: Unknown result type (might be due to invalid IL or missing references) _settingsRow = new GameObject("WeaponSaleLock_SettingsButton", new Type[4] { typeof(RectTransform), typeof(Image), typeof(Button), typeof(LayoutElement) }); _settingsRow.transform.SetParent(_optionsScreen.transform, false); _settingsRow.transform.SetAsLastSibling(); _settingsRow.GetComponent().sizeDelta = new Vector2(360f, 56f); Image component = _settingsRow.GetComponent(); ((Graphic)component).color = new Color(0.12f, 0.06f, 0.12f, 0.72f); AddBorder(_settingsRow.transform, 2f, Color.white); Button component2 = _settingsRow.GetComponent