using System;
using System.Collections;
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 BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OldMarket.InstantFishingRod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OldMarket.InstantFishingRod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4170d81e-5973-4018-a9cc-926e58425dde")]
[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")]
namespace OldMarket.OneClickFishing;
[BepInPlugin("oldmarket.oneclickfishing", "Old Market One Click Fishing", "1.1.0")]
public class OneClickFishingPlugin : BaseUnityPlugin
{
public const string PluginGuid = "oldmarket.oneclickfishing";
public const string PluginName = "Old Market One Click Fishing";
public const string PluginVersion = "1.1.0";
internal static ManualLogSource Log;
internal static ConfigEntry<bool> UseDurabilityFishing;
private void Awake()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
UseDurabilityFishing = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseDurabilityFishing", false, "If true, a single bite consumes all remaining durability of the fishing rod in one go and drops all loot at the player’s feet.");
new Harmony("oldmarket.oneclickfishing").PatchAll();
Log.LogInfo((object)"Old Market One Click Fishing 1.1.0 loaded.");
}
}
[HarmonyPatch(typeof(FishingRod))]
internal static class FishingRodPatches
{
private static readonly FieldInfo HasFishField = AccessTools.Field(typeof(FishingRod), "hasFish");
private static readonly FieldInfo PlayerInventoryField = AccessTools.Field(typeof(FishingRod), "playerInventory");
private static readonly MethodInfo CheckBaitMethod = AccessTools.Method(typeof(FishingRod), "CheckBait", (Type[])null, (Type[])null);
private static readonly MethodInfo ReduceCurrentItemAmountMethod = AccessTools.Method(typeof(PlayerInventory), "ReduceCurrentItemAmount", (Type[])null, (Type[])null);
private static readonly MethodInfo PullFishMethod = AccessTools.Method(typeof(FishingRod), "PullFish", (Type[])null, (Type[])null);
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void AwakePostfix(FishingRod __instance)
{
__instance.minFishTime = 0f;
__instance.maxFishTime = 0f;
}
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void UpdatePostfix(FishingRod __instance)
{
if (!(HasFishField == null) && !(PullFishMethod == null) && (bool)HasFishField.GetValue(__instance))
{
PullFishMethod.Invoke(__instance, null);
}
}
[HarmonyPrefix]
[HarmonyPatch("PullFish")]
private static bool PullFishPrefix(FishingRod __instance)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
if (OneClickFishingPlugin.UseDurabilityFishing == null || !OneClickFishingPlugin.UseDurabilityFishing.Value)
{
return true;
}
if ((Object)(object)GameManager.Instance == (Object)null || PlayerInventoryField == null || CheckBaitMethod == null || ReduceCurrentItemAmountMethod == null)
{
ManualLogSource log = OneClickFishingPlugin.Log;
if (log != null)
{
log.LogWarning((object)"[OneClickFishing] Required reflection members missing. Fallback to original PullFish.");
}
return true;
}
object? value = PlayerInventoryField.GetValue(__instance);
PlayerInventory val = (PlayerInventory)((value is PlayerInventory) ? value : null);
if ((Object)(object)val == (Object)null)
{
return true;
}
int amount = val.GetCurrentInventorySlot().amount;
if (amount <= 0)
{
return false;
}
Vector3 position = ((Component)val).transform.position;
__instance.PullBait();
if ((Object)(object)GameManager.Instance.audioSource != (Object)null && (Object)(object)__instance.audioCatch != (Object)null)
{
GameManager.Instance.audioSource.PlayOneShot(__instance.audioCatch, 0.2f);
}
GameObject val2 = new GameObject("OneClickFishingBurstRunner");
Object.DontDestroyOnLoad((Object)val2);
val2.AddComponent<BurstFishingRunner>().Setup(__instance, val, amount, position, CheckBaitMethod, ReduceCurrentItemAmountMethod);
return false;
}
}
internal class BurstFishingRunner : MonoBehaviour
{
[CompilerGenerated]
private sealed class <BurstRoutine>d__7 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BurstFishingRunner <>4__this;
private GameManager <gm>5__2;
private int <i>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BurstRoutine>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<gm>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
BurstFishingRunner burstFishingRunner = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<gm>5__2 = GameManager.Instance;
if ((Object)(object)<gm>5__2 == (Object)null || (Object)(object)burstFishingRunner.rod == (Object)null || (Object)(object)burstFishingRunner.inventory == (Object)null)
{
Object.Destroy((Object)(object)((Component)burstFishingRunner).gameObject);
return false;
}
<i>5__3 = 0;
break;
case 1:
<>1__state = -1;
<i>5__3++;
break;
}
if (<i>5__3 < burstFishingRunner.remainingUses && burstFishingRunner.inventory.GetCurrentInventorySlot().amount > 0)
{
if (burstFishingRunner.reduceCurrentItemAmountMethod != null)
{
burstFishingRunner.reduceCurrentItemAmountMethod.Invoke(burstFishingRunner.inventory, null);
}
ItemSO val = null;
if (burstFishingRunner.checkBaitMethod != null)
{
object? obj = burstFishingRunner.checkBaitMethod.Invoke(burstFishingRunner.rod, null);
val = (ItemSO)((obj is ItemSO) ? obj : null);
}
if ((Object)(object)val != (Object)null)
{
int num2 = Mathf.Max(((ItemSO)burstFishingRunner.rod.toolSO).basePrice / ((ItemSO)burstFishingRunner.rod.toolSO).amount, 1);
<gm>5__2.SpawnItemAtPositionServerRpc(val.id, burstFishingRunner.dropPosition, false, val.amount, num2, 0);
<gm>5__2.TriggerAchievement("catch_fish");
}
<>2__current = null;
<>1__state = 1;
return true;
}
Object.Destroy((Object)(object)((Component)burstFishingRunner).gameObject);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private FishingRod rod;
private PlayerInventory inventory;
private int remainingUses;
private MethodInfo checkBaitMethod;
private MethodInfo reduceCurrentItemAmountMethod;
private Vector3 dropPosition;
public void Setup(FishingRod rod, PlayerInventory inventory, int uses, Vector3 dropPosition, MethodInfo checkBaitMethod, MethodInfo reduceCurrentItemAmountMethod)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
this.rod = rod;
this.inventory = inventory;
remainingUses = uses;
this.dropPosition = dropPosition;
this.checkBaitMethod = checkBaitMethod;
this.reduceCurrentItemAmountMethod = reduceCurrentItemAmountMethod;
((MonoBehaviour)this).StartCoroutine(BurstRoutine());
}
[IteratorStateMachine(typeof(<BurstRoutine>d__7))]
private IEnumerator BurstRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BurstRoutine>d__7(0)
{
<>4__this = this
};
}
}