using 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("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+993d75b601b1e8ef8f60f1c45a205b2ed5599d4c")]
[assembly: AssemblyProduct("DisableItemsInShop")]
[assembly: AssemblyTitle("lucyddemon.disableitemsinshop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.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.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 readonly ConfigEntry<string> Level;
public readonly ConfigEntry<bool> Explosives;
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;
public IReadOnlyList<string> CustomItemsList => _customItemsList;
public DisableItemsInShopConfig(ConfigFile cfg)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
cfg.SaveOnConfigSet = false;
Level = cfg.Bind<string>("General", "DisableLevel", "Shop", new ConfigDescription("Where should items be disabled", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Shop", "Lobby", "Both" }), Array.Empty<object>()));
Explosives = cfg.Bind<bool>("General", "DisableExplosives", true, (ConfigDescription)null);
Guns = cfg.Bind<bool>("General", "DisableGuns", false, (ConfigDescription)null);
Melees = cfg.Bind<bool>("General", "DisableMelees", false, (ConfigDescription)null);
Drones = cfg.Bind<bool>("General", "DisableDrones", false, (ConfigDescription)null);
Orbs = cfg.Bind<bool>("General", "DisableOrbs", false, (ConfigDescription)null);
RubberDuck = cfg.Bind<bool>("General", "DisableRubberDuck", false, (ConfigDescription)null);
CustomItems = cfg.Bind<string>("Custom", "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();
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();
}
public void CacheCustomItemsList()
{
_customItemsList = (from item in CustomItems.Value.Split(',')
select item.Trim() into item
where !string.IsNullOrEmpty(item)
select item).ToList();
}
}
[BepInPlugin("lucyddemon.disableitemsinshop", "DisableItemsInShop", "1.4.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; }
public static bool IsInDisabledLevel
{
get
{
bool flag = SemiFunc.RunIsShop();
bool flag2 = SemiFunc.RunIsLobby();
return BoundConfig.Level.Value switch
{
"Shop" => flag,
"Lobby" => flag2,
"Both" => flag || flag2,
_ => false,
};
}
}
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)"DisableItemsInShop 1.4.0 by LucydDemon has loaded!");
}
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 = "1.4.0";
public const string PLUGIN_AUTHOR = "LucydDemon";
}
}
namespace DisableItemsInShop.Patches
{
[HarmonyPatch(typeof(ItemGun))]
internal static class ItemGunPatch
{
private static bool IsGunDisabled
{
get
{
if (Plugin.IsInDisabledLevel)
{
return Plugin.BoundConfig.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.IsInDisabledLevel)
{
return Plugin.BoundConfig.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.IsInDisabledLevel)
{
return Plugin.BoundConfig.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 (Plugin.IsInDisabledLevel)
{
DisableItemsInShopConfig boundConfig = Plugin.BoundConfig;
if (ShouldDisableItem(((Object)__instance).name, boundConfig))
{
__instance.ToggleDisable(true);
Plugin.Logger.LogDebug((object)("Disabled item usage: " + ((Object)__instance).name));
}
}
}
private static bool ShouldDisableItem(string itemName, DisableItemsInShopConfig cfg)
{
bool flag = cfg.Explosives.Value && (itemName.StartsWith("Item Grenade") || itemName.StartsWith("Item Mine"));
bool flag2 = cfg.Guns.Value && itemName.StartsWith("Item Gun");
bool flag3 = cfg.Drones.Value && itemName.StartsWith("Item Drone");
bool flag4 = cfg.Orbs.Value && itemName.StartsWith("Item Orb");
bool flag5 = cfg.CustomItemsList.Any((string item) => itemName.IndexOf(item, StringComparison.OrdinalIgnoreCase) >= 0);
return flag || flag2 || flag3 || flag4 || flag5;
}
}
}