Decompiled source of RandomEncounters v1.2.4

RandomEncounters\RandomEncounters.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Crest;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RandomEncounters")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("raddude")]
[assembly: AssemblyProduct("RandomEncounters")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("06b0b4cd-89d7-4ff2-8dc9-3eaa535b8d99")]
[assembly: AssemblyFileVersion("1.2.4.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.4.0")]
[module: UnverifiableCode]
namespace RandomEncounters;

internal class SeaLifeMod
{
	[CompilerGenerated]
	private sealed class <InstantiateWhales>d__16 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private GameObject <whalePrefab>5__1;

		private int <i>5__2;

		private GameObject <whale>5__3;

		private Component <ai>5__4;

		private Component <effectController>5__5;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<whalePrefab>5__1 = null;
			<whale>5__3 = null;
			<ai>5__4 = null;
			<effectController>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0154: 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)RE_Plugin.SeaLifeModPluginInstance == (Object)null)
				{
					return false;
				}
				<whalePrefab>5__1 = RE_Plugin.SeaLifeModPluginInstance.GetPrivateField<GameObject>("animalPrefab");
				s_whaleSpawns = new List<GameObject>();
				<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)Refs.shiftingWorld != (Object)null && _allSoundsLoaded));
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<i>5__2 = 0;
				while (<i>5__2 < 5)
				{
					<whale>5__3 = Object.Instantiate<GameObject>(<whalePrefab>5__1, Refs.shiftingWorld);
					<ai>5__4 = <whale>5__3.AddComponent(_finWhaleAIType);
					if (<i>5__2 == 0)
					{
						_whale0Ai = <ai>5__4;
					}
					<effectController>5__5 = <whale>5__3.AddComponent(_effectControllerType);
					<effectController>5__5.SetPrivateField("blowholeSounds", _blowholeSounds);
					<effectController>5__5.SetPrivateField("breachSplashSounds", _breachSplashSounds);
					<effectController>5__5.SetPrivateField("breachEmergeSounds", _breachEmergeSounds);
					<effectController>5__5.SetPrivateField("tailSplashSounds", _tailSplashSounds);
					<whale>5__3.transform.position = Vector3.zero;
					<whale>5__3.gameObject.SetActive(false);
					s_whaleSpawns.Add(<whale>5__3);
					<whale>5__3 = null;
					<ai>5__4 = null;
					<effectController>5__5 = null;
					<i>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 <LoadAudioClipsAsync>d__21 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public string baseName;

		public int count;

		public Action<AudioClip[]> onComplete;

		private AudioClip[] <clips>5__1;

		private int <i>5__2;

		private string <clipName>5__3;

		private AssetBundleRequest <request>5__4;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<clips>5__1 = null;
			<clipName>5__3 = null;
			<request>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				_soundsToLoad += count;
				<clips>5__1 = (AudioClip[])(object)new AudioClip[count];
				<i>5__2 = 0;
				goto IL_010c;
			case 1:
			{
				<>1__state = -1;
				ref AudioClip reference = ref <clips>5__1[<i>5__2];
				Object asset = <request>5__4.asset;
				reference = (AudioClip)(object)((asset is AudioClip) ? asset : null);
				_soundsLoaded++;
				<clipName>5__3 = null;
				<request>5__4 = null;
				<i>5__2++;
				goto IL_010c;
			}
			case 2:
				{
					<>1__state = -1;
					break;
				}
				IL_010c:
				if (<i>5__2 < count)
				{
					<clipName>5__3 = $"{baseName}{<i>5__2 + 1:00}";
					<request>5__4 = _assetBundle.LoadAssetAsync<AudioClip>("Assets/Audio/" + <clipName>5__3 + ".wav");
					<>2__current = <request>5__4;
					<>1__state = 1;
					return true;
				}
				break;
			}
			if (_soundsLoaded < _soundsToLoad)
			{
				<>2__current = null;
				<>1__state = 2;
				return true;
			}
			onComplete(<clips>5__1);
			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 <LoadSoundsAsync>d__20 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

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

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

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

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

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				_soundsToLoad = 0;
				_soundsLoaded = 0;
				_assetBundle = RE_Plugin.SeaLifeModPluginInstance.GetPrivateField<AssetBundle>("seaLifeBundle");
				((MonoBehaviour)RE_Plugin.Instance).StartCoroutine(LoadAudioClipsAsync("WhaleBlowMed", 6, delegate(AudioClip[] clips)
				{
					_blowholeSounds = clips;
				}));
				((MonoBehaviour)RE_Plugin.Instance).StartCoroutine(LoadAudioClipsAsync("BreachSplashLarge", 5, delegate(AudioClip[] clips)
				{
					_breachSplashSounds = clips;
				}));
				((MonoBehaviour)RE_Plugin.Instance).StartCoroutine(LoadAudioClipsAsync("BreachSplashSmall", 6, delegate(AudioClip[] clips)
				{
					_breachEmergeSounds = clips;
				}));
				((MonoBehaviour)RE_Plugin.Instance).StartCoroutine(LoadAudioClipsAsync("TailSplash", 4, delegate(AudioClip[] clips)
				{
					_tailSplashSounds = clips;
				}));
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (_soundsLoaded < _soundsToLoad)
			{
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			_allSoundsLoaded = true;
			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();
		}
	}

	private static List<GameObject> s_whaleSpawns;

	private static Type _finWhaleAIType;

	private static Type _effectControllerType;

	private static FastInvokeHandler _triggerRandomAnimation;

	private static int _activeWhales;

	private static Component _whale0Ai;

	private static AssetBundle _assetBundle;

	private static AudioClip[] _blowholeSounds;

	private static AudioClip[] _breachSplashSounds;

	private static AudioClip[] _breachEmergeSounds;

	private static AudioClip[] _tailSplashSounds;

	private static int _soundsToLoad;

	private static int _soundsLoaded;

	private static bool _allSoundsLoaded;

	private const float MAX_DISTANCE = 650f;

	public static void PatchMod()
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Expected O, but got Unknown
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Expected O, but got Unknown
		((MonoBehaviour)RE_Plugin.SeaLifeModPluginInstance).StopAllCoroutines();
		_finWhaleAIType = AccessTools.TypeByName("FinWhaleAI");
		_effectControllerType = AccessTools.TypeByName("EffectController");
		MethodInfo methodInfo = AccessTools.Method(_finWhaleAIType, "TriggerRandomAnimation", (Type[])null, (Type[])null);
		_triggerRandomAnimation = MethodInvoker.GetHandler(methodInfo, false);
		string[] array = new string[3] { "FindPlayer", "CheckDistanceToPlayer", "SetRandomScale" };
		string[] array2 = array;
		foreach (string text in array2)
		{
			MethodInfo methodInfo2 = AccessTools.Method(_finWhaleAIType, text, (Type[])null, (Type[])null);
			MethodInfo methodInfo3 = AccessTools.Method(typeof(SeaLifeModPatches), "DoNotRun", (Type[])null, (Type[])null);
			RE_Plugin.HarmonyInstance.Patch((MethodBase)methodInfo2, new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		MethodInfo methodInfo4 = AccessTools.Method(_effectControllerType, "LoadSounds", (Type[])null, (Type[])null);
		MethodInfo methodInfo5 = AccessTools.Method(typeof(SeaLifeModPatches), "DoNotRun", (Type[])null, (Type[])null);
		RE_Plugin.HarmonyInstance.Patch((MethodBase)methodInfo4, new HarmonyMethod(methodInfo5), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((MonoBehaviour)RE_Plugin.Instance).StartCoroutine(LoadSoundsAsync());
		((MonoBehaviour)RE_Plugin.Instance).StartCoroutine(InstantiateWhales());
	}

	[IteratorStateMachine(typeof(<InstantiateWhales>d__16))]
	private static IEnumerator InstantiateWhales()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <InstantiateWhales>d__16(0);
	}

	internal static void SpawnWhale(int i, Vector3 spawnPosition)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		RE_Plugin.LogDebug("Spawning FinWhale");
		float num = Random.Range(0.8f, 1.4f);
		int num2 = Random.Range(0, 360);
		GameObject val = s_whaleSpawns[i];
		Transform transform = val.transform;
		transform.position = spawnPosition;
		transform.rotation = Quaternion.Euler(0f, (float)num2, 0f);
		transform.localScale = new Vector3(num, num, num);
		val.SetActive(true);
		_activeWhales++;
	}

	internal static void TriggerEntranceAnimation()
	{
		_triggerRandomAnimation.Invoke((object)_whale0Ai, Array.Empty<object>());
	}

	internal static void CheckWhaleDistance()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (_activeWhales == 0)
		{
			return;
		}
		foreach (GameObject s_whaleSpawn in s_whaleSpawns)
		{
			float num = Vector3.Distance(s_whaleSpawn.transform.position, ((Component)Refs.observerMirror).transform.position);
			if (s_whaleSpawn.activeInHierarchy && num > 650f)
			{
				RE_Plugin.LogDebug("Removing FinWhale");
				s_whaleSpawn.SetActive(false);
				_activeWhales--;
			}
		}
	}

	[IteratorStateMachine(typeof(<LoadSoundsAsync>d__20))]
	private static IEnumerator LoadSoundsAsync()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LoadSoundsAsync>d__20(0);
	}

	[IteratorStateMachine(typeof(<LoadAudioClipsAsync>d__21))]
	private static IEnumerator LoadAudioClipsAsync(string baseName, int count, Action<AudioClip[]> onComplete)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LoadAudioClipsAsync>d__21(0)
		{
			baseName = baseName,
			count = count,
			onComplete = onComplete
		};
	}
}
public class SeaLifeModPatches
{
	[HarmonyPrefix]
	public static bool DoNotRun()
	{
		return false;
	}
}
internal class EncounterGenerator : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <GenerateDenseFog>d__12 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public EncounterGenerator <>4__this;

		private int <i>5__1;

		private Dictionary<AudioSource, float>.KeyCollection.Enumerator <>s__2;

		private AudioSource <audioSource>5__3;

		private int <i>5__4;

		private Vector3 <spawnPoint>5__5;

		private int <i>5__6;

		private Dictionary<AudioSource, float>.KeyCollection.Enumerator <>s__7;

		private AudioSource <audioSource>5__8;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__2 = default(Dictionary<AudioSource, float>.KeyCollection.Enumerator);
			<audioSource>5__3 = null;
			<>s__7 = default(Dictionary<AudioSource, float>.KeyCollection.Enumerator);
			<audioSource>5__8 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Expected O, but got Unknown
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (!Configs.enableDenseFog.Value || DenseFog.IsRunning || WeatherStorms.instance.InvokePrivateMethod<float>("GetNormalizedDistance") < 0.75f)
				{
					return false;
				}
				DenseFog.Spawn();
				<i>5__1 = 0;
				goto IL_017d;
			case 1:
				<>1__state = -1;
				<i>5__1++;
				goto IL_017d;
			case 2:
				<>1__state = -1;
				<i>5__4++;
				goto IL_025e;
			case 3:
				<>1__state = -1;
				DenseFog.ClearFog();
				<i>5__6 = 0;
				break;
			case 4:
				{
					<>1__state = -1;
					<i>5__6++;
					break;
				}
				IL_017d:
				if (<i>5__1 < 4000)
				{
					<>s__2 = DenseFog.WaveAudioSources.Keys.GetEnumerator();
					try
					{
						while (<>s__2.MoveNext())
						{
							<audioSource>5__3 = <>s__2.Current;
							<audioSource>5__3.volume = Mathf.Lerp(DenseFog.WaveAudioSources[<audioSource>5__3], 0f, (float)<i>5__1 / 1000f);
							<audioSource>5__3 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__2).Dispose();
					}
					<>s__2 = default(Dictionary<AudioSource, float>.KeyCollection.Enumerator);
					DenseFog.WindAudioSource.source.volume = Mathf.Lerp(DenseFog.WindAudioSource.origVolume, 0.0001f, (float)<i>5__1 / 1000f);
					<>2__current = (object)new WaitForSeconds(0.001f);
					<>1__state = 1;
					return true;
				}
				<i>5__4 = 0;
				goto IL_025e;
				IL_025e:
				if (<i>5__4 < 4)
				{
					<spawnPoint>5__5 = GameState.currentBoat.position + GameState.currentBoat.right * (200f + Random.Range(20f, 60f) * (float)<i>5__4) + GameState.currentBoat.forward * (float)Random.Range(-200, 200);
					Flotsam.SpawnItem(<spawnPoint>5__5, (Random.Range(1, 100) > 50) ? AssetLoader.SmallWreck : AssetLoader.Hull, 1f, wreckage: true);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				}
				<>2__current = (object)new WaitForSeconds((float)Configs.fogDuration.Value);
				<>1__state = 3;
				return true;
			}
			if (<i>5__6 < 1000)
			{
				<>s__7 = DenseFog.WaveAudioSources.Keys.GetEnumerator();
				try
				{
					while (<>s__7.MoveNext())
					{
						<audioSource>5__8 = <>s__7.Current;
						<audioSource>5__8.volume = Mathf.Lerp(0f, DenseFog.WaveAudioSources[<audioSource>5__8], (float)<i>5__6 / 1000f);
						<audioSource>5__8 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__7).Dispose();
				}
				<>s__7 = default(Dictionary<AudioSource, float>.KeyCollection.Enumerator);
				DenseFog.WindAudioSource.source.volume = Mathf.Lerp(0.0001f, DenseFog.WindAudioSource.origVolume, (float)<i>5__6 / 1000f);
				<>2__current = (object)new WaitForSeconds(0.001f);
				<>1__state = 4;
				return true;
			}
			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 <GenerateFishingBonanza>d__13 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public EncounterGenerator <>4__this;

		private float <stormDistance>5__1;

		private GameObject <seagullsGO>5__2;

		private GameObject <seagulls>5__3;

		private ParticleSystem <seagullsPS>5__4;

		private MainModule <main>5__5;

		private RotationOverLifetimeModule <rol>5__6;

		private VelocityOverLifetimeModule <vol>5__7;

		private RotationBySpeedModule <rbs>5__8;

		private ParticleSystemRenderer <seagullPSR>5__9;

		private ShapeModule <shape>5__10;

		private EmissionModule <emission>5__11;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0052: 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)
			<seagullsGO>5__2 = null;
			<seagulls>5__3 = null;
			<seagullsPS>5__4 = null;
			<main>5__5 = default(MainModule);
			<rol>5__6 = default(RotationOverLifetimeModule);
			<vol>5__7 = default(VelocityOverLifetimeModule);
			<rbs>5__8 = default(RotationBySpeedModule);
			<seagullPSR>5__9 = null;
			<shape>5__10 = default(ShapeModule);
			<emission>5__11 = default(EmissionModule);
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: 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_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: 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_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: 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_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				<stormDistance>5__1 = WeatherStorms.instance.InvokePrivateMethod<float>("GetNormalizedDistance");
				if (!Configs.enableFishingBonanza.Value || (Object)(object)GameState.currentBoat == (Object)null || <stormDistance>5__1 < 0.75f)
				{
					RE_Plugin.LogDebug($"Storm too close for fishing bonanza {<stormDistance>5__1} {<stormDistance>5__1 < 0.75f}");
					return false;
				}
				Transform? obj = ((IEnumerable<Transform>)((Component)Refs.islands[3]).GetComponentsInChildren<Transform>()).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "seagulls"));
				<seagullsGO>5__2 = ((obj != null) ? ((Component)obj).gameObject : null);
				if ((Object)(object)<seagullsGO>5__2 == (Object)null)
				{
					RE_Plugin.LogDebug("No seagulls found");
					return false;
				}
				<seagulls>5__3 = Object.Instantiate<GameObject>(<seagullsGO>5__2, Refs.shiftingWorld);
				if (!<seagulls>5__3.activeInHierarchy)
				{
					<seagulls>5__3.SetActive(true);
				}
				<seagulls>5__3.GetComponent<AudioSource>().PlayOneShot(<seagulls>5__3.GetComponent<AudioSource>().clip);
				<seagullsPS>5__4 = <seagulls>5__3.GetComponent<ParticleSystem>();
				<main>5__5 = <seagullsPS>5__4.main;
				((MainModule)(ref <main>5__5)).maxParticles = 25;
				((MainModule)(ref <main>5__5)).startLifetime = MinMaxCurve.op_Implicit((float)Configs.fishingBonanzaDuration.Value);
				((MainModule)(ref <main>5__5)).startRotation = MinMaxCurve.op_Implicit(0f);
				((MainModule)(ref <main>5__5)).startRotation3D = false;
				<rol>5__6 = <seagullsPS>5__4.rotationOverLifetime;
				((RotationOverLifetimeModule)(ref <rol>5__6)).enabled = false;
				((RotationOverLifetimeModule)(ref <rol>5__6)).x = MinMaxCurve.op_Implicit(0f);
				((RotationOverLifetimeModule)(ref <rol>5__6)).y = MinMaxCurve.op_Implicit(0f);
				((RotationOverLifetimeModule)(ref <rol>5__6)).z = MinMaxCurve.op_Implicit(0f);
				<vol>5__7 = <seagullsPS>5__4.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref <vol>5__7)).enabled = true;
				((VelocityOverLifetimeModule)(ref <vol>5__7)).orbitalX = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref <vol>5__7)).orbitalY = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref <vol>5__7)).orbitalZ = MinMaxCurve.op_Implicit(0f);
				((VelocityOverLifetimeModule)(ref <vol>5__7)).orbitalXMultiplier = 0f;
				((VelocityOverLifetimeModule)(ref <vol>5__7)).orbitalYMultiplier = 0f;
				((VelocityOverLifetimeModule)(ref <vol>5__7)).orbitalZMultiplier = 0f;
				<rbs>5__8 = <seagullsPS>5__4.rotationBySpeed;
				((RotationBySpeedModule)(ref <rbs>5__8)).enabled = false;
				<seagullPSR>5__9 = <seagulls>5__3.GetComponent<ParticleSystemRenderer>();
				<seagullPSR>5__9.alignment = (ParticleSystemRenderSpace)2;
				<shape>5__10 = <seagullsPS>5__4.shape;
				((ShapeModule)(ref <shape>5__10)).shapeType = (ParticleSystemShapeType)18;
				((ShapeModule)(ref <shape>5__10)).scale = new Vector3(25f, 25f, 0.2f);
				<emission>5__11 = <seagullsPS>5__4.emission;
				if (!((EmissionModule)(ref <emission>5__11)).enabled)
				{
					((EmissionModule)(ref <emission>5__11)).enabled = true;
				}
				RE_Plugin.LogDebug("Starting fishing bonanza");
				FishingBonanza.IsBonanzaActive = true;
				<>4__this._moveSeagulls = true;
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveSeagulls(<seagulls>5__3.transform, GameState.currentBoat));
				<>2__current = (object)new WaitForSeconds((float)Configs.fishingBonanzaDuration.Value);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				RE_Plugin.LogDebug("Stopping fishing bonanza");
				FishingBonanza.IsBonanzaActive = false;
				<>4__this._moveSeagulls = false;
				Object.Destroy((Object)(object)<seagulls>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();
		}
	}

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

		private object <>2__current;

		public EncounterGenerator <>4__this;

		private WeatherStorms <weatherStorms>5__1;

		private WanderingStorm <storm>5__2;

		private WanderingStormLightning <lightning>5__3;

		private Region <targetRegion>5__4;

		private float <origInertiaWindScale>5__5;

		private float <origWindSpeedMult>5__6;

		private float <origSmallWavesMult>5__7;

		private float <origLightningInterval>5__8;

		private float <origRainDensity>5__9;

		private float <stormDist>5__10;

		private Vector3 <vector>5__11;

		private float <translateSpeed>5__12;

		private int <i>5__13;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<weatherStorms>5__1 = null;
			<storm>5__2 = null;
			<lightning>5__3 = null;
			<targetRegion>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: 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_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Expected O, but got Unknown
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (!Configs.enableIntenseStorm.Value)
				{
					return false;
				}
				<weatherStorms>5__1 = WeatherStorms.instance;
				<storm>5__2 = <weatherStorms>5__1.GetCurrentStorm();
				<lightning>5__3 = ((Component)((Component)<storm>5__2).transform.GetChild(3)).GetComponent<WanderingStormLightning>();
				<targetRegion>5__4 = RegionBlender.instance.GetPrivateField<Region>("currentTargetRegion");
				<origInertiaWindScale>5__5 = IntenseStorm.oceanUpdaterCrest.inertiaWindScale;
				<origWindSpeedMult>5__6 = IntenseStorm.oceanUpdaterCrest.GetPrivateField<float>("windSpeedMult");
				<origSmallWavesMult>5__7 = IntenseStorm.oceanUpdaterCrest.GetPrivateField<float>("smallWavesMult");
				<origLightningInterval>5__8 = <lightning>5__3.GetPrivateField<float>("lightningInterval");
				<origRainDensity>5__9 = <targetRegion>5__4.stormWeather.particles.rainDensity;
				<lightning>5__3.SetPrivateField("lightningInterval", 5f);
				<targetRegion>5__4.stormWeather.particles.rainDensity = 70f;
				<stormDist>5__10 = Vector3.Distance(((Component)Camera.main).transform.position, ((Component)<storm>5__2).transform.position);
				<vector>5__11 = ((Component)Camera.main).transform.position - ((Component)<storm>5__2).transform.position;
				<vector>5__11.y = 0f;
				RE_Plugin.LogDebug(((Object)<storm>5__2).name + " approaching");
				goto IL_02a6;
			case 1:
				<>1__state = -1;
				<stormDist>5__10 = Vector3.Distance(((Component)Camera.main).transform.position, ((Component)<storm>5__2).transform.position);
				goto IL_02a6;
			case 2:
				{
					<>1__state = -1;
					<i>5__13++;
					break;
				}
				IL_02a6:
				if (<stormDist>5__10 > 1500f)
				{
					<vector>5__11 = ((Component)Camera.main).transform.position - ((Component)<storm>5__2).transform.position;
					<vector>5__11.y = 0f;
					Wind.currentBaseWind = <vector>5__11 * 50f;
					<translateSpeed>5__12 = ((<weatherStorms>5__1.InvokePrivateMethod<float>("GetNormalizedDistance") < <weatherStorms>5__1.GetPrivateField<float>("rainBorder")) ? 0.005f : 0.25f);
					((Component)<storm>5__2).transform.Translate(<vector>5__11 * <translateSpeed>5__12);
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 1;
					return true;
				}
				RE_Plugin.LogDebug(((Object)<storm>5__2).name + " arrived");
				IntenseStorm.oceanUpdaterCrest.inertiaWindScale = 0.22f;
				IntenseStorm.oceanUpdaterCrest.SetPrivateField("windSpeedMult", 5f);
				IntenseStorm.oceanUpdaterCrest.SetPrivateField("smallWavesMult", 0.4f);
				<i>5__13 = 0;
				break;
			}
			if (<i>5__13 < Configs.intenseStormDuration.Value)
			{
				Wind.currentBaseWind = <vector>5__11 * 50f;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 2;
				return true;
			}
			RE_Plugin.LogDebug(((Object)<storm>5__2).name + " dying down");
			<lightning>5__3.SetPrivateField("lightningInterval", <origLightningInterval>5__8);
			Weather.instance.currentRegion.stormWeather.particles.rainDensity = <origRainDensity>5__9;
			IntenseStorm.oceanUpdaterCrest.inertiaWindScale = <origInertiaWindScale>5__5;
			IntenseStorm.oceanUpdaterCrest.SetPrivateField("windSpeedMult", <origWindSpeedMult>5__6);
			IntenseStorm.oceanUpdaterCrest.SetPrivateField("smallWavesMult", <origSmallWavesMult>5__7);
			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 <GenerateWhales>d__11 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public EncounterGenerator <>4__this;

		private Vector3 <boatPosition>5__1;

		private int <i>5__2;

		private Vector3 <randomOffset>5__3;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (!Configs.controlSeaLifeMod.Value || (Object)(object)RE_Plugin.SeaLifeModPluginInstance == (Object)null)
				{
					return false;
				}
				<boatPosition>5__1 = GameState.currentBoat.position;
				<i>5__2 = 0;
				goto IL_00e9;
			case 1:
				<>1__state = -1;
				SeaLifeMod.SpawnWhale(<i>5__2, <boatPosition>5__1 + <randomOffset>5__3);
				<i>5__2++;
				goto IL_00e9;
			case 2:
				{
					<>1__state = -1;
					SeaLifeMod.TriggerEntranceAnimation();
					return false;
				}
				IL_00e9:
				if (<i>5__2 < Random.Range(2, 5))
				{
					<randomOffset>5__3 = new Vector3((float)Random.Range(-200, 200), -8f, (float)Random.Range(-200, 200));
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				}
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 2;
				return true;
			}
		}

		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 <MoveSeagulls>d__14 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Transform seagulls;

		public Transform boat;

		public EncounterGenerator <>4__this;

		private Vector3 <targetPosition>5__1;

		private Vector3 <newRotation>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0030: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (<>4__this._moveSeagulls)
			{
				<targetPosition>5__1 = boat.position + boat.up * 40f;
				seagulls.position = Vector3.Lerp(seagulls.position, <targetPosition>5__1, 0.2f * Time.deltaTime);
				<newRotation>5__2 = seagulls.eulerAngles;
				<newRotation>5__2.y = Mathf.LerpAngle(seagulls.eulerAngles.y, boat.eulerAngles.y - 90f, 0.2f * Time.deltaTime);
				seagulls.rotation = Quaternion.Euler(<newRotation>5__2);
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			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 <ScheduleEncounter>d__8 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public EncounterGenerator <>4__this;

		private int <minTime>5__1;

		private int <range>5__2;

		private int <timeToNextEncounter>5__3;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitUntil((Func<bool>)(() => GameState.playing));
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<minTime>5__1 = Mathf.Abs(Configs.generateEncounterMinTime.Value);
				<range>5__2 = Mathf.Abs(Configs.generateEncounterTimeRange.Value);
				<timeToNextEncounter>5__3 = <minTime>5__1 + Random.Range(0, <range>5__2);
				<>2__current = (object)new WaitForSeconds((float)<timeToNextEncounter>5__3);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				if ((Object)(object)GameState.currentBoat != (Object)null)
				{
					<>4__this.Generate();
				}
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ScheduleEncounter());
				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();
		}
	}

	private bool _moveSeagulls;

	private const float MIN_DISTANCE = 1000f;

	public static EncounterGenerator Instance { get; private set; }

	public void Awake()
	{
		if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Instance = this;
		((MonoBehaviour)this).StartCoroutine(ScheduleEncounter());
	}

	public void Update()
	{
		SeaLifeMod.CheckWhaleDistance();
	}

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

	private void Generate()
	{
		if (!GameState.playing)
		{
			return;
		}
		if (GameState.distanceToLand <= 1000f)
		{
			RE_Plugin.LogDebug($"Too close to land (distance: {GameState.distanceToLand}), skipping encounter generation.");
			return;
		}
		if (GameState.sleeping)
		{
			RE_Plugin.LogDebug("Player sleeping, skipping encounter generation.");
			return;
		}
		int num = 100 + Mathf.Abs(Configs.encounterRollMaxIncrease.Value);
		int num2 = Random.Range(1, num);
		RE_Plugin.LogDebug($"Roll: {num2}");
		int num3 = num2;
		int num4 = num3;
		if (num4 <= 10)
		{
			GenerateFlotsam();
			return;
		}
		int num5 = num4;
		if (num5 > 10 && num5 <= 15)
		{
			GenerateFlotsam();
			((MonoBehaviour)this).StartCoroutine(GenerateWhales());
			return;
		}
		int num6 = num4;
		if (num6 > 15 && num6 <= 40)
		{
			((MonoBehaviour)this).StartCoroutine(GenerateWhales());
			return;
		}
		int num7 = num4;
		if (num7 > 40 && num7 <= 45)
		{
			((MonoBehaviour)this).StartCoroutine(GenerateDenseFog());
			return;
		}
		int num8 = num4;
		if (num8 > 45 && num8 <= 55)
		{
			((MonoBehaviour)this).StartCoroutine(GenerateFishingBonanza());
			return;
		}
		int num9 = num4;
		if (num9 > 55 && num9 <= 60)
		{
			((MonoBehaviour)this).StartCoroutine(GenerateIntenseStorm());
			return;
		}
		int num10 = num4;
		if (num10 > 60)
		{
			RE_Plugin.LogDebug("No encounter this time");
		}
	}

	private static void GenerateFlotsam()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		if (Configs.enableFlotsam.Value)
		{
			Vector3 spawnPoint = GameState.currentBoat.position + GameState.currentBoat.right * 100f + GameState.currentBoat.forward * (float)Random.Range(-30, 30);
			Flotsam.Spawn(spawnPoint);
		}
	}

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

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

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

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

	[IteratorStateMachine(typeof(<GenerateIntenseStorm>d__15))]
	private IEnumerator GenerateIntenseStorm()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <GenerateIntenseStorm>d__15(0)
		{
			<>4__this = this
		};
	}
}
internal class DenseFog
{
	[HarmonyPatch(typeof(OceanColorBlender))]
	private class OceanColorBlenderPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("ApplyPalette")]
		public static void ApplyFogDensity(ref OceanColorPalette palette)
		{
			if (IsRunning)
			{
				_originalFogDensity = ((_originalFogDensity == 0f) ? palette.fogDensity : _originalFogDensity);
				_currentFogDensity = ((_currentFogDensity == 0f) ? palette.fogDensity : _currentFogDensity);
				if (_clearFog && _currentFogDensity > _originalFogDensity)
				{
					_currentFogDensity -= 1E-05f;
				}
				if (!_clearFog && _currentFogDensity < 0.06f)
				{
					_currentFogDensity += 1E-05f;
				}
				palette.fogDensity = _currentFogDensity;
				if (_clearFog && _currentFogDensity <= _originalFogDensity)
				{
					IsRunning = false;
					_currentFogDensity = 0f;
					_originalFogDensity = 0f;
					Traverse.Create((object)GameObject.Find("wind").GetComponent<Wind>()).Field("timer").SetValue((object)0);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Wind))]
	private class WindPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetNewGustTarget")]
		public static bool NoGust(ref Vector3 ___currentGustTarget, Vector3 ___currentWindTarget)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!IsRunning)
			{
				return true;
			}
			___currentGustTarget = ___currentWindTarget;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetNewWindTarget")]
		public static bool LightWind(ref Vector3 ___currentWindTarget)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!IsRunning)
			{
				return true;
			}
			___currentWindTarget = ((Vector3)(ref Wind.currentBaseWind)).normalized * 3f;
			return false;
		}
	}

	[HarmonyPatch(typeof(WaveSound))]
	private class WaveSoundPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("UpdateIntensity")]
		public static bool SetToMinVolume()
		{
			if (!IsRunning)
			{
				return true;
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void GetAudioSource(AudioSource ___audio)
		{
			WaveAudioSources.Add(___audio, ___audio.volume);
		}
	}

	[HarmonyPatch(typeof(WindSound))]
	private class WindSoundPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static bool SetToMinVolume()
		{
			if (!IsRunning)
			{
				return true;
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void GetAudioSource(AudioSource ___audio)
		{
			WindAudioSource = (___audio, ___audio.volume);
		}
	}

	private static bool _clearFog = true;

	private static float _currentFogDensity = 0f;

	private static float _originalFogDensity = 0f;

	private const float MAX_FOG_DENSITY = 0.06f;

	public static bool IsRunning { get; private set; } = false;


	public static Dictionary<AudioSource, float> WaveAudioSources { get; private set; } = new Dictionary<AudioSource, float>();


	public static (AudioSource source, float origVolume) WindAudioSource { get; private set; } = (null, 0f);


	public static void Spawn()
	{
		RE_Plugin.LogDebug("Spawning fog");
		foreach (AudioSource item in WaveAudioSources.Keys.ToList())
		{
			WaveAudioSources[item] = item.volume;
		}
		WindAudioSource = (WindAudioSource.source, WindAudioSource.source.volume);
		_clearFog = false;
		IsRunning = true;
	}

	public static void ClearFog()
	{
		RE_Plugin.LogDebug("Clearing fog");
		_clearFog = true;
	}
}
internal class FishingBonanza
{
	[HarmonyPatch(typeof(FishingRodFish))]
	[HarmonyPatch("Update")]
	private class FishingRodFishPatches
	{
		[HarmonyPostfix]
		public static void IncreaseCatchChance(FishingRodFish __instance, ShipItemFishingRod ___rod, SimpleFloatingObject ___floater, ConfigurableJoint ___bobberJoint, ref float ___fishTimer)
		{
			//IL_0089: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!IsBonanzaActive || (Object)(object)__instance.currentFish != (Object)null || ((ShipItem)___rod).health <= 0f || (!Object.op_Implicit((Object)(object)((PickupableItem)___rod).held) && !RE_Plugin.IdleFishingPluginDetected && !RE_Plugin.HooksHangMorePluginDetected) || !((FloatingObjectBase)___floater).InWater)
			{
				return;
			}
			SoftJointLimit linearLimit = ___bobberJoint.linearLimit;
			if (((SoftJointLimit)(ref linearLimit)).limit <= 1f || ((Component)__instance).gameObject.layer == 16)
			{
				return;
			}
			___fishTimer -= Time.deltaTime;
			float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)___rod).transform.position);
			float num2 = Mathf.InverseLerp(3f, 20f, num) * 2.5f + 0.5f;
			if (___fishTimer <= 0f)
			{
				___fishTimer = 1f;
				float num3 = (Object.op_Implicit((Object)(object)((PickupableItem)___rod).held) ? 20f : 3f);
				if (Random.Range(0f, 100f) < num2 * num3)
				{
					__instance.CatchFish();
				}
			}
		}
	}

	public static bool IsBonanzaActive { get; set; }
}
internal class Flotsam
{
	private static readonly int[] _cargos = new int[36]
	{
		1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
		11, 13, 14, 15, 16, 17, 18, 19, 24, 25,
		26, 27, 201, 202, 206, 212, 213, 214, 216, 219,
		220, 222, 223, 224, 227, 228
	};

	private static readonly int[] _consumables = new int[4] { 104, 108, 131, 132 };

	private static readonly int[] _bottles = new int[5] { 55, 56, 57, 58, 59 };

	private static readonly int[] _tobaccoCrates = new int[4] { 311, 313, 315, 319 };

	private const int MAX_CARGO_TYPES = 4;

	private const int MAX_CARGOS = 3;

	private const int MAX_CONSUME_TYPES = 2;

	internal static void Spawn(Vector3 spawnPoint)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: 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_0232: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < Random.Range(1, 4); i++)
		{
			int num = Random.Range(0, _cargos.Length - 1);
			for (int j = 0; j < Random.Range(1, 3); j++)
			{
				RE_Plugin.LogDebug($"Choice: {_cargos[num]}");
				GameObject val = PrefabsDirectory.instance.directory[_cargos[num]];
				float amount = (float)Math.Round((decimal)Random.Range(0f, val.GetComponent<ShipItem>().amount));
				SpawnItem(spawnPoint, val, amount);
			}
		}
		for (int k = 0; k < Random.Range(1, 2); k++)
		{
			int num2 = Random.Range(0, _consumables.Length - 1);
			RE_Plugin.LogDebug($"Choice: {_consumables[num2]}");
			GameObject val2 = PrefabsDirectory.instance.directory[_consumables[num2]];
			float amount2 = (float)Math.Round((decimal)Random.Range(0f, val2.GetComponent<ShipItem>().amount));
			SpawnItem(spawnPoint, val2, amount2);
		}
		for (int l = 0; l < Random.Range(5, 10); l++)
		{
			int num3 = Random.Range(0, _bottles.Length - 1);
			RE_Plugin.LogDebug($"Choice: {_bottles[num3]}");
			GameObject prefabGO = PrefabsDirectory.instance.directory[_bottles[num3]];
			float amount3 = 0f;
			SpawnItem(spawnPoint, prefabGO, amount3);
		}
		int num4 = Random.Range(0, _tobaccoCrates.Length - 1);
		RE_Plugin.LogDebug($"Choice: {_tobaccoCrates[num4]}");
		GameObject val3 = PrefabsDirectory.instance.directory[_tobaccoCrates[num4]];
		float amount4 = (float)Math.Round((decimal)Random.Range(0f, val3.GetComponent<ShipItem>().amount));
		SpawnItem(spawnPoint, val3, amount4);
		SpawnItem(spawnPoint, AssetLoader.SmallWreck, 1f, wreckage: true);
	}

	internal static void SpawnItem(Vector3 spawnPoint, GameObject prefabGO, float amount, bool wreckage = false)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(prefabGO, spawnPoint, Quaternion.Euler((float)Random.Range(0, 360), (float)Random.Range(0, 360), (float)Random.Range(0, 360)));
		val.GetComponent<ShipItem>().sold = true;
		val.GetComponent<SaveablePrefab>().RegisterToSave();
		if (Object.op_Implicit((Object)(object)val.GetComponent<Good>()))
		{
			val.GetComponent<Good>().RegisterAsMissionless();
		}
		val.GetComponent<ShipItem>().amount = amount;
		val.GetComponent<ShipItem>().health = amount;
		if (wreckage)
		{
			((GoPointerButton)val.GetComponent<ShipItem>()).unclickable = true;
			val.transform.parent = Refs.shiftingWorld;
		}
		RE_Plugin.LogDebug("Prefab " + ((Object)prefabGO).name + " spawned");
	}
}
internal class IntenseStorm
{
	[HarmonyPatch(typeof(OceanUpdaterCrest))]
	private static class OceanUpdaterCrestPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void Awake(OceanUpdaterCrest __instance)
		{
			oceanUpdaterCrest = __instance;
		}
	}

	internal static OceanUpdaterCrest oceanUpdaterCrest;
}
[BepInPlugin("com.raddude82.randomencounters", "RandomEncounters", "1.2.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RE_Plugin : BaseUnityPlugin
{
	public const string PLUGIN_GUID = "com.raddude82.randomencounters";

	public const string PLUGIN_NAME = "RandomEncounters";

	public const string PLUGIN_VERSION = "1.2.4";

	public const string SEALIFEMOD_GUID = "com.yourname.sailwind.sealifeplugin";

	public const string IDLEFISHING_GUID = "ISA_IdleFishing";

	public const string HOOKSHANGMORE_GUID = "com.raddude82.hookshangmore";

	private static ManualLogSource _logger;

	internal static BaseUnityPlugin SeaLifeModPluginInstance { get; private set; }

	internal static bool IdleFishingPluginDetected { get; private set; }

	internal static bool HooksHangMorePluginDetected { get; private set; }

	internal static RE_Plugin Instance { get; private set; }

	internal static Harmony HarmonyInstance { get; private set; }

	public static bool IsFlotsamEnabled => Configs.enableFlotsam.Value;

	public static bool IsSeaLifeModEnabled => (Object)(object)SeaLifeModPluginInstance != (Object)null && Configs.controlSeaLifeMod.Value;

	public static bool IsIntenseStormEnabled => Configs.enableIntenseStorm.Value;

	public static bool IsDenseFogEnabled => Configs.enableDenseFog.Value;

	public static bool IsFishingBonanzaEnabled => Configs.enableFishingBonanza.Value;

	internal static void LogDebug(string message)
	{
		_logger.LogDebug((object)message);
	}

	internal static void LogInfo(string message)
	{
		_logger.LogInfo((object)message);
	}

	internal static void LogWarning(string message)
	{
		_logger.LogWarning((object)message);
	}

	internal static void LogError(string message)
	{
		_logger.LogError((object)message);
	}

	private void Awake()
	{
		if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Instance = this;
		_logger = ((BaseUnityPlugin)this).Logger;
		Configs.InitializeConfigs();
		((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAssetBundle());
		HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude82.randomencounters");
		foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
		{
			BepInPlugin metadata = pluginInfo.Value.Metadata;
			if (Configs.controlSeaLifeMod.Value && metadata.GUID.Equals("com.yourname.sailwind.sealifeplugin"))
			{
				LogInfo("com.yourname.sailwind.sealifeplugin found");
				SeaLifeModPluginInstance = pluginInfo.Value.Instance;
				SeaLifeMod.PatchMod();
			}
			if (metadata.GUID.Equals("ISA_IdleFishing"))
			{
				LogInfo("ISA_IdleFishing found");
				IdleFishingPluginDetected = true;
			}
			if (metadata.GUID.Equals("com.raddude82.hookshangmore"))
			{
				LogInfo("com.raddude82.hookshangmore found");
				HooksHangMorePluginDetected = true;
			}
		}
		((Component)this).gameObject.AddComponent<EncounterGenerator>();
	}
}
internal class AssetLoader
{
	[CompilerGenerated]
	private sealed class <LoadAssetBundle>d__10 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private string <bundlePath>5__1;

		private AssetBundleCreateRequest <assetBundleRequest>5__2;

		private AssetBundle <assetBundle>5__3;

		private AssetBundleRequest <request>5__4;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<bundlePath>5__1 = null;
			<assetBundleRequest>5__2 = null;
			<assetBundle>5__3 = null;
			<request>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				RE_Plugin.LogDebug("Loading bundle");
				<bundlePath>5__1 = FindAssetPath("wreckage_bundle");
				if (string.IsNullOrEmpty(<bundlePath>5__1))
				{
					RE_Plugin.LogError("Asset bundle path not found.");
					return false;
				}
				<assetBundleRequest>5__2 = AssetBundle.LoadFromFileAsync(<bundlePath>5__1);
				<>2__current = <assetBundleRequest>5__2;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<assetBundle>5__3 = <assetBundleRequest>5__2.assetBundle;
				if ((Object)(object)<assetBundle>5__3 == (Object)null)
				{
					RE_Plugin.LogError("Failed to load " + <bundlePath>5__1);
				}
				<request>5__4 = <assetBundle>5__3.LoadAllAssetsAsync();
				<>2__current = <request>5__4;
				<>1__state = 2;
				return true;
			case 2:
			{
				<>1__state = -1;
				Object? obj = ((IEnumerable<Object>)<request>5__4.allAssets).FirstOrDefault((Func<Object, bool>)((Object a) => a.name == "hull"));
				Hull = (GameObject)(object)((obj is GameObject) ? obj : null);
				Object? obj2 = ((IEnumerable<Object>)<request>5__4.allAssets).FirstOrDefault((Func<Object, bool>)((Object a) => a.name == "small_wreck"));
				SmallWreck = (GameObject)(object)((obj2 is GameObject) ? obj2 : null);
				if ((Object)(object)Hull == (Object)null || (Object)(object)SmallWreck == (Object)null)
				{
					RE_Plugin.LogError("Failed to load all assets from the bundle.");
				}
				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();
		}
	}

	private static readonly List<string> assetPaths = new List<string>
	{
		Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)RE_Plugin.Instance).Info.Location), "Assets"),
		Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)RE_Plugin.Instance).Info.Location))
	};

	public static GameObject Hull { get; private set; }

	public static GameObject SmallWreck { get; private set; }

	public static string FindAssetPath(string fileName)
	{
		foreach (string assetPath in assetPaths)
		{
			string text = Path.Combine(assetPath, fileName);
			if (File.Exists(text))
			{
				return text;
			}
		}
		return null;
	}

	[IteratorStateMachine(typeof(<LoadAssetBundle>d__10))]
	internal static IEnumerator LoadAssetBundle()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LoadAssetBundle>d__10(0);
	}
}
internal class Configs
{
	internal static ConfigEntry<int> encounterRollMaxIncrease;

	internal static ConfigEntry<int> generateEncounterMinTime;

	internal static ConfigEntry<int> generateEncounterTimeRange;

	internal static ConfigEntry<bool> enableFlotsam;

	internal static ConfigEntry<bool> controlSeaLifeMod;

	internal static ConfigEntry<bool> enableDenseFog;

	internal static ConfigEntry<int> fogDuration;

	internal static ConfigEntry<bool> enableFishingBonanza;

	internal static ConfigEntry<int> fishingBonanzaDuration;

	internal static ConfigEntry<bool> enableIntenseStorm;

	internal static ConfigEntry<int> intenseStormDuration;

	internal static void InitializeConfigs()
	{
		ConfigFile config = ((BaseUnityPlugin)RE_Plugin.Instance).Config;
		encounterRollMaxIncrease = config.Bind<int>("Settings", "Encounter roll max increase", 0, "Default chance for an encounter to happen is 60/100. Increasing this increases the bottom number, so your chances of an encounter decrease.");
		generateEncounterMinTime = config.Bind<int>("Settings", "Minimum encounter chance time", 900, "Minimum time in seconds to get a chance roll for an encounter, a random amount of time in the configured time range will be added to this.");
		generateEncounterTimeRange = config.Bind<int>("Settings", "Time range for encounter chance", 300, "Time range in seconds after minimum time when an encounter chance will happen.");
		enableFlotsam = config.Bind<bool>("Settings", "Enable flotsam encounters", true, "Enable flotsam encounters.");
		controlSeaLifeMod = config.Bind<bool>("Settings", "Control SeaLifeMod spawns", true, "Use this mod to control SeaLifeMod spawns.");
		enableDenseFog = config.Bind<bool>("Settings", "Enable dense fog encounters", true, "Enable dense fog encounters.");
		fogDuration = config.Bind<int>("Settings", "Fog encounter duration", 300, "In seconds, the amount of time the fog encounter lasts.");
		enableFishingBonanza = config.Bind<bool>("Settings", "Enable fishing bonanza encounters", true, "Enable fishing bonanza encounters.");
		fishingBonanzaDuration = config.Bind<int>("Settings", "Fishing bonanza duration", 300, "In seconds, the amount of time the fishing bonanza encounter lasts.");
		enableIntenseStorm = config.Bind<bool>("Settings", "Enable intense storm encounters", true, "Enable intense storm encounters.");
		intenseStormDuration = config.Bind<int>("Settings", "Intense storm duration", 300, "In seconds, the amount of time the intense storm encounter lasts.");
	}
}
internal static class Extensions
{
	public static T GetPrivateField<T>(this object obj, string field)
	{
		return (T)Traverse.Create(obj).Field(field).GetValue();
	}

	public static void SetPrivateField(this object obj, string field, object value)
	{
		Traverse.Create(obj).Field(field).SetValue(value);
	}

	public static T InvokePrivateMethod<T>(this object obj, string method)
	{
		return Traverse.Create(obj).Method(method, Array.Empty<object>()).GetValue<T>();
	}

	public static T InvokePrivateMethod<T>(this object obj, string method, params object[] parameters)
	{
		return Traverse.Create(obj).Method(method, parameters).GetValue<T>();
	}
}