Decompiled source of FishingGame v1.0.3

Games/FishingGame/FishingGame.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Mirror;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FishingGame")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FishingGame")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6aff4382-d7d6-48eb-8573-8464e0e3b96b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FishingGameMod
{
	[BepInPlugin("com.Syd4r.fishinggame", "Fishing Game", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class FishingGamePlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Fishing Game Assembly loaded by BepInEx! Waiting for Base Loader...");
		}
	}
}
namespace MoreGamesBase
{
	public class FishingGame : GameBase
	{
		private class FishMovementData
		{
			public GameObject fishInstance;

			public float speed;

			public int direction;

			public float leftBound;

			public float rightBound;
		}

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

			private object <>2__current;

			public GameObject fish;

			public FishingGame <>4__this;

			private Vector3 <startScale>5__1;

			private Vector3 <peakScale>5__2;

			private Vector3 <startLocalPos>5__3;

			private Vector3 <targetLocalPos>5__4;

			private float <timeElapsed>5__5;

			private float <duration>5__6;

			private float <progressNormalized>5__7;

			private float <scaleCurve>5__8;

			private float <moveCurve>5__9;

			private Vector3 <currentMovingAnchor>5__10;

			private float <currentShakeIntensity>5__11;

			private Vector3 <randomOffset>5__12;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)fish == (Object)null)
					{
						return false;
					}
					<startScale>5__1 = fish.transform.localScale;
					<peakScale>5__2 = <startScale>5__1 * 2.5f;
					<startLocalPos>5__3 = fish.transform.localPosition;
					<targetLocalPos>5__4 = new Vector3(0f, 0f - <>4__this.currentDepth - 1f, <startLocalPos>5__3.z);
					<timeElapsed>5__5 = 0f;
					<duration>5__6 = 1.4f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<timeElapsed>5__5 < <duration>5__6)
				{
					if ((Object)(object)fish == (Object)null)
					{
						return false;
					}
					<timeElapsed>5__5 += Time.deltaTime;
					<progressNormalized>5__7 = <timeElapsed>5__5 / <duration>5__6;
					<scaleCurve>5__8 = Mathf.Sin(<progressNormalized>5__7 * (float)Math.PI * 0.5f);
					fish.transform.localScale = Vector3.Lerp(<startScale>5__1, <peakScale>5__2, <scaleCurve>5__8);
					<moveCurve>5__9 = Mathf.SmoothStep(0f, 1f, <progressNormalized>5__7);
					<currentMovingAnchor>5__10 = Vector3.Lerp(<startLocalPos>5__3, <targetLocalPos>5__4, <moveCurve>5__9);
					<currentShakeIntensity>5__11 = Mathf.Lerp(0.08f, 0f, <progressNormalized>5__7);
					<randomOffset>5__12 = Vector2.op_Implicit(Random.insideUnitCircle) * <currentShakeIntensity>5__11;
					fish.transform.localPosition = <currentMovingAnchor>5__10 + <randomOffset>5__12;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if ((Object)(object)fish != (Object)null)
				{
					fish.transform.localPosition = <targetLocalPos>5__4;
					fish.transform.localScale = <peakScale>5__2;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public FishingGame <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.ForceVisualReset();
					<>4__this.activeResetCoroutine = null;
					((GameBase)<>4__this).ResetGame();
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public FishingGame <>4__this;

			private int <fishDensityCount>5__1;

			private int <maxFishIndex>5__2;

			private int <i>5__3;

			private float <progress>5__4;

			private float <assignedYHeight>5__5;

			private float <exponent>5__6;

			private float <randomVal>5__7;

			private int <fishTypeIndex>5__8;

			private int <startDir>5__9;

			private float <assignedSpeed>5__10;

			private float <multiplierReward>5__11;

			private string <commandMessage>5__12;

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

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

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

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

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (<>4__this.fishPrefabs == null || <>4__this.fishPrefabs.Length == 0)
				{
					return false;
				}
				<fishDensityCount>5__1 = 20;
				<maxFishIndex>5__2 = Mathf.Min(19, <>4__this.fishPrefabs.Length - 1);
				<i>5__3 = 0;
				while (<i>5__3 < <fishDensityCount>5__1)
				{
					<progress>5__4 = (float)<i>5__3 / (float)(<fishDensityCount>5__1 - 1);
					<assignedYHeight>5__5 = Mathf.Lerp(-2f, -7.3f, <progress>5__4);
					<exponent>5__6 = Mathf.Lerp(4f, 0.2f, <progress>5__4);
					<randomVal>5__7 = Mathf.Pow(Random.value, <exponent>5__6);
					<fishTypeIndex>5__8 = Mathf.RoundToInt(<randomVal>5__7 * (float)<maxFishIndex>5__2);
					<fishTypeIndex>5__8 = Mathf.Clamp(<fishTypeIndex>5__8, 0, <maxFishIndex>5__2);
					<startDir>5__9 = Random.Range(0, 2);
					<assignedSpeed>5__10 = Random.Range(0.3f, 0.7f);
					<multiplierReward>5__11 = <>4__this.GetMultiplierForFishIndex(<fishTypeIndex>5__8);
					<commandMessage>5__12 = string.Format(CultureInfo.InvariantCulture, "{0},{1},{2:F2},{3:F2},{4:F2}", <fishTypeIndex>5__8, <startDir>5__9, <assignedSpeed>5__10, <assignedYHeight>5__5, <multiplierReward>5__11);
					<>4__this.BroadcastSpawnFish(<commandMessage>5__12);
					<commandMessage>5__12 = null;
					<i>5__3++;
				}
				return false;
			}

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

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

		public Transform backgroundParent;

		public GameObject hookPrefab;

		public GameObject[] fishPrefabs;

		private readonly float fallSpeed = 0.5f;

		private readonly float minX = -0.4f;

		private readonly float maxX = 0.4f;

		private readonly float maxDepth = 8f;

		private GameObject hookInstance;

		private List<GameObject> activeFish = new List<GameObject>();

		private List<FishMovementData> activeFishMovement = new List<FishMovementData>();

		private float currentDepth = 0f;

		private float hookX = 0f;

		private Vector3 initialBackgroundPos = Vector3.zero;

		private bool hasCachedPosition = false;

		private float gameStartTime;

		private Coroutine activeResetCoroutine = null;

		private void Start()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			CacheBackgroundPosition();
			if (!((Object)(object)hookPrefab != (Object)null) || !((Object)(object)hookInstance == (Object)null))
			{
				return;
			}
			hookInstance = Object.Instantiate<GameObject>(hookPrefab, hookPrefab.transform);
			hookInstance.transform.localPosition = new Vector3(hookInstance.transform.localPosition.x, hookInstance.transform.localPosition.y, hookInstance.transform.localPosition.z);
			if (((NetworkBehaviour)this).isServer)
			{
				Rigidbody2D val = hookInstance.GetComponent<Rigidbody2D>();
				if ((Object)(object)val == (Object)null)
				{
					val = hookInstance.AddComponent<Rigidbody2D>();
				}
				val.bodyType = (RigidbodyType2D)1;
				HookCollisionRelay hookCollisionRelay = hookInstance.GetComponent<HookCollisionRelay>();
				if ((Object)(object)hookCollisionRelay == (Object)null)
				{
					hookCollisionRelay = hookInstance.AddComponent<HookCollisionRelay>();
				}
				hookCollisionRelay.mainGameController = this;
			}
		}

		private void CacheBackgroundPosition()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)backgroundParent != (Object)null && !hasCachedPosition)
			{
				initialBackgroundPos = backgroundParent.localPosition;
				hasCachedPosition = true;
			}
		}

		public override bool Weaved()
		{
			return true;
		}

		public void BroadcastStartFall(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.FishingGame::UserRpcStartFall(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		public void BroadcastMoveHook(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.FishingGame::UserRpcMoveHook(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		public void BroadcastSpawnFish(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.FishingGame::UserRpcSpawnFish(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		public void BroadcastClearFish(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.FishingGame::UserRpcClearFish(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		public void BroadcastCatchFish(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.FishingGame::UserRpcCatchFish(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		protected override void StartGame()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (activeResetCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(activeResetCoroutine);
				activeResetCoroutine = null;
				ForceVisualReset();
				((GameBase)this).ResetGame();
			}
			((GameBase)this).StartGame();
			CacheBackgroundPosition();
			if (((NetworkBehaviour)this).isServer)
			{
				gameStartTime = Time.time;
				currentDepth = 0f;
				hookX = 0f;
				if ((Object)(object)hookInstance != (Object)null)
				{
					hookInstance.transform.localPosition = new Vector3(0f, -1f, 0f);
				}
				base.isPlaying = true;
				BroadcastClearFish("clear");
				BroadcastMoveHook("0");
				((MonoBehaviour)this).StartCoroutine(SpawnFishWithSpacing());
				BroadcastStartFall("start");
			}
		}

		public void UserRpcStartFall(string networkText)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkClient.active)
			{
				CacheBackgroundPosition();
				currentDepth = 0f;
				hookX = 0f;
				if ((Object)(object)hookInstance != (Object)null)
				{
					hookInstance.transform.localPosition = new Vector3(0f, -1f, 0f);
				}
				base.isPlaying = true;
			}
		}

		private void EndGame(bool won, float multiplier, string triggerReason = "Unknown")
		{
			if (!base.isPlaying)
			{
				return;
			}
			base.isPlaying = false;
			float num = Time.time - gameStartTime;
			if (((NetworkBehaviour)this).isServer)
			{
				if (won && multiplier > 0f)
				{
					((GameBase)this).Payout((double)multiplier, (ChangeType)1, (Dictionary<string, object>)null, -1L);
				}
				activeResetCoroutine = ((MonoBehaviour)this).StartCoroutine(ResetGameRoutine());
			}
		}

		private void ForceVisualReset()
		{
			//IL_0046: 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)
			BroadcastClearFish("clear");
			currentDepth = 0f;
			hookX = 0f;
			if ((Object)(object)backgroundParent != (Object)null && hasCachedPosition)
			{
				backgroundParent.localPosition = initialBackgroundPos;
			}
			if ((Object)(object)hookInstance != (Object)null)
			{
				hookInstance.transform.localPosition = new Vector3(0f, -1f, 0f);
			}
			BroadcastMoveHook("0");
		}

		[IteratorStateMachine(typeof(<ResetGameRoutine>d__29))]
		private IEnumerator ResetGameRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ResetGameRoutine>d__29(0)
			{
				<>4__this = this
			};
		}

		[Server]
		public void MoveLeft(PlayerInteract interact = null)
		{
			//IL_006d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && base.isPlaying)
			{
				hookX = Mathf.Clamp(hookX - 0.2f, minX, maxX);
				if ((Object)(object)hookInstance != (Object)null)
				{
					hookInstance.transform.localPosition = new Vector3(hookX, hookInstance.transform.localPosition.y, hookInstance.transform.localPosition.z);
				}
				BroadcastMoveHook(hookX.ToString(CultureInfo.InvariantCulture));
			}
		}

		[Server]
		public void MoveRight(PlayerInteract interact = null)
		{
			//IL_006d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && base.isPlaying)
			{
				hookX = Mathf.Clamp(hookX + 0.2f, minX, maxX);
				if ((Object)(object)hookInstance != (Object)null)
				{
					hookInstance.transform.localPosition = new Vector3(hookX, hookInstance.transform.localPosition.y, hookInstance.transform.localPosition.z);
				}
				BroadcastMoveHook(hookX.ToString(CultureInfo.InvariantCulture));
			}
		}

		public void UserRpcMoveHook(string networkText)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkClient.active && !((Object)(object)hookInstance == (Object)null) && float.TryParse(networkText, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				hookInstance.transform.localPosition = new Vector3(Mathf.Clamp(result, minX, maxX), hookInstance.transform.localPosition.y, hookInstance.transform.localPosition.z);
			}
		}

		private void Update()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isPlaying)
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			currentDepth += fallSpeed * deltaTime;
			if ((Object)(object)backgroundParent != (Object)null)
			{
				backgroundParent.localPosition = new Vector3(initialBackgroundPos.x, initialBackgroundPos.y + currentDepth, initialBackgroundPos.z);
			}
			for (int num = activeFishMovement.Count - 1; num >= 0; num--)
			{
				FishMovementData fishMovementData = activeFishMovement[num];
				if (!((Object)(object)fishMovementData.fishInstance == (Object)null))
				{
					Vector3 localPosition = fishMovementData.fishInstance.transform.localPosition;
					localPosition.x += fishMovementData.speed * (float)fishMovementData.direction * deltaTime;
					fishMovementData.fishInstance.transform.localPosition = localPosition;
					if (fishMovementData.direction == 1 && localPosition.x >= fishMovementData.rightBound)
					{
						fishMovementData.direction = -1;
						FlipFishVisual(fishMovementData.fishInstance, faceRight: false);
					}
					else if (fishMovementData.direction == -1 && localPosition.x <= fishMovementData.leftBound)
					{
						fishMovementData.direction = 1;
						FlipFishVisual(fishMovementData.fishInstance, faceRight: true);
					}
				}
			}
			if (((NetworkBehaviour)this).isServer && currentDepth >= maxDepth)
			{
				EndGame(won: false, 0f, "Depth Reached Max Limits");
			}
		}

		private void FlipFishVisual(GameObject fishObj, bool faceRight)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			Vector3 localScale = fishObj.transform.localScale;
			localScale.x = (faceRight ? Mathf.Abs(localScale.x) : (0f - Mathf.Abs(localScale.x)));
			fishObj.transform.localScale = localScale;
			TextMeshPro componentInChildren = fishObj.GetComponentInChildren<TextMeshPro>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Vector3 localScale2 = componentInChildren.transform.localScale;
				localScale2.x = Mathf.Abs(localScale2.x) * ((localScale.x < 0f) ? (-1f) : 1f);
				componentInChildren.transform.localScale = localScale2;
			}
		}

		public void HandleFishCollision(GameObject hitObject)
		{
			if (((NetworkBehaviour)this).isServer && base.isPlaying && !((Object)(object)hitObject.GetComponent<TextMeshPro>() != (Object)null))
			{
				float result = 1f;
				string[] array = ((Object)hitObject).name.Split(new char[1] { '_' });
				if (array.Length >= 3 && array[0] == "Fish")
				{
					float.TryParse(array[2], NumberStyles.Any, CultureInfo.InvariantCulture, out result);
				}
				else if (!((Object)hitObject).name.Contains("Fish") && (Object)(object)hitObject.GetComponentInChildren<TextMeshPro>() == (Object)null)
				{
					return;
				}
				BroadcastCatchFish(((Object)hitObject).name);
				EndGame(won: true, result, "Hook collided with " + ((Object)hitObject).name);
			}
		}

		[IteratorStateMachine(typeof(<SpawnFishWithSpacing>d__36))]
		private IEnumerator SpawnFishWithSpacing()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnFishWithSpacing>d__36(0)
			{
				<>4__this = this
			};
		}

		private float GetMultiplierForFishIndex(int index)
		{
			int num = 1;
			if (Random.value < 0.003f)
			{
				num = 10;
			}
			int num2 = index + 1;
			if (num2 >= 1 && num2 <= 5)
			{
				float num3 = (float)(num2 - 1) / 4f;
				return (float)num * Mathf.Lerp(0.1f, 0.25f, num3);
			}
			if (num2 >= 6 && num2 <= 11)
			{
				float num4 = (float)(num2 - 6) / 5f;
				return (float)num * Mathf.Lerp(0.25f, 0.5f, num4);
			}
			if (num2 == 12 || num2 == 13)
			{
				return (float)num * Random.Range(1f, 3f);
			}
			if (num2 == 14 || num2 == 15)
			{
				return (float)num * 1.5f;
			}
			if (num2 == 16 || num2 == 17)
			{
				return (float)num * 3f;
			}
			return num2 switch
			{
				18 => 0f, 
				19 => 0f, 
				20 => (float)num * 10f, 
				_ => (float)num * 1f, 
			};
		}

		public void UserRpcSpawnFish(string networkText)
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active || fishPrefabs == null || fishPrefabs.Length == 0)
			{
				return;
			}
			string[] array = networkText.Split(new char[1] { ',' });
			if (array.Length != 5)
			{
				return;
			}
			int num = int.Parse(array[0]);
			int num2 = int.Parse(array[1]);
			float speed = float.Parse(array[2], CultureInfo.InvariantCulture);
			float num3 = float.Parse(array[3], CultureInfo.InvariantCulture);
			float num4 = float.Parse(array[4], CultureInfo.InvariantCulture);
			if (num < 0 || num >= fishPrefabs.Length)
			{
				return;
			}
			GameObject val = fishPrefabs[num];
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, backgroundParent);
			((Object)val2).name = string.Format(CultureInfo.InvariantCulture, "Fish_{0}_{1:F2}_{2}", num, num4, Guid.NewGuid().ToString().Substring(0, 5));
			Vector3 localScale = backgroundParent.localScale;
			val2.transform.localScale = new Vector3(val.transform.localScale.x / ((localScale.x != 0f) ? localScale.x : 1f), val.transform.localScale.y / ((localScale.y != 0f) ? localScale.y : 1f), val.transform.localScale.z / ((localScale.z != 0f) ? localScale.z : 1f));
			float num5 = -0.6f;
			float num6 = 0.6f;
			float num7 = ((num2 == 0) ? num5 : num6);
			val2.transform.localPosition = new Vector3(num7, num3, 0.1f);
			SpriteRenderer val3 = val2.GetComponent<SpriteRenderer>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val2.GetComponentInChildren<SpriteRenderer>();
			}
			if ((Object)(object)val3 != (Object)null)
			{
				((Renderer)val3).sortingOrder = 10;
			}
			int direction = ((num2 == 0) ? 1 : (-1));
			FlipFishVisual(val2, num2 == 0);
			TextMeshPro componentInChildren = val2.GetComponentInChildren<TextMeshPro>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).text = num4.ToString("0.##", CultureInfo.InvariantCulture) + "x";
				componentInChildren.sortingOrder = 11;
				componentInChildren.transform.localPosition = new Vector3(componentInChildren.transform.localPosition.x, componentInChildren.transform.localPosition.y, -0.05f);
				((TMP_Text)componentInChildren).fontStyle = (FontStyles)1;
				((TMP_Text)componentInChildren).outlineWidth = 0.4f;
				((TMP_Text)componentInChildren).outlineColor = Color32.op_Implicit(Color.black);
				if (num4 < 1f)
				{
					((Graphic)componentInChildren).color = new Color(1f, 0.35f, 0.35f);
				}
				else if (num4 >= 10f)
				{
					((Graphic)componentInChildren).color = new Color(1f, 0.84f, 0f);
				}
				else
				{
					((Graphic)componentInChildren).color = new Color(0.2f, 1f, 0.2f);
				}
			}
			activeFish.Add(val2);
			activeFishMovement.Add(new FishMovementData
			{
				fishInstance = val2,
				speed = speed,
				direction = direction,
				leftBound = num5,
				rightBound = num6
			});
		}

		public void UserRpcCatchFish(string networkText)
		{
			if (NetworkClient.active)
			{
				base.isPlaying = false;
				GameObject val = activeFish.Find((GameObject f) => (Object)(object)f != (Object)null && ((Object)f).name == networkText);
				if ((Object)(object)val != (Object)null)
				{
					((MonoBehaviour)this).StartCoroutine(AnimateCaughtFishSequence(val));
				}
			}
		}

		[IteratorStateMachine(typeof(<AnimateCaughtFishSequence>d__40))]
		private IEnumerator AnimateCaughtFishSequence(GameObject fish)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AnimateCaughtFishSequence>d__40(0)
			{
				<>4__this = this,
				fish = fish
			};
		}

		public void UserRpcClearFish(string networkText)
		{
			if (!NetworkClient.active)
			{
				return;
			}
			foreach (GameObject item in activeFish)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
			activeFish.Clear();
			activeFishMovement.Clear();
		}
	}
	public class HookCollisionRelay : MonoBehaviour
	{
		public FishingGame mainGameController;

		private void OnTriggerEnter2D(Collider2D col)
		{
			if ((Object)(object)mainGameController != (Object)null)
			{
				mainGameController.HandleFishCollision(((Component)col).gameObject);
			}
		}
	}
}