Decompiled source of SteadyCast v1.0.1

SteadyCast.dll

Decompiled 4 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SteadyCast
{
	[BepInPlugin("welffi.howtofish.steadycast", "SteadyCast", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "welffi.howtofish.steadycast";

		public const string Name = "SteadyCast";

		public const string Version = "1.0.1";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("welffi.howtofish.steadycast").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SteadyCast 1.0.1 loaded - casts now start from a fixed position.");
		}
	}
	internal static class BaitSteadier
	{
		private static readonly FieldInfo BaitField = AccessTools.Field(typeof(FishingRod), "_bait");

		private static readonly FieldInfo IsPullingBackField = AccessTools.Field(typeof(FishingRod), "_isPullingBack");

		private static readonly FieldInfo CurLineLengthMultiField = AccessTools.Field(typeof(FishingRod), "_curLineLengthMulti");

		internal static void SteadyBait(FishingRod rod)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)rod) || !(bool)IsPullingBackField.GetValue(rod))
			{
				return;
			}
			Player holder = ((Item)rod).Holder;
			if (!Object.op_Implicit((Object)(object)holder) || !((NetworkBehaviour)holder).Owner.IsLocalClient || !Object.op_Implicit((Object)(object)Player.LocalPlayer) || (int)CurLineLengthMultiField.GetValue(rod) != 0)
			{
				return;
			}
			object? value = BaitField.GetValue(rod);
			Bait val = (Bait)((value is Bait) ? value : null);
			if (!Object.op_Implicit((Object)(object)val) || !((Component)val).gameObject.activeInHierarchy || Object.op_Implicit((Object)(object)val.ItemOnBait))
			{
				return;
			}
			Transform camObject = Player.LocalPlayer.CamObject;
			if (Object.op_Implicit((Object)(object)camObject))
			{
				RaycastHit val2 = default(RaycastHit);
				Vector3 position = (Physics.Raycast(camObject.position, camObject.forward, ref val2, 2.5f, LayerMask.op_Implicit(GameInfo.LevelLayer)) ? Vector3.Lerp(camObject.position, ((RaycastHit)(ref val2)).point, 0.9f) : (camObject.position + camObject.forward * 2f));
				((Component)val).transform.position = position;
				((Component)val).transform.up = Vector3.up;
				Rigidbody rig = val.Rig;
				if (Object.op_Implicit((Object)(object)rig) && !rig.isKinematic)
				{
					rig.linearVelocity = Vector3.zero;
					rig.angularVelocity = Vector3.zero;
				}
			}
		}
	}
	[HarmonyPatch(typeof(FishingRod), "ReelOutInput")]
	internal static class FishingRod_ReelOutInput_SteadyCast
	{
		private static void Postfix(FishingRod __instance)
		{
			try
			{
				BaitSteadier.SteadyBait(__instance);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"SteadyCast: SteadyBait threw - {arg}");
			}
		}
	}
}