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 AllToolsUnlockable v1.0.0
AllToolsUnlockable.dll
Decompiled 7 months agousing System; using System.Collections.Generic; 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AllToolsUnlockable")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("All Tools Unlockable")] [assembly: AssemblyTitle("AllToolsUnlockable")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AllToolsUnlockable { [BepInPlugin("AllToolsUnlockable", "All Tools Unlockable", "1.0.0")] [Harmony] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private static ConfigEntry<bool> unlockSilkshots; private static ConfigEntry<bool> unlockPurseOrSatchel; private static ConfigEntry<bool> unlockCurveclaw; private static ConfigEntry<bool> unlockDruidsEye; private static ConfigEntry<bool> unlockClawMirror; private static ConfigEntry<bool> reunlockSnareSetter; private static ConfigEntry<bool> unlockNeedlePhial; private static ConfigEntry<bool> debugPrint; private static ConfigFile cfg; private static bool AddingTools; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("AllToolsUnlockable"); val.PatchAll(); unlockSilkshots = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockSidegrade", "unlockSilkshots", false, "Unlock the other Silkshots when one is acquired"); unlockPurseOrSatchel = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockSidegrade", "unlockPurseOrSatchel", false, "Unlock Dead Bug's Purse or Shell Satchel when the other is acquired"); unlockCurveclaw = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockDowngrade", "unlockCurveclaw", false, "Re-unlock Curveclaw when Curvesickle is acquired"); unlockDruidsEye = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockDowngrade", "unlockDruidsEye", false, "Re-unlock Druid's Eye when Druid's Eyes are acquired"); unlockClawMirror = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockDowngrade", "unlockClawMirror", false, "Re-unlock Claw Mirror when Claw Mirrors are acquired"); reunlockSnareSetter = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockMisc", "reunlockSnareSetter", false, "Re-unlock Snare Setter when you enter Act 3"); unlockNeedlePhial = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockMisc", "unlockNeedlePhial", false, "Unlock Needle Phial when the Plasmium Gland is acquired"); debugPrint = ((BaseUnityPlugin)this).Config.Bind<bool>("DEBUG", "debugPrintTools", false, "Print the unlock state of all tools to the console in the format \"{tool.IsUnlocked}/{tool.IsUnlockedNotHidden}: {tool.name}\""); cfg = ((BaseUnityPlugin)this).Config; AddingTools = false; Logger.LogInfo((object)"Plugin AllToolsUnlockable is loaded!"); } [HarmonyPatch(typeof(HeroController), "NearBench")] [HarmonyPrefix] private static void AddMissingToolsNearBench(bool isNearBench) { if (isNearBench) { AddMissingTools(); } } [HarmonyPatch(typeof(ToolItem), "Unlock")] [HarmonyPostfix] private static void AddMissingToolsUnlock(Action afterTutorialMsg = null, PopupFlags popupFlags = 3) { if (!AddingTools) { AddMissingTools(); } } private static void AddMissingTools() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown AddingTools = true; cfg.Reload(); if (debugPrint.Value) { Logger.LogInfo((object)"DEBUG - Print Tools"); DebugPrintTools(); } Logger.LogInfo((object)"Potentially adding tools:"); using IEnumerator<ToolItem> enumerator = ((NamedScriptableObjectList<ToolItem>)(ToolItemList)typeof(ToolItemManager).GetField("toolItems", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ManagerSingleton<ToolItemManager>.Instance)).GetEnumerator(); Dictionary<string, ToolItem> dictionary = new Dictionary<string, ToolItem>(); while (enumerator.MoveNext()) { ToolItem current = enumerator.Current; if (Object.op_Implicit((Object)(object)current)) { switch (current.name) { case "Dead Mans Purse": case "Shell Satchel": case "WebShot Forge": case "WebShot Architect": case "WebShot Weaver": case "Curve Claws": case "Curve Claws Upgraded": case "Mosscreep Tool 1": case "Mosscreep Tool 2": case "Dazzle Bind": case "Dazzle Bind Upgraded": case "Silk Snare": case "Extractor": dictionary.Add(current.name, current); break; } } } if (unlockSilkshots.Value) { Logger.LogInfo((object)"Try unlock Silkshots"); ConditionalUnlockAny(dictionary, "WebShot Forge", "WebShot Architect", "WebShot Weaver"); } if (unlockPurseOrSatchel.Value) { Logger.LogInfo((object)"Try unlock Dead Bug's Purse or Shell Satchel"); ConditionalUnlockAny(dictionary, "Dead Mans Purse", "Shell Satchel"); } if (unlockCurveclaw.Value) { Logger.LogInfo((object)"Try unlock Curveclaw downgrade"); ConditionalUnlockOne(dictionary, "Curve Claws Upgraded", "Curve Claws"); } if (unlockDruidsEye.Value) { Logger.LogInfo((object)"Try unlock Druid's Eye downgrade"); ConditionalUnlockOne(dictionary, "Mosscreep Tool 2", "Mosscreep Tool 1"); } if (unlockClawMirror.Value) { Logger.LogInfo((object)"Try unlock Claw Mirror downgrade"); ConditionalUnlockOne(dictionary, "Dazzle Bind Upgraded", "Dazzle Bind"); } if (reunlockSnareSetter.Value) { Logger.LogInfo((object)"Try unlock Snare Setter"); if (PlayerData.instance.act3_wokeUp) { ToolItem val = dictionary["Silk Snare"]; if (val.IsUnlocked && !val.IsUnlockedNotHidden) { Logger.LogInfo((object)"Unlocking tool \"Silk Snare\""); val.SetUnlockedTestsComplete(); val.Unlock((Action)null, (PopupFlags)3); } } } if (unlockNeedlePhial.Value) { Logger.LogInfo((object)"Try unlock Needle Phial"); if (PlayerData.instance.HasLifebloodSyringeGland) { ToolItem val2 = dictionary["Extractor"]; if (val2.IsUnlocked && !val2.IsUnlockedNotHidden) { Logger.LogInfo((object)"Unlocking tool \"Extractor\""); val2.SetUnlockedTestsComplete(); val2.Unlock((Action)null, (PopupFlags)3); } } } AddingTools = false; Logger.LogInfo((object)"Completed"); } private static void ConditionalUnlockAny(Dictionary<string, ToolItem> toolDict, params string[] tools) { foreach (string key in tools) { ConditionalUnlockOne(toolDict, key, tools); } } private static void ConditionalUnlockOne(Dictionary<string, ToolItem> toolDict, string key, params string[] tools) { if (!toolDict[key].IsUnlockedNotHidden) { return; } foreach (string text in tools) { if (!(key == text)) { ToolItem val = toolDict[text]; if (!val.IsUnlockedNotHidden) { Logger.LogInfo((object)("Unlocking tool \"" + text + "\" as tool \"" + key + "\" is unlocked")); val.SetUnlockedTestsComplete(); val.Unlock((Action)null, (PopupFlags)3); } } } } private static void DebugPrintTools() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown Logger.LogInfo((object)"All tools:"); foreach (ToolItem item in (NamedScriptableObjectList<ToolItem>)(ToolItemList)typeof(ToolItemManager).GetField("toolItems", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ManagerSingleton<ToolItemManager>.Instance)) { if (Object.op_Implicit((Object)(object)item)) { Logger.LogInfo((object)$"{item.IsUnlocked}/{item.IsUnlockedNotHidden}: {item.name}"); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "AllToolsUnlockable"; public const string PLUGIN_NAME = "All Tools Unlockable"; public const string PLUGIN_VERSION = "1.0.0"; } }