Decompiled source of SomethingFishy v1.0.0

Fishy.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.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Fishy;

internal static class Access
{
	private static readonly Func<FishingFloat, Character> _getOwner = AccessTools.MethodDelegate<Func<FishingFloat, Character>>(AccessTools.Method(typeof(FishingFloat), "GetOwner", (Type[])null, (Type[])null), (object)null, true);

	private static readonly Action<FishingFloat, Fish> _setCatch = AccessTools.MethodDelegate<Action<FishingFloat, Fish>>(AccessTools.Method(typeof(FishingFloat), "SetCatch", (Type[])null, (Type[])null), (object)null, true);

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

	private static readonly FieldRef<Fish, FishingFloat> _waypointFF = AccessTools.FieldRefAccess<Fish, FishingFloat>("m_waypointFF");

	private static readonly FieldRef<FishingFloat, Fish> _nibbler = AccessTools.FieldRefAccess<FishingFloat, Fish>("m_nibbler");

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

	private static FieldInfo _visField;

	private static bool _visSearched;

	private static MethodInfo _showHands;

	private static bool _showSearched;

	public static FishingFloat Heading(Fish f)
	{
		if (!((Object)(object)f != (Object)null))
		{
			return null;
		}
		return _waypointFF.Invoke(f);
	}

	public static Fish Nibbler(FishingFloat ff)
	{
		if (!((Object)(object)ff != (Object)null))
		{
			return null;
		}
		return _nibbler.Invoke(ff);
	}

	public static float NibbleTime(FishingFloat ff)
	{
		if (!((Object)(object)ff != (Object)null))
		{
			return -100f;
		}
		return _nibbleTime.Invoke(ff);
	}

	public static void SetNibbleTime(FishingFloat ff, float t)
	{
		if ((Object)(object)ff != (Object)null)
		{
			_nibbleTime.Invoke(ff) = t;
		}
	}

	public static float LineLength(FishingFloat ff)
	{
		if (!((Object)(object)ff != (Object)null))
		{
			return 0f;
		}
		return _lineLength.Invoke(ff);
	}

	public static Character Owner(FishingFloat ff)
	{
		if (!((Object)(object)ff != (Object)null))
		{
			return null;
		}
		return _getOwner(ff);
	}

	public static void SetCatch(FishingFloat ff, Fish fish)
	{
		if ((Object)(object)ff != (Object)null)
		{
			_setCatch(ff, fish);
		}
	}

	public static Transform RightHand(Player p)
	{
		if ((Object)(object)p == (Object)null)
		{
			return null;
		}
		try
		{
			if (!_visSearched)
			{
				_visSearched = true;
				_visField = AccessTools.Field(typeof(Humanoid), "m_visEquipment");
			}
			VisEquipment val = (VisEquipment)((_visField != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.m_rightHand != (Object)null)
			{
				return val.m_rightHand;
			}
		}
		catch
		{
		}
		return FindDeep(((Component)p).transform, "RightHand");
	}

	public static bool HideRightHand(Player p)
	{
		try
		{
			return (Object)(object)p != (Object)null && ((Humanoid)p).HideHandItems(true, false);
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] Olta gizlenemedi: " + ex.Message));
			return false;
		}
	}

	public static void ShowRightHand(Player p)
	{
		if ((Object)(object)p == (Object)null)
		{
			return;
		}
		try
		{
			if (!_showSearched)
			{
				_showSearched = true;
				_showHands = AccessTools.Method(typeof(Humanoid), "ShowHandItems", new Type[2]
				{
					typeof(bool),
					typeof(bool)
				}, (Type[])null);
			}
			if (_showHands != null)
			{
				_showHands.Invoke(p, new object[2] { true, false });
			}
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] Olta geri takılamadı: " + ex.Message));
		}
	}

	private static Transform FindDeep(Transform t, string name)
	{
		if ((Object)(object)t == (Object)null)
		{
			return null;
		}
		if (((Object)t).name == name)
		{
			return t;
		}
		for (int i = 0; i < t.childCount; i++)
		{
			Transform val = FindDeep(t.GetChild(i), name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	public static ItemDrop Item(Fish fish)
	{
		if (!((Object)(object)fish != (Object)null))
		{
			return null;
		}
		return ((Component)fish).GetComponent<ItemDrop>();
	}
}
[DefaultExecutionOrder(10000)]
internal class CatchShow : MonoBehaviour
{
	private const float GraceTime = 0.6f;

	private const float ShrinkTime = 0.25f;

	private const float ForwardOffset = 0.1f;

	private const float SwayDeg = 9f;

	private const float SpinDeg = 30f;

	private const float CamIn = 0.7f;

	private const float CamOut = 0.5f;

	private const float CamElev = 18f;

	private const float LookHeight = 1.35f;

	private const float LookRight = 0.15f;

	private const float CamMinDist = 0.8f;

	private const float CamPad = 0.15f;

	private static readonly string[] BlockLayers = new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" };

	private static CatchShow _current;

	private Player _player;

	private Transform _hand;

	private GameObject _held;

	private List<Mesh> _meshes;

	private float _t;

	private float _life;

	private bool _hasEmote;

	private bool _hidRod;

	private bool _ending;

	private bool _ownsInput;

	private bool _camOn;

	private float _zoom;

	private float _fovSaved = -1f;

	public static bool TakeInput()
	{
		if ((Object)(object)_current == (Object)null || _current._ending)
		{
			return false;
		}
		_current._ownsInput = true;
		return true;
	}

	public static bool Begin(Player p, FishView fishView, string fishPrefab = null)
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		if (Plugin.CatchAnim == null || !Plugin.CatchAnim.Value || (Object)(object)p == (Object)null)
		{
			return false;
		}
		try
		{
			Stop();
			string text = ((Plugin.CatchEmote != null) ? Plugin.CatchEmote.Value : "point");
			bool flag = !string.IsNullOrEmpty(text);
			if (flag && !p.StartEmote(text, true))
			{
				Plugin.Log("Balık kaldırma: emote başlatılamadı (gemide / saldırıda olabilir)");
				return false;
			}
			bool hidRod = Plugin.CatchHideRod != null && Plugin.CatchHideRod.Value && Access.HideRightHand(p);
			CatchShow catchShow = new GameObject("Fishy_CatchShow").AddComponent<CatchShow>();
			catchShow._player = p;
			catchShow._hasEmote = flag;
			catchShow._hidRod = hidRod;
			catchShow._life = ((Plugin.CatchShowSeconds != null) ? Plugin.CatchShowSeconds.Value : 5f);
			catchShow._zoom = ((Plugin.CatchZoom != null) ? Plugin.CatchZoom.Value : 0f);
			catchShow._camOn = Plugin.CatchCamera == null || Plugin.CatchCamera.Value;
			if (catchShow._zoom > 0.001f && (Object)(object)GameCamera.instance != (Object)null)
			{
				catchShow._fovSaved = GameCamera.instance.m_fov;
			}
			catchShow._hand = Access.RightHand(p);
			if (fishView != null && (Object)(object)catchShow._hand != (Object)null)
			{
				catchShow._held = fishView.TakeHeldModel(out catchShow._meshes);
				if ((Object)(object)catchShow._held != (Object)null)
				{
					catchShow.Place(0f, 1f);
				}
			}
			else
			{
				Plugin.Log("Balık kaldırma: sağ el ya da balık modeli yok, sadece emote");
			}
			_current = catchShow;
			NetShow.Show(fishPrefab);
			return true;
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] Balık kaldırma çalışmadı: " + ex.Message));
			return false;
		}
	}

	public static void Stop()
	{
		if ((Object)(object)_current != (Object)null)
		{
			_current.RestoreZoom();
			_current.GiveInput();
			Object.Destroy((Object)(object)((Component)_current).gameObject);
			_current = null;
		}
	}

	private void Place(float t, float scale)
	{
		//IL_002e: 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_0048: 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_007f: 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_00c9: 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)
		if (!((Object)(object)_held == (Object)null) && !((Object)(object)_hand == (Object)null))
		{
			_held.transform.position = _hand.position + ((Component)_player).transform.forward * 0.1f;
			_held.transform.rotation = Quaternion.Euler(Mathf.Sin(t * 2.4f) * 9f, ((Component)_player).transform.eulerAngles.y + Mathf.Sin(t * 0.9f) * 30f, Mathf.Sin(t * 1.9f + 1f) * 9f);
			_held.transform.localScale = Vector3.one * scale;
		}
	}

	private void End()
	{
		if (!_ending)
		{
			_ending = true;
			_life = Mathf.Min(_life, _t + 0.5f);
			GiveInput();
		}
	}

	private void LateUpdate()
	{
		_t += Time.deltaTime;
		if ((Object)(object)_player == (Object)null || ((Character)_player).IsDead())
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		if (!_ending && _hasEmote && _t > 0.6f && !((Character)_player).InEmote())
		{
			End();
		}
		if (!_ending && WantsOut())
		{
			End();
		}
		if (!_ending && _t >= _life - 0.5f)
		{
			End();
		}
		if (_t >= _life)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float scale = Mathf.Clamp01((_life - _t) / 0.25f);
		if ((Object)(object)_hand != (Object)null)
		{
			Place(_t, scale);
		}
		float w = Mathf.Min(Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_t / 0.7f)), Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((_life - _t) / 0.5f)));
		ApplyZoom(w);
		if (_camOn)
		{
			ApplyCamera(w);
		}
	}

	private static bool WantsOut()
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (!Input.GetKeyDown((KeyCode)119) && !Input.GetKeyDown((KeyCode)97) && !Input.GetKeyDown((KeyCode)115) && !Input.GetKeyDown((KeyCode)100) && !Input.GetKeyDown((KeyCode)27))
		{
			return Input.GetKeyDown((KeyCode)((Plugin.CancelKey == null) ? 9 : ((int)Plugin.CancelKey.Value)));
		}
		return true;
	}

	private void ApplyCamera(float w)
	{
		//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_0034: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0099: 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_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_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_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: 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_0186: 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_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		GameCamera instance = GameCamera.instance;
		if (!((Object)(object)instance == (Object)null) && !(w <= 0f))
		{
			Transform transform = ((Component)_player).transform;
			Vector3 val = transform.position + Vector3.up * 1.35f + transform.right * 0.15f;
			float num = ((Plugin.CatchCameraAngle != null) ? Plugin.CatchCameraAngle.Value : 120f);
			float num2 = ((Plugin.CatchCameraDistance != null) ? Plugin.CatchCameraDistance.Value : 2.4f);
			Vector3 val2 = Dir(transform, num, 18f);
			float num3 = num2;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.SphereCast(val, 0.2f, val2, ref val3, num2, LayerMask.GetMask(BlockLayers)))
			{
				num3 = Mathf.Max(0.8f, ((RaycastHit)(ref val3)).distance - 0.15f);
			}
			Transform transform2 = ((Component)instance).transform;
			Vector3 val4 = transform2.position - val;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			Vector3 val5 = ((magnitude > 0.01f) ? (val4 / magnitude) : (-transform.forward));
			float num4 = Mathf.Atan2(Vector3.Dot(val5, transform.right), Vector3.Dot(val5, transform.forward)) * 57.29578f;
			if (num4 < 0f)
			{
				num4 += 360f;
			}
			Vector3 val6 = Dir(el: Mathf.Lerp(Mathf.Asin(Mathf.Clamp(val5.y, -1f, 1f)) * 57.29578f, 18f, w), pt: transform, az: Mathf.Lerp(num4, num, w));
			Vector3 val7 = val + val6 * Mathf.Lerp(magnitude, num3, w);
			Quaternion val8 = Quaternion.Slerp(transform2.rotation, Quaternion.LookRotation(val - val7), w);
			transform2.SetPositionAndRotation(val7, val8);
		}
	}

	private static Vector3 Dir(Transform pt, float az, float el)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		float num = az * ((float)Math.PI / 180f);
		float num2 = el * ((float)Math.PI / 180f);
		Vector3 val = (pt.forward * Mathf.Cos(num) + pt.right * Mathf.Sin(num)) * Mathf.Cos(num2) + Vector3.up * Mathf.Sin(num2);
		return ((Vector3)(ref val)).normalized;
	}

	private void ApplyZoom(float w)
	{
		if (!(_fovSaved < 0f) && !((Object)(object)GameCamera.instance == (Object)null))
		{
			GameCamera.instance.m_fov = Mathf.Lerp(_fovSaved, _fovSaved * (1f - _zoom), w);
		}
	}

	private void RestoreZoom()
	{
		if (_fovSaved < 0f)
		{
			return;
		}
		try
		{
			if ((Object)(object)GameCamera.instance != (Object)null)
			{
				GameCamera.instance.m_fov = _fovSaved;
			}
		}
		catch
		{
		}
		_fovSaved = -1f;
	}

	private void GiveInput()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (_ownsInput)
		{
			_ownsInput = false;
			InputReleaser.Begin((KeyCode)323, (KeyCode)((Plugin.PullKey == null) ? 32 : ((int)Plugin.PullKey.Value)), (KeyCode)((Plugin.CancelKey == null) ? 9 : ((int)Plugin.CancelKey.Value)));
		}
	}

	private void OnDestroy()
	{
		NetShow.ShowEnd();
		if ((Object)(object)_current == (Object)(object)this)
		{
			_current = null;
		}
		if ((Object)(object)_held != (Object)null)
		{
			Object.Destroy((Object)(object)_held);
		}
		if (_meshes != null)
		{
			foreach (Mesh mesh in _meshes)
			{
				if ((Object)(object)mesh != (Object)null)
				{
					Object.Destroy((Object)(object)mesh);
				}
			}
		}
		_held = null;
		_meshes = null;
		RestoreZoom();
		GiveInput();
		if (_hidRod)
		{
			_hidRod = false;
			Access.ShowRightHand(_player);
		}
	}
}
internal static class FishStats
{
	private static readonly List<float> Sorted = new List<float>();

	private static int _builtFrom = -1;

	private static readonly HashSet<string> VanillaNames = new HashSet<string>
	{
		"Fish1", "Fish2", "Fish3", "Fish4_cave", "Fish5", "Fish6", "Fish7", "Fish8", "Fish9", "Fish10",
		"Fish11", "Fish12"
	};

	private static readonly List<float> Vanilla = new List<float>();

	public static float Strength(Fish f)
	{
		if ((Object)(object)f == (Object)null)
		{
			return 1f;
		}
		float num = (f.m_escapeMin + f.m_escapeMax) * 0.5f;
		float num2 = (f.m_escapeWaitMin + f.m_escapeWaitMax) * 0.5f;
		float num3 = ((num + num2 > 0.01f) ? (num / (num + num2)) : 0f);
		return f.m_staminaUse * (1f - num3) + f.m_escapeStaminaUse * num3;
	}

	public static float Rank(Fish fish)
	{
		Build();
		List<float> list = ((Vanilla.Count >= 2) ? Vanilla : Sorted);
		if (list.Count < 2)
		{
			return 0.5f;
		}
		float num = Strength(fish);
		if (num <= list[0])
		{
			return 0f;
		}
		if (num >= list[list.Count - 1])
		{
			return 1f;
		}
		for (int i = 0; i < list.Count - 1; i++)
		{
			if (num < list[i + 1])
			{
				float num2 = list[i + 1] - list[i];
				float num3 = ((num2 > 0.0001f) ? ((num - list[i]) / num2) : 0f);
				return Mathf.Clamp01(((float)i + num3) / (float)(list.Count - 1));
			}
		}
		return 1f;
	}

	private static void Build()
	{
		ZNetScene instance = ZNetScene.instance;
		if ((Object)(object)instance == (Object)null || instance.m_prefabs == null || _builtFrom == instance.m_prefabs.Count)
		{
			return;
		}
		_builtFrom = instance.m_prefabs.Count;
		Sorted.Clear();
		Vanilla.Clear();
		List<string> list = new List<string>();
		foreach (GameObject prefab in instance.m_prefabs)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				continue;
			}
			Fish component = prefab.GetComponent<Fish>();
			if (!((Object)(object)component == (Object)null))
			{
				float item = Strength(component);
				Sorted.Add(item);
				if (VanillaNames.Contains(((Object)prefab).name))
				{
					Vanilla.Add(item);
				}
				list.Add(((Object)prefab).name + " " + item.ToString("0.0") + " (çekme " + component.m_staminaUse + ", kaçış " + component.m_escapeStaminaUse + ", kaçış " + component.m_escapeMin + "-" + component.m_escapeMax + " sn +" + component.m_escapeMaxPerLevel + "/yıldız, bekleme " + component.m_escapeWaitMin + "-" + component.m_escapeWaitMax + " sn, hız " + component.m_speed + ")");
			}
		}
		Sorted.Sort();
		Vanilla.Sort();
		Logger.LogInfo((object)("[Fishy] Balık güç tablosu (" + Sorted.Count + " balık):\n  " + string.Join("\n  ", list)));
	}
}
public enum Pattern
{
	Spin,
	Murk,
	Drift,
	Twin,
	Storm,
	Pendulum,
	Jump,
	Hold,
	Order,
	Puff,
	Lantern,
	Ice
}
public enum PoolMode
{
	Fixed,
	AllRandom,
	ByStrength
}
public enum PatternChoice
{
	Auto,
	Spin,
	Murk,
	Drift,
	Twin,
	Storm,
	Pendulum,
	Jump,
	Hold,
	Order,
	Puff,
	Lantern,
	Ice
}
internal struct FishInfo
{
	public Pattern Pattern;

	public int Tier;

	public FishInfo(Pattern p, int t)
	{
		Pattern = p;
		Tier = t;
	}
}
internal struct TierParams
{
	public int Count;

	public float Speed;

	public float Width;
}
internal static class FishTable
{
	private const int CountMin = 3;

	private const int CountMax = 5;

	private const int CountCap = 7;

	private const float SpeedMin = 2f;

	private const float SpeedMax = 2.9f;

	public const float BaseSpeed = 2f;

	private const float WidthMin = 0.44f;

	private const float WidthMax = 0.28f;

	private const float SpeedPerStar = 0.04f;

	private const int StarsForExtraZone = 3;

	private const int StarsForSecondExtra = 5;

	private static readonly Pattern[] Basic = new Pattern[4]
	{
		Pattern.Spin,
		Pattern.Pendulum,
		Pattern.Murk,
		Pattern.Jump
	};

	private static readonly Pattern[] MidNew = new Pattern[2]
	{
		Pattern.Drift,
		Pattern.Hold
	};

	private static readonly Pattern[] HardNew = new Pattern[2]
	{
		Pattern.Twin,
		Pattern.Storm
	};

	private const float NewShare = 0.5f;

	private static Pattern? _last;

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

	private static readonly Dictionary<string, Pattern> FixedMap = new Dictionary<string, Pattern>
	{
		{
			"Fish1",
			Pattern.Spin
		},
		{
			"Fish2",
			Pattern.Jump
		},
		{
			"Fish3",
			Pattern.Drift
		},
		{
			"Fish4_cave",
			Pattern.Murk
		},
		{
			"Fish5",
			Pattern.Hold
		},
		{
			"Fish6",
			Pattern.Twin
		},
		{
			"Fish7",
			Pattern.Pendulum
		},
		{
			"Fish8",
			Pattern.Order
		},
		{
			"Fish9",
			Pattern.Lantern
		},
		{
			"Fish10",
			Pattern.Ice
		},
		{
			"Fish11",
			Pattern.Storm
		},
		{
			"Fish12",
			Pattern.Puff
		}
	};

	private static string _customRaw;

	private static readonly Dictionary<string, FishInfo> Custom = new Dictionary<string, FishInfo>();

	public static string PrefabName(GameObject go)
	{
		if ((Object)(object)go == (Object)null)
		{
			return "";
		}
		string text = ((Object)go).name;
		int num = text.IndexOf("(Clone)", StringComparison.Ordinal);
		if (num >= 0)
		{
			text = text.Substring(0, num);
		}
		return text.Trim();
	}

	public static Pattern PickPattern(float rank)
	{
		List<KeyValuePair<Pattern, float>> list = new List<KeyValuePair<Pattern, float>>();
		int num = TierOf(rank);
		if (Plugin.PatternPool == null || Plugin.PatternPool.Value == PoolMode.AllRandom)
		{
			foreach (Pattern value in Enum.GetValues(typeof(Pattern)))
			{
				list.Add(new KeyValuePair<Pattern, float>(value, 1f));
			}
		}
		else if (num == 0)
		{
			Pattern[] basic = Basic;
			foreach (Pattern key2 in basic)
			{
				list.Add(new KeyValuePair<Pattern, float>(key2, 1f / (float)Basic.Length));
			}
		}
		else
		{
			List<Pattern> list2 = new List<Pattern>(Basic);
			if (num == 2)
			{
				list2.AddRange(MidNew);
			}
			Pattern[] array = ((num == 1) ? MidNew : HardNew);
			foreach (Pattern item in list2)
			{
				list.Add(new KeyValuePair<Pattern, float>(item, 0.5f / (float)list2.Count));
			}
			Pattern[] basic = array;
			foreach (Pattern key3 in basic)
			{
				list.Add(new KeyValuePair<Pattern, float>(key3, 0.5f / (float)array.Length));
			}
		}
		if (_last.HasValue && list.Count > 1)
		{
			list.RemoveAll((KeyValuePair<Pattern, float> kv) => kv.Key == _last.Value);
		}
		float num2 = 0f;
		foreach (KeyValuePair<Pattern, float> item2 in list)
		{
			num2 += item2.Value;
		}
		float num3 = Random.value * num2;
		Pattern key4 = list[list.Count - 1].Key;
		foreach (KeyValuePair<Pattern, float> item3 in list)
		{
			num3 -= item3.Value;
			if (num3 <= 0f)
			{
				key4 = item3.Key;
				break;
			}
		}
		_last = key4;
		return key4;
	}

	public static Pattern ChoosePattern(Fish fish, float rank, out int customTier)
	{
		customTier = -1;
		string text = PrefabName(((Object)(object)fish != (Object)null) ? ((Component)fish).gameObject : null);
		if (Announced.Add(text))
		{
			Logger.LogInfo((object)("[Fishy] Yeni balık " + text + ": güç " + FishStats.Strength(fish).ToString("0.0") + ", sıra " + rank.ToString("0.00") + " (" + ((TierOf(rank) == 0) ? "zayıf" : ((TierOf(rank) == 1) ? "orta" : "güçlü")) + ")"));
		}
		if (Plugin.ForcePattern != null && Plugin.ForcePattern.Value != PatternChoice.Auto)
		{
			return (Pattern)(Plugin.ForcePattern.Value - 1);
		}
		if (TryCustom(text, out var info))
		{
			customTier = info.Tier;
			return info.Pattern;
		}
		if (Plugin.PatternPool == null || Plugin.PatternPool.Value == PoolMode.Fixed)
		{
			return FixedPattern(text);
		}
		return PickPattern(rank);
	}

	public static Pattern FixedPattern(string prefab)
	{
		if (!string.IsNullOrEmpty(prefab) && FixedMap.TryGetValue(prefab, out var value))
		{
			return value;
		}
		uint num = 2166136261u;
		string text = prefab ?? "";
		foreach (char c in text)
		{
			num ^= c;
			num *= 16777619;
		}
		Pattern[] array = (Pattern[])Enum.GetValues(typeof(Pattern));
		return array[num % (uint)array.Length];
	}

	private static bool TryCustom(string prefab, out FishInfo info)
	{
		string text = ((Plugin.CustomFish != null) ? Plugin.CustomFish.Value : "");
		if (text != _customRaw)
		{
			_customRaw = text;
			Custom.Clear();
			string[] array = (text ?? "").Split(';', ',');
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { '=' });
				if (array2.Length != 2)
				{
					continue;
				}
				string[] array3 = array2[1].Split(new char[1] { ':' });
				if (Enum.TryParse<Pattern>(array3[0].Trim(), ignoreCase: true, out var result))
				{
					int result2 = 0;
					if (array3.Length > 1)
					{
						int.TryParse(array3[1].Trim(), out result2);
					}
					Custom[array2[0].Trim()] = new FishInfo(result, (result2 >= 1) ? (Mathf.Clamp(result2, 1, 3) - 1) : (-1));
				}
			}
		}
		return Custom.TryGetValue(prefab, out info);
	}

	public static TierParams Params(float rank, int stars)
	{
		rank = Mathf.Clamp01(rank);
		float num = ((Plugin.SpeedMult != null) ? Plugin.SpeedMult.Value : 1f);
		float num2 = ((Plugin.ZoneMult != null) ? Plugin.ZoneMult.Value : 1f);
		int num3 = Mathf.RoundToInt(Mathf.Lerp(3f, 5f, rank));
		if (stars >= 3)
		{
			num3++;
		}
		if (stars >= 5)
		{
			num3++;
		}
		return new TierParams
		{
			Count = Mathf.Min(num3, 7),
			Speed = Mathf.Lerp(2f, 2.9f, rank) * (1f + 0.04f * (float)Mathf.Max(0, stars - 1)) * num,
			Width = Mathf.Min(Mathf.Lerp(0.44f, 0.28f, rank) * num2, 1.4f)
		};
	}

	public static float PatternWeight(Pattern p)
	{
		return p switch
		{
			Pattern.Murk => 0.15f, 
			Pattern.Drift => 0.2f, 
			Pattern.Twin => 0.2f, 
			Pattern.Storm => 0.3f, 
			Pattern.Pendulum => 0.05f, 
			Pattern.Jump => 0.15f, 
			Pattern.Hold => 0.15f, 
			Pattern.Order => 0.15f, 
			Pattern.Puff => 0.15f, 
			Pattern.Lantern => 0.2f, 
			Pattern.Ice => 0.2f, 
			_ => 0f, 
		};
	}

	public static int TierOf(float rank)
	{
		if (!(rank < 1f / 3f))
		{
			if (!(rank < 2f / 3f))
			{
				return 2;
			}
			return 1;
		}
		return 0;
	}
}
internal class FishView
{
	private const int Layer = 3;

	private static readonly Vector3 Origin = new Vector3(-10000f, 10000f, -10000f);

	private const int TextureSize = 384;

	private const float ModelLength = 1f;

	private const float PivotY = 0.62f;

	private const float OrthoSize = 0.72f;

	private const float SwayDeg = 7f;

	private const float ThrashDeg = 22f;

	private const float SpinDeg = 35f;

	private const float JerkTime = 0.25f;

	private const float JerkUp = 0.12f;

	private const float FillLight = 0.45f;

	private static readonly Color Background = new Color(0.1f, 0.09f, 0.08f, 1f);

	private GameObject _root;

	private GameObject _pivot;

	private GameObject _model;

	private GameObject _window;

	private Camera _camera;

	private RenderTexture _texture;

	private Texture2D _waterTex;

	private Material _waterMat;

	private WaterOverlay _overlay;

	private readonly List<Mesh> _meshes = new List<Mesh>();

	private float _jerk;

	private float _t;

	private float _origLen;

	private const float HeldMin = 0.35f;

	private const float HeldMax = 0.9f;

	public Transform Window
	{
		get
		{
			if (!((Object)(object)_window != (Object)null))
			{
				return null;
			}
			return _window.transform;
		}
	}

	public static FishView Create(Fish fish, RectTransform parent, float size, Sprite circle, WaterStyle? water = null)
	{
		if ((Object)(object)fish == (Object)null || (Object)(object)parent == (Object)null)
		{
			return null;
		}
		FishView fishView = new FishView();
		try
		{
			if (!fishView.Build(fish, parent, size, circle, water))
			{
				fishView.Dispose();
				return null;
			}
			return fishView;
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] 3D balık kurulamadı, ikon kullanılıyor: " + ex.Message));
			fishView.Dispose();
			return null;
		}
	}

	private bool Build(Fish fish, RectTransform parent, float size, Sprite circle, WaterStyle? water)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_001b: 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_0035: Expected O, but got Unknown
		//IL_006b: 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_0085: Expected O, but got Unknown
		//IL_0804: Unknown result type (might be due to invalid IL or missing references)
		//IL_0809: Unknown result type (might be due to invalid IL or missing references)
		//IL_081c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0822: Unknown result type (might be due to invalid IL or missing references)
		//IL_0827: Unknown result type (might be due to invalid IL or missing references)
		//IL_0835: Unknown result type (might be due to invalid IL or missing references)
		//IL_084f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0873: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: 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_015f: Expected O, but got Unknown
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_043c: 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_01d9: Expected O, but got Unknown
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0497: Unknown result type (might be due to invalid IL or missing references)
		//IL_049c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Expected O, but got Unknown
		//IL_0545: Unknown result type (might be due to invalid IL or missing references)
		//IL_054c: Expected O, but got Unknown
		//IL_057a: Unknown result type (might be due to invalid IL or missing references)
		//IL_058b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0604: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ae: Expected O, but got Unknown
		//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0716: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_072e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0734: Unknown result type (might be due to invalid IL or missing references)
		//IL_073b: Unknown result type (might be due to invalid IL or missing references)
		_root = new GameObject("Fishy_FishView");
		_root.transform.position = Origin;
		_pivot = new GameObject("Pivot");
		_pivot.transform.SetParent(_root.transform, false);
		_pivot.transform.localPosition = new Vector3(0f, 0.62f, 0f);
		_model = new GameObject("Model");
		_model.transform.SetParent(_pivot.transform, false);
		List<Renderer> list = new List<Renderer>();
		LODGroup componentInChildren = ((Component)fish).GetComponentInChildren<LODGroup>();
		if ((Object)(object)componentInChildren != (Object)null && componentInChildren.GetLODs().Length != 0)
		{
			list.AddRange(componentInChildren.GetLODs()[0].renderers);
		}
		if (list.Count == 0)
		{
			list.AddRange(((Component)fish).GetComponentsInChildren<Renderer>(true));
		}
		Transform transform = ((Component)fish).transform;
		int num = 0;
		foreach (Renderer item in list)
		{
			if ((Object)(object)item == (Object)null || item is ParticleSystemRenderer || item is SpriteRenderer || item is TrailRenderer || item is LineRenderer)
			{
				continue;
			}
			Mesh val = null;
			SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((item is SkinnedMeshRenderer) ? item : null);
			if (val2 != null)
			{
				val = new Mesh();
				val2.BakeMesh(val, true);
				_meshes.Add(val);
			}
			else
			{
				MeshFilter component = ((Component)item).GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null)
				{
					val = component.sharedMesh;
				}
			}
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val3 = new GameObject("Part" + num, new Type[2]
				{
					typeof(MeshFilter),
					typeof(MeshRenderer)
				});
				val3.transform.SetParent(_model.transform, false);
				val3.transform.localPosition = transform.InverseTransformPoint(((Component)item).transform.position);
				val3.transform.localRotation = Quaternion.Inverse(transform.rotation) * ((Component)item).transform.rotation;
				if (!(item is SkinnedMeshRenderer))
				{
					val3.transform.localScale = Div(((Component)item).transform.lossyScale, transform.lossyScale);
				}
				val3.GetComponent<MeshFilter>().sharedMesh = val;
				MeshRenderer component2 = val3.GetComponent<MeshRenderer>();
				((Renderer)component2).sharedMaterials = item.sharedMaterials;
				((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)component2).receiveShadows = false;
				num++;
			}
		}
		if (num == 0)
		{
			return false;
		}
		Bounds val4 = LocalBounds(_model);
		float num2 = Mathf.Max(((Bounds)(ref val4)).size.x, Mathf.Max(((Bounds)(ref val4)).size.y, ((Bounds)(ref val4)).size.z));
		if (num2 < 0.0001f)
		{
			return false;
		}
		_origLen = num2;
		float num3 = 1f / num2;
		_model.transform.localScale = Vector3.one * num3;
		if (((Bounds)(ref val4)).size.z >= ((Bounds)(ref val4)).size.x && ((Bounds)(ref val4)).size.z >= ((Bounds)(ref val4)).size.y)
		{
			_model.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
		}
		else if (((Bounds)(ref val4)).size.x >= ((Bounds)(ref val4)).size.y)
		{
			_model.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
		}
		else
		{
			_model.transform.localRotation = Quaternion.identity;
		}
		val4 = WorldBounds(_model);
		Vector3 val5 = default(Vector3);
		((Vector3)(ref val5))..ctor(((Bounds)(ref val4)).center.x, ((Bounds)(ref val4)).max.y, ((Bounds)(ref val4)).center.z);
		Transform transform2 = _model.transform;
		transform2.position += _pivot.transform.position - val5;
		bool flag = water.HasValue && BuildBackdrop(water.Value);
		Transform[] componentsInChildren = _root.GetComponentsInChildren<Transform>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Component)componentsInChildren[i]).gameObject.layer = 3;
		}
		GameObject val6 = new GameObject("Fill");
		val6.transform.SetParent(_root.transform, false);
		val6.transform.rotation = Quaternion.Euler(25f, 30f, 0f);
		Light obj = val6.AddComponent<Light>();
		obj.type = (LightType)1;
		obj.intensity = 0.45f;
		obj.color = new Color(1f, 0.93f, 0.82f);
		obj.cullingMask = 8;
		obj.shadows = (LightShadows)0;
		_texture = new RenderTexture(384, 384, 24, (RenderTextureFormat)0);
		_texture.antiAliasing = 4;
		_texture.Create();
		GameObject val7 = new GameObject("Camera");
		val7.transform.SetParent(_root.transform, false);
		val7.transform.localPosition = new Vector3(0f, 0f, -3f);
		val7.transform.localRotation = Quaternion.identity;
		_camera = val7.AddComponent<Camera>();
		_camera.orthographic = true;
		_camera.orthographicSize = 0.72f;
		_camera.cullingMask = 8;
		_camera.clearFlags = (CameraClearFlags)2;
		_camera.backgroundColor = (flag ? Color.Lerp(water.Value.Top, water.Value.Bottom, 0.5f) : Background);
		_camera.nearClipPlane = 0.1f;
		_camera.farClipPlane = 10f;
		_camera.renderingPath = (RenderingPath)3;
		_camera.allowHDR = false;
		_camera.allowMSAA = false;
		_camera.useOcclusionCulling = false;
		_camera.targetTexture = _texture;
		_camera.aspect = 1f;
		_camera.depth = -50f;
		GameObject val8 = (_window = new GameObject("FishWindow", new Type[1] { typeof(RectTransform) }));
		val8.transform.SetParent((Transform)(object)parent, false);
		((RectTransform)val8.transform).sizeDelta = new Vector2(size, size);
		Image obj2 = val8.AddComponent<Image>();
		obj2.sprite = circle;
		((Graphic)obj2).raycastTarget = false;
		val8.AddComponent<Mask>().showMaskGraphic = false;
		GameObject val9 = new GameObject("Render", new Type[1] { typeof(RectTransform) });
		val9.transform.SetParent(val8.transform, false);
		((RectTransform)val9.transform).sizeDelta = new Vector2(size, size);
		RawImage obj3 = val9.AddComponent<RawImage>();
		obj3.texture = (Texture)(object)_texture;
		((Graphic)obj3).raycastTarget = false;
		if (flag && (Plugin.WaterParticles == null || Plugin.WaterParticles.Value))
		{
			try
			{
				_overlay = new WaterOverlay();
				_overlay.Build(val8.transform, size, water.Value, circle);
			}
			catch (Exception ex)
			{
				Plugin.Log("Su parçacıkları kurulamadı: " + ex.Message);
				if (_overlay != null)
				{
					_overlay.Dispose();
				}
				_overlay = null;
			}
		}
		float num4 = size * 0.5f * (31f / 36f);
		float num5 = size * 0.5f - num4;
		GameObject val10 = new GameObject("Line", new Type[1] { typeof(RectTransform) });
		val10.transform.SetParent(val8.transform, false);
		RectTransform val11 = (RectTransform)val10.transform;
		val11.sizeDelta = new Vector2(2f, num5 + 2f);
		val11.anchoredPosition = new Vector2(0f, num4 + num5 * 0.5f);
		Image obj4 = val10.AddComponent<Image>();
		((Graphic)obj4).color = new Color(0.9f, 0.88f, 0.8f, 0.85f);
		((Graphic)obj4).raycastTarget = false;
		Plugin.Log("3D balık: " + num + " parça, boy " + num2.ToString("0.00"));
		return true;
	}

	public void Animate(float dt, float escapeK, bool ended)
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_pivot == (Object)null))
		{
			_t += dt;
			float num = Mathf.Clamp01((escapeK - 1f) / 0.4f);
			float num2 = Mathf.Lerp(7f, 22f, num) * (ended ? 0.3f : 1f);
			float num3 = Mathf.Lerp(1.6f, 7f, num);
			float num4 = Mathf.Sin(_t * num3) * num2;
			float num5 = Mathf.Sin(_t * 0.7f) * 35f + Mathf.Sin(_t * num3 * 1.3f) * num2 * 0.6f;
			_pivot.transform.localRotation = Quaternion.Euler(0f, num5, num4);
			if (_jerk > 0f)
			{
				_jerk -= dt;
			}
			float num6 = ((_jerk > 0f) ? (Mathf.Sin(_jerk / 0.25f * (float)Math.PI) * 0.12f) : 0f);
			_pivot.transform.localPosition = new Vector3(0f, 0.62f + num6, 0f);
			if (_overlay != null)
			{
				_overlay.Update(dt, num);
			}
		}
	}

	private bool BuildBackdrop(WaterStyle st)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_004e: 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_0061: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		try
		{
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log("Sprites/Default bulunamadı, su arka planı düz renk");
				return false;
			}
			_waterTex = new Texture2D(1, 64, (TextureFormat)4, false);
			((Texture)_waterTex).wrapMode = (TextureWrapMode)1;
			for (int i = 0; i < 64; i++)
			{
				_waterTex.SetPixel(0, i, Color.Lerp(st.Bottom, st.Top, (float)i / 63f));
			}
			_waterTex.Apply();
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			((Object)obj).name = "Water";
			obj.transform.SetParent(_root.transform, false);
			obj.transform.localPosition = new Vector3(0f, 0f, 1.5f);
			obj.transform.localScale = new Vector3(2.16f, 2.16f, 1f);
			_waterMat = new Material(val);
			_waterMat.mainTexture = (Texture)(object)_waterTex;
			MeshRenderer component2 = obj.GetComponent<MeshRenderer>();
			((Renderer)component2).sharedMaterial = _waterMat;
			((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component2).receiveShadows = false;
			return true;
		}
		catch (Exception ex)
		{
			Plugin.Log("Su arka planı kurulamadı: " + ex.Message);
			return false;
		}
	}

	public void Jerk()
	{
		_jerk = 0.25f;
	}

	public GameObject TakeHeldModel(out List<Mesh> meshes)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_0064: 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_0080: 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)
		meshes = null;
		if ((Object)(object)_model == (Object)null || _origLen < 0.0001f)
		{
			return null;
		}
		float num = Mathf.Clamp(_origLen, 0.35f, 0.9f);
		GameObject val = new GameObject("Fishy_HeldFish");
		_model.transform.SetParent(val.transform, false);
		Transform transform = _model.transform;
		transform.localScale *= num;
		Transform transform2 = _model.transform;
		transform2.localPosition *= num;
		Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Component)componentsInChildren[i]).gameObject.layer = 0;
		}
		MeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer obj in componentsInChildren2)
		{
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)obj).receiveShadows = true;
		}
		meshes = new List<Mesh>(_meshes);
		_meshes.Clear();
		_model = null;
		return val;
	}

	public void Dispose()
	{
		try
		{
			if ((Object)(object)_camera != (Object)null)
			{
				_camera.targetTexture = null;
			}
			if ((Object)(object)_texture != (Object)null)
			{
				_texture.Release();
				Object.Destroy((Object)(object)_texture);
			}
			if (_overlay != null)
			{
				_overlay.Dispose();
			}
			if ((Object)(object)_window != (Object)null)
			{
				Object.Destroy((Object)(object)_window);
			}
			if ((Object)(object)_waterMat != (Object)null)
			{
				Object.Destroy((Object)(object)_waterMat);
			}
			if ((Object)(object)_waterTex != (Object)null)
			{
				Object.Destroy((Object)(object)_waterTex);
			}
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
			foreach (Mesh mesh in _meshes)
			{
				if ((Object)(object)mesh != (Object)null)
				{
					Object.Destroy((Object)(object)mesh);
				}
			}
		}
		catch
		{
		}
		_meshes.Clear();
		_root = null;
		_pivot = null;
		_model = null;
		_camera = null;
		_texture = null;
		_window = null;
		_overlay = null;
		_waterMat = null;
		_waterTex = null;
	}

	private static Vector3 Div(Vector3 a, Vector3 b)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: 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_0042: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3((b.x != 0f) ? (a.x / b.x) : 1f, (b.y != 0f) ? (a.y / b.y) : 1f, (b.z != 0f) ? (a.z / b.z) : 1f);
	}

	private static Bounds LocalBounds(GameObject model)
	{
		//IL_0004: 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_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)
		//IL_004d: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_0089: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		Bounds result = default(Bounds);
		MeshFilter[] componentsInChildren = model.GetComponentsInChildren<MeshFilter>();
		foreach (MeshFilter val in componentsInChildren)
		{
			if ((Object)(object)val.sharedMesh == (Object)null)
			{
				continue;
			}
			Bounds bounds = val.sharedMesh.bounds;
			Transform transform = ((Component)val).transform;
			for (int j = 0; j < 8; j++)
			{
				Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))));
				Vector3 val3 = model.transform.InverseTransformPoint(transform.TransformPoint(val2));
				if (!flag)
				{
					((Bounds)(ref result))..ctor(val3, Vector3.zero);
					flag = true;
				}
				else
				{
					((Bounds)(ref result)).Encapsulate(val3);
				}
			}
		}
		return result;
	}

	private static Bounds WorldBounds(GameObject model)
	{
		//IL_0004: 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_002d: 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)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		Bounds result = default(Bounds);
		MeshRenderer[] componentsInChildren = model.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer val in componentsInChildren)
		{
			if (!flag)
			{
				result = ((Renderer)val).bounds;
				flag = true;
			}
			else
			{
				((Bounds)(ref result)).Encapsulate(((Renderer)val).bounds);
			}
		}
		return result;
	}
}
internal class FishyGame : MonoBehaviour
{
	internal class Zone
	{
		public float A;

		public float W;

		public float Vel;

		public float Phase;

		public float Fade;

		public float Life;

		public int Ring;

		public int Order;

		public int Hp;

		public int MaxHp;

		public bool Alive = true;

		public bool Hazard;

		public bool Gold;

		public bool Hidden;

		public bool Ice;

		public Image Arc;

		public Image Mid;

		public Image Fill;

		public Image Marker;

		public Image Tick;

		public Text Label;
	}

	private class Spark
	{
		public RectTransform Rt;

		public Image Img;

		public Text Txt;

		public Vector2 V;

		public float Life;

		public float Max;

		public float Grow;

		public float Size;
	}

	private const float StartDelay = 0.4f;

	private const float EndDelay = 1f;

	private const float GoldShare = 0.26f;

	private const float GoldHit = 0.13f;

	private const float RingSize = 200f;

	private const float InnerRingScale = 0.68f;

	private const float RingInner = 0.84f;

	private static readonly Vector2 PanelSize = new Vector2(600f, 290f);

	private const float RingX = -105f;

	private const float GaugeX = -268f;

	private const float InfoX = 165f;

	private const float InfoW = 250f;

	private static readonly Color StaminaColor = new Color(0.98f, 0.78f, 0.25f, 1f);

	private static readonly Color LineColor = new Color(0.86f, 0.8f, 0.66f, 0.9f);

	private const float TwinOuterSpeed = 0.8f;

	private const float TwinInnerSpeed = 0.9f;

	private const float StormSpeedUp = 1.15f;

	private const float MurkPulse = 1.6f;

	private const float DriftMin = 0.35f;

	private const float DriftMax = 0.8f;

	private const float HazardShare = 0.75f;

	private const float ShakeTime = 0.3f;

	private const float ShakePx = 9f;

	private const float HitFade = 0.35f;

	private static readonly Color TrackColor = new Color(0f, 0f, 0f, 0.55f);

	private static readonly Color ZoneColor = new Color(0.45f, 0.73f, 0.43f, 1f);

	internal static readonly Color GoldColor = new Color(0.89f, 0.67f, 0.3f, 1f);

	private static readonly Color HazardColor = new Color(0.78f, 0.34f, 0.24f, 1f);

	private static readonly Color NeedleColor = new Color(0.95f, 0.93f, 0.86f, 1f);

	internal static readonly Color TextColor = new Color(0.95f, 0.92f, 0.84f, 1f);

	internal static readonly Color Orange = new Color(1f, 0.631f, 0.235f, 1f);

	private const float Tau = (float)Math.PI * 2f;

	private const float OrderLabelOut = 32f;

	private const float WindowGrow = 2f;

	private const float RimInner = 0.95f;

	private readonly List<Image> _rims = new List<Image>();

	private const float NeedleWidth = 6f;

	private const float BoneKnob = 13f;

	private const float PendAmp = 1.9f;

	private const float PendDark = 0.88f;

	private const float PendLit = 0.1f;

	private const float PendRate = 0.55f;

	private const float JumpLifeMin = 2.2f;

	private const float JumpLifeMax = 3.4f;

	private const float JumpWarn = 0.6f;

	private const float HoldWidthMult = 2.4f;

	private const float HoldStartMax = 0.5f;

	private const float HoldGoldMax = 0.2f;

	private const float HoldEndMin = 0.85f;

	private const float IceWidth = 0.16f;

	private const float IceTime = 2.4f;

	private const int IceHpMin = 4;

	private const int IceHpMax = 8;

	private const float PuffRate = 2.2f;

	private const float PuffMin = 0.45f;

	private const float PuffMax = 1.25f;

	private const float PuffGold = 0.75f;

	private const float LanternAhead = 1.2f;

	private const float LanternFade = 0.4f;

	private const float LanternBehind = 0.25f;

	private static readonly Color IceColor = new Color(0.66f, 0.84f, 0.91f, 1f);

	private Zone _stuck;

	private float _stuckT;

	private int _next = 1;

	private Image _cone;

	private float _pendT;

	private Zone _hold;

	private bool _holdGold;

	private Image _pendMask;

	private static FishyGame _active;

	private static Sprite _ringSprite;

	private static Sprite _dotSprite;

	private static Sprite _lineSprite;

	private static Sprite _triSprite;

	private static Sprite _rimSprite;

	private static Sprite _discSprite;

	private FishingFloat _float;

	private Fish _fish;

	private ItemDrop _item;

	private Player _player;

	private FishInfo _info;

	private TierParams _p;

	private readonly List<Zone> _zones = new List<Zone>();

	private readonly float[] _needle = new float[2]
	{
		0f,
		(float)Math.PI
	};

	private readonly float[] _dir = new float[2] { 1f, -1f };

	private float _speed;

	private float _t;

	private float _endT;

	private float _shake;

	private float _punch;

	private const float PunchTime = 0.14f;

	private const float PunchSize = 0.03f;

	private readonly List<Spark> _sparks = new List<Spark>();

	private float _lapAngle;

	private int _hits;

	private int _golds;

	private int _miss;

	private int _lives;

	private int _maxLives;

	private int _ringCount;

	private bool _ended;

	private GameObject _canvas;

	private RectTransform _root;

	private readonly RectTransform[] _needleArm = (RectTransform[])(object)new RectTransform[2];

	private readonly Image[] _tracks = (Image[])(object)new Image[2];

	private RectTransform _icon;

	private RectTransform _panel;

	private Text _title;

	private Text _sub;

	private Text _count;

	private Text _hint;

	private Text _button;

	private readonly List<Image> _lifeDots = new List<Image>();

	private Image _staminaFill;

	private Text _staminaText;

	private float _gaugeH;

	private bool _staminaMode;

	private float _drainPerSec;

	private float _missCost;

	private float _skill;

	private float _rank;

	private int _stars = 1;

	private string _prefab = "";

	private float _escapeK = 1f;

	private bool _inputReleased;

	private Image _buttonImg;

	private FishView _view;

	private PatternFx _fx;

	private float _press;

	private const float StamW = 16f;

	private const float StamH = 190f;

	private const float StamX = -252f;

	private static readonly Color StamFrame = new Color(0.3f, 0.29f, 0.14f, 0.95f);

	private static readonly Color StamBack = new Color(0.1f, 0.1f, 0.06f, 0.85f);

	private static Font _font;

	private static float EscapeSpeed
	{
		get
		{
			if (Plugin.EscapeSpeedUp == null)
			{
				return 1.4f;
			}
			return Plugin.EscapeSpeedUp.Value;
		}
	}

	private static float LapsBeforePull
	{
		get
		{
			if (Plugin.IdleLaps == null)
			{
				return 1.5f;
			}
			return Plugin.IdleLaps.Value;
		}
	}

	public static bool IsOpen => (Object)(object)_active != (Object)null;

	private static KeyCode CancelKey
	{
		get
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.CancelKey == null)
			{
				return (KeyCode)9;
			}
			return Plugin.CancelKey.Value;
		}
	}

	private static KeyCode PullKey
	{
		get
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.PullKey == null)
			{
				return (KeyCode)32;
			}
			return Plugin.PullKey.Value;
		}
	}

	internal static Vector2 PanelPos => new Vector2((Plugin.PanelX != null) ? Plugin.PanelX.Value : 300f, (Plugin.PanelY != null) ? Plugin.PanelY.Value : (-60f));

	internal static float PanelScale
	{
		get
		{
			if (Plugin.PanelScale == null)
			{
				return 1.1f;
			}
			return Plugin.PanelScale.Value;
		}
	}

	public static bool Owns(FishingFloat ff)
	{
		if ((Object)(object)_active != (Object)null && !_active._ended && (Object)(object)ff != (Object)null)
		{
			return (Object)(object)_active._float == (Object)(object)ff;
		}
		return false;
	}

	public static void Begin(FishingFloat ff, Fish fish)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		if ((Object)(object)_active != (Object)null)
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
		{
			return;
		}
		GameObject val = new GameObject("Fishy_Ring");
		FishyGame fishyGame = (_active = val.AddComponent<FishyGame>());
		try
		{
			fishyGame.Init(ff, fish, localPlayer);
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("[Fishy] Halka kurulamadı, vanilla balık tutma devam ediyor: " + ex));
			_active = null;
			fishyGame._ended = true;
			Object.Destroy((Object)(object)val);
		}
	}

	private void Init(FishingFloat ff, Fish fish, Player p)
	{
		_float = ff;
		_fish = fish;
		_player = p;
		_item = Access.Item(fish);
		string text = FishTable.PrefabName(((Component)fish).gameObject);
		int stars = ((!((Object)(object)_item != (Object)null) || _item.m_itemData == null) ? 1 : _item.m_itemData.m_quality);
		_rank = FishStats.Rank(fish);
		_info.Pattern = FishTable.ChoosePattern(fish, _rank, out var customTier);
		if (customTier >= 0)
		{
			_rank = (float)customTier / 2f;
		}
		if (Plugin.ForceTier != null && Plugin.ForceTier.Value > 0)
		{
			_rank = (float)(Plugin.ForceTier.Value - 1) / 2f;
		}
		_info.Tier = FishTable.TierOf(_rank);
		_p = FishTable.Params(Mathf.Clamp01(_rank - FishTable.PatternWeight(_info.Pattern)), stars);
		Plugin.Log("Zorluk: güç " + FishStats.Strength(fish).ToString("0.0") + ", sıra " + _rank.ToString("0.00") + ", yıldız " + stars + " → " + _p.Count + " bölge, hız " + _p.Speed.ToString("0.0") + ", genişlik " + _p.Width.ToString("0.00"));
		_speed = _p.Speed;
		_maxLives = (_lives = ((Plugin.Lives != null) ? Plugin.Lives.Value : 3));
		_staminaMode = Plugin.Mode == null || Plugin.Mode.Value == LineMode.Stamina;
		if (_staminaMode)
		{
			SetupStamina(ff, fish);
		}
		_ringCount = ((_info.Pattern != Pattern.Twin) ? 1 : 2);
		_needle[0] = Random.Range(0f, (float)Math.PI * 2f);
		_needle[1] = (_needle[0] + (float)Math.PI) % ((float)Math.PI * 2f);
		MakeZones();
		Plugin.Log("Balık takıldı: " + text + " desen " + _info.Pattern.ToString() + " grup " + (_info.Tier + 1));
		LogVanillaTime(ff, fish);
		BuildUI();
		GUIManager.BlockInput(true);
		_prefab = text;
		NetShow.Ring(_prefab, 0, _p.Count, escaping: false);
	}

	private void MakeZones()
	{
		int count = _p.Count;
		float num = (float)Math.PI * 2f / (float)count;
		for (int i = 0; i < count; i++)
		{
			Zone zone = new Zone
			{
				A = Wrap((float)i * num + Random.Range(0.2f, Mathf.Max(0.25f, num - 0.2f))),
				W = _p.Width * Random.Range(0.9f, 1.1f),
				Phase = Random.Range(0f, (float)Math.PI * 2f),
				Ring = ((_info.Pattern == Pattern.Twin) ? (i % 2) : 0),
				Life = Random.Range(2.2f, 3.4f)
			};
			if (_info.Pattern == Pattern.Pendulum)
			{
				float num2 = 3.04f;
				zone.A = Wrap(-1.52f + ((float)i + Random.Range(0.2f, 0.8f)) / (float)count * num2);
				zone.W = Mathf.Min(zone.W, num2 / (float)count * 0.9f);
			}
			if (_info.Pattern == Pattern.Hold)
			{
				zone.W = Mathf.Min(new float[3]
				{
					1.5f,
					_p.Width * 2.4f,
					num * 0.7f
				});
				zone.A = Wrap((float)i * num + num / 2f + Random.Range(-0.1f, 0.1f));
			}
			if (_info.Pattern == Pattern.Jump)
			{
				zone.Hidden = i > 0;
			}
			if (_info.Pattern == Pattern.Drift)
			{
				zone.Vel = Random.Range(0.35f, 0.8f) * Mathf.Lerp(0.5f, 1.2f, _rank) * ((Random.value < 0.5f) ? (-1f) : 1f);
			}
			_zones.Add(zone);
		}
		if (_info.Pattern == Pattern.Order)
		{
			List<int> list = new List<int>();
			for (int j = 1; j <= count; j++)
			{
				list.Add(j);
			}
			for (int num3 = list.Count - 1; num3 > 0; num3--)
			{
				int index = Random.Range(0, num3 + 1);
				int value = list[num3];
				list[num3] = list[index];
				list[index] = value;
			}
			for (int k = 0; k < count; k++)
			{
				_zones[k].Order = list[k];
			}
		}
		if (_info.Pattern == Pattern.Ice)
		{
			int num4 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Lerp(1f, (float)(count - 1), _rank)), 1, Mathf.Max(1, count - 1));
			int num5 = Mathf.RoundToInt(Mathf.Lerp(4f, 8f, _rank));
			for (int l = 0; l < num4; l++)
			{
				_zones.Add(new Zone
				{
					A = Wrap(_zones[l].A + num / 2f),
					W = 0.16f,
					Ice = true,
					Hp = num5,
					MaxHp = num5
				});
			}
		}
		if (_info.Pattern == Pattern.Storm)
		{
			int num6 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Lerp(1f, (float)(count - 1), _rank)), 1, Mathf.Max(1, count - 1));
			for (int m = 0; m < num6; m++)
			{
				_zones.Add(new Zone
				{
					A = Wrap(_zones[m].A + num / 2f),
					W = _p.Width * 0.75f,
					Hazard = true
				});
			}
		}
	}

	private void Update()
	{
		try
		{
			Tick();
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("[Fishy] Halkada hata, güvenli kapatıldı (balık bırakıldı): " + ex));
			if (!_ended)
			{
				ReleaseFish(snap: false);
			}
			Close();
		}
	}

	private void Tick()
	{
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Unknown result type (might be due to invalid IL or missing references)
		float deltaTime = Time.deltaTime;
		_t += deltaTime;
		if (_ended)
		{
			_endT -= deltaTime;
			Draw(deltaTime);
			if (_endT <= 0f)
			{
				Close();
			}
			return;
		}
		if ((Object)(object)_player == (Object)null || ((Character)_player).IsDead() || (Object)(object)_player != (Object)(object)Player.m_localPlayer)
		{
			ReleaseFish(snap: false);
			Close();
			return;
		}
		if ((Object)(object)_fish == (Object)null || (Object)(object)_float == (Object)null)
		{
			_ended = true;
			Close();
			return;
		}
		if (Input.GetKeyDown(CancelKey))
		{
			ReleaseFish(snap: false);
			Finish(L.T("released"), good: false);
			return;
		}
		if (_t >= 0.4f)
		{
			bool flag = false;
			try
			{
				flag = _fish.IsEscaping();
			}
			catch
			{
			}
			_escapeK = Mathf.MoveTowards(_escapeK, flag ? EscapeSpeed : 1f, deltaTime * 3f);
			NetShow.Ring(_prefab, _hits, _p.Count, flag);
			float num = ((_info.Pattern == Pattern.Twin) ? 0.8f : 1f) * _escapeK;
			if (_stuck != null)
			{
				_stuckT -= deltaTime;
				if (_stuckT <= 0f)
				{
					Zone stuck = _stuck;
					_stuck = null;
					stuck.Alive = false;
					stuck.Fade = 0.35f;
					Hurt(1);
					if (_ended)
					{
						return;
					}
				}
			}
			else if (_info.Pattern == Pattern.Ice)
			{
				float num2 = Wrap(_needle[0] + _dir[0] * _speed * num * deltaTime);
				Zone zone = null;
				foreach (Zone zone2 in _zones)
				{
					if (zone2.Ice && zone2.Alive && AngDist(num2, zone2.A) < zone2.W / 2f)
					{
						zone = zone2;
						break;
					}
				}
				if (zone != null)
				{
					_stuck = zone;
					_stuckT = 2.4f;
					_needle[0] = Wrap(zone.A - _dir[0] * zone.W / 2f);
				}
				else
				{
					_needle[0] = num2;
				}
			}
			else if (_info.Pattern == Pattern.Pendulum)
			{
				_pendT += deltaTime * _speed * num * 0.55f;
				_needle[0] = Wrap(Mathf.Sin(_pendT) * 1.9f);
				_dir[0] = ((Mathf.Cos(_pendT) >= 0f) ? 1f : (-1f));
			}
			else
			{
				_needle[0] = Wrap(_needle[0] + _dir[0] * _speed * num * deltaTime);
			}
			if (_stuck == null)
			{
				_lapAngle += _speed * num * deltaTime;
			}
			if (_lapAngle >= (float)Math.PI * 2f * LapsBeforePull)
			{
				_lapAngle = 0f;
				Hurt(1);
				if (_ended)
				{
					return;
				}
			}
			_needle[1] = Wrap(_needle[1] + _dir[1] * _speed * 0.9f * _escapeK * deltaTime);
			foreach (Zone zone3 in _zones)
			{
				if (zone3.Vel != 0f && zone3.Alive)
				{
					zone3.A = Wrap(zone3.A + zone3.Vel * deltaTime);
				}
			}
			if (_info.Pattern == Pattern.Jump)
			{
				foreach (Zone zone4 in _zones)
				{
					if (zone4.Alive && !zone4.Hidden)
					{
						zone4.Life -= deltaTime * (_speed / 2f);
						if (zone4.Life <= 0f)
						{
							zone4.A = JumpSpot();
							zone4.Life = Random.Range(2.2f, 3.4f);
						}
					}
				}
			}
			if (_hold != null && HoldProgress(_hold) < 0f)
			{
				Zone hold = _hold;
				_hold = null;
				HitZone(hold, 0, _holdGold);
				if (_ended)
				{
					return;
				}
			}
			if (_staminaMode && _drainPerSec > 0f)
			{
				Spend(_drainPerSec * deltaTime);
			}
			if (!_ended && (Input.GetMouseButtonDown(0) || Input.GetKeyDown(PullKey)))
			{
				Act();
			}
			if (!_ended && _hold != null && (Input.GetMouseButtonUp(0) || Input.GetKeyUp(PullKey)))
			{
				Release();
			}
		}
		if (!_ended)
		{
			Draw(deltaTime);
		}
	}

	private void Act()
	{
		_press = 0.08f;
		if (_info.Pattern == Pattern.Hold)
		{
			foreach (Zone zone2 in _zones)
			{
				if (!zone2.Alive)
				{
					continue;
				}
				float num = HoldProgress(zone2);
				if (!(num < 0f))
				{
					if (num < 0.5f)
					{
						_hold = zone2;
						_holdGold = num <= 0.2f;
						return;
					}
					break;
				}
			}
			Hurt(1);
			return;
		}
		if (_stuck != null)
		{
			_stuck.Hp--;
			if (_stuck.Hp <= 0)
			{
				_stuck.Alive = false;
				_stuck.Fade = 0.35f;
				_stuck.Gold = true;
				_stuck = null;
				if (_view != null)
				{
					_view.Jerk();
				}
			}
			return;
		}
		Zone zone = null;
		float num2 = 0f;
		float num3 = 0f;
		int ring = 0;
		foreach (Zone zone3 in _zones)
		{
			if (!zone3.Alive || zone3.Hidden || zone3.Ice || (_info.Pattern == Pattern.Lantern && LanternAlpha(zone3) < 0.15f))
			{
				continue;
			}
			float num4 = ZoneW(zone3);
			for (int i = 0; i < _ringCount; i++)
			{
				if (zone3.Ring == i)
				{
					float num5 = AngDist(_needle[i], zone3.A);
					if (num5 <= num4 / 2f && (zone == null || num5 < num2))
					{
						zone = zone3;
						num2 = num5;
						ring = i;
						num3 = num4;
					}
				}
			}
		}
		if (zone != null && _info.Pattern == Pattern.Order && zone.Order != _next)
		{
			Hurt(1);
			return;
		}
		if (zone != null && zone.Hazard)
		{
			zone.Alive = false;
			zone.Fade = 0.35f;
			Hurt(2);
			return;
		}
		if (zone == null)
		{
			Hurt(1);
			return;
		}
		bool gold = num2 <= num3 * 0.13f;
		if (_info.Pattern == Pattern.Puff && PuffK(zone) < 0.75f)
		{
			gold = false;
		}
		HitZone(zone, ring, gold);
	}

	private void Release()
	{
		Zone hold = _hold;
		_hold = null;
		if (hold != null && hold.Alive)
		{
			float num = HoldProgress(hold);
			if (num < 0f || num >= 0.85f)
			{
				HitZone(hold, 0, _holdGold);
			}
			else
			{
				Hurt(1);
			}
		}
	}

	private void HitZone(Zone z, int ring, bool gold)
	{
		z.Alive = false;
		z.Fade = 0.35f;
		z.Gold = gold;
		if (_staminaMode)
		{
			Spend(HitCost());
			if (_ended)
			{
				return;
			}
		}
		_hits++;
		_lapAngle = 0f;
		if (gold)
		{
			_golds++;
		}
		float num = 1f + (float)Mathf.Min(_hits - 1, 6) * 0.045f;
		float cut = ((Plugin.GameSoundLength != null) ? Plugin.GameSoundLength.Value : 0.4f);
		if (!GameSfx.Play(GameSfx.HitNames(), gold ? (num * 1.1f) : num, 1f, cut))
		{
			FxSound.Play(FxKind.Reel, num);
		}
		FxSound.Play(gold ? FxKind.Gold : FxKind.Good, num);
		HitEffect(z, ring, gold);
		_punch = 0.14f;
		if (_view != null)
		{
			_view.Jerk();
		}
		if (_info.Pattern == Pattern.Order)
		{
			_next++;
		}
		if (_info.Pattern == Pattern.Drift)
		{
			_dir[0] = 0f - _dir[0];
		}
		if (_info.Pattern == Pattern.Storm)
		{
			_dir[0] = 0f - _dir[0];
			_speed *= Mathf.Lerp(1.05f, 1.15f, _rank);
		}
		if (_info.Pattern == Pattern.Jump)
		{
			foreach (Zone zone in _zones)
			{
				if (zone.Alive && zone.Hidden)
				{
					zone.Hidden = false;
					zone.A = JumpSpot();
					zone.Life = Random.Range(2.2f, 3.4f);
					break;
				}
			}
		}
		bool flag = false;
		foreach (Zone zone2 in _zones)
		{
			if (zone2.Alive && !zone2.Hazard && !zone2.Ice)
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			Win();
		}
	}

	private void HitEffect(Zone z, int ring, bool gold)
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_0094: 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_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: 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_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: 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_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_root == (Object)null)
		{
			return;
		}
		try
		{
			float num = 200f * ((ring == 0) ? 1f : 0.68f);
			float num2 = num * 0.5f * 1.8399999f * 0.5f;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(Mathf.Sin(z.A), Mathf.Cos(z.A));
			Vector2 val2 = val * num2;
			Color val3 = (Color)(gold ? GoldColor : new Color(0.78f, 0.96f, 0.72f, 1f));
			Image val4 = NewImage("Flash", (Transform)(object)_root, _lineSprite, val3, new Vector2(num + 6f, num + 6f));
			_sparks.Add(new Spark
			{
				Rt = ((Graphic)val4).rectTransform,
				Img = val4,
				Life = 0.32f,
				Max = 0.32f,
				Grow = (gold ? 0.2f : 0.12f),
				Size = num + 6f
			});
			int num3 = (gold ? 14 : 8);
			for (int i = 0; i < num3; i++)
			{
				float num4 = Random.Range(5f, gold ? 11f : 8f);
				Image val5 = NewImage("Spark", (Transform)(object)_root, _dotSprite, val3, new Vector2(num4, num4));
				((Graphic)val5).rectTransform.anchoredPosition = val2;
				float num5 = Random.Range(-1f, 1f);
				Vector2 v = new Vector2(val.x * Mathf.Cos(num5) - val.y * Mathf.Sin(num5), val.x * Mathf.Sin(num5) + val.y * Mathf.Cos(num5)) * Random.Range(70f, 180f);
				_sparks.Add(new Spark
				{
					Rt = ((Graphic)val5).rectTransform,
					Img = val5,
					V = v,
					Life = 0.45f,
					Max = 0.45f,
					Size = num4
				});
			}
			Text val6 = NewText("Pop", (Transform)(object)_root, gold ? 26 : 20, val2 + val * 20f, 220f, (TextAnchor)4);
			val6.text = (gold ? L.T("hit_gold") : L.T("hit_good"));
			((Graphic)val6).color = val3;
			_sparks.Add(new Spark
			{
				Rt = ((Graphic)val6).rectTransform,
				Txt = val6,
				V = new Vector2(0f, 46f),
				Life = 0.6f,
				Max = 0.6f
			});
		}
		catch (Exception ex)
		{
			Plugin.Log("Vuruş efekti: " + ex.Message);
		}
	}

	private void UpdateSparks(float dt)
	{
		//IL_008d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: 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_00b9: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: 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_0122: Unknown result type (might be due to invalid IL or missing references)
		for (int num = _sparks.Count - 1; num >= 0; num--)
		{
			Spark spark = _sparks[num];
			spark.Life -= dt;
			if ((Object)(object)spark.Rt == (Object)null || spark.Life <= 0f)
			{
				if ((Object)(object)spark.Rt != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)spark.Rt).gameObject);
				}
				_sparks.RemoveAt(num);
			}
			else
			{
				float num2 = spark.Life / spark.Max;
				RectTransform rt = spark.Rt;
				rt.anchoredPosition += spark.V * dt;
				spark.V *= 0.94f;
				if ((Object)(object)spark.Img != (Object)null)
				{
					Color color = ((Graphic)spark.Img).color;
					color.a = num2;
					((Graphic)spark.Img).color = color;
					if (spark.Grow > 0f)
					{
						spark.Rt.sizeDelta = Vector2.one * (spark.Size * (1f + spark.Grow * (1f - num2)));
					}
					else
					{
						((Transform)spark.Rt).localScale = Vector3.one * (0.4f + 0.6f * num2);
					}
				}
				if ((Object)(object)spark.Txt != (Object)null)
				{
					Color color2 = ((Graphic)spark.Txt).color;
					color2.a = Mathf.Clamp01(num2 * 1.8f);
					((Graphic)spark.Txt).color = color2;
				}
			}
		}
	}

	private float PuffK(Zone z)
	{
		return 0.5f + 0.5f * Mathf.Sin(_t * 2.2f + z.Phase);
	}

	private float ZoneW(Zone z)
	{
		if (_info.Pattern != Pattern.Puff)
		{
			return z.W;
		}
		return z.W * Mathf.Lerp(0.45f, 1.25f, PuffK(z));
	}

	private float LanternAlpha(Zone z)
	{
		float num = Wrap((_dir[0] > 0f) ? (z.A - _needle[0]) : (_needle[0] - z.A));
		if (num < 1.2f)
		{
			return 1f - Mathf.Max(0f, (num - 0.8000001f) / 0.4f);
		}
		float num2 = (float)Math.PI * 2f - num;
		if (!(num2 < 0.25f))
		{
			return 0f;
		}
		return 1f - num2 / 0.25f;
	}

	private float JumpSpot()
	{
		return Wrap(_needle[0] + _dir[0] * Random.Range(1.3f, 4.983186f));
	}

	private float HoldProgress(Zone z)
	{
		float num = Wrap(z.A - _dir[0] * z.W / 2f);
		float num2 = Wrap((_dir[0] > 0f) ? (_needle[0] - num) : (num - _needle[0]));
		if (!(num2 <= z.W))
		{
			return -1f;
		}
		return num2 / z.W;
	}

	private void Hurt(int n)
	{
		_miss += n;
		_shake = 0.3f;
		FxSound.Play(FxKind.Miss);
		if (_staminaMode)
		{
			Spend(_missCost * (float)n);
			return;
		}
		_lives = Mathf.Max(0, _lives - n);
		if (_lives <= 0)
		{
			ReleaseFish(snap: true);
			Finish(L.T("escaped"), good: false);
		}
	}

	private void SetupStamina(FishingFloat ff, Fish fish)
	{
		_skill = ((Character)_player).GetSkillFactor((SkillType)104);
		_stars = ((!((Object)(object)_item != (Object)null) || _item.m_itemData == null) ? 1 : _item.m_itemData.m_quality);
		_drainPerSec = Mathf.Lerp(ff.m_hookedStaminaPerSec, ff.m_hookedStaminaPerSecMaxSkill, _skill) * Cfg(Plugin.DrainMult, 1f);
		_missCost = Cfg(Plugin.MissStamina, 12f) * (1f + 0.25f * (float)_info.Tier) * Mathf.Lerp(1f, 0.5f, _skill);
		Plugin.Log("Dayanıklılık: akış " + _drainPerSec.ToString("0.0") + "/sn, çekiş " + HitCost().ToString("0.0") + " (kaçarken daha çok), ıska " + _missCost.ToString("0.0") + ", beceri " + _skill.ToString("0.00"));
	}

	private float HitCost()
	{
		if ((Object)(object)_float == (Object)null || (Object)(object)_fish == (Object)null)
		{
			return 0f;
		}
		float num = _float.m_pullStaminaUse + _fish.GetStaminaUse() * (float)_stars;
		return Mathf.Lerp(num, num * _float.m_pullStaminaUseMaxSkillMultiplier, _skill) * Cfg(Plugin.HitStaminaSeconds, 0.5f);
	}

	private void LogVanillaTime(FishingFloat ff, Fish fish)
	{
		if (Plugin.VerboseLog == null || !Plugin.VerboseLog.Value)
		{
			return;
		}
		try
		{
			float skillFactor = ((Character)_player).GetSkillFactor((SkillType)104);
			float num = Access.LineLength(ff);
			float num2 = Mathf.Lerp(ff.m_pullLineSpeed, ff.m_pullLineSpeedMaxSkill, skillFactor);
			float num3 = ((num2 > 0f) ? (num / num2) : 0f);
			Plugin.Log("Vanilla karşılaştırma: misina " + num.ToString("0.0") + " m, sarma " + num2.ToString("0.00") + " m/sn (beceri 0 = " + ff.m_pullLineSpeed + ", 100 = " + ff.m_pullLineSpeedMaxSkill + ") → kaçışsız ~" + num3.ToString("0") + " sn, kaçışlarla ~" + (num3 * 1.3f).ToString("0") + " sn. Balık kaçış: " + fish.m_escapeMin + "-" + fish.m_escapeMax + " sn, bekleme " + fish.m_escapeWaitMin + "-" + fish.m_escapeWaitMax + " sn");
		}
		catch (Exception ex)
		{
			Plugin.Log("Vanilla karşılaştırma okunamadı: " + ex.Message);
		}
	}

	private static float Cfg(ConfigEntry<float> e, float def)
	{
		return e?.Value ?? def;
	}

	private void Spend(float v)
	{
		if (!(v <= 0f) && !((Object)(object)_player == (Object)null))
		{
			((Character)_player).UseStamina(v);
			if (_player.GetStamina() <= 0.01f)
			{
				ReleaseFish(snap: false);
				Finish(L.T("tired"), good: false);
			}
		}
	}

	private void Win()
	{
		int num = ((!((Object)(object)_item != (Object)null) || _item.m_itemData == null) ? 1 : _item.m_itemData.m_quality);
		bool flag = _golds >= _p.Count && _miss == 0;
		int num2 = 0;
		bool flag2 = _miss == 0;
		if (flag2 && Plugin.PerfectBonus != null)
		{
			num2 += Plugin.PerfectBonus.Value;
		}
		if (_golds >= _p.Count && Plugin.AllGoldBonus != null)
		{
			num2 += Plugin.AllGoldBonus.Value;
		}
		int num3 = 0;
		if ((Object)(object)_item != (Object)null && _item.m_itemData != null && num2 > 0)
		{
			int quality = _item.m_itemData.m_quality;
			int num4 = Mathf.Clamp(quality + num2, 1, 5);
			if (num4 != quality)
			{
				_item.SetQuality(num4);
			}
			num3 = num4 - quality;
		}
		Fish fish = _fish;
		FishingFloat ff = _float;
		string text = FishingFloat.Catch(fish, (Character)(object)_player);
		_ended = true;
		try
		{
			if (!string.IsNullOrEmpty(text) && Localization.instance != null)
			{
				((Character)_player).Message((MessageType)1, Localization.instance.Localize(text), 0, (Sprite)null, false);
			}
		}
		catch
		{
		}
		CloseFloat(ff, fish);
		if (!GameSfx.Play(flag ? GameSfx.Perfect : GameSfx.Catch))
		{
			FxSound.Play(FxKind.Catch);
		}
		bool flag3 = _golds >= _p.Count && _miss == 0;
		if (num >= ((Plugin.CatchMinQuality != null) ? Plugin.CatchMinQuality.Value : 2) && (flag3 || Plugin.CatchOnlyPerfect == null || !Plugin.CatchOnlyPerfect.Value))
		{
			CatchShow.Begin(_player, _view, _prefab);
		}
		if (flag3)
		{
			Treasure.TryGive(_player, _info.Tier);
		}
		float num5 = ((Plugin.SkillXp != null) ? Plugin.SkillXp.Value : 0f);
		if (num5 > 0f)
		{
			((Character)_player).RaiseSkill((SkillType)104, num5 * (float)(1 + _info.Tier));
		}
		string text2 = (flag2 ? L.T("perfect") : L.T("caught"));
		if (num3 > 0)
		{
			text2 = text2 + "\n" + L.T("quality_up", num3);
		}
		Finish(text2, good: true);
		Plugin.Log("Yakalandı: " + _hits + " vuruş, " + _golds + " altın, " + _miss + " hata, kalite +" + num3 + ", süre " + _t.ToString("0.0") + " sn (desen " + _info.Pattern.ToString() + ")");
	}

	private void Finish(string text, bool good)
	{
		//IL_0042: 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)
		NetShow.Result(good);
		_ended = true;
		_endT = 1f;
		if ((Object)(object)_title != (Object)null)
		{
			_title.text = text;
			((Graphic)_title).color = (good ? Orange : TextColor);
		}
		if ((Object)(object)_sub != (Object)null)
		{
			_sub.text = "";
		}
		if ((Object)(object)_hint != (Object)null)
		{
			_hint.text = "";
		}
		ReleaseInput();
	}

	private void ReleaseFish(bool snap)
	{
		//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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		Fish fish = _fish;
		FishingFloat val = _float;
		_ended = true;
		try
		{
			if ((Object)(object)val != (Object)null)
			{
				Access.SetCatch(val, null);
			}
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] Şamandıranın balık kaydı silinemedi: " + ex.Message));
		}
		try
		{
			if ((Object)(object)fish != (Object)null)
			{
				fish.OnHooked((FishingFloat)null);
			}
		}
		catch (Exception ex2)
		{
			Logger.LogWarning((object)("[Fishy] Balık bırakılamadı: " + ex2.Message));
		}
		if (!snap)
		{
			GameSfx.Play(new string[1] { "UI_Drop_M_01" }, 1f, 0.8f);
		}
		if (!snap || (Object)(object)val == (Object)null)
		{
			return;
		}
		try
		{
			if (val.m_lineBreakEffect != null)
			{
				val.m_lineBreakEffect.Create(((Component)val).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
			}
		}
		catch
		{
		}
		DestroyFloat(val);
	}

	private static void CloseFloat(FishingFloat ff, Fish fish)
	{
		try
		{
			if ((Object)(object)ff != (Object)null)
			{
				Access.SetCatch(ff, null);
			}
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] SetCatch: " + ex.Message));
		}
		try
		{
			if ((Object)(object)fish != (Object)null)
			{
				fish.OnHooked((FishingFloat)null);
			}
		}
		catch
		{
		}
		DestroyFloat(ff);
	}

	private static void DestroyFloat(FishingFloat ff)
	{
		try
		{
			ZNetView val = (((Object)(object)ff != (Object)null) ? ((Component)ff).GetComponent<ZNetView>() : null);
			if ((Object)(object)val != (Object)null && val.IsValid() && val.IsOwner())
			{
				val.Destroy();
			}
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[Fishy] Şamandıra kaldırılamadı: " + ex.Message));
		}
	}

	private void ReleaseInput()
	{
		//IL_0018: 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_0052: Expected I4, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected I4, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if (_inputReleased)
		{
			return;
		}
		_inputReleased = true;
		if (!CatchShow.TakeInput())
		{
			if (Input.GetKey(CancelKey) || Input.GetKey((KeyCode)323) || Input.GetKey(PullKey))
			{
				InputReleaser.Begin((KeyCode)323, (KeyCode)(int)PullKey, (KeyCode)(int)CancelKey);
			}
			else
			{
				GUIManager.BlockInput(false);
			}
		}
	}

	private void Close()
	{
		_ended = true;
		ReleaseInput();
		if ((Object)(object)_active == (Object)(object)this)
		{
			_active = null;
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	private void OnDestroy()
	{
		if (!_ended)
		{
			ReleaseFish(snap: false);
		}
		ReleaseInput();
		if ((Object)(object)_active == (Object)(object)this)
		{
			_active = null;
		}
		NetShow.RingEnd();
		if (_fx != null)
		{
			_fx.Dispose();
			_fx = null;
		}
		if (_view != null)
		{
			_view.Dispose();
			_view = null;
		}
		if ((Object)(object)_canvas != (Object)null)
		{
			Object.Destroy((Object)(object)_canvas);
		}
	}

	private void BuildUI()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_00e0: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d4: 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_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: 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)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bda: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c22: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c4a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c7e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ca6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ce4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0949: Unknown result type (might be due to invalid IL or missing references)
		//IL_0952: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_045d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_068f: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_0514: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0561: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_078d: Unknown result type (might be due to invalid IL or missing references)
		//IL_077b: Unknown result type (might be due to invalid IL or missing references)
		MakeSprites();
		_canvas = new GameObject("Fishy_Canvas");
		_canvas.transform.SetParent(((Component)this).transform, false);
		Canvas obj = _canvas.AddComponent<Canvas>();
		obj.renderMode = (RenderMode)0;
		obj.sortingOrder = 500;
		CanvasScaler obj2 = _canvas.AddComponent<CanvasScaler>();
		obj2.uiScaleMode = (ScaleMode)1;
		obj2.referenceResolution = new Vector2(1920f, 1080f);
		obj2.matchWidthOrHeight = 1f;
		Image val = NewImage("Panel", _canvas.transform, null, new Color(0.07f, 0.06f, 0.05f, 0.85f), PanelSize);
		Style.ApplyPanel(val);
		_panel = ((Graphic)val).rectTransform;
		_panel.anchoredPosition = PanelPos;
		((Transform)_panel).localScale = Vector3.one * PanelScale;
		_root = NewRect("Ring", (Transform)(object)_panel, new Vector2(200f, 200f));
		_root.anchoredPosition = new Vector2(-105f, 0f);
		for (int i = 0; i < _ringCount; i++)
		{
			float num = 200f * ((i == 0) ? 1f : 0.68f);
			_tracks[i] = NewImage("Track" + i, (Transform)(object)_root, _ringSprite, TrackColor, new Vector2(num, num));
			NewImage("Outer" + i, (Transform)(object)_root, _lineSprite, LineColor, new Vector2(num + 6f, num + 6f));
			_rims.Add(NewImage("Inner" + i, (Transform)(object)_root, _rimSprite, LineColor, new Vector2(num * 0.84f + 2f, num * 0.84f + 2f)));
		}
		if (_info.Pattern == Pattern.Pendulum)
		{
			_pendMask = NewArc("PendMask", 208f, new Color(0f, 0f, 0f, 0.88f));
			SetArc(_pendMask, (float)Math.PI, 2.4831855f, new Color(0f, 0f, 0f, 0.88f), 1f);
			SetArc(NewArc("PendLit", 200f, Color.white), 0f, 3.8f, new Color(1f, 0.97f, 0.88f, 0.1f), 1f);
			float num2 = 91.99999f;
			float num3 = 32f;
			float[] array = new float[2] { -1.9f, 1.9f };
			foreach (float num4 in array)
			{
				Image obj3 = NewImage("PendStop", (Transform)(object)_root, null, NeedleColor, new Vector2(4f, num3));
				((Graphic)obj3).rectTransform.anchoredPosition = new Vector2(Mathf.Sin(num4), Mathf.Cos(num4)) * num2;
				((Transform)((Graphic)obj3).rectTransform).localEulerAngles = new Vector3(0f, 0f, (0f - num4) * 57.29578f);
			}
		}
		if (_info.Pattern == Pattern.Lantern)
		{
			_cone = NewImage("Lantern", (Transform)(object)_root, _dotSprite, new Color(0.95f, 0.85f, 0.55f, 0.16f), new Vector2(220f, 220f));
			_cone.type = (Type)3;
			_cone.fillMethod = (FillMethod)4;
			_cone.fillOrigin = 2;
			_cone.fillClockwise = true;
		}
		foreach (Zone zone in _zones)
		{
			float num5 = 200f * ((zone.Ring == 0) ? 1f : 0.68f);
			zone.Arc = NewArc("Zone", num5, zone.Ice ? IceColor : (zone.Hazard ? HazardColor : ZoneColor));
			if (!zone.Hazard && !zone.Ice)
			{
				zone.Mid = NewArc("Gold", num5, GoldColor);
				zone.Tick = NewImage("Tick", (Transform)(object)_root, null, new Color(1f, 0.96f, 0.85f, 0f), new Vector2(3f, num5 * 0.5f * 0.16000003f + 4f));
				zone.Marker = NewImage("Marker", (Transform)(object)_root, _triSprite, GoldColor, new Vector2(18f, 16f));
			}
			if (_info.Pattern == Pattern.Order && zone.Order > 0)
			{
				zone.Label = NewText("No" + zone.Order, (Transform)(object)_root, 22, Vector2.zero, 40f, (TextAnchor)4);
				zone.Label.text = zone.Order.ToString();
				float num6 = num5 * 0.5f + 32f;
				((Graphic)zone.Label).rectTransform.anchoredPosition = new Vector2(Mathf.Sin(zone.A) * num6, Mathf.Cos(zone.A) * num6);
			}
			if (_info.Pattern == Pattern.Hold)
			{
				zone.Fill = NewArc("Fill", num5 * 1.8399999f * 0.5f + 6f, NeedleColor);
			}
		}
		for (int k = 0; k < _ringCount; k++)
		{
			float num7 = 200f * ((k == 0) ? 1f : 0.68f);
			float radius = num7 * 0.5f * 1.8399999f * 0.5f;
			float num8 = num7 * 0.5f * 0.16000003f + 14f;
			RectTransform val2 = NewRect("Needle" + k, (Transform)(object)_root, new Vector2(1f, 1f));
			Bone(val2, radius, num8 + 6f, new Color(0f, 0f, 0f, 0.65f), 2.5f);
			Bone(val2, radius, num8 + 6f, NeedleColor, 0f);
			_needleArm[k] = val2;
		}
		if (Plugin.Fish3D == null || Plugin.Fish3D.Value)
		{
			float size = 200f * ((_ringCount > 1) ? 0.68f : 1f) * 0.84f + 2f;
			WaterStyle? water = null;
			if (Plugin.WaterBackground == null || Plugin.WaterBackground.Value != WaterChoice.Off)
			{
				water = WaterLook.For(((Object)(object)_float != (Object)null) ? ((Component)_float).transform.position : ((Component)_fish).transform.position, _info.Pattern == Pattern.Lantern);
			}
			_view = FishView.Create(_fish, _root, size, _discSprite, water);
		}
		try
		{
			_fx = new PatternFx();
			float[] array2 = new float[_ringCount];
			for (int l = 0; l < _ringCount; l++)
			{
				array2[l] = 200f * ((l == 0) ? 1f : 0.68f);
			}
			float windowSize = 200f * ((_ringCount > 1) ? 0.68f : 1f) * 0.84f + 2f;
			_fx.Build(_info.Pattern, _root, (_view != null) ? _view.Window : null, windowSize, array2, 0.84f, _zones, _dotSprite);
			if (_info.Pattern == Pattern.Lantern && (Object)(object)_fx.Box != (Object)null)
			{
				((Transform)_fx.Box).SetSiblingIndex(_ringCount * 3 + 1);
			}
		}
		catch (Exception ex)
		{
			Plugin.Log("Desen süsleri kurulamadı: " + ex.Message);
			_fx = null;
		}
		Sprite val3 = null;
		try
		{
			if (_view == null && (Object)(object)_item != (Object)null && _item.m_itemData != null)
			{
				val3 = _item.m_itemData.GetIcon();
			}
		}
		catch
		{
		}
		if ((Object)(object)val3 != (Object)null)
		{
			float num9 = ((_ringCount > 1) ? 70f : 96f);
			Image val4 = NewImage("Fish", (Transform)(object)_root, val3, Color.white, new Vector2(num9, num9));
			val4.preserveAspect = true;
			_icon = ((Graphic)val4).rectTransform;
		}
		float num10 = (_gaugeH = PanelSize.y - 70f);
		if (_staminaMode)
		{
			BuildStamina();
		}
		else
		{
			((Graphic)NewImage("GaugeLine", (Transform)(object)_panel, null, LineColor, new Vector2(2f, num10 + 10f))).rectTransform.anchoredPosition = new Vector2(-268f, 0f);
			float num11 = num10 / (float)Mathf.Max(1, _maxLives);
			for (int m = 0; m < _maxLives; m++)
			{
				Image val5 = NewImage("Line" + m, (Transform)(object)_panel, null, ZoneColor, new Vector2(12f, num11 - 6f));
				((Graphic)val5).rectTransform.anchoredPosition = new Vector2(-268f, (0f - num10) / 2f + num11 * ((float)m + 0.5f));
				_lifeDots.Add(val5);
			}
		}
		_title = NewText("Title", (Transform)(object)_panel, 30, new Vector2(165f, 92f), 250f, (TextAnchor)3);
		_title.text = FishName();
		((Graphic)_title).color = Orange;
		_sub = NewText("Pattern", (Transform)(object)_panel, 19, new Vector2(165f, 56f), 250f, (TextAnchor)3);
		_sub.text = L.T("pattern_" + _info.Pattern) + "   " + new string('●', _info.Tier + 1) + new string('○', 2 - _info.Tier);
		((Graphic)_sub).color = new Color(TextColor.r, TextColor.g, TextColor.b, 0.8f);
		_count = NewText("Count", (Transform)(object)_panel, 24, new Vector2(165f, 16f), 250f, (TextAnchor)3);
		Image val6 = NewImage("Button", (Transform)(object)_panel, null, new Color(0.35f, 0.12f, 0.1f, 0.95f), new Vector2(250f, 50f));
		Style.ApplyButton(val6);
		((Graphic)val6).rectTransform.anchoredPosition = new Vector2(165f, -48f);
		_button = NewText("Label", (Transform)(object)((Graphic)val6).rectTransform, 20, Vector2.zero, 250f, (TextAnchor)4);
		_button.text = L.T("pull", KeyName(PullKey));
		_buttonImg = val6;
		_hint = NewText("Hint", (Transform)(object)_panel, 18, new Vector2(165f, -98f), 250f, (TextAnchor)4);
		_hint.text = L.T("let_go", KeyName(CancelKey));
		((Graphic)_hint).color = new Color(TextColor.r, TextColor.g, TextColor.b, 0.65f);
		foreach (Image rim in _rims)
		{
			if ((Object)(object)rim != (Object)null)
			{
				((Component)rim).transform.SetAsLastSibling();
			}
		}
		for (int n = 0; n < _ringCount; n++)
		{
			if ((Object)(object)_needleArm[n] != (Object)null)
			{
				((Transform)_needleArm[n]).SetAsLastSibling();
			}
		}
		foreach (Zone zone2 in _zones)
		{
			if ((Object)(object)zone2.Label != (Object)null)
			{
				((Component)zone2.Label).transform.SetAsLastSibling();
			}
		}
		Draw(0f);
	}

	private string FishName()
	{
		try
		{
			string text = (((Object)(object)_item != (Object)null && _item.m_itemData != null) ? _item.m_itemData.m_shared.m_name : "");
			if (!string.IsNullOrEmpty(text) &&