Decompiled source of CoastalFishing v2.2.4

CoastalFishingMod.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
using UnityEngine.Rendering;

[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 MarcCoastalFishing
{
	[DisallowMultipleComponent]
	public sealed class FishingAnimator : MonoBehaviour
	{
		private const string ZClip = "mf_anim";

		private const string ZSeq = "mf_anim_seq";

		private const string ZStart = "mf_anim_t";

		private const string ZLoop = "mf_anim_loop";

		private const string ZHold = "mf_hold";

		private Player _player;

		private ZNetView _nview;

		private Animator _animator;

		private FishingIK _ik;

		private PlayableGraph _graph;

		private AnimationPlayableOutput _output;

		private AnimationMixerPlayable _mixer;

		private readonly AnimationClipPlayable[] _slot = (AnimationClipPlayable[])(object)new AnimationClipPlayable[2];

		private int _activeSlot = -1;

		private float _mix = 1f;

		private float _mixSpeed = 1f;

		private float _weight;

		private float _weightTarget;

		private float _weightSpeed = 4f;

		private float _idleTime;

		private string _clip;

		private double _start;

		private bool _loop;

		private int _seq;

		private int _seenSeq = -1;

		private int _lockCount;

		private bool _handIKActive;

		private string _heldKey = string.Empty;

		private GameObject _heldVisual;

		private const string ZPause = "mf_anim_pause";

		private bool _paused;

		private static readonly Vector3 HeldOffset = new Vector3(0f, -0.05f, 0.08f);

		private static readonly Quaternion HeldRotation = Quaternion.Euler(0f, 90f, 0f);

		private bool _heldLogged;

		private static readonly FieldRef<VisEquipment, GameObject> RightItemInstanceRef = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_rightItemInstance");

		private static readonly FieldRef<VisEquipment, int> RightItemHashRef = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentRightItemHash");

		private static int _boatHookHash;

		private VisEquipment _vis;

		private Transform _pole;

		private Transform _poleModel;

		private Quaternion _poleBase;

		private Quaternion _aimLocal = Quaternion.identity;

		private float _poleWeight;

		public static FishingAnimator Local
		{
			get
			{
				if (!((Object)(object)Player.m_localPlayer != (Object)null))
				{
					return null;
				}
				return ((Component)Player.m_localPlayer).GetComponent<FishingAnimator>();
			}
		}

		public string CurrentClip => _clip;

		public float ClipTime
		{
			get
			{
				if (_clip != null)
				{
					return (float)(Util.Now - _start);
				}
				return 0f;
			}
		}

		public Player Player => _player;

		public bool IsLocal
		{
			get
			{
				if ((Object)(object)_player != (Object)null)
				{
					return (Object)(object)_player == (Object)(object)Player.m_localPlayer;
				}
				return false;
			}
		}

		public GearBase Carried { get; internal set; }

		public bool IsLocked => _lockCount > 0;

		public Quaternion? LockedFacing { get; set; }

		public bool Aiming { get; set; }

		public Vector3 HookTip { get; private set; }

		public bool HookTipValid { get; private set; }

		public void Lock()
		{
			_lockCount++;
		}

		public void Unlock()
		{
			_lockCount = Mathf.Max(0, _lockCount - 1);
			if (_lockCount == 0)
			{
				LockedFacing = null;
			}
		}

		public void ClearLocks()
		{
			_lockCount = 0;
			LockedFacing = null;
			Aiming = false;
		}

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
			_nview = ((Component)this).GetComponent<ZNetView>();
		}

		private void OnDestroy()
		{
			DestroyGraph();
			if ((Object)(object)_heldVisual != (Object)null)
			{
				Object.Destroy((Object)(object)_heldVisual);
			}
			if ((Object)(object)Carried != (Object)null && (Object)(object)Carried.CarrierAnimator == (Object)(object)this)
			{
				Carried = null;
			}
		}

		public float Play(string clipName, bool loop = false, float fade = 0.2f, float fallbackLength = 1f)
		{
			if (!IsLocal)
			{
				return 0f;
			}
			double now = Util.Now;
			_seq++;
			if ((Object)(object)_nview != (Object)null && _nview.IsValid())
			{
				ZDO zDO = _nview.GetZDO();
				zDO.Set("mf_anim", clipName ?? string.Empty);
				zDO.Set("mf_anim_seq", _seq);
				zDO.Set("mf_anim_t", (long)(now * 1000.0));
				zDO.Set("mf_anim_loop", loop);
			}
			_seenSeq = _seq;
			SetPaused(paused: false);
			Apply(clipName, loop, now, fade);
			return ModAssets.ClipLength(clipName, fallbackLength);
		}

		public void Stop(float fade = 0.3f)
		{
			if (IsLocal)
			{
				Play(null, loop: false, fade);
			}
		}

		public void SetPaused(bool paused)
		{
			if (IsLocal && paused != _paused)
			{
				_paused = paused;
				if ((Object)(object)_nview != (Object)null && _nview.IsValid())
				{
					_nview.GetZDO().Set("mf_anim_pause", paused);
				}
				ApplyPause();
			}
		}

		private void ApplyPause()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (((PlayableGraph)(ref _graph)).IsValid() && _activeSlot >= 0 && PlayableExtensions.IsValid<AnimationClipPlayable>(_slot[_activeSlot]))
			{
				PlayableExtensions.SetSpeed<AnimationClipPlayable>(_slot[_activeSlot], _paused ? 0.0 : 1.0);
			}
		}

		public void SetHeldItem(string catchKey)
		{
			if (IsLocal && !((Object)(object)_nview == (Object)null) && _nview.IsValid())
			{
				_nview.GetZDO().Set("mf_hold", catchKey ?? string.Empty);
			}
		}

		private void UpdateHeldVisual()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			string text = (((Object)(object)_nview != (Object)null && _nview.IsValid()) ? _nview.GetZDO().GetString("mf_hold", string.Empty) : string.Empty);
			if (!(text != _heldKey))
			{
				return;
			}
			_heldKey = text;
			if ((Object)(object)_heldVisual != (Object)null)
			{
				Object.Destroy((Object)(object)_heldVisual);
			}
			_heldVisual = null;
			if (!string.IsNullOrEmpty(text) && (Object)(object)Bone((HumanBodyBones)18) != (Object)null)
			{
				_heldVisual = Object.Instantiate<GameObject>(ModAssets.Model(Ids.Model(text), new Vector3(0.1f, 0.08f, 0.3f)), ((Component)_player).transform, false);
				((Object)_heldVisual).name = "mf_held_" + text;
				_heldVisual.SetActive(true);
				Collider[] componentsInChildren = _heldVisual.GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.Destroy((Object)(object)componentsInChildren[i]);
				}
				_heldVisual.transform.localScale = Vector3.one;
				_heldLogged = false;
				PlaceHeldVisual();
			}
		}

		private void PlaceHeldVisual()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_heldVisual == (Object)null)
			{
				return;
			}
			Transform val = Bone((HumanBodyBones)18);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Quaternion val2 = val.rotation * HeldRotation;
			_heldVisual.transform.SetPositionAndRotation(val.position + val.rotation * HeldOffset, val2);
			if (_heldLogged || !IsLocal)
			{
				return;
			}
			_heldLogged = true;
			Bounds val3 = default(Bounds);
			bool flag = false;
			Renderer[] componentsInChildren = _heldVisual.GetComponentsInChildren<Renderer>();
			foreach (Renderer val4 in componentsInChildren)
			{
				if (!flag)
				{
					val3 = val4.bounds;
					flag = true;
				}
				else
				{
					((Bounds)(ref val3)).Encapsulate(val4.bounds);
				}
			}
			Plugin.Log.LogInfo((object)("[Held] " + _heldKey + ": " + (flag ? $"size {((Bounds)(ref val3)).size.x:F2}x{((Bounds)(ref val3)).size.y:F2}x{((Bounds)(ref val3)).size.z:F2} m, {Vector3.Distance(((Bounds)(ref val3)).center, val.position):F2} m from the hand" : "no renderers")));
		}

		public Transform Bone(HumanBodyBones bone)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Animator animatorCached = GetAnimatorCached();
			if (!((Object)(object)animatorCached != (Object)null) || !animatorCached.isHuman)
			{
				return null;
			}
			return animatorCached.GetBoneTransform(bone);
		}

		public void GetChestAnchor(out Vector3 pos, out Quaternion rot)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(((Component)_player).transform.forward, Vector3.up);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.forward;
			}
			rot = Quaternion.LookRotation(val2, Vector3.up);
			Transform val3 = Bone((HumanBodyBones)54) ?? Bone((HumanBodyBones)8) ?? Bone((HumanBodyBones)7);
			Vector3 val4 = (((Object)(object)val3 != (Object)null) ? val3.position : (((Component)_player).transform.position + Vector3.up * 1.25f));
			pos = val4 + val2 * 0.14f + Vector3.down * 0.12f;
		}

		public bool GetHandsMid(out Vector3 pos)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = Bone((HumanBodyBones)17);
			Transform val2 = Bone((HumanBodyBones)18);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				pos = ((Component)_player).transform.position + ((Component)_player).transform.forward * 0.4f + Vector3.up * 1f;
				return false;
			}
			pos = (val.position + val2.position) * 0.5f;
			return true;
		}

		public Quaternion BodyYaw()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(((Component)_player).transform.forward, Vector3.up);
			if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f))
			{
				return Quaternion.identity;
			}
			return Quaternion.LookRotation(((Vector3)(ref val)).normalized);
		}

		private void Update()
		{
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			EnsureIK();
			UpdateHeldVisual();
			if (!IsLocal && (Object)(object)_nview != (Object)null && _nview.IsValid())
			{
				ZDO zDO = _nview.GetZDO();
				int num = zDO.GetInt("mf_anim_seq", 0);
				if (num != _seenSeq)
				{
					_seenSeq = num;
					string clipName = zDO.GetString("mf_anim", string.Empty);
					double start = (double)zDO.GetLong("mf_anim_t", 0L) / 1000.0;
					Apply(clipName, zDO.GetBool("mf_anim_loop", false), start, 0.2f);
				}
				bool flag = zDO.GetBool("mf_anim_pause", false);
				if (flag != _paused)
				{
					_paused = flag;
					ApplyPause();
				}
			}
			if (!((PlayableGraph)(ref _graph)).IsValid())
			{
				return;
			}
			if ((Object)(object)_animator == (Object)null || !((Behaviour)_animator).isActiveAndEnabled || (Object)(object)((AnimationPlayableOutput)(ref _output)).GetTarget() != (Object)(object)_animator)
			{
				DestroyGraph();
				return;
			}
			float deltaTime = Time.deltaTime;
			_weight = Mathf.MoveTowards(_weight, _weightTarget, _weightSpeed * deltaTime);
			PlayableOutputExtensions.SetWeight<AnimationPlayableOutput>(_output, _weight);
			if (_mix < 1f && _activeSlot >= 0)
			{
				_mix = Mathf.MoveTowards(_mix, 1f, _mixSpeed * deltaTime);
				PlayableExtensions.SetInputWeight<AnimationMixerPlayable>(_mixer, _activeSlot, _mix);
				PlayableExtensions.SetInputWeight<AnimationMixerPlayable>(_mixer, 1 - _activeSlot, 1f - _mix);
				if (_mix >= 1f)
				{
					ClearSlot(1 - _activeSlot);
				}
			}
			if (_weight <= 0f && _weightTarget <= 0f)
			{
				_idleTime += deltaTime;
				if (_idleTime > 0.5f)
				{
					DestroyGraph();
				}
			}
			else
			{
				_idleTime = 0f;
			}
		}

		private void Apply(string clipName, bool loop, double start, float fade)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			AnimationClip val = (string.IsNullOrEmpty(clipName) ? null : ModAssets.Clip(clipName));
			_clip = (string.IsNullOrEmpty(clipName) ? null : clipName);
			_start = start;
			_loop = loop;
			Player player = _player;
			Plugin.Debug($"{((player != null) ? player.GetPlayerName() : null)}: play '{clipName}' loop={loop}");
			float num = 1f / Mathf.Max(0.05f, fade);
			if ((Object)(object)val == (Object)null)
			{
				_weightTarget = 0f;
				_weightSpeed = num;
			}
			else if (EnsureGraph())
			{
				int num2 = ((_activeSlot >= 0) ? (1 - _activeSlot) : 0);
				ClearSlot(num2);
				AnimationClipPlayable val2 = AnimationClipPlayable.Create(_graph, val);
				((AnimationClipPlayable)(ref val2)).SetApplyFootIK(true);
				((AnimationClipPlayable)(ref val2)).SetApplyPlayableIK(false);
				float num3 = Mathf.Max(0f, (float)(Util.Now - start));
				if (!loop && !((Motion)val).isLooping)
				{
					num3 = Mathf.Min(num3, val.length);
				}
				PlayableExtensions.SetTime<AnimationClipPlayable>(val2, (double)num3);
				((PlayableGraph)(ref _graph)).Connect<AnimationClipPlayable, AnimationMixerPlayable>(val2, 0, _mixer, num2);
				_slot[num2] = val2;
				PlayableExtensions.SetSpeed<AnimationClipPlayable>(val2, _paused ? 0.0 : 1.0);
				bool num4 = _activeSlot >= 0 && _weight > 0.01f;
				_activeSlot = num2;
				if (num4)
				{
					_mix = 0f;
					_mixSpeed = num;
					PlayableExtensions.SetInputWeight<AnimationMixerPlayable>(_mixer, num2, 0f);
				}
				else
				{
					_mix = 1f;
					PlayableExtensions.SetInputWeight<AnimationMixerPlayable>(_mixer, num2, 1f);
					ClearSlot(1 - num2);
				}
				_weightTarget = 1f;
				_weightSpeed = num;
			}
		}

		private Animator GetAnimatorCached()
		{
			if ((Object)(object)_animator == (Object)null)
			{
				_animator = Util.GetAnimator((Character)(object)_player);
			}
			return _animator;
		}

		private bool EnsureGraph()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (((PlayableGraph)(ref _graph)).IsValid())
			{
				return true;
			}
			Animator animatorCached = GetAnimatorCached();
			if ((Object)(object)animatorCached == (Object)null || !animatorCached.isHuman)
			{
				Plugin.Log.LogWarning((object)"Player animator missing or not Humanoid; fishing animations disabled.");
				return false;
			}
			_graph = PlayableGraph.Create("MarcFishing_" + (((Object)(object)_player != (Object)null) ? _player.GetPlayerName() : "player"));
			((PlayableGraph)(ref _graph)).SetTimeUpdateMode((DirectorUpdateMode)1);
			_mixer = AnimationMixerPlayable.Create(_graph, 2);
			_output = AnimationPlayableOutput.Create(_graph, "MarcFishing", animatorCached);
			PlayableOutputExtensions.SetSourcePlayable<AnimationPlayableOutput, AnimationMixerPlayable>(_output, _mixer);
			PlayableOutputExtensions.SetWeight<AnimationPlayableOutput>(_output, 0f);
			_weight = 0f;
			_activeSlot = -1;
			((PlayableGraph)(ref _graph)).Play();
			return true;
		}

		private void ClearSlot(int slot)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (slot >= 0 && ((PlayableGraph)(ref _graph)).IsValid())
			{
				if (PlayableExtensions.IsValid<AnimationClipPlayable>(_slot[slot]))
				{
					((PlayableGraph)(ref _graph)).Disconnect<AnimationMixerPlayable>(_mixer, slot);
					PlayableExtensions.Destroy<AnimationClipPlayable>(_slot[slot]);
				}
				_slot[slot] = default(AnimationClipPlayable);
				PlayableExtensions.SetInputWeight<AnimationMixerPlayable>(_mixer, slot, 0f);
			}
		}

		private void DestroyGraph()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (((PlayableGraph)(ref _graph)).IsValid())
			{
				((PlayableGraph)(ref _graph)).Destroy();
			}
			_slot[0] = default(AnimationClipPlayable);
			_slot[1] = default(AnimationClipPlayable);
			_activeSlot = -1;
			_weight = 0f;
			_weightTarget = 0f;
			_idleTime = 0f;
		}

		private void EnsureIK()
		{
			if (!((Object)(object)_ik != (Object)null))
			{
				Animator animatorCached = GetAnimatorCached();
				if (!((Object)(object)animatorCached == (Object)null))
				{
					_ik = ((Component)animatorCached).GetComponent<FishingIK>() ?? ((Component)animatorCached).gameObject.AddComponent<FishingIK>();
					_ik.Owner = this;
				}
			}
		}

		private void LateUpdate()
		{
			UpdatePoleAim();
			PlaceHeldVisual();
		}

		private void UpdatePoleAim()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			HookTipValid = false;
			Transform val = FindHeldHook();
			if ((Object)(object)val == (Object)null)
			{
				_pole = null;
				_poleWeight = 0f;
				return;
			}
			Transform parent = val.parent;
			if ((Object)(object)parent != (Object)(object)_pole)
			{
				_pole = parent;
				_poleModel = val;
				_poleBase = parent.localRotation;
				_poleWeight = 0f;
				_aimLocal = Quaternion.identity;
			}
			parent.localRotation = _poleBase;
			Vector3 target = default(Vector3);
			bool hooked = false;
			bool flag = false;
			if (_clip == "PullInBuoyWithHook")
			{
				GearBase gearBase = FindGearBusyForMe();
				flag = (Object)(object)gearBase != (Object)null && gearBase.TryGetHookTarget(out target, out hooked);
			}
			if (flag && !hooked && (Object)(object)parent.parent != (Object)null)
			{
				Vector3 val2 = _poleModel.TransformDirection(BoatHookModel.HookDir);
				Vector3 val3 = target - parent.position;
				if (((Vector3)(ref val3)).sqrMagnitude > 0.04f && ((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
				{
					Quaternion val4 = Quaternion.FromToRotation(((Vector3)(ref val2)).normalized, ((Vector3)(ref val3)).normalized);
					Quaternion rotation = parent.parent.rotation;
					_aimLocal = Quaternion.Inverse(rotation) * val4 * rotation;
				}
			}
			_poleWeight = Mathf.MoveTowards(_poleWeight, flag ? 1f : 0f, Time.deltaTime / 0.3f);
			if (_poleWeight > 0f)
			{
				parent.localRotation = Quaternion.Slerp(Quaternion.identity, _aimLocal, Mathf.SmoothStep(0f, 1f, _poleWeight)) * _poleBase;
			}
			HookTip = _poleModel.TransformPoint(BoatHookModel.HookEnd);
			HookTipValid = _poleWeight > 0.95f;
		}

		private Transform FindHeldHook()
		{
			if ((Object)(object)_vis == (Object)null)
			{
				_vis = ((Component)this).GetComponent<VisEquipment>();
			}
			if ((Object)(object)_vis == (Object)null)
			{
				return null;
			}
			if (_boatHookHash == 0)
			{
				_boatHookHash = Util.StableHash("MF_BoatHook");
			}
			if (RightItemHashRef.Invoke(_vis) != _boatHookHash)
			{
				return null;
			}
			GameObject val = RightItemInstanceRef.Invoke(_vis);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return val.transform.Find("held");
		}

		private GearBase FindGearBusyForMe()
		{
			long num = (((Object)(object)_player != (Object)null) ? _player.GetPlayerID() : 0);
			if (num == 0L)
			{
				return null;
			}
			foreach (GearBase instance in GearBase.Instances)
			{
				if ((Object)(object)instance != (Object)null && instance.BusyPlayer == num)
				{
					return instance;
				}
			}
			return null;
		}

		internal void ApplyHandIK(Animator animator)
		{
			//IL_0022: 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)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			if (_poleWeight > 0.01f && (Object)(object)_pole != (Object)null)
			{
				Vector3 val = HookTip - _pole.position;
				if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
				{
					_handIKActive = true;
					animator.SetIKPositionWeight((AvatarIKGoal)2, Mathf.SmoothStep(0f, 0.85f, _poleWeight));
					animator.SetIKPosition((AvatarIKGoal)2, _pole.position + ((Vector3)(ref val)).normalized * 0.55f);
					animator.SetIKRotationWeight((AvatarIKGoal)2, 0f);
					animator.SetIKPositionWeight((AvatarIKGoal)3, 0f);
					animator.SetIKRotationWeight((AvatarIKGoal)3, 0f);
					return;
				}
			}
			GearBase carried = Carried;
			float num = (((Object)(object)carried != (Object)null) ? carried.HandIKWeight(this) : 0f);
			if (num <= 0.001f || !carried.GetGripPoints(out var left, out var right, out var rot))
			{
				if (_handIKActive)
				{
					_handIKActive = false;
					animator.SetIKPositionWeight((AvatarIKGoal)2, 0f);
					animator.SetIKPositionWeight((AvatarIKGoal)3, 0f);
					animator.SetIKRotationWeight((AvatarIKGoal)2, 0f);
					animator.SetIKRotationWeight((AvatarIKGoal)3, 0f);
				}
			}
			else
			{
				_handIKActive = true;
				animator.SetIKPositionWeight((AvatarIKGoal)2, num);
				animator.SetIKPositionWeight((AvatarIKGoal)3, num);
				animator.SetIKPosition((AvatarIKGoal)2, left);
				animator.SetIKPosition((AvatarIKGoal)3, right);
				animator.SetIKRotationWeight((AvatarIKGoal)2, num * 0.85f);
				animator.SetIKRotationWeight((AvatarIKGoal)3, num * 0.85f);
				animator.SetIKRotation((AvatarIKGoal)2, rot * Quaternion.Euler(0f, 0f, 90f));
				animator.SetIKRotation((AvatarIKGoal)3, rot * Quaternion.Euler(0f, 0f, -90f));
			}
		}
	}
	public sealed class FishingIK : MonoBehaviour
	{
		internal FishingAnimator Owner;

		private Animator _animator;

		private void OnAnimatorIK(int layerIndex)
		{
			if (!((Object)(object)Owner == (Object)null))
			{
				if ((Object)(object)_animator == (Object)null)
				{
					_animator = ((Component)this).GetComponent<Animator>();
				}
				Owner.ApplyHandIK(_animator);
			}
		}
	}
	internal static class PlayerPatches
	{
		[HarmonyPatch(typeof(Player), "Awake")]
		private static class PlayerAwake
		{
			private static void Postfix(Player __instance)
			{
				if ((Object)(object)((Component)__instance).GetComponent<FishingAnimator>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<FishingAnimator>();
				}
				if ((Object)(object)((Component)__instance).GetComponent<LocalFishingInput>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<LocalFishingInput>();
				}
			}
		}

		[HarmonyPatch(typeof(Player), "SetControls")]
		private static class SetControls
		{
			private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return;
				}
				FishingAnimator component = ((Component)__instance).GetComponent<FishingAnimator>();
				if (!((Object)(object)component == (Object)null) && (component.IsLocked || !((Object)(object)component.Carried == (Object)null) || component.Aiming))
				{
					if (component.IsLocked)
					{
						movedir = Vector3.zero;
						crouch = false;
						autoRun = false;
						run = false;
					}
					attack = (attackHold = (secondaryAttack = (secondaryAttackHold = false)));
					block = (blockHold = false);
					jump = (dodge = false);
				}
			}
		}

		[HarmonyPatch(typeof(Character), "UpdateRotation")]
		private static class HoldBodyDuringSequences
		{
			private static bool Prefix(Character __instance, float turnSpeed, float dt, ref float __result)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				FishingAnimator component = ((Component)__instance).GetComponent<FishingAnimator>();
				if ((Object)(object)component == (Object)null || !component.IsLocked)
				{
					return true;
				}
				Quaternion rotation = ((Component)__instance).transform.rotation;
				Quaternion val = component.LockedFacing ?? rotation;
				((Component)__instance).transform.rotation = Quaternion.RotateTowards(rotation, val, turnSpeed * dt);
				__result = 0f;
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "GetRunSpeedFactor")]
		private static class RunSpeedWhileCarrying
		{
			private static void Postfix(Player __instance, ref float __result)
			{
				if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !(((Character)__instance).m_runSpeed <= 0f))
				{
					FishingAnimator component = ((Component)__instance).GetComponent<FishingAnimator>();
					if (!((Object)(object)component == (Object)null) && !((Object)(object)component.Carried == (Object)null))
					{
						__result = Mathf.Max(0.1f, __result - Plugin.CarryRunSpeedPenalty.Value / ((Character)__instance).m_runSpeed);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "AlwaysRotateCamera")]
		private static class FaceCameraWhileAiming
		{
			private static void Postfix(Player __instance, ref bool __result)
			{
				if (!__result && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
				{
					FishingAnimator component = ((Component)__instance).GetComponent<FishingAnimator>();
					if (!((Object)(object)component == (Object)null) && (component.Aiming || ((Object)(object)component.Carried != (Object)null && (ZInput.GetButton("Block") || ZInput.GetButton("JoyBlock")))))
					{
						__result = true;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Interact")]
		private static class PlayerInteract
		{
			private static bool Prefix(Player __instance)
			{
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				FishingAnimator component = ((Component)__instance).GetComponent<FishingAnimator>();
				if (!((Object)(object)component == (Object)null))
				{
					if (!component.IsLocked && (Object)(object)component.Carried == (Object)null)
					{
						return !component.Aiming;
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UseItem")]
		private static class UseItem
		{
			private static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer || item == null)
				{
					return true;
				}
				FishingAnimator component = ((Component)val).GetComponent<FishingAnimator>();
				if ((Object)(object)component != (Object)null && (component.IsLocked || (Object)(object)component.Carried != (Object)null || component.Aiming))
				{
					Util.Center(((Object)(object)component.Carried != (Object)null) ? "Put down what you're carrying first." : "You're busy.");
					return false;
				}
				if (inventory != ((Humanoid)val).GetInventory())
				{
					return true;
				}
				return !CarryActions.TryTakeOutOfInventory(val, item);
			}
		}
	}
	internal static class ModAssets
	{
		private static readonly string[] BundleNames = new string[2] { "marcfishing", "marcs_fishing_assets" };

		private static AssetBundle _bundle;

		private static string _bundlePath;

		private static readonly Dictionary<string, GameObject> Models = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, Sprite> Icons = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, AnimationClip> ClipsByName = new Dictionary<string, AnimationClip>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, GameObject> Placeholders = new Dictionary<string, GameObject>();

		private static readonly Dictionary<string, Sprite> FallbackIcons = new Dictionary<string, Sprite>();

		private static readonly HashSet<string> Warned = new HashSet<string>();

		public static bool HasBundle => (Object)(object)_bundle != (Object)null;

		public static void Load(string pluginDllPath)
		{
			string path = Path.GetDirectoryName(pluginDllPath) ?? ".";
			string[] bundleNames = BundleNames;
			foreach (string text in bundleNames)
			{
				string[] array = new string[2]
				{
					Path.Combine(path, text),
					Path.Combine(path, "Assets", text)
				};
				foreach (string text2 in array)
				{
					if (File.Exists(text2))
					{
						_bundlePath = text2;
						break;
					}
				}
				if (_bundlePath != null)
				{
					break;
				}
			}
			if (_bundlePath == null)
			{
				Plugin.Log.LogError((object)("Asset bundle 'marcfishing' not found next to " + Path.GetFileName(pluginDllPath) + ". Using placeholder boxes and no animations."));
				return;
			}
			_bundle = AssetBundle.LoadFromFile(_bundlePath);
			if ((Object)(object)_bundle == (Object)null)
			{
				Plugin.Log.LogError((object)("Failed to load asset bundle " + _bundlePath + ". Was it built with Unity 6000.0.x for StandaloneWindows64?"));
				return;
			}
			GameObject[] array2 = _bundle.LoadAllAssets<GameObject>();
			foreach (GameObject val in array2)
			{
				Models[((Object)val).name] = val;
			}
			Sprite[] array3 = _bundle.LoadAllAssets<Sprite>();
			foreach (Sprite val2 in array3)
			{
				Icons[((Object)val2).name] = val2;
			}
			AnimationClip[] array4 = _bundle.LoadAllAssets<AnimationClip>();
			foreach (AnimationClip val3 in array4)
			{
				ClipsByName[((Object)val3).name] = val3;
			}
			Plugin.Log.LogInfo((object)$"Loaded bundle {_bundlePath}: {Models.Count} models, {Icons.Count} icons, {ClipsByName.Count} clips.");
			bundleNames = Clips.All;
			foreach (string text3 in bundleNames)
			{
				if (!ClipsByName.TryGetValue(text3, out var value))
				{
					Plugin.Log.LogWarning((object)("Clip '" + text3 + "' missing from bundle."));
					continue;
				}
				string text4 = (value.humanMotion ? "humanoid OK" : "NOT HUMANOID - will not play on the player");
				(value.humanMotion ? new Action<object>(Plugin.Log.LogInfo) : new Action<object>(Plugin.Log.LogError))($"Clip {((Object)value).name}: {value.length:F2}s, loop={((Motion)value).isLooping}, {text4}");
			}
		}

		public static string Summary()
		{
			if (!((Object)(object)_bundle == (Object)null))
			{
				return $"bundle {Path.GetFileName(_bundlePath)}, {ClipsByName.Values.Count((AnimationClip c) => c.humanMotion)}/{Clips.All.Length} humanoid clips";
			}
			return "NO BUNDLE";
		}

		public static AnimationClip Clip(string name)
		{
			if (name != null && ClipsByName.TryGetValue(name, out var value) && value.humanMotion)
			{
				return value;
			}
			WarnOnce("clip:" + name, "Animation '" + name + "' unavailable; skipping it.");
			return null;
		}

		public static float ClipLength(string name, float fallback)
		{
			AnimationClip val = Clip(name);
			if (!((Object)(object)val != (Object)null))
			{
				return fallback;
			}
			return val.length;
		}

		public static GameObject Model(string name, Vector3 placeholderSize)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			if (Models.TryGetValue(name, out var value))
			{
				return value;
			}
			WarnOnce("model:" + name, "Model '" + name + "' missing from bundle; using a placeholder box.");
			if (!Placeholders.TryGetValue(name, out var value2))
			{
				value2 = new GameObject(name);
				value2.transform.SetParent(PrefabFactory.Holder, false);
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
				Object.DestroyImmediate((Object)(object)val.GetComponent<Collider>());
				val.transform.SetParent(value2.transform, false);
				val.transform.localScale = placeholderSize;
				val.transform.localPosition = new Vector3(0f, placeholderSize.y * 0.5f, 0f);
				BoxCollider obj = value2.AddComponent<BoxCollider>();
				obj.size = placeholderSize;
				obj.center = val.transform.localPosition;
				Placeholders[name] = value2;
			}
			return value2;
		}

		public static Sprite Icon(string key)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			if (Icons.TryGetValue(Ids.Icon(key), out var value))
			{
				return value;
			}
			if (FallbackIcons.TryGetValue(key, out value))
			{
				return value;
			}
			WarnOnce("icon:" + key, "Icon 'Icon_" + key + "' missing from bundle; using a plain icon.");
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.25f + (float)(key.Length * 37 % 60) / 100f, 0.45f, 0.55f, 1f);
			Color[] array = (Color[])(object)new Color[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = ((float)j - 31.5f) / 28f;
					float num2 = ((float)i - 31.5f) / 20f;
					array[i * 64 + j] = ((num * num + num2 * num2 <= 1f) ? val2 : Color.clear);
				}
			}
			val.SetPixels(array);
			val.Apply();
			value = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
			((Object)value).name = "Icon_" + key;
			FallbackIcons[key] = value;
			return value;
		}

		private static void WarnOnce(string key, string message)
		{
			if (Warned.Add(key))
			{
				Plugin.Log.LogWarning((object)message);
			}
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	internal static class Commands
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__1_0;

			public static ConsoleEvent <>9__1_1;

			public static ConsoleOptionsFetcher <>9__1_2;

			public static ConsoleEvent <>9__1_3;

			public static ConsoleEvent <>9__1_4;

			public static ConsoleEvent <>9__1_5;

			public static Func<GearBase, bool> <>9__1_11;

			public static ConsoleEvent <>9__1_6;

			public static Func<GearBase, bool> <>9__1_12;

			public static ConsoleEvent <>9__1_7;

			internal void <Postfix>b__1_0(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					string[] array = new string[4] { "MF_LobsterPot", "MF_GillNet", "MF_FishBox", "MF_BoatHook" };
					foreach (string prefabName in array)
					{
						Util.GiveOrDrop(localPlayer, prefabName);
					}
					Util.GiveOrDrop(localPlayer, "MF_FishingBuoy", 2);
					Util.GiveOrDrop(localPlayer, "FishRaw", 5);
					args.Context.AddString("Gave pot, net, fish box, boat hook, 2 buoys and 5 raw fish (bait).");
				}
			}

			internal void <Postfix>b__1_1(ConsoleEventArgs args)
			{
				<>c__DisplayClass1_0 CS$<>8__locals8 = new <>c__DisplayClass1_0
				{
					args = args
				};
				FishingAnimator local = FishingAnimator.Local;
				if ((Object)(object)local == (Object)null)
				{
					return;
				}
				if (CS$<>8__locals8.args.Length < 2 || CS$<>8__locals8.args[1] == "list")
				{
					CS$<>8__locals8.args.Context.AddString("Clips: " + string.Join(", ", Clips.All));
					return;
				}
				string text = Clips.All.FirstOrDefault((string c) => c.ToLowerInvariant() == CS$<>8__locals8.args[1].ToLowerInvariant()) ?? CS$<>8__locals8.args[1];
				bool flag = CS$<>8__locals8.args.Length > 2 && CS$<>8__locals8.args[2] == "loop";
				float num = local.Play(text, flag);
				AnimationClip val = ModAssets.Clip(text);
				CS$<>8__locals8.args.Context.AddString(((Object)(object)val == (Object)null) ? ("'" + text + "' is not in the bundle or is not Humanoid.") : $"Playing {text} ({num:F2}s, humanMotion={val.humanMotion}, loop={flag}).");
			}

			internal List<string> <Postfix>b__1_2()
			{
				return new List<string>(Clips.All);
			}

			internal void <Postfix>b__1_3(ConsoleEventArgs args)
			{
				FishingAnimator local = FishingAnimator.Local;
				if (!((Object)(object)local == (Object)null))
				{
					local.Stop();
					local.ClearLocks();
				}
			}

			internal void <Postfix>b__1_4(ConsoleEventArgs args)
			{
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass1_1 CS$<>8__locals3 = new <>c__DisplayClass1_1();
				args.Context.AddString("Coastal Fishing 2.2.4: " + ModAssets.Summary());
				CS$<>8__locals3.p = Player.m_localPlayer;
				if ((Object)(object)CS$<>8__locals3.p == (Object)null)
				{
					return;
				}
				foreach (GearBase item in GearBase.Instances.Where((GearBase g) => Vector3.Distance(((Component)g).transform.position, ((Component)CS$<>8__locals3.p).transform.position) < 80f))
				{
					string arg = ((item is LobsterPotGear lobsterPotGear) ? lobsterPotGear.StateName : ((item is GillNetGear gillNetGear) ? gillNetGear.StateName : ""));
					args.Context.AddString($"  {item.DisplayName} {arg} at {((Component)item).transform.position:F1}" + (item.IsCarried ? " carried" : "") + (((Object)(object)item.BoundShip != (Object)null) ? (" on " + Util.PrefabName(((Component)item.BoundShip).gameObject)) : "") + string.Format(" owner={0} catch={1}", item.NView.IsOwner() ? "me" : "other", CatchList.Get(item.Zdo).Count));
				}
			}

			internal void <Postfix>b__1_5(ConsoleEventArgs args)
			{
				<>c__DisplayClass1_2 CS$<>8__locals2 = new <>c__DisplayClass1_2
				{
					p = Player.m_localPlayer
				};
				if ((Object)(object)CS$<>8__locals2.p == (Object)null)
				{
					return;
				}
				float result;
				float num = ((args.Length > 1 && float.TryParse(args[1], out result)) ? result : 60f);
				int num2 = 0;
				foreach (GearBase item in GearBase.Instances.Where((GearBase g) => Vector3.Distance(((Component)g).transform.position, ((Component)CS$<>8__locals2.p).transform.position) < 60f))
				{
					if (item is LobsterPotGear lobsterPotGear)
					{
						lobsterPotGear.AddSoakMinutes(num);
						num2++;
					}
					else if (item is GillNetGear gillNetGear)
					{
						gillNetGear.AddSoakMinutes(num);
						num2++;
					}
				}
				args.Context.AddString($"Added {num} soak minutes to {num2} piece(s) of gear.");
			}

			internal void <Postfix>b__1_6(ConsoleEventArgs args)
			{
				GearBase gearBase = Nearest((GearBase g2) => g2 is LobsterPotGear || g2 is GillNetGear);
				if (!((Object)(object)gearBase == (Object)null))
				{
					gearBase.ClaimOwnership();
					List<string> list = ((gearBase is LobsterPotGear) ? CatchList.RollPot(60f, 1.4f) : CatchList.RollNet(90f, 40f));
					CatchList.Set(gearBase.Zdo, list);
					args.Context.AddString(gearBase.DisplayName + ": " + CatchList.Describe(list));
				}
			}

			internal bool <Postfix>b__1_11(GearBase g2)
			{
				if (!(g2 is LobsterPotGear))
				{
					return g2 is GillNetGear;
				}
				return true;
			}

			internal void <Postfix>b__1_7(ConsoleEventArgs args)
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				GearBase gearBase = Nearest((GearBase _) => true);
				if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)gearBase == (Object)null))
				{
					Vector3 val = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 0.8f;
					Ship standingOnShip = ((Character)localPlayer).GetStandingOnShip();
					if (gearBase is LobsterPotGear lobsterPotGear)
					{
						lobsterPotGear.ResetToIdleAt(val, ((Component)localPlayer).transform.rotation, standingOnShip);
					}
					else if (gearBase is GillNetGear gillNetGear)
					{
						gillNetGear.ResetToIdleAt(val, ((Component)localPlayer).transform.rotation, standingOnShip);
					}
					else
					{
						gearBase.EndUse();
						gearBase.PlaceAt(val, ((Component)localPlayer).transform.rotation, standingOnShip);
					}
					FishingAnimator.Local?.ClearLocks();
					args.Context.AddString("Reset " + gearBase.DisplayName + ".");
				}
			}

			internal bool <Postfix>b__1_12(GearBase _)
			{
				return true;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass1_0
		{
			public ConsoleEventArgs args;

			internal bool <Postfix>b__8(string c)
			{
				return c.ToLowerInvariant() == args[1].ToLowerInvariant();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass1_1
		{
			public Player p;

			public Func<GearBase, bool> <>9__9;

			internal bool <Postfix>b__9(GearBase g)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				return Vector3.Distance(((Component)g).transform.position, ((Component)p).transform.position) < 80f;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass1_2
		{
			public Player p;

			public Func<GearBase, bool> <>9__10;

			internal bool <Postfix>b__10(GearBase g)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				return Vector3.Distance(((Component)g).transform.position, ((Component)p).transform.position) < 60f;
			}
		}

		private static bool _added;

		private static void Postfix()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			if (_added)
			{
				return;
			}
			_added = true;
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate(ConsoleEventArgs args)
				{
					Player localPlayer = Player.m_localPlayer;
					if (!((Object)(object)localPlayer == (Object)null))
					{
						string[] array = new string[4] { "MF_LobsterPot", "MF_GillNet", "MF_FishBox", "MF_BoatHook" };
						foreach (string prefabName in array)
						{
							Util.GiveOrDrop(localPlayer, prefabName);
						}
						Util.GiveOrDrop(localPlayer, "MF_FishingBuoy", 2);
						Util.GiveOrDrop(localPlayer, "FishRaw", 5);
						args.Context.AddString("Gave pot, net, fish box, boat hook, 2 buoys and 5 raw fish (bait).");
					}
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("mf_give", "[Coastal Fishing] give fishing gear, a boat hook and bait", (ConsoleEvent)obj, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj2 = <>c.<>9__1_1;
			if (obj2 == null)
			{
				ConsoleEvent val2 = delegate(ConsoleEventArgs args)
				{
					FishingAnimator local = FishingAnimator.Local;
					if (!((Object)(object)local == (Object)null))
					{
						if (args.Length < 2 || args[1] == "list")
						{
							args.Context.AddString("Clips: " + string.Join(", ", Clips.All));
						}
						else
						{
							string text = Clips.All.FirstOrDefault((string c) => c.ToLowerInvariant() == args[1].ToLowerInvariant()) ?? args[1];
							bool flag = args.Length > 2 && args[2] == "loop";
							float num = local.Play(text, flag);
							AnimationClip val9 = ModAssets.Clip(text);
							args.Context.AddString(((Object)(object)val9 == (Object)null) ? ("'" + text + "' is not in the bundle or is not Humanoid.") : $"Playing {text} ({num:F2}s, humanMotion={val9.humanMotion}, loop={flag}).");
						}
					}
				};
				<>c.<>9__1_1 = val2;
				obj2 = (object)val2;
			}
			object obj3 = <>c.<>9__1_2;
			if (obj3 == null)
			{
				ConsoleOptionsFetcher val3 = () => new List<string>(Clips.All);
				<>c.<>9__1_2 = val3;
				obj3 = (object)val3;
			}
			new ConsoleCommand("mf_play", "[Coastal Fishing] mf_play <clip> [loop] - play a fishing clip on yourself", (ConsoleEvent)obj2, false, false, false, false, false, false, (ConsoleOptionsFetcher)obj3, false, false, false);
			object obj4 = <>c.<>9__1_3;
			if (obj4 == null)
			{
				ConsoleEvent val4 = delegate
				{
					FishingAnimator local = FishingAnimator.Local;
					if (!((Object)(object)local == (Object)null))
					{
						local.Stop();
						local.ClearLocks();
					}
				};
				<>c.<>9__1_3 = val4;
				obj4 = (object)val4;
			}
			new ConsoleCommand("mf_stop", "[Coastal Fishing] stop the fishing clip", (ConsoleEvent)obj4, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj5 = <>c.<>9__1_4;
			if (obj5 == null)
			{
				ConsoleEvent val5 = delegate(ConsoleEventArgs args)
				{
					//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
					args.Context.AddString("Coastal Fishing 2.2.4: " + ModAssets.Summary());
					Player p = Player.m_localPlayer;
					if ((Object)(object)p == (Object)null)
					{
						return;
					}
					foreach (GearBase item in GearBase.Instances.Where((GearBase g) => Vector3.Distance(((Component)g).transform.position, ((Component)p).transform.position) < 80f))
					{
						string arg = ((item is LobsterPotGear lobsterPotGear) ? lobsterPotGear.StateName : ((item is GillNetGear gillNetGear) ? gillNetGear.StateName : ""));
						args.Context.AddString($"  {item.DisplayName} {arg} at {((Component)item).transform.position:F1}" + (item.IsCarried ? " carried" : "") + (((Object)(object)item.BoundShip != (Object)null) ? (" on " + Util.PrefabName(((Component)item.BoundShip).gameObject)) : "") + string.Format(" owner={0} catch={1}", item.NView.IsOwner() ? "me" : "other", CatchList.Get(item.Zdo).Count));
					}
				};
				<>c.<>9__1_4 = val5;
				obj5 = (object)val5;
			}
			new ConsoleCommand("mf_status", "[Coastal Fishing] show bundle and nearby gear status", (ConsoleEvent)obj5, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj6 = <>c.<>9__1_5;
			if (obj6 == null)
			{
				ConsoleEvent val6 = delegate(ConsoleEventArgs args)
				{
					Player p = Player.m_localPlayer;
					if (!((Object)(object)p == (Object)null))
					{
						float result;
						float num = ((args.Length > 1 && float.TryParse(args[1], out result)) ? result : 60f);
						int num2 = 0;
						foreach (GearBase item2 in GearBase.Instances.Where((GearBase g) => Vector3.Distance(((Component)g).transform.position, ((Component)p).transform.position) < 60f))
						{
							if (item2 is LobsterPotGear lobsterPotGear)
							{
								lobsterPotGear.AddSoakMinutes(num);
								num2++;
							}
							else if (item2 is GillNetGear gillNetGear)
							{
								gillNetGear.AddSoakMinutes(num);
								num2++;
							}
						}
						args.Context.AddString($"Added {num} soak minutes to {num2} piece(s) of gear.");
					}
				};
				<>c.<>9__1_5 = val6;
				obj6 = (object)val6;
			}
			new ConsoleCommand("mf_soak", "[Coastal Fishing] mf_soak <minutes> - age deployed pots and nets within 60 m", (ConsoleEvent)obj6, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj7 = <>c.<>9__1_6;
			if (obj7 == null)
			{
				ConsoleEvent val7 = delegate(ConsoleEventArgs args)
				{
					GearBase gearBase = Nearest((GearBase g2) => g2 is LobsterPotGear || g2 is GillNetGear);
					if (!((Object)(object)gearBase == (Object)null))
					{
						gearBase.ClaimOwnership();
						List<string> list = ((gearBase is LobsterPotGear) ? CatchList.RollPot(60f, 1.4f) : CatchList.RollNet(90f, 40f));
						CatchList.Set(gearBase.Zdo, list);
						args.Context.AddString(gearBase.DisplayName + ": " + CatchList.Describe(list));
					}
				};
				<>c.<>9__1_6 = val7;
				obj7 = (object)val7;
			}
			new ConsoleCommand("mf_catch", "[Coastal Fishing] put a test catch in the nearest pot or net", (ConsoleEvent)obj7, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj8 = <>c.<>9__1_7;
			if (obj8 == null)
			{
				ConsoleEvent val8 = delegate(ConsoleEventArgs args)
				{
					//IL_0044: Unknown result type (might be due to invalid IL or missing references)
					//IL_004f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0059: Unknown result type (might be due to invalid IL or missing references)
					//IL_005e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_0079: Unknown result type (might be due to invalid IL or missing references)
					//IL_0080: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
					//IL_009b: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
					Player localPlayer = Player.m_localPlayer;
					GearBase gearBase = Nearest((GearBase _) => true);
					if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)gearBase == (Object)null))
					{
						Vector3 val9 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 0.8f;
						Ship standingOnShip = ((Character)localPlayer).GetStandingOnShip();
						if (gearBase is LobsterPotGear lobsterPotGear)
						{
							lobsterPotGear.ResetToIdleAt(val9, ((Component)localPlayer).transform.rotation, standingOnShip);
						}
						else if (gearBase is GillNetGear gillNetGear)
						{
							gillNetGear.ResetToIdleAt(val9, ((Component)localPlayer).transform.rotation, standingOnShip);
						}
						else
						{
							gearBase.EndUse();
							gearBase.PlaceAt(val9, ((Component)localPlayer).transform.rotation, standingOnShip);
						}
						FishingAnimator.Local?.ClearLocks();
						args.Context.AddString("Reset " + gearBase.DisplayName + ".");
					}
				};
				<>c.<>9__1_7 = val8;
				obj8 = (object)val8;
			}
			new ConsoleCommand("mf_reset", "[Coastal Fishing] put the nearest gear back to idle at your feet", (ConsoleEvent)obj8, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}

		private static GearBase Nearest(Func<GearBase, bool> filter)
		{
			Player p = Player.m_localPlayer;
			if ((Object)(object)p == (Object)null)
			{
				return null;
			}
			return (from g in GearBase.Instances.Where(filter)
				orderby Vector3.Distance(((Component)g).transform.position, ((Component)p).transform.position)
				select g).FirstOrDefault((GearBase g) => Vector3.Distance(((Component)g).transform.position, ((Component)p).transform.position) < 100f);
		}
	}
	internal static class BoatHookModel
	{
		public static readonly Vector3 HookDir;

		public static readonly Vector3 HandleEnd;

		public static readonly Vector3 HookEnd;

		public const float ModelLength = 2.774f;

		public static readonly Vector3 ExpectedBoundsSize;

		public const float GameLength = 1.7f;

		public static readonly Vector3 SpearTipDir;

		public const float HandleBehindHand = 0.45f;

		public static float Scale => 0.6128335f;

		public static bool Matches(Bounds modelBounds)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Bounds)(ref modelBounds)).size - ExpectedBoundsSize;
			return ((Vector3)(ref val)).magnitude < 0.1f;
		}

		public static bool Place(Transform model, Vector3 hookDirection, Vector3 handlePosition)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!PrefabFactory.LocalBounds(model, out var b) || !Matches(b))
			{
				return false;
			}
			float scale = Scale;
			Quaternion val = Quaternion.FromToRotation(HookDir, ((Vector3)(ref hookDirection)).normalized);
			model.localScale = Vector3.one * scale;
			model.localRotation = val;
			model.localPosition = handlePosition - val * (HandleEnd * scale);
			return true;
		}

		static BoatHookModel()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(0.0016f, 0.7878f, 0.6159f);
			HookDir = ((Vector3)(ref val)).normalized;
			HandleEnd = new Vector3(0f, 0.01f, -0.883f);
			HookEnd = new Vector3(0.004f, 2.196f, 0.826f);
			ExpectedBoundsSize = new Vector3(0.223f, 2.2f, 1.881f);
			SpearTipDir = Vector3.back;
		}
	}
	internal static class Ids
	{
		public const string Prefix = "MF_";

		public const string LobsterPot = "MF_LobsterPot";

		public const string GillNet = "MF_GillNet";

		public const string FishBox = "MF_FishBox";

		public const string BoatHook = "MF_BoatHook";

		public const string Buoy = "MF_FishingBuoy";

		public const string LobsterPotGear = "MF_LobsterPotGear";

		public const string GillNetGear = "MF_GillNetGear";

		public const string FishBoxGear = "MF_FishBoxGear";

		public const string BoatHookGear = "MF_BoatHookGear";

		public const string PrepTable = "MF_PrepTable";

		public const string CrabSmall = "MF_CoastalCrab_Small";

		public const string CrabLarge = "MF_CoastalCrab_Large";

		public const string CrabGiant = "MF_CoastalCrab_Giant";

		public const string CrabSwarm = "MF_CoastalCrab_Swarm";

		public static readonly string[] FishSpecies = new string[3] { "Mackerel", "Haddock", "Pollack" };

		public static readonly string[] ShellSpecies = new string[2] { "Lobster", "Crab" };

		public const string CrabToesRaw = "MF_CrabToes_Raw";

		public const string CrabToesCooked = "MF_CrabToes_Cooked";

		public const string LobsterBoiled = "MF_Lobster_Boiled";

		public const string ModelNetDeployed = "Model_NetDeployed";

		public const string ModelNetHauling = "Model_NetHauling";

		public const string ModelBuoy = "Model_Buoy";

		public static readonly string[] FishBoxFillModels = new string[4] { "Model_FishBox_Empty", "Model_FishBox_Less", "Model_FishBox_Medium", "Model_FishBox_Full" };

		public static string SeabedCreature(string species, int tier)
		{
			return string.Format("{0}Seabed{1}_T{2}", "MF_", species, tier);
		}

		public static string Catch(string species, int tier)
		{
			return string.Format("{0}{1}_T{2}", "MF_", species, tier);
		}

		public static string CatchKey(string species, int tier)
		{
			return $"{species}_T{tier}";
		}

		public static string CatchItemFromKey(string key)
		{
			return "MF_" + key;
		}

		public static string Fillet(string fish)
		{
			return "MF_" + fish + "_Fillet";
		}

		public static string Roasted(string fish)
		{
			return "MF_" + fish + "_Roasted";
		}

		public static string Model(string key)
		{
			return "Model_" + key;
		}

		public static string Icon(string key)
		{
			return "Icon_" + key;
		}

		public static bool TryParseCatch(string prefabName, out string species, out int tier)
		{
			species = null;
			tier = 0;
			if (string.IsNullOrEmpty(prefabName) || !prefabName.StartsWith("MF_"))
			{
				return false;
			}
			int num = prefabName.LastIndexOf("_T");
			if (num < 0 || num + 2 >= prefabName.Length)
			{
				return false;
			}
			if (!int.TryParse(prefabName.Substring(num + 2), out tier) || tier < 1 || tier > 3)
			{
				return false;
			}
			species = prefabName.Substring("MF_".Length, num - "MF_".Length);
			if (Array.IndexOf(FishSpecies, species) < 0)
			{
				return Array.IndexOf(ShellSpecies, species) >= 0;
			}
			return true;
		}

		public static IEnumerable<string> AllCatchItems()
		{
			string[] fishSpecies = FishSpecies;
			foreach (string s in fishSpecies)
			{
				for (int t = 1; t <= 3; t++)
				{
					yield return Catch(s, t);
				}
			}
			fishSpecies = ShellSpecies;
			foreach (string s in fishSpecies)
			{
				for (int t = 1; t <= 3; t++)
				{
					yield return Catch(s, t);
				}
			}
		}
	}
	internal static class Clips
	{
		public const string PickUp = "PickUp";

		public const string PutDown = "PutDown";

		public const string ThrowBuoy = "ThrowBuoy";

		public const string PullInBuoy = "PullInBuoyWithHook";

		public const string PlaceFish = "PlaceFishInFishBox";

		public const string FeedIntro = "FeedNet_Intro";

		public const string FeedLoop = "FeedNet_Loop";

		public const string FeedOutro = "FeedNet_Outro";

		public const string PotIntro = "HaulPot_Intro";

		public const string PotLoop = "HaulPot_Loop";

		public const string PotLift = "HaulPot_LiftAndPlace";

		public const string PotOutro = "HaulPot_Outro";

		public const string NetIntro = "HaulNet_Intro";

		public const string NetLoop = "HaulNet_Loop";

		public const string NetOutro = "HaulNet_Outro";

		public static readonly string[] All = new string[15]
		{
			"PickUp", "PutDown", "ThrowBuoy", "PullInBuoyWithHook", "PlaceFishInFishBox", "FeedNet_Intro", "FeedNet_Loop", "FeedNet_Outro", "HaulPot_Intro", "HaulPot_Loop",
			"HaulPot_LiftAndPlace", "HaulPot_Outro", "HaulNet_Intro", "HaulNet_Loop", "HaulNet_Outro"
		};

		public const float PickUpGrab = 14f / 15f;

		public const float PickUpSettled = 2.1f;

		public const float PutDownRelease = 1.9333333f;

		public const float ThrowRelease = 3.5f;

		public const float PullBuoyStart = 1f;

		public const float PullBuoyEnd = 5f;

		public const float PlaceFishGrab = 1.0666667f;

		public const float PlaceFishDrop = 3.1666667f;

		public const float PlaceFishTurnDeg = 75f;

		public const float PotLiftGrab = 2.4f;

		public const float PotLiftSetDown = 4.3333335f;
	}
	internal sealed class ItemDef
	{
		public string Name;

		public string Template;

		public string Model;

		public string Icon;

		public string DisplayName;

		public string Description;

		public ItemType Type = (ItemType)1;

		public int Stack = 20;

		public float Weight = 0.5f;

		public bool Equippable;

		public Vector3 PlaceholderSize = new Vector3(0.3f, 0.12f, 0.12f);

		public float Scale = 1f;

		public float Food;

		public float FoodStamina;

		public float FoodBurnTime;

		public float FoodRegen;

		public string Station;

		public (string item, int amount)[] Recipe;
	}
	internal static class ItemDefs
	{
		public static readonly List<ItemDef> All = Build();

		public static int FilletYield(int tier)
		{
			if (tier < 3)
			{
				if (tier != 2)
				{
					return 2;
				}
				return 4;
			}
			return 7;
		}

		public static int CrabToeYield(int tier)
		{
			if (tier < 3)
			{
				if (tier != 2)
				{
					return 2;
				}
				return 3;
			}
			return 5;
		}

		private static List<ItemDef> Build()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0701: Unknown result type (might be due to invalid IL or missing references)
			List<ItemDef> list = new List<ItemDef>();
			list.Add(new ItemDef
			{
				Name = "MF_LobsterPot",
				Template = "Wood",
				Model = "Model_LobsterPot",
				Icon = "LobsterPot",
				DisplayName = "Lobster pot",
				Description = "Too big for your pack: you carry it in your arms, and can set it down on your boat, on the ground or in a cart. Bait it, then throw it over the side in deep water.",
				Type = (ItemType)16,
				Stack = 1,
				Weight = 10f,
				PlaceholderSize = new Vector3(0.7f, 0.45f, 0.5f),
				Station = "piece_workbench",
				Recipe = new(string, int)[3]
				{
					("Wood", 10),
					("Thistle", 5),
					("MF_FishingBuoy", 1)
				}
			});
			list.Add(new ItemDef
			{
				Name = "MF_GillNet",
				Template = "Wood",
				Model = "Model_NetPile",
				Icon = "GillNet",
				DisplayName = "Gill net",
				Description = "Too big for your pack: you carry it in your arms, and can set it down on your boat, on the ground or in a cart. From your boat, throw the first buoy, sail away while the net pays out, then drop the end buoy.",
				Type = (ItemType)16,
				Stack = 1,
				Weight = 8f,
				PlaceholderSize = new Vector3(0.8f, 0.35f, 0.6f),
				Station = "piece_workbench",
				Recipe = new(string, int)[2]
				{
					("Thistle", 15),
					("MF_FishingBuoy", 2)
				}
			});
			list.Add(new ItemDef
			{
				Name = "MF_FishBox",
				Template = "Wood",
				Model = "Model_FishBox_Empty",
				Icon = "FishBox",
				DisplayName = "Fish box",
				Description = "Too big for your pack: you carry it in your arms, and can set it down on your boat, on the ground or in a cart. Keeps your catch on deck.",
				Type = (ItemType)16,
				Stack = 1,
				Weight = 6f,
				PlaceholderSize = new Vector3(0.9f, 0.4f, 0.55f),
				Station = "piece_workbench",
				Recipe = new(string, int)[1] { ("Wood", 5) }
			});
			list.Add(new ItemDef
			{
				Name = "MF_BoatHook",
				Template = "SpearFlint",
				Model = "Model_BoatHook",
				Icon = "BoatHook",
				DisplayName = "Boat hook",
				Description = "Equip it to reach and pull in buoys from the boat. With it equipped, Shift+E lays it down on the deck or the ground.",
				Type = (ItemType)3,
				Stack = 1,
				Weight = 2f,
				Equippable = true,
				PlaceholderSize = new Vector3(0.05f, 0.05f, 2.2f),
				Scale = 0.6128335f,
				Station = "forge",
				Recipe = new(string, int)[2]
				{
					("Wood", 2),
					("BronzeNails", 1)
				}
			});
			list.Add(new ItemDef
			{
				Name = "MF_FishingBuoy",
				Template = "Wood",
				Model = "Model_Buoy",
				Icon = "FishingBuoy",
				DisplayName = "Fishing buoy",
				Description = "Marks gear in the water. Used to make pots and nets.",
				Stack = 10,
				Weight = 1f,
				PlaceholderSize = new Vector3(0.3f, 0.55f, 0.3f),
				Station = "piece_workbench",
				Recipe = new(string, int)[2]
				{
					("Wood", 2),
					("Raspberry", 2)
				}
			});
			list.Add(Scaled(Raw("MF_CrabToes_Raw", "CrabToes_Raw", "Raw crab claws", "Cook them in a cauldron."), 0.6f));
			list.Add(Scaled(Food("MF_CrabToes_Cooked", "CrabToes_Cooked", "Boiled crab claws", "Sweet, succulent claw meat.", 80, 55), 0.6f));
			list.Add(Food("MF_Lobster_Boiled", "Lobster_Boiled", "Boiled lobster", "A whole boiled lobster. A real feast.", 75, 50));
			List<ItemDef> list2 = list;
			Dictionary<string, (int, int, string)> dictionary = new Dictionary<string, (int, int, string)>
			{
				{
					"Mackerel",
					(75, 65, "Oily and rich, straight off the fire.")
				},
				{
					"Haddock",
					(65, 58, "Firm white flakes.")
				},
				{
					"Pollack",
					(60, 55, "Roasted over an open flame.")
				}
			};
			string[] fishSpecies = Ids.FishSpecies;
			foreach (string text in fishSpecies)
			{
				list2.Add(Raw(Ids.Fillet(text), text + "_Fillet", text + " fillet", "Raw fillet. Cook it on a cooking station."));
				list2.Add(Food(Ids.Roasted(text), text + "_Roasted", "Roasted " + text.ToLowerInvariant(), dictionary[text].Item3, dictionary[text].Item1, dictionary[text].Item2));
			}
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>
			{
				{ "Mackerel", "A whole mackerel. Clean it at a preparation table." },
				{ "Haddock", "A whole haddock. Clean it at a preparation table." },
				{ "Pollack", "A whole pollack. Clean it at a preparation table." },
				{ "Lobster", "A live lobster. Boil it in a cauldron." },
				{ "Crab", "A live crab. Crack it at a preparation table for its claws." }
			};
			string[] array = new string[3] { "Small", "Medium", "Large" };
			foreach (string item in new List<string>(Ids.FishSpecies) { "Lobster", "Crab" })
			{
				for (int j = 1; j <= 3; j++)
				{
					list2.Add(new ItemDef
					{
						Name = Ids.Catch(item, j),
						Template = "FishRaw",
						Model = Ids.Model($"{item}_T{j}"),
						Icon = $"{item}_T{j}",
						DisplayName = array[j - 1] + " " + item.ToLowerInvariant(),
						Description = dictionary2[item],
						Stack = 10,
						Weight = 0.6f + (float)j * 0.5f,
						PlaceholderSize = new Vector3(0.12f, 0.1f, 0.25f + (float)j * 0.1f)
					});
				}
			}
			return list2;
		}

		private static ItemDef Scaled(ItemDef def, float scale)
		{
			def.Scale = scale;
			return def;
		}

		private static ItemDef Raw(string name, string key, string display, string desc)
		{
			return new ItemDef
			{
				Name = name,
				Template = "FishRaw",
				Model = Ids.Model(key),
				Icon = key,
				DisplayName = display,
				Description = desc,
				Stack = 20,
				Weight = 0.5f
			};
		}

		private static ItemDef Food(string name, string key, string display, string desc, int hp, int stamina)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			return new ItemDef
			{
				Name = name,
				Template = "FishCooked",
				Model = Ids.Model(key),
				Icon = key,
				DisplayName = display,
				Description = desc,
				Type = (ItemType)2,
				Stack = 20,
				Weight = 0.5f,
				Food = hp,
				FoodStamina = stamina,
				FoodBurnTime = 1200f,
				FoodRegen = 2f
			};
		}
	}
	internal static class PrefabFactory
	{
		private static Transform _holder;

		private static readonly Dictionary<string, GameObject> Built = new Dictionary<string, GameObject>();

		public static Transform Holder
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: 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_0024: Expected O, but got Unknown
				if ((Object)(object)_holder == (Object)null)
				{
					GameObject val = new GameObject("MarcCoastalFishing_Prefabs");
					val.SetActive(false);
					Object.DontDestroyOnLoad((Object)val);
					_holder = val.transform;
				}
				return _holder;
			}
		}

		public static GameObject Get(string name)
		{
			if (!Built.TryGetValue(name, out var value))
			{
				return null;
			}
			return value;
		}

		public static IEnumerable<GameObject> AllItems()
		{
			foreach (ItemDef item in ItemDefs.All)
			{
				if (Built.TryGetValue(item.Name, out var value))
				{
					yield return value;
				}
			}
		}

		public static IEnumerable<GameObject> AllNetworked()
		{
			foreach (GameObject value in Built.Values)
			{
				if ((Object)(object)value.GetComponent<ZNetView>() != (Object)null)
				{
					yield return value;
				}
			}
		}

		public static void EnsureBuilt()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			foreach (ItemDef item in ItemDefs.All)
			{
				if (!Built.ContainsKey(item.Name))
				{
					TryBuildItem(item);
				}
			}
			if (!Built.ContainsKey("MF_LobsterPotGear"))
			{
				Add(BuildGear<LobsterPotGear>("MF_LobsterPotGear", "Model_LobsterPot", new Vector3(0.7f, 0.45f, 0.5f)));
			}
			if (!Built.ContainsKey("MF_GillNetGear"))
			{
				Add(BuildGear<GillNetGear>("MF_GillNetGear", "Model_NetPile", new Vector3(0.8f, 0.35f, 0.6f)));
			}
			if (!Built.ContainsKey("MF_FishBoxGear"))
			{
				Add(BuildFishBox());
			}
			if (!Built.ContainsKey("MF_BoatHookGear"))
			{
				Add(BuildBoatHookGear());
			}
			if (!Built.ContainsKey("MF_PrepTable"))
			{
				Add(BuildPrepTable());
			}
			foreach (string prefabName in Wildlife.PrefabNames)
			{
				if (!Built.ContainsKey(prefabName))
				{
					Add(Wildlife.Build(prefabName));
				}
			}
		}

		private static void Add(GameObject go)
		{
			if ((Object)(object)go != (Object)null)
			{
				Built[((Object)go).name] = go;
			}
		}

		private static void TryBuildItem(ItemDef def)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.Vanilla(def.Template);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val.GetComponent<ItemDrop>() == (Object)null))
			{
				GameObject val2 = Object.Instantiate<GameObject>(val, Holder, false);
				((Object)val2).name = def.Name;
				Transform val3 = val.transform.Find("attach");
				for (int num = val2.transform.childCount - 1; num >= 0; num--)
				{
					Object.DestroyImmediate((Object)(object)((Component)val2.transform.GetChild(num)).gameObject);
				}
				Collider[] components = val2.GetComponents<Collider>();
				for (int i = 0; i < components.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)components[i]);
				}
				GameObject val4 = ModAssets.Model(def.Model, def.PlaceholderSize);
				GameObject val5 = Object.Instantiate<GameObject>(val4, val2.transform, false);
				((Object)val5).name = "visual";
				val5.SetActive(true);
				if (!Mathf.Approximately(def.Scale, 1f))
				{
					Transform transform = val5.transform;
					transform.localScale *= def.Scale;
				}
				if (def.Equippable && (Object)(object)val3 != (Object)null)
				{
					BuildAttach(val2, val4, val3, def.Name == "MF_BoatHook");
				}
				Util.SetLayerRecursive(val2, val.layer);
				ItemDrop component = val2.GetComponent<ItemDrop>();
				SharedData shared = component.m_itemData.m_shared;
				shared.m_name = def.DisplayName;
				shared.m_description = def.Description;
				shared.m_icons = (Sprite[])(object)new Sprite[1] { ModAssets.Icon(def.Icon) };
				shared.m_itemType = def.Type;
				shared.m_maxStackSize = def.Stack;
				shared.m_weight = def.Weight;
				shared.m_maxQuality = 1;
				shared.m_variants = 0;
				shared.m_value = 0;
				shared.m_teleportable = true;
				if (def.Food > 0f)
				{
					shared.m_food = def.Food;
					shared.m_foodStamina = def.FoodStamina;
					shared.m_foodBurnTime = def.FoodBurnTime;
					shared.m_foodRegen = def.FoodRegen;
					shared.m_foodEitr = 0f;
				}
				component.m_itemData.m_dropPrefab = val2;
				Built[def.Name] = val2;
				Plugin.Debug("Built item " + def.Name + " from " + def.Template);
			}
		}

		private static void BuildAttach(GameObject prefab, GameObject model, Transform templateAttach, bool boatHook)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("attach");
			val.transform.SetParent(prefab.transform, false);
			val.transform.localPosition = templateAttach.localPosition;
			val.transform.localRotation = templateAttach.localRotation;
			val.transform.localScale = templateAttach.localScale;
			GameObject val2 = Object.Instantiate<GameObject>(model, val.transform, false);
			((Object)val2).name = "held";
			Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			if (boatHook)
			{
				if (BoatHookModel.Place(val2.transform, BoatHookModel.SpearTipDir, -BoatHookModel.SpearTipDir * 0.45f))
				{
					BuildBoatHookBack(prefab, model, templateAttach);
					return;
				}
				Plugin.Log.LogWarning((object)"Boat hook model doesn't match its recorded geometry; using bounding-box alignment.");
			}
			if (LocalBounds(templateAttach, out var b) && LocalBounds(val2.transform, out var b2))
			{
				Vector3 val3 = LongestAxis(((Bounds)(ref b)).size);
				Quaternion val4 = Quaternion.FromToRotation(LongestAxis(((Bounds)(ref b2)).size), val3);
				val2.transform.localRotation = val4;
				val2.transform.localPosition = ((Bounds)(ref b)).center - val4 * ((Bounds)(ref b2)).center;
			}
		}

		private static void BuildBoatHookBack(GameObject prefab, GameObject model, Transform templateAttach)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("attach_back");
			val.transform.SetParent(prefab.transform, false);
			val.transform.SetSiblingIndex(0);
			val.transform.localPosition = templateAttach.localPosition;
			val.transform.localRotation = templateAttach.localRotation;
			val.transform.localScale = templateAttach.localScale;
			GameObject val2 = Object.Instantiate<GameObject>(model, val.transform, false);
			((Object)val2).name = "held";
			Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			if (!BoatHookModel.Place(val2.transform, BoatHookModel.SpearTipDir, -BoatHookModel.SpearTipDir * 0.85f))
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		internal static bool LocalBounds(Transform root, out Bounds b)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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)
			b = default(Bounds);
			bool flag = false;
			MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = val.sharedMesh.bounds;
				Matrix4x4 val2 = root.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix;
				for (int j = 0; j < 8; j++)
				{
					Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))));
					Vector3 val4 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3);
					if (!flag)
					{
						b = new Bounds(val4, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref b)).Encapsulate(val4);
					}
				}
			}
			return flag;
		}

		internal static Vector3 LongestAxis(Vector3 size)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (size.x >= size.y && size.x >= size.z)
			{
				return Vector3.right;
			}
			if (size.y >= size.z)
			{
				return Vector3.up;
			}
			return Vector3.forward;
		}

		private static GameObject NewNetworkedRoot(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(Holder, false);
			val.AddComponent<ZNetView>().m_persistent = true;
			return val;
		}

		private static GameObject AddVisual(GameObject root, string modelName, Vector3 placeholderSize)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(ModAssets.Model(modelName, placeholderSize), root.transform, false);
			((Object)obj).name = "visual";
			obj.SetActive(true);
			return obj;
		}

		private static GameObject BuildGear<T>(string name, string model, Vector3 placeholderSize) where T : GearBase
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = NewNetworkedRoot(name);
			AddVisual(obj, model, placeholderSize);
			Util.SetLayerRecursive(obj, Util.GearLayer);
			obj.AddComponent<T>();
			return obj;
		}

		private static GameObject BuildFishBox()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NewNetworkedRoot("MF_FishBoxGear");
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0.9f, 0.4f, 0.55f);
			for (int i = 0; i < Ids.FishBoxFillModels.Length; i++)
			{
				GameObject obj = Object.Instantiate<GameObject>(ModAssets.Model(Ids.FishBoxFillModels[i], val2), val.transform, false);
				((Object)obj).name = "fill" + i;
				obj.SetActive(i == 0);
				Collider[] componentsInChildren = obj.GetComponentsInChildren<Collider>(true);
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[j]);
				}
			}
			BoxCollider val3 = val.AddComponent<BoxCollider>();
			if (LocalBounds(val.transform, out var b))
			{
				val3.center = ((Bounds)(ref b)).center;
				val3.size = ((Bounds)(ref b)).size;
			}
			else
			{
				val3.center = new Vector3(0f, val2.y * 0.5f, 0f);
				val3.size = val2;
			}
			Util.SetLayerRecursive(val, Util.GearLayer);
			GameObject val4 = new GameObject("storage");
			val4.transform.SetParent(val.transform, false);
			Container val5 = val4.AddComponent<Container>();
			val5.m_name = "Fish box";
			val5.m_width = 5;
			val5.m_height = 3;
			val5.m_rootObjectOverride = val.GetComponent<ZNetView>();
			Container val6 = Util.VanillaComponent<Container>("piece_chest_wood");
			if ((Object)(object)val6 != (Object)null)
			{
				val5.m_bkg = val6.m_bkg;
				val5.m_openEffects = val6.m_openEffects;
				val5.m_closeEffects = val6.m_closeEffects;
			}
			val.AddComponent<FishBoxGear>();
			return val;
		}

		private static GameObject BuildBoatHookGear()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknow