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 © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("06b0b4cd-89d7-4ff2-8dc9-3eaa535b8d99")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] namespace RandomEncounters; internal class SeaLifeMod { [CompilerGenerated] private sealed class d__16 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private GameObject 5__1; private int 5__2; private GameObject 5__3; private Component 5__4; private Component 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__3 = null; 5__4 = null; 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; } 5__1 = RE_Plugin.SeaLifeModPluginInstance.GetPrivateField("animalPrefab"); s_whaleSpawns = new List(); <>2__current = (object)new WaitUntil((Func)(() => (Object)(object)Refs.shiftingWorld != (Object)null && _allSoundsLoaded)); <>1__state = 1; return true; case 1: <>1__state = -1; 5__2 = 0; while (5__2 < 5) { 5__3 = Object.Instantiate(5__1, Refs.shiftingWorld); 5__4 = 5__3.AddComponent(_finWhaleAIType); if (5__2 == 0) { _whale0Ai = 5__4; } 5__5 = 5__3.AddComponent(_effectControllerType); 5__5.SetPrivateField("blowholeSounds", _blowholeSounds); 5__5.SetPrivateField("breachSplashSounds", _breachSplashSounds); 5__5.SetPrivateField("breachEmergeSounds", _breachEmergeSounds); 5__5.SetPrivateField("tailSplashSounds", _tailSplashSounds); 5__3.transform.position = Vector3.zero; 5__3.gameObject.SetActive(false); s_whaleSpawns.Add(5__3); 5__3 = null; 5__4 = null; 5__5 = null; 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 d__21 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string baseName; public int count; public Action onComplete; private AudioClip[] 5__1; private int 5__2; private string 5__3; private AssetBundleRequest 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; _soundsToLoad += count; 5__1 = (AudioClip[])(object)new AudioClip[count]; 5__2 = 0; goto IL_010c; case 1: { <>1__state = -1; ref AudioClip reference = ref 5__1[5__2]; Object asset = 5__4.asset; reference = (AudioClip)(object)((asset is AudioClip) ? asset : null); _soundsLoaded++; 5__3 = null; 5__4 = null; 5__2++; goto IL_010c; } case 2: { <>1__state = -1; break; } IL_010c: if (5__2 < count) { 5__3 = $"{baseName}{5__2 + 1:00}"; 5__4 = _assetBundle.LoadAssetAsync("Assets/Audio/" + 5__3 + ".wav"); <>2__current = 5__4; <>1__state = 1; return true; } break; } if (_soundsLoaded < _soundsToLoad) { <>2__current = null; <>1__state = 2; return true; } onComplete(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 d__20 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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("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 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(d__16))] private static IEnumerator InstantiateWhales() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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()); } 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(d__20))] private static IEnumerator LoadSoundsAsync() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0); } [IteratorStateMachine(typeof(d__21))] private static IEnumerator LoadAudioClipsAsync(string baseName, int count, Action onComplete) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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 d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EncounterGenerator <>4__this; private List 5__1; private AudioSource 5__2; private float 5__3; private float 5__4; private float 5__5; private List.Enumerator <>s__6; private AudioSource 5__7; private int 5__8; private Vector3 5__9; private float 5__10; private float 5__11; private List.Enumerator <>s__12; private AudioSource 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; <>s__6 = default(List.Enumerator); 5__7 = null; <>s__12 = default(List.Enumerator); 5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: 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("GetNormalizedDistance") < 0.75f) { return false; } DenseFog.Spawn(); 5__1 = DenseFog.WaveAudioSources.Keys.ToList(); 5__2 = DenseFog.WindAudioSource.source; 5__3 = DenseFog.WindAudioSource.origVolume; 5__4 = 0f; goto IL_01b9; case 1: <>1__state = -1; 5__4 += Time.deltaTime; goto IL_01b9; case 2: <>1__state = -1; 5__8++; goto IL_029c; case 3: <>1__state = -1; DenseFog.ClearFog(); 5__10 = 0f; break; case 4: { <>1__state = -1; 5__10 += Time.deltaTime; break; } IL_01b9: if (5__4 < 4f) { 5__5 = 5__4 / 4f; <>s__6 = 5__1.GetEnumerator(); try { while (<>s__6.MoveNext()) { 5__7 = <>s__6.Current; 5__7.volume = Mathf.Lerp(DenseFog.WaveAudioSources[5__7], 0f, 5__5); 5__7 = null; } } finally { ((IDisposable)<>s__6).Dispose(); } <>s__6 = default(List.Enumerator); if ((Object)(object)5__2 != (Object)null) { 5__2.volume = Mathf.Lerp(5__3, 0.0001f, 5__5); } <>2__current = null; <>1__state = 1; return true; } 5__8 = 0; goto IL_029c; IL_029c: if (5__8 < 4) { 5__9 = GameState.currentBoat.position + GameState.currentBoat.right * (200f + Random.Range(20f, 60f) * (float)5__8) + GameState.currentBoat.forward * (float)Random.Range(-200, 200); Flotsam.SpawnItem(5__9, (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 (5__10 < 4f) { 5__11 = 5__10 / 4f; <>s__12 = 5__1.GetEnumerator(); try { while (<>s__12.MoveNext()) { 5__13 = <>s__12.Current; 5__13.volume = Mathf.Lerp(0f, DenseFog.WaveAudioSources[5__13], 5__11); 5__13 = null; } } finally { ((IDisposable)<>s__12).Dispose(); } <>s__12 = default(List.Enumerator); if ((Object)(object)5__2 != (Object)null) { 5__2.volume = Mathf.Lerp(0.0001f, 5__3, 5__11); } <>2__current = null; <>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 d__13 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EncounterGenerator <>4__this; private float 5__1; private GameObject 5__2; private GameObject 5__3; private ParticleSystem 5__4; private MainModule
5__5; private RotationOverLifetimeModule 5__6; private VelocityOverLifetimeModule 5__7; private RotationBySpeedModule 5__8; private ParticleSystemRenderer 5__9; private ShapeModule 5__10; private EmissionModule 5__11; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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) 5__2 = null; 5__3 = null; 5__4 = null;
5__5 = default(MainModule); 5__6 = default(RotationOverLifetimeModule); 5__7 = default(VelocityOverLifetimeModule); 5__8 = default(RotationBySpeedModule); 5__9 = null; 5__10 = default(ShapeModule); 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; 5__1 = WeatherStorms.instance.InvokePrivateMethod("GetNormalizedDistance"); if (!Configs.enableFishingBonanza.Value || (Object)(object)GameState.currentBoat == (Object)null || 5__1 < 0.75f) { RE_Plugin.LogDebug($"Storm too close for fishing bonanza {5__1} {5__1 < 0.75f}"); return false; } Transform? obj = ((IEnumerable)((Component)Refs.islands[3]).GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "seagulls")); 5__2 = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)5__2 == (Object)null) { RE_Plugin.LogDebug("No seagulls found"); return false; } 5__3 = Object.Instantiate(5__2, Refs.shiftingWorld); if (!5__3.activeInHierarchy) { 5__3.SetActive(true); } 5__3.GetComponent().PlayOneShot(5__3.GetComponent().clip); 5__4 = 5__3.GetComponent();
5__5 = 5__4.main; ((MainModule)(ref
5__5)).maxParticles = 25; ((MainModule)(ref
5__5)).startLifetime = MinMaxCurve.op_Implicit((float)Configs.fishingBonanzaDuration.Value); ((MainModule)(ref
5__5)).startRotation = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref
5__5)).startRotation3D = false; 5__6 = 5__4.rotationOverLifetime; ((RotationOverLifetimeModule)(ref 5__6)).enabled = false; ((RotationOverLifetimeModule)(ref 5__6)).x = MinMaxCurve.op_Implicit(0f); ((RotationOverLifetimeModule)(ref 5__6)).y = MinMaxCurve.op_Implicit(0f); ((RotationOverLifetimeModule)(ref 5__6)).z = MinMaxCurve.op_Implicit(0f); 5__7 = 5__4.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref 5__7)).enabled = true; ((VelocityOverLifetimeModule)(ref 5__7)).orbitalX = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref 5__7)).orbitalY = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref 5__7)).orbitalZ = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref 5__7)).orbitalXMultiplier = 0f; ((VelocityOverLifetimeModule)(ref 5__7)).orbitalYMultiplier = 0f; ((VelocityOverLifetimeModule)(ref 5__7)).orbitalZMultiplier = 0f; 5__8 = 5__4.rotationBySpeed; ((RotationBySpeedModule)(ref 5__8)).enabled = false; 5__9 = 5__3.GetComponent(); 5__9.alignment = (ParticleSystemRenderSpace)2; 5__10 = 5__4.shape; ((ShapeModule)(ref 5__10)).shapeType = (ParticleSystemShapeType)18; ((ShapeModule)(ref 5__10)).scale = new Vector3(25f, 25f, 0.2f); 5__11 = 5__4.emission; if (!((EmissionModule)(ref 5__11)).enabled) { ((EmissionModule)(ref 5__11)).enabled = true; } RE_Plugin.LogDebug("Starting fishing bonanza"); FishingBonanza.IsBonanzaActive = true; <>4__this._moveSeagulls = true; ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveSeagulls(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)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 d__15 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EncounterGenerator <>4__this; private WeatherStorms 5__1; private WanderingStorm 5__2; private WanderingStormLightning 5__3; private Region 5__4; private float 5__5; private float 5__6; private float 5__7; private float 5__8; private float 5__9; private float 5__10; private Vector3 5__11; private float 5__12; private int 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 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; } 5__1 = WeatherStorms.instance; 5__2 = 5__1.GetCurrentStorm(); 5__3 = ((Component)((Component)5__2).transform.GetChild(3)).GetComponent(); 5__4 = RegionBlender.instance.GetPrivateField("currentTargetRegion"); 5__5 = IntenseStorm.oceanUpdaterCrest.inertiaWindScale; 5__6 = IntenseStorm.oceanUpdaterCrest.GetPrivateField("windSpeedMult"); 5__7 = IntenseStorm.oceanUpdaterCrest.GetPrivateField("smallWavesMult"); 5__8 = 5__3.GetPrivateField("lightningInterval"); 5__9 = 5__4.stormWeather.particles.rainDensity; 5__3.SetPrivateField("lightningInterval", 5f); 5__4.stormWeather.particles.rainDensity = 70f; 5__10 = Vector3.Distance(((Component)Camera.main).transform.position, ((Component)5__2).transform.position); 5__11 = ((Component)Camera.main).transform.position - ((Component)5__2).transform.position; 5__11.y = 0f; RE_Plugin.LogDebug(((Object)5__2).name + " approaching"); goto IL_02a6; case 1: <>1__state = -1; 5__10 = Vector3.Distance(((Component)Camera.main).transform.position, ((Component)5__2).transform.position); goto IL_02a6; case 2: { <>1__state = -1; 5__13++; break; } IL_02a6: if (5__10 > 1500f) { 5__11 = ((Component)Camera.main).transform.position - ((Component)5__2).transform.position; 5__11.y = 0f; Wind.currentBaseWind = 5__11 * 50f; 5__12 = ((5__1.InvokePrivateMethod("GetNormalizedDistance") < 5__1.GetPrivateField("rainBorder")) ? 0.005f : 0.25f); ((Component)5__2).transform.Translate(5__11 * 5__12); <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 1; return true; } RE_Plugin.LogDebug(((Object)5__2).name + " arrived"); IntenseStorm.oceanUpdaterCrest.inertiaWindScale = 0.22f; IntenseStorm.oceanUpdaterCrest.SetPrivateField("windSpeedMult", 5f); IntenseStorm.oceanUpdaterCrest.SetPrivateField("smallWavesMult", 0.4f); 5__13 = 0; break; } if (5__13 < Configs.intenseStormDuration.Value) { Wind.currentBaseWind = 5__11 * 50f; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } RE_Plugin.LogDebug(((Object)5__2).name + " dying down"); 5__3.SetPrivateField("lightningInterval", 5__8); Weather.instance.currentRegion.stormWeather.particles.rainDensity = 5__9; IntenseStorm.oceanUpdaterCrest.inertiaWindScale = 5__5; IntenseStorm.oceanUpdaterCrest.SetPrivateField("windSpeedMult", 5__6); IntenseStorm.oceanUpdaterCrest.SetPrivateField("smallWavesMult", 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 d__11 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EncounterGenerator <>4__this; private Vector3 5__1; private int 5__2; private WaitForSeconds 5__3; private int 5__4; private Vector3 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00b3: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!Configs.controlSeaLifeMod.Value || (Object)(object)RE_Plugin.SeaLifeModPluginInstance == (Object)null) { return false; } 5__1 = GameState.currentBoat.position; 5__2 = Random.Range(2, 5); 5__3 = new WaitForSeconds(2f); 5__4 = 0; goto IL_0102; case 1: <>1__state = -1; SeaLifeMod.SpawnWhale(5__4, 5__1 + 5__5); 5__4++; goto IL_0102; case 2: { <>1__state = -1; SeaLifeMod.TriggerEntranceAnimation(); return false; } IL_0102: if (5__4 < 5__2) { 5__5 = new Vector3((float)Random.Range(-200, 200), -8f, (float)Random.Range(-200, 200)); <>2__current = 5__3; <>1__state = 1; return true; } <>2__current = 5__3; <>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 d__14 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Transform seagulls; public Transform boat; public EncounterGenerator <>4__this; private Vector3 5__1; private Vector3 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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) { 5__1 = boat.position + boat.up * 40f; seagulls.position = Vector3.Lerp(seagulls.position, 5__1, 0.2f * Time.deltaTime); 5__2 = seagulls.eulerAngles; 5__2.y = Mathf.LerpAngle(seagulls.eulerAngles.y, boat.eulerAngles.y - 90f, 0.2f * Time.deltaTime); seagulls.rotation = Quaternion.Euler(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 d__8 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EncounterGenerator <>4__this; private int 5__1; private int 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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)(() => GameState.playing)); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = Mathf.Abs(Configs.generateEncounterMinTime.Value); 5__2 = Mathf.Abs(Configs.generateEncounterTimeRange.Value); 5__3 = 5__1 + Random.Range(0, 5__2); <>2__current = (object)new WaitForSeconds((float)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(d__8))] private IEnumerator ScheduleEncounter() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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 * 200f + GameState.currentBoat.forward * (float)Random.Range(-30, 30); Flotsam.Spawn(spawnPoint); } } [IteratorStateMachine(typeof(d__11))] private IEnumerator GenerateWhales() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__12))] private IEnumerator GenerateDenseFog() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__13))] private IEnumerator GenerateFishingBonanza() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__13(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__14))] private IEnumerator MoveSeagulls(Transform seagulls, Transform boat) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { <>4__this = this, seagulls = seagulls, boat = boat }; } [IteratorStateMachine(typeof(d__15))] private IEnumerator GenerateIntenseStorm() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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()).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) { if (!WaveAudioSources.ContainsKey(___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 WaveAudioSources { get; private set; } = new Dictionary(); 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; } if ((Object)(object)WindAudioSource.source != (Object)null) { 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 { [CompilerGenerated] private sealed class d__10 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CrateInventory crateInventory; public ShipItem item; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; item.sold = true; crateInventory.InsertItem(item); 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 d__9 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ShipItemCrate crate; private CrateInventory 5__1; private int 5__2; private int 5__3; private GameObject 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 2; return true; case 2: <>1__state = -1; 5__1 = ((Component)crate).GetComponent(); 5__2 = (int)((ShipItem)crate).amount; 5__3 = 0; while (5__3 < 5__2) { RE_Plugin.LogDebug("Inserting item " + ((ShipItem)crate).amount); 5__4 = Object.Instantiate(crate.GetContainedPrefab(), ((Component)crate).transform.position + new Vector3(0f, 100.5f, 0f), ((Component)crate).transform.rotation); ShipItemCrate obj = crate; ((ShipItem)obj).amount = ((ShipItem)obj).amount - 1f; 5__4.GetComponent().RegisterToSave(); if (Object.op_Implicit((Object)(object)5__4.GetComponent())) { if (crate.smokedFood) { 5__4.GetComponent().smoked = 1f; 5__4.GetComponent().amount = 1.01f; } 5__4.GetComponent().dried = 1f; 5__4.GetComponent().UpdateMaterial(); } ((MonoBehaviour)EncounterGenerator.Instance).StartCoroutine(InsertItem(5__1, 5__4.GetComponent())); 5__4 = null; 5__3++; } ((ShipItem)crate).UpdateLookText(); ((ShipItem)crate).itemRigidbodyC.UpdateMass(); RE_Plugin.LogDebug("Unsealed crate."); 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 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().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().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().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(prefabGO, spawnPoint, Quaternion.Euler((float)Random.Range(0, 360), (float)Random.Range(0, 360), (float)Random.Range(0, 360))); ShipItem component = val.GetComponent(); component.sold = true; component.amount = amount; component.health = amount; val.GetComponent().RegisterToSave(); Good component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.RegisterAsMissionless(); } ShipItemCrate val2 = (ShipItemCrate)(object)((component is ShipItemCrate) ? component : null); if (val2 != null) { ((MonoBehaviour)EncounterGenerator.Instance).StartCoroutine(UnsealCrate(val2)); } if (wreckage) { ((GoPointerButton)val.GetComponent()).unclickable = true; val.transform.parent = Refs.shiftingWorld; } RE_Plugin.LogDebug("Prefab " + ((Object)prefabGO).name + " spawned"); } [IteratorStateMachine(typeof(d__9))] internal static IEnumerator UnsealCrate(ShipItemCrate crate) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { crate = crate }; } [IteratorStateMachine(typeof(d__10))] private static IEnumerator InsertItem(CrateInventory crateInventory, ShipItem item) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { crateInventory = crateInventory, item = item }; } } 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.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [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.3.0"; 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 pluginInfo in Chainloader.PluginInfos) { BepInPlugin metadata = pluginInfo.Value.Metadata; if (Configs.controlSeaLifeMod.Value && metadata.GUID.Equals("com.yourname.sailwind.sealifeplugin")) { LogInfo("SealLifeMod mod found"); SeaLifeModPluginInstance = pluginInfo.Value.Instance; SeaLifeMod.PatchMod(); } if (metadata.GUID.Equals("ISA_IdleFishing")) { LogInfo("IdleFishing mod found"); IdleFishingPluginDetected = true; } if (metadata.GUID.Equals("com.raddude82.hookshangmore")) { LogInfo("HooksHangMore mod found"); HooksHangMorePluginDetected = true; } } ((Component)this).gameObject.AddComponent(); } } internal class AssetLoader { [CompilerGenerated] private sealed class d__10 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private string 5__1; private AssetBundleCreateRequest 5__2; private AssetBundle 5__3; private AssetBundleRequest 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 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"); 5__1 = FindAssetPath("wreckage_bundle"); if (string.IsNullOrEmpty(5__1)) { RE_Plugin.LogError("Asset bundle path not found"); return false; } 5__2 = AssetBundle.LoadFromFileAsync(5__1); <>2__current = 5__2; <>1__state = 1; return true; case 1: <>1__state = -1; 5__3 = 5__2.assetBundle; if ((Object)(object)5__3 == (Object)null) { RE_Plugin.LogError("Failed to load " + 5__1); } 5__4 = 5__3.LoadAllAssetsAsync(); <>2__current = 5__4; <>1__state = 2; return true; case 2: { <>1__state = -1; Object? obj = ((IEnumerable)5__4.allAssets).FirstOrDefault((Func)((Object a) => a.name == "hull")); Hull = (GameObject)(object)((obj is GameObject) ? obj : null); Object? obj2 = ((IEnumerable)5__4.allAssets).FirstOrDefault((Func)((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; } RE_Plugin.LogInfo("Assets loaded"); 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 assetPaths = new List { 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(d__10))] internal static IEnumerator LoadAssetBundle() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0); } } internal class Configs { internal static ConfigEntry encounterRollMaxIncrease; internal static ConfigEntry generateEncounterMinTime; internal static ConfigEntry generateEncounterTimeRange; internal static ConfigEntry enableFlotsam; internal static ConfigEntry controlSeaLifeMod; internal static ConfigEntry enableDenseFog; internal static ConfigEntry fogDuration; internal static ConfigEntry enableFishingBonanza; internal static ConfigEntry fishingBonanzaDuration; internal static ConfigEntry enableIntenseStorm; internal static ConfigEntry intenseStormDuration; internal static void InitializeConfigs() { ConfigFile config = ((BaseUnityPlugin)RE_Plugin.Instance).Config; encounterRollMaxIncrease = config.Bind("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("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("Settings", "Time range for encounter chance", 300, "Time range in seconds after minimum time when an encounter chance will happen."); enableFlotsam = config.Bind("Settings", "Enable flotsam encounters", true, "Enable flotsam encounters."); controlSeaLifeMod = config.Bind("Settings", "Control SeaLifeMod spawns", true, "Use this mod to control SeaLifeMod spawns."); enableDenseFog = config.Bind("Settings", "Enable dense fog encounters", true, "Enable dense fog encounters."); fogDuration = config.Bind("Settings", "Fog encounter duration", 300, "In seconds, the amount of time the fog encounter lasts."); enableFishingBonanza = config.Bind("Settings", "Enable fishing bonanza encounters", true, "Enable fishing bonanza encounters."); fishingBonanzaDuration = config.Bind("Settings", "Fishing bonanza duration", 300, "In seconds, the amount of time the fishing bonanza encounter lasts."); enableIntenseStorm = config.Bind("Settings", "Enable intense storm encounters", true, "Enable intense storm encounters."); intenseStormDuration = config.Bind("Settings", "Intense storm duration", 300, "In seconds, the amount of time the intense storm encounter lasts."); } } internal static class Extensions { public static T GetPrivateField(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(this object obj, string method) { return Traverse.Create(obj).Method(method, Array.Empty()).GetValue(); } public static T InvokePrivateMethod(this object obj, string method, params object[] parameters) { return Traverse.Create(obj).Method(method, parameters).GetValue(); } }