Decompiled source of OdinRealmFishing v0.89.0

BepInEx/plugins/OdinRealmFishingMod.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OdinRealmFishingMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1a59867b7a4a9033a450b6ba2d8d6be88a162b7e")]
[assembly: AssemblyProduct("OdinRealmFishingMod")]
[assembly: AssemblyTitle("OdinRealmFishingMod")]
[assembly: AssemblyVersion("1.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 OdinRealmFishingMod
{
	public class CaughtFishVisual : MonoBehaviour
	{
		private const float DriftForce = 0.15f;

		private const float DriftTorque = 0.05f;

		private const float BoundaryForce = 2f;

		private Vector3 m_center;

		private Transform m_centerTransform;

		private Vector3 m_lastCenter;

		private float m_radius;

		private EffectList m_splashEffects;

		private Rigidbody m_body;

		private bool m_direct;

		private float m_nextSplashTime;

		private float m_noiseSeed;

		private Vector3 CurrentCenter
		{
			get
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)m_centerTransform != (Object)null))
				{
					return m_center;
				}
				return m_centerTransform.position;
			}
		}

		public void Init(Vector3 center, float radius, EffectList splashEffects)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			m_center = center;
			m_lastCenter = center;
			m_centerTransform = null;
			m_radius = radius;
			m_splashEffects = splashEffects;
		}

		public void Init(Transform centerTransform, float radius, EffectList splashEffects)
		{
			//IL_0009: 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)
			m_centerTransform = centerTransform;
			m_lastCenter = centerTransform.position;
			m_radius = radius;
			m_splashEffects = splashEffects;
		}

		private void Awake()
		{
			m_nextSplashTime = Time.time + Random.Range(2f, 4f);
			m_noiseSeed = Random.Range(0f, 100f);
			if ((Object)(object)m_centerTransform != (Object)null)
			{
				m_direct = true;
				Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				return;
			}
			m_body = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)m_body == (Object)null)
			{
				m_body = ((Component)this).gameObject.AddComponent<Rigidbody>();
			}
			m_body.useGravity = false;
			m_body.linearDamping = 3f;
			m_body.angularDamping = 3f;
		}

		private void LateUpdate()
		{
			//IL_002e: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_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)
			//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_0092: 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_00c2: 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_00fe: 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)
			if (!m_direct)
			{
				return;
			}
			if ((Object)(object)m_centerTransform == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Vector3 val = SmoothNoise(0.25f, 0.17f) * m_radius;
			val.z *= 0.3f;
			((Component)this).transform.position = m_centerTransform.position + m_centerTransform.rotation * val;
			Vector3 val2 = SmoothNoise(0.2f, 9.41f);
			((Component)this).transform.rotation = Quaternion.Euler(val2.x * 15f, Time.time * 20f + m_noiseSeed * 10f, val2.z * 15f);
			if (Time.time >= m_nextSplashTime)
			{
				EffectList splashEffects = m_splashEffects;
				if (splashEffects != null)
				{
					splashEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
				}
				m_nextSplashTime = Time.time + Random.Range(2f, 4f);
			}
		}

		private Vector3 SmoothNoise(float frequency, float salt)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			float num = Time.time * frequency + m_noiseSeed;
			return new Vector3(Mathf.PerlinNoise(num, salt) * 2f - 1f, Mathf.PerlinNoise(num, salt + 5.3f) * 2f - 1f, Mathf.PerlinNoise(num, salt + 11.9f) * 2f - 1f);
		}

		private void FixedUpdate()
		{
			//IL_0018: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_002d: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b4: 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_004c: 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_00d8: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (m_direct || (Object)(object)m_body == (Object)null)
			{
				return;
			}
			Vector3 currentCenter = CurrentCenter;
			Vector3 val = currentCenter - m_lastCenter;
			m_lastCenter = currentCenter;
			if (((Vector3)(ref val)).sqrMagnitude > 0f)
			{
				Rigidbody body = m_body;
				body.position += val;
			}
			m_body.AddForce(SmoothNoise(0.6f, 0.17f) * 0.15f, (ForceMode)0);
			m_body.AddTorque(SmoothNoise(0.4f, 9.41f) * 0.05f, (ForceMode)0);
			Vector3 val2 = ((Component)this).transform.position - currentCenter;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude > m_radius)
			{
				float num = magnitude - m_radius;
				m_body.AddForce(-((Vector3)(ref val2)).normalized * (2f * num), (ForceMode)0);
			}
			if (Time.time >= m_nextSplashTime)
			{
				EffectList splashEffects = m_splashEffects;
				if (splashEffects != null)
				{
					splashEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
				}
				m_nextSplashTime = Time.time + Random.Range(2f, 4f);
			}
		}
	}
	public static class CaughtFishVisualFactory
	{
		public static GameObject Spawn(string speciesPrefabName, Vector3 worldPosition, Transform followCenter, float radius)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			GameObject prefab = ZNetScene.instance.GetPrefab(speciesPrefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			bool activeSelf = prefab.activeSelf;
			prefab.SetActive(false);
			GameObject val = Object.Instantiate<GameObject>(prefab, worldPosition, Quaternion.identity);
			prefab.SetActive(activeSelf);
			EffectList splashEffects = null;
			Fish component = val.GetComponent<Fish>();
			if ((Object)(object)component != (Object)null)
			{
				splashEffects = component.m_jumpEffects;
				Object.DestroyImmediate((Object)(object)component);
			}
			ZNetView component2 = val.GetComponent<ZNetView>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component2);
			}
			ZSyncTransform component3 = val.GetComponent<ZSyncTransform>();
			if ((Object)(object)component3 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component3);
			}
			ItemDrop component4 = val.GetComponent<ItemDrop>();
			if ((Object)(object)component4 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component4);
			}
			for (int i = 0; i < 2; i++)
			{
				MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true);
				foreach (MonoBehaviour val2 in componentsInChildren)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)val2);
					}
				}
			}
			if ((Object)(object)val.GetComponent<ZNetView>() != (Object)null || (Object)(object)val.GetComponentInChildren<Fish>(true) != (Object)null || (Object)(object)val.GetComponentInChildren<Character>(true) != (Object)null)
			{
				Plugin.Log.LogError((object)("[Net] refusing to activate caught-fish visual '" + speciesPrefabName + "': stripping failed (called from a physics callback?)"));
				Object.Destroy((Object)(object)val);
				return null;
			}
			Collider[] componentsInChildren2 = val.GetComponentsInChildren<Collider>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[j]);
			}
			CaughtFishVisual caughtFishVisual = val.AddComponent<CaughtFishVisual>();
			if ((Object)(object)followCenter != (Object)null)
			{
				caughtFishVisual.Init(followCenter, radius, splashEffects);
			}
			else
			{
				caughtFishVisual.Init(worldPosition, radius, splashEffects);
			}
			val.SetActive(true);
			return val;
		}
	}
	public static class CustomAudio
	{
		private const string NetBreakSoundFileName = "ropesnap.wav";

		private const float NetBreakVolume = 2f;

		public static AudioClip NetBreakClip { get; private set; }

		public static IEnumerator LoadNetBreakSound()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string path = Path.Combine(directoryName ?? string.Empty, "ropesnap.wav");
			if (!File.Exists(path))
			{
				Plugin.Log.LogWarning((object)("[OdinRealmFishing] No net-break sound found at " + path + " - the vanilla WearNTear break effect will play instead until one is added."));
				yield break;
			}
			string text = "file://" + path;
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)20);
			try
			{
				yield return request.SendWebRequest();
				if (!string.IsNullOrEmpty(request.error))
				{
					Plugin.Log.LogWarning((object)("[OdinRealmFishing] Failed to load net-break sound from " + path + ": " + request.error));
					yield break;
				}
				NetBreakClip = DownloadHandlerAudioClip.GetContent(request);
				Plugin.Log.LogInfo((object)("[OdinRealmFishing] Loaded net-break sound from " + path));
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		public static void PlayNetBreakSound(Vector3 position)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)NetBreakClip != (Object)null)
			{
				AudioSource.PlayClipAtPoint(NetBreakClip, position, 2f);
			}
		}
	}
	public static class CustomIcons
	{
		public const string Trap = "OdinRealmFishing-trap-icon.png";

		public const string Net = "OdinRealmFishing-net-icon.png";

		public const string Pole = "OdinRealmFishing-pole-icon.png";

		public const string Klippfisk = "klippfisk-icon.png";

		public static Sprite Load(string resourceName)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_00a9: 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)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				Plugin.Log.LogWarning((object)("[Icons] embedded resource not found: " + resourceName));
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				num = stream.Read(array, i, array.Length - i);
				if (num <= 0)
				{
					break;
				}
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array))
			{
				Plugin.Log.LogWarning((object)("[Icons] could not decode " + resourceName));
				return null;
			}
			((Texture)val).filterMode = (FilterMode)1;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	public class DynamicRope : MonoBehaviour
	{
		public Transform PointA;

		public Transform PointB;

		private void LateUpdate()
		{
			//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_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_0035: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0070: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			if (!((Object)(object)PointA == (Object)null) && !((Object)(object)PointB == (Object)null))
			{
				Vector3 position = PointA.position;
				Vector3 position2 = PointB.position;
				Vector3 val = position2 - position;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (!(magnitude < 0.0001f))
				{
					((Component)this).transform.position = (position + position2) / 2f;
					((Component)this).transform.rotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized);
					Vector3 localScale = ((Component)this).transform.localScale;
					localScale.y = magnitude / 2f;
					((Component)this).transform.localScale = localScale;
				}
			}
		}
	}
	internal static class FishingPoleRangePatch
	{
		public const float RangeMeters = 10f;

		public const float ThrowSpeedScale = 0.6f;
	}
	[HarmonyPatch(typeof(FishingFloat), "Setup")]
	internal static class FishingPoleRangeSetupPatch
	{
		private const float ClampMargin = 1f;

		private static readonly FieldRef<FishingFloat, float> LineLength = AccessTools.FieldRefAccess<FishingFloat, float>("m_lineLength");

		private static void Postfix(FishingFloat __instance, Character owner, ItemData item)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_0139: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			if (item == null || (Object)(object)item.m_dropPrefab == (Object)null || ((Object)item.m_dropPrefab).name != "OdinFishPole")
			{
				return;
			}
			float num = 10f;
			float num2 = num - 1f;
			__instance.m_maxDistance = num;
			Transform val = Utils.FindChild(((Component)owner).transform, "_RodTop", (IterativeSearchType)0);
			Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : ((Component)owner).transform.position);
			Vector3 position = ((Component)__instance).transform.position;
			Vector3 val3 = position - val2;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			Plugin.Log.LogInfo((object)string.Format("[Pole] cast landed {0:0.0}m from {1}", magnitude, ((Object)(object)val != (Object)null) ? "rod tip" : "player (rod tip not found)"));
			if (magnitude <= num2)
			{
				return;
			}
			float y = val3.y;
			float num3 = Mathf.Sqrt(Mathf.Max(0f, num2 * num2 - y * y));
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(val3.x, 0f, val3.z);
			if (!(((Vector3)(ref val4)).sqrMagnitude < 0.0001f))
			{
				Vector3 val5 = val2 + ((Vector3)(ref val4)).normalized * num3;
				val5.y = position.y;
				((Component)__instance).transform.position = val5;
				Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.position = val5;
					component.linearVelocity = Vector3.zero;
				}
				LineLength.Invoke(__instance) = Vector3.Distance(val2, val5);
				Plugin.Log.LogInfo((object)$"[Pole] clamped cast to {Vector3.Distance(val2, val5):0.0}m");
			}
		}
	}
	public static class FishNetItemVisualBuilder
	{
		private const float SizeScale = 1.5f;

		private const int LayerCount = 4;

		private const float LayerSpacing = 0.03375f;

		private const float BaseRadius = 0.22500001f;

		private const float InnerRadiusFraction = 0.5f;

		private const int SpokeCount = 7;

		private const int RingSegments = 10;

		private const float CordRadius = 0.011f;

		public static void Build(GameObject prefab)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>();
			Material[] materials = ((componentsInChildren.Length != 0) ? ((Renderer)componentsInChildren[0]).sharedMaterials : null);
			MeshRenderer[] array = componentsInChildren;
			for (int i = 0; i < array.Length; i++)
			{
				((Renderer)array[i]).enabled = false;
			}
			BoxCollider[] componentsInChildren2 = prefab.GetComponentsInChildren<BoxCollider>(true);
			BoxCollider existing = ((componentsInChildren2.Length != 0) ? componentsInChildren2[0] : null);
			for (int j = 1; j < componentsInChildren2.Length; j++)
			{
				((Collider)componentsInChildren2[j]).enabled = false;
			}
			Transform val = prefab.transform.Find("attach");
			Transform val2 = (((Object)(object)val != (Object)null) ? val : prefab.transform);
			Transform transform = new GameObject("NetBundleVisual").transform;
			transform.SetParent(val2, false);
			transform.localPosition = Vector3.zero;
			transform.localRotation = Quaternion.identity;
			Random random = new Random(20260926);
			Bounds bounds = new Bounds(Vector3.zero, Vector3.zero);
			bool boundsStarted = false;
			for (int k = 0; k < 4; k++)
			{
				Transform transform2 = new GameObject("NetLayer" + k).transform;
				transform2.SetParent(transform, false);
				transform2.localPosition = new Vector3(Jitter(random, 0.03f), 0.011f + (float)k * 0.03375f, Jitter(random, 0.03f));
				transform2.localRotation = Quaternion.Euler(Jitter(random, 6f), Jitter(random, 22f), Jitter(random, 6f));
				float num = 0.8f + (float)random.NextDouble() * 0.3f;
				float num2 = 0.22500001f * num;
				float num3 = num2 * 0.5f;
				float num4 = (float)random.NextDouble() * 360f;
				for (int l = 0; l < 7; l++)
				{
					float num5 = num4 + (float)l * 51.42857f;
					Vector3 val3 = Quaternion.Euler(0f, num5, 0f) * Vector3.forward;
					AddCord(transform2, transform, random, val3 * num3, val3 * num2, materials, Track);
				}
				AddRing(transform2, transform, random, num3, materials, Track);
				AddRing(transform2, transform, random, num2, materials, Track);
			}
			FitCollider(prefab, existing, transform, bounds);
			void Track(Vector3 pilePoint)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//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)
				if (!boundsStarted)
				{
					bounds = new Bounds(pilePoint, Vector3.zero);
					boundsStarted = true;
				}
				else
				{
					((Bounds)(ref bounds)).Encapsulate(pilePoint);
				}
			}
		}

		private static void AddCord(Transform layer, Transform pile, Random rng, Vector3 a, Vector3 b, Material[] materials, Action<Vector3> track)
		{
			//IL_0000: 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_0027: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_005d: 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_0060: 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_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_009a: 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_009d: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00c6: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			a += new Vector3(Jitter(rng, 0.012f), Jitter(rng, 0.006f), Jitter(rng, 0.012f));
			b += new Vector3(Jitter(rng, 0.012f), Jitter(rng, 0.006f), Jitter(rng, 0.012f));
			Vector3 val = (a + b) / 2f + new Vector3(Jitter(rng, 0.014f), Jitter(rng, 0.012f), Jitter(rng, 0.014f));
			RopeSegmentBuilder.CreateStaticSegment(layer, a, val, 0.011f, materials);
			RopeSegmentBuilder.CreateStaticSegment(layer, val, b, 0.011f, materials);
			track(pile.InverseTransformPoint(layer.TransformPoint(a)));
			track(pile.InverseTransformPoint(layer.TransformPoint(val)));
			track(pile.InverseTransformPoint(layer.TransformPoint(b)));
		}

		private static void AddRing(Transform layer, Transform pile, Random rng, float radius, Material[] materials, Action<Vector3> track)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)rng.NextDouble() * 360f;
			for (int i = 0; i < 10; i++)
			{
				float num2 = num + (float)i * 36f;
				float num3 = num + (float)(i + 1) * 36f;
				Vector3 a = Quaternion.Euler(0f, num2, 0f) * Vector3.forward * radius;
				Vector3 b = Quaternion.Euler(0f, num3, 0f) * Vector3.forward * radius;
				AddCord(layer, pile, rng, a, b, materials, track);
			}
		}

		private static void FitCollider(GameObject prefab, BoxCollider existing, Transform pile, Bounds pileBounds)
		{
			//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_002b: 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_0033: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0071: 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_0088: 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_0092: 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_009a: 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)
			BoxCollider val = (((Object)(object)existing != (Object)null) ? existing : prefab.AddComponent<BoxCollider>());
			((Collider)val).enabled = true;
			Transform transform = ((Component)val).transform;
			Vector3 min = ((Bounds)(ref pileBounds)).min;
			Vector3 max = ((Bounds)(ref pileBounds)).max;
			Bounds val2 = default(Bounds);
			bool flag = false;
			Vector3 val3 = default(Vector3);
			for (int i = 0; i < 8; i++)
			{
				((Vector3)(ref val3))..ctor(((i & 1) == 0) ? min.x : max.x, ((i & 2) == 0) ? min.y : max.y, ((i & 4) == 0) ? min.z : max.z);
				Vector3 val4 = transform.InverseTransformPoint(pile.TransformPoint(val3));
				if (!flag)
				{
					((Bounds)(ref val2))..ctor(val4, Vector3.zero);
					flag = true;
				}
				else
				{
					((Bounds)(ref val2)).Encapsulate(val4);
				}
			}
			val.center = ((Bounds)(ref val2)).center;
			val.size = ((Bounds)(ref val2)).size;
		}

		private static float Jitter(Random rng, float magnitude)
		{
			return ((float)rng.NextDouble() * 2f - 1f) * magnitude;
		}
	}
	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Recipe),
		typeof(bool),
		typeof(int),
		typeof(int)
	})]
	internal static class FishNetStationLevelPatch
	{
		private const int RequiredLevel = 3;

		private static readonly FieldRef<Player, Dictionary<string, int>> KnownStations = AccessTools.FieldRefAccess<Player, Dictionary<string, int>>("m_knownStations");

		private static void Postfix(Player __instance, Recipe recipe, bool discover, ref bool __result)
		{
			if (discover && __result && !((Object)(object)recipe == (Object)null) && !((Object)(object)recipe.m_item == (Object)null) && !(((Object)((Component)recipe.m_item).gameObject).name != "OdinFishNet") && !((Object)(object)recipe.m_craftingStation == (Object)null))
			{
				string name = recipe.m_craftingStation.m_name;
				__result = KnownStations.Invoke(__instance).TryGetValue(name, out var value) && value >= 3;
			}
		}
	}
	[HarmonyPatch(typeof(Fish), "CustomFixedUpdate")]
	internal static class FishNullBodyGuardPatch
	{
		private static readonly HashSet<int> Reported = new HashSet<int>();

		private static bool Prefix(Fish __instance, Rigidbody ___m_body)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)___m_body))
			{
				return true;
			}
			if (Reported.Add(((Object)__instance).GetInstanceID()))
			{
				Transform transform = ((Component)__instance).transform;
				Plugin.Log.LogWarning((object)("[FishGuard] Fish '" + ((Object)transform).name + "' has no Rigidbody; skipping its update. " + string.Format("pos={0} parent={1} ", transform.position, ((Object)(object)transform.parent != (Object)null) ? ((Object)transform.parent).name : "none") + $"activeInHierarchy={((Component)__instance).gameObject.activeInHierarchy} " + $"hasZNetView={(Object)(object)((Component)__instance).GetComponent<ZNetView>() != (Object)null} " + $"isOurVisual={(Object)(object)((Component)__instance).GetComponent<CaughtFishVisual>() != (Object)null}"));
			}
			return false;
		}
	}
	public static class FishPoleVisualBuilder
	{
		private const float SegmentLength = 0.51f;

		private const float BendDegrees = 6f;

		private const float PoleRadius = 0.02f;

		private const float BranchLength = 0.05f;

		private const float BranchRadius = 0.012f;

		private const float BranchAngleDegrees = 50f;

		private static readonly (int Segment, float T, float RollDegrees)[] Branches = new(int, float, float)[5]
		{
			(0, 0.55f, 20f),
			(1, 0.25f, 200f),
			(1, 0.75f, 110f),
			(2, 0.4f, 290f),
			(2, 0.85f, 45f)
		};

		public static void Build(GameObject prefab)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_009a: 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_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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00d7: 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)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00fe: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0117: 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)
			//IL_0129: 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_013b: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>();
			Material[] materials = ((componentsInChildren.Length != 0) ? ((Renderer)componentsInChildren[0]).sharedMaterials : null);
			MeshRenderer[] array = componentsInChildren;
			for (int i = 0; i < array.Length; i++)
			{
				((Renderer)array[i]).enabled = false;
			}
			Transform val = prefab.transform.Find("attach");
			Transform val2 = (((Object)(object)val != (Object)null) ? val : prefab.transform);
			Transform transform = new GameObject("RopePoleVisual").transform;
			transform.SetParent(val2, false);
			transform.localPosition = Vector3.zero;
			transform.localRotation = Quaternion.identity;
			Vector3 zero = Vector3.zero;
			Vector3 forward = Vector3.forward;
			Vector3 val3 = zero + forward * 0.51f;
			Vector3 val4 = Quaternion.Euler(-6f, 0f, 0f) * forward;
			Vector3 val5 = val3 + val4 * 0.51f;
			Vector3 val6 = Quaternion.Euler(6f, 0f, 0f) * val4;
			Vector3 val7 = val5 + val6 * 0.51f;
			RopeSegmentBuilder.CreateStaticSegment(transform, zero, val3, 0.02f, materials);
			RopeSegmentBuilder.CreateStaticSegment(transform, val3, val5, 0.02f, materials);
			RopeSegmentBuilder.CreateStaticSegment(transform, val5, val7, 0.02f, materials);
			Vector3[] array2 = (Vector3[])(object)new Vector3[3] { zero, val3, val5 };
			Vector3[] array3 = (Vector3[])(object)new Vector3[3] { val3, val5, val7 };
			(int, float, float)[] branches = Branches;
			for (int i = 0; i < branches.Length; i++)
			{
				(int, float, float) tuple = branches[i];
				int item = tuple.Item1;
				float item2 = tuple.Item2;
				float item3 = tuple.Item3;
				Vector3 val8 = array3[item] - array2[item];
				Vector3 normalized = ((Vector3)(ref val8)).normalized;
				Vector3 val9 = Vector3.Lerp(array2[item], array3[item], item2);
				val8 = Vector3.Cross(normalized, Vector3.up);
				Vector3 normalized2 = ((Vector3)(ref val8)).normalized;
				Vector3 val10 = Vector3.Cross(normalized, normalized2);
				float num = item3 * (MathF.PI / 180f);
				Vector3 val11 = normalized2 * Mathf.Cos(num) + val10 * Mathf.Sin(num);
				float num2 = 0.87266463f;
				val8 = normalized * Mathf.Cos(num2) + val11 * Mathf.Sin(num2);
				Vector3 normalized3 = ((Vector3)(ref val8)).normalized;
				RopeSegmentBuilder.CreateStaticSegment(transform, val9, val9 + normalized3 * 0.05f, 0.012f, materials);
			}
			Transform val12 = Utils.FindChild(prefab.transform, "_RodTop", (IterativeSearchType)0);
			if ((Object)(object)val12 != (Object)null)
			{
				val12.SetParent(transform, false);
				val12.localPosition = val7;
			}
		}
	}
	public class FishTrap : MonoBehaviour, Hoverable, Interactable
	{
		public string m_name = "Fish Trap";

		public Transform m_spawnPoint;

		public int m_maxFish = 1;

		public string m_extractText = "Collect";

		public string m_checkText = "Check";

		public string m_emptyText = "(Empty)";

		private ZNetView m_nview;

		private const string DefaultFish = "Fish1";

		private const int TrappedFishQuality = 1;

		private const float FishActivationDelaySec = 300f;

		private const float FishCheckIntervalSec = 2f;

		private const float FishCatchRadius = 5f;

		private const string KeyPlacedTimeSec = "OdinFishTrap_PlacedTimeSec";

		private const string KeyCount = "OdinFishTrap_Count";

		private const string KeySpecies = "OdinFishTrap_Species";

		private const float CaughtFishRadius = 0.25f;

		private GameObject m_caughtFishVisual;

		private void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if (m_nview.GetZDO() != null)
			{
				if (m_nview.IsOwner() && m_nview.GetZDO().GetLong("OdinFishTrap_PlacedTimeSec", -1L) == -1 && (Object)(object)ZNet.instance != (Object)null)
				{
					m_nview.GetZDO().Set("OdinFishTrap_PlacedTimeSec", (long)ZNet.instance.GetTimeSeconds());
				}
				m_nview.Register("RPC_Extract", (Action<long>)RPC_Extract);
				((MonoBehaviour)this).InvokeRepeating("UpdateFishTrap", 0f, 2f);
				((MonoBehaviour)this).InvokeRepeating("SyncCaughtFishVisual", 0.5f, 1f);
			}
		}

		public string GetHoverText()
		{
			int fishCount = GetFishCount();
			if (fishCount > 0)
			{
				return Localization.instance.Localize($"{m_name} ( {fishCount} / {m_maxFish} )\n[<color=yellow><b>$KEY_Use</b></color>] {m_extractText}");
			}
			return Localization.instance.Localize(m_name + " " + m_emptyText + "\n[<color=yellow><b>$KEY_Use</b></color>] " + m_checkText);
		}

		public string GetHoverName()
		{
			return m_name;
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public bool Interact(Humanoid character, bool repeat, bool alt)
		{
			if (repeat)
			{
				return false;
			}
			if (GetFishCount() > 0)
			{
				Extract(character);
			}
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		private void UpdateFishTrap()
		{
			if (m_nview.IsValid() && m_nview.IsOwner() && GetFishCount() < m_maxFish && !((Object)(object)ZNet.instance == (Object)null))
			{
				long num = m_nview.GetZDO().GetLong("OdinFishTrap_PlacedTimeSec", -1L);
				if (num >= 0 && (long)ZNet.instance.GetTimeSeconds() - num >= 300)
				{
					TryCatchNearbyFish();
				}
			}
		}

		private void TryCatchNearbyFish()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 5f);
			for (int i = 0; i < array.Length; i++)
			{
				Fish componentInParent = ((Component)array[i]).GetComponentInParent<Fish>();
				if (!((Object)(object)componentInParent == (Object)null) && ((Behaviour)componentInParent).enabled)
				{
					ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>();
					if (!((Object)(object)component == (Object)null) && component.IsValid())
					{
						string species = ((Object)((Component)componentInParent).gameObject).name.Replace("(Clone)", "").Trim();
						component.ClaimOwnership();
						component.Destroy();
						AddFish(species);
						break;
					}
				}
			}
		}

		private void AddFish(string species)
		{
			m_nview.GetZDO().Set("OdinFishTrap_Species", species);
			m_nview.GetZDO().Set("OdinFishTrap_Count", 1);
		}

		private int GetFishCount()
		{
			if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid())
			{
				return 0;
			}
			return m_nview.GetZDO().GetInt("OdinFishTrap_Count", 0);
		}

		private void Extract(Humanoid character)
		{
			//IL_009e: 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_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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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 (GetFishCount() <= 0)
			{
				return;
			}
			string text = m_nview.GetZDO().GetString("OdinFishTrap_Species", "Fish1");
			GameObject prefab = ZNetScene.instance.GetPrefab(text);
			ItemDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("[OdinRealmFishing] Unknown fish prefab '" + text + "', skipping extract."));
				return;
			}
			ItemData val2 = val.m_itemData.Clone();
			val2.m_dropPrefab = prefab;
			val2.m_worldLevel = (byte)Game.m_worldLevel;
			val2.m_quality = 1;
			val2.m_stack = 1;
			if (!character.GetInventory().AddItem(val2))
			{
				Vector2 val3 = Random.insideUnitCircle * 0.5f;
				Vector3 val4 = m_spawnPoint.position + new Vector3(val3.x, 0f, val3.y);
				ItemDrop component = Object.Instantiate<GameObject>(prefab, val4, Quaternion.identity).GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetQuality(1);
				}
			}
			m_nview.InvokeRPC("RPC_Extract", Array.Empty<object>());
		}

		private void RPC_Extract(long caller)
		{
			if (GetFishCount() > 0)
			{
				DespawnCaughtFishVisual();
				ResetTrap();
			}
		}

		private void ResetTrap()
		{
			m_nview.GetZDO().Set("OdinFishTrap_Count", 0);
			m_nview.GetZDO().Set("OdinFishTrap_Species", "");
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				m_nview.GetZDO().Set("OdinFishTrap_PlacedTimeSec", (long)ZNet.instance.GetTimeSeconds());
			}
		}

		private void SyncCaughtFishVisual()
		{
			if (m_nview.IsValid())
			{
				bool flag = GetFishCount() > 0;
				if (flag && (Object)(object)m_caughtFishVisual == (Object)null)
				{
					SpawnCaughtFishVisual(m_nview.GetZDO().GetString("OdinFishTrap_Species", "Fish1"));
				}
				else if (!flag && (Object)(object)m_caughtFishVisual != (Object)null)
				{
					DespawnCaughtFishVisual();
				}
			}
		}

		private void SpawnCaughtFishVisual(string speciesPrefabName)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			DespawnCaughtFishVisual();
			if (!((Object)(object)m_spawnPoint == (Object)null))
			{
				m_caughtFishVisual = CaughtFishVisualFactory.Spawn(speciesPrefabName, m_spawnPoint.position, null, 0.25f);
				if ((Object)(object)m_caughtFishVisual != (Object)null)
				{
					m_caughtFishVisual.transform.SetParent(m_spawnPoint, true);
				}
			}
		}

		private void DespawnCaughtFishVisual()
		{
			if ((Object)(object)m_caughtFishVisual != (Object)null)
			{
				Object.Destroy((Object)(object)m_caughtFishVisual);
				m_caughtFishVisual = null;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
	internal static class FishTrapPlacementPatch
	{
		private const string FishTrapPrefabName = "OdinFishTrap";

		private const float HeightTolerance = 0.5f;

		private static WaterVolume s_previousVolume;

		private static void Postfix(GameObject ___m_placementGhost, ref PlacementStatus ___m_placementStatus)
		{
			//IL_0036: 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 (!((Object)(object)___m_placementGhost == (Object)null) && !(((Object)___m_placementGhost).name.Replace("(Clone)", "").Trim() != "OdinFishTrap"))
			{
				Vector3 position = ___m_placementGhost.transform.position;
				float waterLevel = Floating.GetWaterLevel(position, ref s_previousVolume);
				if (Mathf.Abs(position.y - waterLevel) > 0.5f)
				{
					___m_placementStatus = (PlacementStatus)1;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Piece),
		typeof(RequirementMode)
	})]
	internal static class FishTrapStationLevelPatch
	{
		private const int RequiredLevel = 3;

		private static readonly FieldRef<Player, Dictionary<string, int>> KnownStations = AccessTools.FieldRefAccess<Player, Dictionary<string, int>>("m_knownStations");

		private static void Postfix(Player __instance, Piece piece, RequirementMode mode, ref bool __result)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (__result && !((Object)(object)piece == (Object)null) && ((Object)piece).name.StartsWith("OdinFishTrap") && (int)mode != 0 && !((Object)(object)piece.m_craftingStation == (Object)null))
			{
				string name = piece.m_craftingStation.m_name;
				__result = KnownStations.Invoke(__instance).TryGetValue(name, out var value) && value >= 3;
			}
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	internal static class FishWorkbenchPrepPatch
	{
		private static readonly HashSet<string> FishPrefabNames = new HashSet<string>
		{
			"Fish1", "Fish2", "Fish3", "Fish4_cave", "Fish5", "Fish6", "Fish7", "Fish8", "Fish9", "Fish10",
			"Fish11", "Fish12"
		};

		private static readonly HashSet<string> ExcludedRecipeItems = new HashSet<string> { "FishAndBreadUncooked" };

		private static bool _applied;

		private static void Postfix(ObjectDB __instance)
		{
			if (_applied || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("piece_preptable");
			GameObject prefab2 = ZNetScene.instance.GetPrefab("piece_workbench");
			CraftingStation val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null);
			CraftingStation val2 = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent<CraftingStation>() : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return;
			}
			List<Recipe> list = new List<Recipe>();
			foreach (Recipe recipe in __instance.m_recipes)
			{
				if (!((Object)(object)recipe.m_craftingStation != (Object)(object)val) && UsesFish(recipe) && !ExcludedRecipeItems.Contains(((Object)((Component)recipe.m_item).gameObject).name))
				{
					Recipe val3 = Object.Instantiate<Recipe>(recipe);
					((Object)val3).name = ((Object)recipe).name + "_OdinWorkbench";
					val3.m_craftingStation = val2;
					val3.m_minStationLevel = 1;
					list.Add(val3);
					Plugin.Log.LogInfo((object)("[OdinRealmFishing] Added level-2 Workbench recipe for '" + ((Object)((Component)recipe.m_item).gameObject).name + "' (cloned from its Food Preparation Table recipe)."));
				}
			}
			__instance.m_recipes.AddRange(list);
			_applied = true;
		}

		private static bool UsesFish(Recipe recipe)
		{
			Requirement[] resources = recipe.m_resources;
			foreach (Requirement val in resources)
			{
				if ((Object)(object)val.m_resItem != (Object)null && FishPrefabNames.Contains(((Object)((Component)val.m_resItem).gameObject).name))
				{
					return true;
				}
			}
			return false;
		}
	}
	[BepInPlugin("com.odinrealm.fishingmod", "OdinRealmFishing", "0.88.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const float KlippfiskHealth = 29f;

		private const float KlippfiskStamina = 29f;

		private const string KlippfiskTextureResource = "OdinRealmFishing_klippfisk_texture.png";

		public const string PluginGuid = "com.odinrealm.fishingmod";

		public const string PluginName = "OdinRealmFishing";

		public const string PluginVersion = "0.88.9";

		internal static ManualLogSource Log;

		private readonly HashSet<string> _loggedShipTypes = new HashSet<string>();

		private void CreateKlippfiskSoupItem()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= CreateKlippfiskSoupItem;
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("OdinKlippfisk", "CarrotSoup");
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Failed to clone CarrotSoup for Klippfisk - is Jotunn loaded correctly?");
				return;
			}
			ItemConfig val2 = new ItemConfig();
			val2.Name = "Klippfisk";
			val2.Icons = IconArray(CustomIcons.Load("klippfisk-icon.png"));
			val2.Description = "A hearty soup of cooked fish, carrot and thistle.";
			val2.CraftingStation = "piece_cauldron";
			val2.MinStationLevel = 1;
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("FishCooked", 1, 0, true),
				new RequirementConfig("Carrot", 2, 0, true),
				new RequirementConfig("Thistle", 1, 0, true)
			};
			ItemConfig val3 = val2;
			CustomItem val4 = new CustomItem(val, true, val3);
			ItemManager.Instance.AddItem(val4);
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_food = 29f;
			shared.m_foodStamina = 29f;
			ApplyKlippfiskTexture(val);
			Log.LogInfo((object)"OdinRealmFishing 0.88.9: Klippfisk soup registered");
		}

		private void ApplyKlippfiskTexture(GameObject prefab)
		{
			//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_0061: Expected O, but got Unknown
			MeshRenderer componentInChildren = prefab.GetComponentInChildren<MeshRenderer>();
			if ((Object)(object)componentInChildren == (Object)null || ((Renderer)componentInChildren).sharedMaterials.Length == 0 || (Object)(object)((Renderer)componentInChildren).sharedMaterials[0] == (Object)null)
			{
				Log.LogWarning((object)"[Klippfisk] no material found to re-texture");
				return;
			}
			Texture2D val = LoadKlippfiskTexture();
			if (!((Object)(object)val == (Object)null))
			{
				Material[] sharedMaterials = ((Renderer)componentInChildren).sharedMaterials;
				Material val2 = new Material(sharedMaterials[0])
				{
					mainTexture = (Texture)(object)val
				};
				sharedMaterials[0] = val2;
				((Renderer)componentInChildren).sharedMaterials = sharedMaterials;
			}
		}

		private Texture2D LoadKlippfiskTexture()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OdinRealmFishing_klippfisk_texture.png");
			if (stream == null)
			{
				Log.LogWarning((object)"[Klippfisk] embedded resource not found: OdinRealmFishing_klippfisk_texture.png");
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				num = stream.Read(array, i, array.Length - i);
				if (num <= 0)
				{
					break;
				}
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array))
			{
				Log.LogWarning((object)"[Klippfisk] could not decode OdinRealmFishing_klippfisk_texture.png");
				return null;
			}
			return val;
		}

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.odinrealm.fishingmod").PatchAll();
			OdinFishingBait.RegisterLocalization();
			PrefabManager.OnVanillaPrefabsAvailable += CreateFishTrapPiece;
			PrefabManager.OnVanillaPrefabsAvailable += CreateFishNetItem;
			PrefabManager.OnVanillaPrefabsAvailable += CreateFishingPoleItem;
			PrefabManager.OnVanillaPrefabsAvailable += CreateKlippfiskSoupItem;
			((MonoBehaviour)this).InvokeRepeating("LogShipControlsOffset", 2f, 2f);
			((MonoBehaviour)this).StartCoroutine(CustomAudio.LoadNetBreakSound());
		}

		private void LogShipControlsOffset()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Ship standingOnShip = ((Character)localPlayer).GetStandingOnShip();
			if (!((Object)(object)standingOnShip == (Object)null) && !((Object)(object)standingOnShip.m_shipControlls == (Object)null))
			{
				string text = ((Object)standingOnShip).name.Replace("(Clone)", "").Trim();
				if (_loggedShipTypes.Add(text))
				{
					Vector3 val = ((Component)standingOnShip).transform.InverseTransformPoint(((Component)standingOnShip.m_shipControlls).transform.position);
					Log.LogInfo((object)$"[OdinRealmFishing] Ship '{text}' ShipControlls local offset: {val}");
				}
			}
		}

		private static Sprite[] IconArray(Sprite icon)
		{
			if (!((Object)(object)icon != (Object)null))
			{
				return null;
			}
			return (Sprite[])(object)new Sprite[1] { icon };
		}

		private void CreateFishTrapPiece()
		{
			//IL_0070: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= CreateFishTrapPiece;
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("OdinFishTrap", "piece_beehive");
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Failed to clone piece_beehive for the fish trap - is Jotunn loaded correctly?");
				return;
			}
			Beehive component = val.GetComponent<Beehive>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			SpawnOnDamaged component2 = val.GetComponent<SpawnOnDamaged>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			Transform transform = new GameObject("FishSpawnPoint").transform;
			transform.SetParent(val.transform, false);
			transform.localPosition = new Vector3(0f, 0.5f, 0f);
			BuildSlatCrate(val.transform);
			val.AddComponent<FishTrap>().m_spawnPoint = transform;
			PieceConfig val2 = new PieceConfig();
			val2.PieceTable = "Hammer";
			val2.Category = "Crafting";
			val2.Name = "Fish Trap";
			val2.Icon = CustomIcons.Load("OdinRealmFishing-trap-icon.png");
			val2.CraftingStation = "piece_workbench";
			val2.Description = "A slatted crate that traps a fish of the local waters. Build it at the water's surface, somewhere fish actually swim by.";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Wood", 4, 0, true),
				new RequirementConfig("Resin", 1, 0, true),
				new RequirementConfig("DeerHide", 1, 0, true)
			};
			PieceConfig val3 = val2;
			CustomPiece val4 = new CustomPiece(val, true, val3);
			PieceManager.Instance.AddPiece(val4);
			Log.LogInfo((object)"OdinRealmFishing 0.88.9: fish trap piece registered");
		}

		private static void BuildSlatCrate(Transform parent)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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)
			//IL_010c: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: 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)
			MeshRenderer[] componentsInChildren = ((Component)parent).GetComponentsInChildren<MeshRenderer>();
			Material[] materials = ((componentsInChildren.Length != 0) ? ((Renderer)componentsInChildren[0]).sharedMaterials : null);
			MeshRenderer[] array = componentsInChildren;
			for (int i = 0; i < array.Length; i++)
			{
				((Renderer)array[i]).enabled = false;
			}
			Collider[] componentsInChildren2 = ((Component)parent).GetComponentsInChildren<Collider>();
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren2[i]);
			}
			ParticleSystem[] componentsInChildren3 = ((Component)parent).GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem obj in componentsInChildren3)
			{
				obj.Stop(true, (ParticleSystemStopBehavior)0);
				((Component)obj).gameObject.SetActive(false);
			}
			AudioSource[] componentsInChildren4 = ((Component)parent).GetComponentsInChildren<AudioSource>(true);
			foreach (AudioSource obj2 in componentsInChildren4)
			{
				obj2.Stop();
				((Behaviour)obj2).enabled = false;
			}
			Transform transform = new GameObject("SlatCrateVisual").transform;
			transform.SetParent(parent, false);
			transform.localPosition = new Vector3(0f, 0.4f, 0f);
			Vector3[] array2 = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(0.4f, 0f, 0.4f),
				new Vector3(0.4f, 0f, -0.4f),
				new Vector3(-0.4f, 0f, 0.4f),
				new Vector3(-0.4f, 0f, -0.4f)
			};
			foreach (Vector3 localPosition in array2)
			{
				AddSlatCube(transform, localPosition, new Vector3(0.05f, 0.8f, 0.05f), materials);
			}
			for (int j = 0; j < 3; j++)
			{
				float num = -0.4f + 0.8f * ((float)j + 0.5f) / 3f;
				AddSlatCube(transform, new Vector3(0f, num, 0.4f), new Vector3(0.8f, 0.04f, 0.05f), materials);
				AddSlatCube(transform, new Vector3(0f, num, -0.4f), new Vector3(0.8f, 0.04f, 0.05f), materials);
				AddSlatCube(transform, new Vector3(0.4f, num, 0f), new Vector3(0.05f, 0.04f, 0.8f), materials);
				AddSlatCube(transform, new Vector3(-0.4f, num, 0f), new Vector3(0.05f, 0.04f, 0.8f), materials);
			}
			AddSlatCube(transform, new Vector3(0f, -0.4f, 0f), new Vector3(0.8f, 0.04f, 0.8f), materials);
			float num2 = 4f / 15f;
			for (int k = 0; k < 3; k++)
			{
				float num3 = -0.4f + 0.8f * ((float)k + 0.5f) / 3f;
				AddSlatCube(transform, new Vector3(0f, num2, num3), new Vector3(0.8f, 0.04f, 0.05f), materials);
			}
		}

		private static void AddSlatCube(Transform parent, Vector3 localPosition, Vector3 size, Material[] materials)
		{
			//IL_002d: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			if (materials != null && materials.Length != 0)
			{
				((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterials = materials;
			}
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			val.transform.localScale = size;
		}

		private void CreateFishNetItem()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= CreateFishNetItem;
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("OdinFishNet", "FishingRod");
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Failed to clone FishingRod for the fish net item - is Jotunn loaded correctly?");
				return;
			}
			FishNetItemVisualBuilder.Build(val);
			ItemConfig val2 = new ItemConfig();
			val2.Name = "Fish Net";
			val2.Icons = IconArray(CustomIcons.Load("OdinRealmFishing-net-icon.png"));
			val2.Description = "A net for catching fish from a boat. Attach it to the fish net cleat at a ship's stern and tow it behind you.";
			val2.CraftingStation = "piece_workbench";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("DeerHide", 4, 0, true),
				new RequirementConfig("Stone", 2, 0, true),
				new RequirementConfig("BronzeNails", 5, 0, true)
			};
			ItemConfig val3 = val2;
			CustomItem val4 = new CustomItem(val, true, val3);
			ItemManager.Instance.AddItem(val4);
			Log.LogInfo((object)"OdinRealmFishing 0.88.9: fish net item registered");
		}

		private void CreateFishingPoleItem()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= CreateFishingPoleItem;
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("OdinFishPole", "FishingRod");
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Failed to clone FishingRod for the fishing pole item - is Jotunn loaded correctly?");
				return;
			}
			FishPoleVisualBuilder.Build(val);
			ItemConfig val2 = new ItemConfig();
			val2.Name = "Fishing Pole";
			val2.Icons = IconArray(CustomIcons.Load("OdinRealmFishing-pole-icon.png"));
			val2.Description = "A simple fishing pole. Baited with uncooked Neck Tail, it catches Meadows fish.";
			val2.CraftingStation = "piece_workbench";
			val2.MinStationLevel = 1;
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Wood", 1, 0, true),
				new RequirementConfig("Resin", 1, 0, true),
				new RequirementConfig("LeatherScraps", 1, 0, true)
			};
			ItemConfig val3 = val2;
			CustomItem val4 = new CustomItem(val, true, val3);
			ItemManager.Instance.AddItem(val4);
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_ammoType = "$ammo_odin_necktail";
			Attack attack = shared.m_attack;
			attack.m_projectileVel *= 0.6f;
			Attack attack2 = shared.m_attack;
			attack2.m_projectileVelMin *= 0.6f;
			Log.LogInfo((object)"OdinRealmFishing 0.88.9: fishing pole item registered");
		}
	}
	internal static class OdinFishingBait
	{
		public const string NeckTailAmmoType = "$ammo_odin_necktail";

		public static void RegisterLocalization()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string> { { "ammo_odin_necktail", "Neck Tail" } });
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	internal static class NeckTailBaitFlagPatch
	{
		private static bool _applied;

		private static void Postfix(ObjectDB __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!_applied)
			{
				GameObject itemPrefab = __instance.GetItemPrefab("NeckTail");
				if (!((Object)(object)itemPrefab == (Object)null))
				{
					SharedData shared = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared;
					shared.m_itemType = (ItemType)23;
					shared.m_ammoType = "$ammo_odin_necktail";
					_applied = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Fish), "Awake")]
	internal static class MeadowsFishBaitPatch
	{
		private static void Postfix(Fish __instance)
		{
			//IL_0018: 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_0023: Invalid comparison between Unknown and I4
			//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)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			if (WorldGenerator.instance == null || (int)WorldGenerator.instance.GetBiome(((Component)__instance).transform.position) != 1)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("NeckTail");
			if (!((Object)(object)prefab == (Object)null))
			{
				ItemDrop neckTailItem = prefab.GetComponent<ItemDrop>();
				if (!__instance.m_baits.Exists((BaitSetting bait) => (Object)(object)bait.m_bait == (Object)(object)neckTailItem))
				{
					__instance.m_baits.Add(new BaitSetting
					{
						m_bait = neckTailItem,
						m_chance = 1f
					});
				}
			}
		}
	}
	public class NetCatchZone : MonoBehaviour
	{
		private const float NetBreakDelaySeconds = 1.5f;

		private const string NetPrefabName = "OdinFishNet";

		private static readonly HashSet<string> NetBreakingCreatures = new HashSet<string> { "Serpent", "Troll", "Bear", "Lox", "Abomination" };

		private static readonly Dictionary<string, int> FixedQualityCreatures = new Dictionary<string, int>
		{
			{ "Leech", 5 },
			{ "Neck", 5 },
			{ "Greyling", 5 },
			{ "Boar", 5 },
			{ "Deer", 5 }
		};

		public Action OnNetLost;

		public Transform CleatAnchor;

		public NetDeployState DeployState;

		public ZNetView ShipView;

		private bool m_netBreaking;

		public NetFishCollector Collector;

		private void OnTriggerEnter(Collider other)
		{
			TryCatch(other);
		}

		private void OnTriggerStay(Collider other)
		{
			TryCatch(other);
		}

		private void TryCatch(Collider other)
		{
			//IL_0126: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			bool flag = (Object)(object)DeployState == (Object)null || DeployState.IsDeployed;
			Character componentInParent = ((Component)other).GetComponentInParent<Character>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				string text = ((Object)((Component)componentInParent).gameObject).name.Replace("(Clone)", "").Trim();
				if (NetBreakingCreatures.Contains(text))
				{
					if (!m_netBreaking)
					{
						m_netBreaking = true;
						HandleNetBreakingCreature();
					}
					return;
				}
				if (flag && FixedQualityCreatures.TryGetValue(text, out var value))
				{
					HandleFixedQualityCatch(componentInParent, text, value);
					return;
				}
			}
			Fish componentInParent2 = ((Component)other).GetComponentInParent<Fish>();
			if (!flag || (Object)(object)componentInParent2 == (Object)null)
			{
				return;
			}
			ZNetView component = ((Component)componentInParent2).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid())
			{
				ItemDrop component2 = ((Component)componentInParent2).GetComponent<ItemDrop>();
				string text2 = ((Object)((Component)componentInParent2).gameObject).name.Replace("(Clone)", "").Trim();
				int num = ((!((Object)(object)component2 != (Object)null)) ? 1 : component2.m_itemData.m_quality);
				if (!((Object)(object)Collector != (Object)null) || Collector.TryReserve(num))
				{
					Vector3 position = ((Component)componentInParent2).transform.position;
					EffectList jumpEffects = componentInParent2.m_jumpEffects;
					component.ClaimOwnership();
					component.Destroy();
					jumpEffects.CreateSilently(position, Quaternion.identity);
					Plugin.Log.LogInfo((object)$"[Net] caught {text2} q{num} at {position}");
					ReportCaught(text2, num);
				}
			}
		}

		private void ReportCaught(string species, int quality)
		{
			if ((Object)(object)ShipView != (Object)null && ShipView.IsValid())
			{
				ShipView.InvokeRPC("RPC_OdinNetFishCaught", new object[2] { species, quality });
			}
		}

		private void HandleFixedQualityCatch(Character character, string species, int quality)
		{
			//IL_003c: 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_0053: 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)
			ZNetView component = ((Component)character).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && (!((Object)(object)Collector != (Object)null) || Collector.TryReserve(quality)))
			{
				Vector3 position = ((Component)character).transform.position;
				component.ClaimOwnership();
				component.Destroy();
				VanillaEffects.GetFallbackSplashEffect().CreateSilently(position, Quaternion.identity);
				ReportCaught(species, quality);
			}
		}

		private void HandleNetBreakingCreature()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			CustomAudio.PlayNetBreakSound(((Component)this).transform.position);
			((MonoBehaviour)this).StartCoroutine(DelayedNetBreak());
		}

		private IEnumerator DelayedNetBreak()
		{
			yield return (object)new WaitForSeconds(1.5f);
			if ((Object)(object)CleatAnchor != (Object)null)
			{
				VanillaEffects.GetPlaceEffect().Create(CleatAnchor.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
			}
			DropNetItem();
			OnNetLost?.Invoke();
		}

		private void DropNetItem()
		{
			//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_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_0049: 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)
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("OdinFishNet") : null);
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.25f;
				Object.Instantiate<GameObject>(val, val2, Quaternion.identity);
			}
		}
	}
	public class NetDeployState : MonoBehaviour
	{
		private struct RingEntry
		{
			public Rigidbody Body;

			public float Radius;

			public RingWaterFloat WaterFloat;

			public bool IsRing0;
		}

		private const float SpeedThreshold = 1.5f;

		private const float TransitionSeconds = 6f;

		private const float IdleDriftForce = 0.6f;

		private const float IdleDriftFrequency = 0.35f;

		private const float IdleDriftVerticalScale = 0.2f;

		private const float IdleBridleDistance = 5f;

		private const int KinematicSettleFixedFrames = 2;

		private Rigidbody m_shipBody;

		private Transform m_anchor;

		private Rigidbody m_ring0Body;

		private SpringJoint m_ring0Joint;

		private float m_deployedBridleDistance;

		private readonly List<RingEntry> m_rings = new List<RingEntry>();

		private float m_blend = 1f;

		public bool IsDeployed => m_blend > 0.5f;

		public void Init(Rigidbody shipBody, Transform anchor)
		{
			m_shipBody = shipBody;
			m_anchor = anchor;
			m_blend = ((CurrentSpeed() > 1.5f) ? 1f : 0f);
		}

		public void RegisterRing(Rigidbody body, float radius, RingWaterFloat waterFloat, bool isRing0, SpringJoint ring0Joint, float deployedBridleDistance)
		{
			m_rings.Add(new RingEntry
			{
				Body = body,
				Radius = radius,
				WaterFloat = waterFloat,
				IsRing0 = isRing0
			});
			if (isRing0)
			{
				m_ring0Body = body;
				m_ring0Joint = ring0Joint;
				m_deployedBridleDistance = deployedBridleDistance;
			}
		}

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(ReleaseFromKinematicSettle());
		}

		private IEnumerator ReleaseFromKinematicSettle()
		{
			for (int i = 0; i < 2; i++)
			{
				yield return (object)new WaitForFixedUpdate();
			}
			foreach (RingEntry ring in m_rings)
			{
				if ((Object)(object)ring.Body != (Object)null)
				{
					ring.Body.isKinematic = false;
				}
			}
		}

		private float CurrentSpeed()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_shipBody != (Object)null))
			{
				return 0f;
			}
			Vector3 linearVelocity = m_shipBody.linearVelocity;
			return ((Vector3)(ref linearVelocity)).magnitude;
		}

		private void FixedUpdate()
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_00a2: 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)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_00e1: 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_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_shipBody == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float num = ((CurrentSpeed() > 1.5f) ? 1f : 0f);
			m_blend = Mathf.MoveTowards(m_blend, num, Time.fixedDeltaTime / 6f);
			if ((Object)(object)m_ring0Joint != (Object)null)
			{
				m_ring0Joint.maxDistance = Mathf.Lerp(5f, m_deployedBridleDistance, m_blend);
			}
			Quaternion val2;
			float num2;
			if ((Object)(object)m_ring0Body != (Object)null && (Object)(object)m_anchor != (Object)null)
			{
				Vector3 val = m_anchor.position - m_ring0Body.position;
				val.y = 0f;
				float y;
				if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f))
				{
					val2 = m_shipBody.rotation;
					y = ((Quaternion)(ref val2)).eulerAngles.y;
				}
				else
				{
					val2 = Quaternion.LookRotation(val);
					y = ((Quaternion)(ref val2)).eulerAngles.y;
				}
				num2 = y;
			}
			else
			{
				val2 = m_shipBody.rotation;
				num2 = ((Quaternion)(ref val2)).eulerAngles.y;
			}
			float num3 = Mathf.Lerp(90f, 0f, m_blend);
			Vector3 val3 = default(Vector3);
			for (int i = 0; i < m_rings.Count; i++)
			{
				RingEntry ringEntry = m_rings[i];
				if ((Object)(object)ringEntry.Body == (Object)null)
				{
					continue;
				}
				ringEntry.Body.MoveRotation(Quaternion.Euler(num3, num2, 0f));
				if ((Object)(object)ringEntry.WaterFloat != (Object)null)
				{
					ringEntry.WaterFloat.OrientationBlend = m_blend;
					ringEntry.WaterFloat.InfluenceWeight = (ringEntry.IsRing0 ? 1f : (1f - m_blend));
				}
				if (!ringEntry.IsRing0 && !ringEntry.Body.isKinematic)
				{
					float num4 = 1f - m_blend;
					if (num4 > 0f)
					{
						float num5 = Time.time * 0.35f;
						float num6 = (float)i * 10.37f;
						((Vector3)(ref val3))..ctor(Mathf.PerlinNoise(num5 + num6, 0.11f) * 2f - 1f, (Mathf.PerlinNoise(num5 + num6, 3.71f) * 2f - 1f) * 0.2f, Mathf.PerlinNoise(num5 + num6, 7.23f) * 2f - 1f);
						ringEntry.Body.AddForce(val3 * (0.6f * num4), (ForceMode)0);
					}
				}
			}
		}
	}
	public class NetFishCollector : MonoBehaviour
	{
		private const float WanderFractionOfRingRadius = 0.6f;

		public const int MaxTotalQuality = 15;

		public Transform FishAnchor;

		public float FishAnchorRadius;

		public Transform CreatureAnchor;

		public float CreatureAnchorRadius;

		public ZNetView ShipView;

		private int m_decoratedCount;

		private readonly List<GameObject> m_decorations = new List<GameObject>();

		public int TotalQuality { get; private set; }

		private static bool IsCreature(string species)
		{
			if (!(species == "Leech"))
			{
				return species == "Neck";
			}
			return true;
		}

		public bool TryReserve(int quality)
		{
			if (TotalQuality + quality > 15)
			{
				return false;
			}
			TotalQuality += quality;
			return true;
		}

		private void FixedUpdate()
		{
			if (!((Object)(object)ShipView == (Object)null) && ShipView.IsValid())
			{
				(string, int)[] array = ParseCaughtFish(ShipView.GetZDO().GetString("OdinNetCaughtFish", ""));
				if (array.Length < m_decoratedCount)
				{
					DespawnAll();
				}
				for (int i = m_decoratedCount; i < array.Length; i++)
				{
					SpawnDecoration(array[i].Item1);
				}
				m_decoratedCount = array.Length;
			}
		}

		private void SpawnDecoration(string species)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			bool num = IsCreature(species);
			Transform val = (num ? CreatureAnchor : FishAnchor);
			float num2 = (num ? CreatureAnchorRadius : FishAnchorRadius);
			if (!((Object)(object)val == (Object)null))
			{
				GameObject item = CaughtFishVisualFactory.Spawn(species, val.position, val, num2 * 0.6f);
				m_decorations.Add(item);
			}
		}

		private void DespawnAll()
		{
			foreach (GameObject decoration in m_decorations)
			{
				if ((Object)(object)decoration != (Object)null)
				{
					Object.Destroy((Object)(object)decoration);
				}
			}
			m_decorations.Clear();
			m_decoratedCount = 0;
		}

		private void OnDestroy()
		{
			DespawnAll();
		}

		public static (string Species, int Quality)[] ParseCaughtFish(string raw)
		{
			if (string.IsNullOrEmpty(raw))
			{
				return Array.Empty<(string, int)>();
			}
			string[] array = raw.Split(';');
			(string, int)[] array2 = new(string, int)[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				string[] array3 = array[i].Split(':');
				int result;
				int item = ((array3.Length <= 1 || !int.TryParse(array3[1], out result)) ? 1 : result);
				array2[i] = (array3[0], item);
			}
			return array2;
		}
	}
	public static class NetMeshBuilder
	{
		public static Mesh BuildTaperedSock(int rings, int segments, float mouthRadius, float tailRadius, float length, float dropDepth)
		{
			//IL_0074: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			List<Vector3> list = new List<Vector3>(rings * segments + 1);
			List<int> list2 = new List<int>();
			Vector3 val = default(Vector3);
			for (int i = 0; i < rings; i++)
			{
				float num = (float)i / (float)(rings - 1);
				float num2 = Mathf.Lerp(mouthRadius, tailRadius, num);
				((Vector3)(ref val))..ctor(0f, 0f - mouthRadius - dropDepth * num, (0f - length) * num);
				for (int j = 0; j < segments; j++)
				{
					float num3 = (float)j / (float)segments * MathF.PI * 2f;
					Vector3 val2 = new Vector3(Mathf.Cos(num3), Mathf.Sin(num3), 0f) * num2;
					list.Add(val + val2);
				}
			}
			for (int k = 0; k < rings - 1; k++)
			{
				int num4 = k * segments;
				int num5 = (k + 1) * segments;
				for (int l = 0; l < segments; l++)
				{
					int item = num4 + l;
					int item2 = num4 + (l + 1) % segments;
					int item3 = num5 + l;
					int item4 = num5 + (l + 1) % segments;
					list2.Add(item);
					list2.Add(item3);
					list2.Add(item2);
					list2.Add(item2);
					list2.Add(item3);
					list2.Add(item4);
				}
			}
			int count = list.Count;
			int num6 = (rings - 1) * segments;
			list.Add(new Vector3(0f, 0f - mouthRadius - dropDepth, 0f - length));
			for (int m = 0; m < segments; m++)
			{
				int item5 = num6 + m;
				int item6 = num6 + (m + 1) % segments;
				list2.Add(item5);
				list2.Add(item6);
				list2.Add(count);
			}
			Mesh val3 = new Mesh
			{
				name = "OdinFishNetMesh"
			};
			val3.SetVertices(list);
			val3.SetTriangles(list2, 0);
			val3.RecalculateNormals();
			val3.RecalculateBounds();
			return val3;
		}
	}
	public static class NetPhysicsChain
	{
		private const int SegmentCount = 5;

		private const float SegmentLength = 0.5f;

		private const float MouthRadius = 0.5f;

		private const float TailRadius = 0.05f;

		private const float SegmentMass = 0.5f;

		private const float SpringForce = 50f;

		private const float SpringDamper = 5f;

		public static GameObject Spawn(Transform anchor, Rigidbody shipBody, Material[] materials)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a4: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OdinFishNetChain");
			val.transform.SetParent(anchor, false);
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			Rigidbody connectedBody = shipBody;
			Vector3 val2 = anchor.position;
			Vector3 val3 = -anchor.forward;
			for (int i = 0; i < 5; i++)
			{
				float num = (float)i / 5f;
				float num2 = (float)(i + 1) / 5f;
				float mouthRadius = Mathf.Lerp(0.5f, 0.05f, num);
				float tailRadius = Mathf.Lerp(0.5f, 0.05f, num2);
				val2 += val3 * 0.5f;
				GameObject val4 = new GameObject($"Segment{i}");
				val4.transform.SetParent(val.transform, true);
				val4.transform.position = val2;
				val4.transform.rotation = anchor.rotation;
				Rigidbody val5 = val4.AddComponent<Rigidbody>();
				val5.mass = 0.5f;
				val5.useGravity = false;
				val5.linearDamping = 2f;
				val5.angularDamping = 2f;
				SpringJoint obj = val4.AddComponent<SpringJoint>();
				((Joint)obj).connectedBody = connectedBody;
				((Joint)obj).autoConfigureConnectedAnchor = true;
				obj.spring = 50f;
				obj.damper = 5f;
				obj.minDistance = 0f;
				obj.maxDistance = 0.5f;
				val4.AddComponent<MeshFilter>().sharedMesh = NetMeshBuilder.BuildTaperedSock(4, 10, mouthRadius, tailRadius, 0.5f, 0f);
				MeshRenderer val6 = val4.AddComponent<MeshRenderer>();
				if (materials != null && materials.Length != 0)
				{
					((Renderer)val6).sharedMaterials = materials;
				}
				connectedBody = val5;
			}
			return val;
		}
	}
	public class NetShipAnchorProxy : MonoBehaviour
	{
		private Rigidbody m_body;

		private Transform m_target;

		public void Init(Transform target)
		{
			m_target = target;
			m_body = ((Component)this).GetComponent<Rigidbody>();
		}

		private void FixedUpdate()
		{
			//IL_0029: 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)
			if (!((Object)(object)m_target == (Object)null) && !((Object)(object)m_body == (Object)null))
			{
				m_body.MovePosition(m_target.position);
				m_body.MoveRotation(m_target.rotation);
			}
		}
	}
	public class RingDistanceClamp : MonoBehaviour
	{
		public Rigidbody PreviousBody;

		public float MaxDistance;

		private Rigidbody m_body;

		private void Awake()
		{
			m_body = ((Component)this).GetComponent<Rigidbody>();
		}

		private void FixedUpdate()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008d: Unknown result type (might be due to i