Decompiled source of InstantFishingLoot v1.0.0

BepInEx/plugins/InstantFishingLoot.dll

Decompiled 11 hours ago
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 HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("InstantFishingLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InstantFishingLoot")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c08a16b2-6285-4fce-999b-0519bae99862")]
[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("InstantFishingLoot", "Instant Fishing Loot", "1.0.0")]
public class InstantFishingLoot : BaseUnityPlugin
{
	[HarmonyPatch(typeof(FishingManager), "InvokeFishBite")]
	private static class FishingManager_InvokeFishBite_Patch
	{
		private static bool Prefix(FishingManager __instance, ref IEnumerator __result)
		{
			__result = InvokeFishBiteNoWait(__instance);
			return false;
		}
	}

	[HarmonyPatch(typeof(FishingRodTool), "StartPullOutFishMinigame")]
	private static class FishingRodTool_StartPullOutFishMinigame_Patch
	{
		private static bool Prefix(FishingRodTool __instance)
		{
			//IL_0028: 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)
			try
			{
				FishingFloat val = LastFloatRef.Invoke(__instance);
				if ((Object)(object)val != (Object)null)
				{
					FishingFloatPosRef.Invoke(__instance) = ((Component)val).transform.position;
				}
			}
			catch
			{
			}
			try
			{
				__instance.OnFishPullOut();
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)FishingUI.Instance != (Object)null)
				{
					FishingUI.Instance.CloseScreen();
				}
			}
			catch
			{
			}
			return false;
		}

		private static void Postfix(FishingRodTool __instance)
		{
		}
	}

	[CompilerGenerated]
	private sealed class <AutoCompleteAfterDelay>d__14 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float seconds;

		public FishingRodTool rod;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <AutoCompleteAfterDelay>d__14(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (seconds > 0f)
				{
					<>2__current = (object)new WaitForSeconds(seconds);
					<>1__state = 2;
					return true;
				}
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			try
			{
				FishingFloat val = LastFloatRef.Invoke(rod);
				if ((Object)(object)val != (Object)null)
				{
					FishingFloatPosRef.Invoke(rod) = ((Component)val).transform.position;
				}
			}
			catch
			{
			}
			try
			{
				rod.OnFishPullOut();
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)FishingUI.Instance != (Object)null)
				{
					FishingUI.Instance.CloseScreen();
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)PlayerInventory.Instance != (Object)null)
				{
					PlayerInventory.Instance.SetState((State)0);
				}
			}
			catch
			{
			}
			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();
		}
	}

	[CompilerGenerated]
	private sealed class <InvokeFishBiteNoWait>d__10 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public FishingManager manager;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <InvokeFishBiteNoWait>d__10(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			int num = <>1__state;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
				PlayerInventory instance = PlayerInventory.Instance;
				if (!((Object)(object)instance == (Object)null) && (int)instance.state == 0)
				{
					FishingRodTool val = FishingRodRef.Invoke(manager);
					if (!((Object)(object)val == (Object)null))
					{
						manager.difficulty = Random.Range(0, 3);
						instance.lastFishingDifficulty = manager.difficulty;
						val.StartPullOutFishMinigame();
						RemoveRod(manager, val);
					}
				}
			}
			else
			{
				<>1__state = -1;
			}
			<>2__current = null;
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string PluginGuid = "InstantFishingLoot";

	public const string PluginName = "Instant Fishing Loot";

	public const string PluginVersion = "1.0.0";

	internal static InstantFishingLoot Runner;

	private const bool SuppressMinigameUI = true;

	private const float AutoCompleteDelaySeconds = 0.25f;

	private static readonly FieldRef<FishingManager, FishingRodTool> FishingRodRef = AccessTools.FieldRefAccess<FishingManager, FishingRodTool>("fishingRod");

	private static readonly Action<FishingManager, FishingRodTool> RemoveRod = AccessTools.MethodDelegate<Action<FishingManager, FishingRodTool>>(AccessTools.Method(typeof(FishingManager), "RemoveRod", (Type[])null, (Type[])null), (object)null, true);

	private static readonly FieldRef<FishingRodTool, FishingFloat> LastFloatRef = AccessTools.FieldRefAccess<FishingRodTool, FishingFloat>("lastFloatObject");

	private static readonly FieldRef<FishingRodTool, Vector3> FishingFloatPosRef = AccessTools.FieldRefAccess<FishingRodTool, Vector3>("fishingFloatPos");

	private void Awake()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		Runner = this;
		new Harmony("InstantFishingLoot").PatchAll();
	}

	[IteratorStateMachine(typeof(<InvokeFishBiteNoWait>d__10))]
	private static IEnumerator InvokeFishBiteNoWait(FishingManager manager)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <InvokeFishBiteNoWait>d__10(0)
		{
			manager = manager
		};
	}

	[IteratorStateMachine(typeof(<AutoCompleteAfterDelay>d__14))]
	private static IEnumerator AutoCompleteAfterDelay(FishingRodTool rod, float seconds)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <AutoCompleteAfterDelay>d__14(0)
		{
			rod = rod,
			seconds = seconds
		};
	}
}