using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("InfiniteTools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InfiniteTools")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0d2eaa2c-42c1-4097-aabe-487d3c5656f0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.dream.InfiniteTools", "Infinite Tools", "1.0.0")]
public class InfiniteTools : BaseUnityPlugin
{
private static ConfigEntry<bool> CfgEnableInfiniteAllToolsUse;
private static List<ConfigEntry<bool>> ToolConfigEntries = new List<ConfigEntry<bool>>();
private static readonly List<string> ToolUnofficialNames = new List<string>
{
"Cogwork Flier", "Cogwork Saw", "Conch Drill", "Curve Claws", "Screw Attack", "Flea Brew", "Flintstone", "Harpoon", "Pimpilo", "Lifeblood Syringe",
"Rosary Cannon", "WebShot Architect", "Sting Shard", "Straight Pin", "Tack", "Tri Pin", "Shakra Ring", "Lightning Rod"
};
private static readonly List<string> ToolNames = new List<string>
{
"Cogfly", "Cogwork Wheel", "Conchcutter", "Curveclaw", "Delver's Drill", "Flea Brew", "Flintslate", "Longpin", "Pimpillo", "Plasmium Phial",
"Rosary Cannon", "Silkshot", "Sting Shard", "Straight Pin", "Tacks", "Threefold Pin", "Throwing Ring", "Voltvessels"
};
private void Awake()
{
CfgEnableInfiniteAllToolsUse = ((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "Enable Infinite Use for All Tools", true, "Enable infinite use for all tools.");
for (int i = 0; i < ToolNames.Count; i++)
{
ToolConfigEntries.Add(((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "Enable Infinite Use for " + ToolNames[i].Replace("'", ""), false, "Enable or disable infinite use for the " + ToolNames[i].Replace("'", "") + " tool."));
}
ToolItemManager.IsInfiniteToolUseEnabled = CfgEnableInfiniteAllToolsUse.Value;
CfgEnableInfiniteAllToolsUse.SettingChanged += delegate
{
ToolItemManager.IsInfiniteToolUseEnabled = CfgEnableInfiniteAllToolsUse.Value;
};
Harmony.CreateAndPatchAll(typeof(InfiniteTools), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"InfiniteTools is loaded!");
}
public static void ReplenishTool(ToolItem tool)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)tool != (Object)null && ((ToolBase)tool).IsEquipped)
{
Data savedData = tool.SavedData;
savedData.AmountLeft = ToolItemManager.GetToolStorageAmount(tool);
tool.SavedData = savedData;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ToolItemManager), "ReportBoundAttackToolUsed")]
public static void PostfixReportBoundAttackToolUsed(ToolItemManager __instance, AttackToolBinding binding)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (CfgEnableInfiniteAllToolsUse.Value)
{
return;
}
try
{
ToolItem boundAttackTool = ToolItemManager.GetBoundAttackTool(binding, (ToolEquippedReadSource)0);
if ((Object)(object)boundAttackTool != (Object)null && ToolConfigEntries[ToolUnofficialNames.IndexOf(boundAttackTool.name)].Value)
{
ReplenishTool(boundAttackTool);
}
}
catch (Exception arg)
{
Debug.LogError((object)$"[UsageWatcher] Exception: {arg}");
}
}
}