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 DisableItemsInShop v2.0.0
BepInEx/plugins/DisableItemsInShop/lucyddemon.disableitemsinshop.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 DisableItemsInShop.Patches; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("LucydDemon")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+59e8bf6e02a43d0231ef2f40359ba2869180ec99")] [assembly: AssemblyProduct("DisableItemsInShop")] [assembly: AssemblyTitle("lucyddemon.disableitemsinshop")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 DisableItemsInShop { internal class DisableItemsInShopConfig { public class Section { public readonly ConfigEntry<bool> Explosives; public readonly ConfigEntry<bool> CartWeapons; public readonly ConfigEntry<bool> Guns; public readonly ConfigEntry<bool> Melees; public readonly ConfigEntry<bool> Drones; public readonly ConfigEntry<bool> Orbs; public readonly ConfigEntry<bool> RubberDuck; private readonly ConfigEntry<string> CustomItems; private List<string> _customItemsList = new List<string>(); public IReadOnlyList<string> CustomItemsList => _customItemsList; internal Section(ConfigFile cfg, string sectionName) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown Explosives = cfg.Bind<bool>(sectionName, "DisableExplosives", true, (ConfigDescription)null); CartWeapons = cfg.Bind<bool>(sectionName, "DisableCartWeapons", true, (ConfigDescription)null); Guns = cfg.Bind<bool>(sectionName, "DisableGuns", false, (ConfigDescription)null); Melees = cfg.Bind<bool>(sectionName, "DisableMelees", false, (ConfigDescription)null); Drones = cfg.Bind<bool>(sectionName, "DisableDrones", false, (ConfigDescription)null); Orbs = cfg.Bind<bool>(sectionName, "DisableOrbs", false, (ConfigDescription)null); RubberDuck = cfg.Bind<bool>(sectionName, "DisableRubberDuck", false, (ConfigDescription)null); CustomItems = cfg.Bind<string>(sectionName, "DisableCustomItems", "", new ConfigDescription("Comma-separated list of item name patterns to disable. Only works for toggleable items like guns, mines, etc. (ex. Rifle, Drone, ...)", (AcceptableValueBase)null, Array.Empty<object>())); CacheCustomItemsList(); } public void CacheCustomItemsList() { _customItemsList = (from item in CustomItems.Value.Split(',') select item.Trim() into item where !string.IsNullOrEmpty(item) select item).ToList(); } } public readonly Section Shop; public readonly Section Lobby; public DisableItemsInShopConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; Shop = new Section(cfg, "Shop"); Lobby = new Section(cfg, "Lobby"); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } [BepInPlugin("lucyddemon.disableitemsinshop", "DisableItemsInShop", "2.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("lucyddemon.disableitemsinshop"); internal static Plugin Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal static DisableItemsInShopConfig BoundConfig { get; private set; } internal static DisableItemsInShopConfig.Section? ActiveConfig { get { if (!SemiFunc.RunIsShop()) { if (!SemiFunc.RunIsLobby()) { return null; } return BoundConfig.Lobby; } return BoundConfig.Shop; } } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; BoundConfig = new DisableItemsInShopConfig(((BaseUnityPlugin)this).Config); harmony.PatchAll(typeof(ItemTogglePatch)); harmony.PatchAll(typeof(ItemGunPatch)); harmony.PatchAll(typeof(ItemMeleePatch)); harmony.PatchAll(typeof(ItemRubberDuckPatch)); Logger.LogInfo((object)"\ud83d\udeab DisableItemsInShop 2.0.0 by LucydDemon initialized!"); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } internal static class MyPluginInfo { public const string PLUGIN_GUID = "lucyddemon.disableitemsinshop"; public const string PLUGIN_NAME = "DisableItemsInShop"; public const string PLUGIN_VERSION = "2.0.0"; public const string PLUGIN_AUTHOR = "LucydDemon"; } } namespace DisableItemsInShop.Patches { [HarmonyPatch(typeof(ItemGun))] internal static class ItemGunPatch { private static bool IsGunDisabled { get { if (Plugin.ActiveConfig != null) { return Plugin.ActiveConfig.Guns.Value; } return false; } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(ItemGun __instance) { if (IsGunDisabled) { Plugin.Logger.LogDebug((object)("Disabled gun misfire: " + ((Object)__instance).name)); } } [HarmonyPatch("Misfire")] [HarmonyPrefix] private static bool Misfire_Prefix(ItemGun __instance) { if (!IsGunDisabled) { return true; } return false; } } [HarmonyPatch(typeof(ItemMelee))] internal static class ItemMeleePatch { private static bool IsMeleeDisabled { get { if (Plugin.ActiveConfig != null) { return Plugin.ActiveConfig.Melees.Value; } return false; } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(ItemMelee __instance) { if (IsMeleeDisabled) { Plugin.Logger.LogDebug((object)("Disabled item usage: " + ((Object)__instance).name)); } } [HarmonyPatch("Update")] [HarmonyPrefix] private static bool Update_Prefix(ItemMelee __instance) { if (!IsMeleeDisabled) { return true; } return false; } } [HarmonyPatch(typeof(ItemRubberDuck))] internal static class ItemRubberDuckPatch { private static bool IsRubberDuckDisabled { get { if (Plugin.ActiveConfig != null) { return Plugin.ActiveConfig.RubberDuck.Value; } return false; } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(ItemRubberDuck __instance) { if (IsRubberDuckDisabled) { Plugin.Logger.LogDebug((object)("Disabled item usage: " + ((Object)__instance).name)); } } [HarmonyPatch("Quack")] [HarmonyPrefix] private static bool Quack_Prefix(ItemRubberDuck __instance) { if (!IsRubberDuckDisabled) { return true; } return false; } } [HarmonyPatch(typeof(ItemToggle))] internal static class ItemTogglePatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(ItemToggle __instance) { if (ShouldDisableItem(((Object)__instance).name)) { __instance.ToggleDisable(true); Plugin.Logger.LogDebug((object)("Disabled item usage: " + ((Object)__instance).name)); } } private static bool ShouldDisableItem(string itemName) { string itemName2 = itemName; if (Plugin.ActiveConfig == null) { return false; } bool value = Plugin.ActiveConfig.Explosives.Value; bool value2 = Plugin.ActiveConfig.CartWeapons.Value; bool value3 = Plugin.ActiveConfig.Guns.Value; bool value4 = Plugin.ActiveConfig.Drones.Value; bool value5 = Plugin.ActiveConfig.Orbs.Value; bool flag = value && (itemName2.StartsWith("Item Grenade") || itemName2.StartsWith("Item Mine")); bool flag2 = value2 && (itemName2.StartsWith("Item Cart Cannon") || itemName2.StartsWith("Item Cart Laser")); bool flag3 = value3 && itemName2.StartsWith("Item Gun"); bool flag4 = value4 && itemName2.StartsWith("Item Drone"); bool flag5 = value5 && itemName2.StartsWith("Item Orb"); bool flag6 = Plugin.ActiveConfig.CustomItemsList.Any((string item) => itemName2.IndexOf(item, StringComparison.OrdinalIgnoreCase) >= 0); return flag || flag2 || flag3 || flag4 || flag5 || flag6; } } }