The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of Safe Beehive Looting v2.1.0
tony4twentys-Safe Beehive Looting.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; 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("Safe Beehive Looting")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Safe Beehive Looting")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("825daf2a-23c0-489c-b237-ebbe84d04038")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("tony4twentys.Safe_Beehive_looting", "Safe Beehive Looting", "2.1.0")] public class SafeBeehiveLooting : BaseUnityPlugin { [HarmonyPatch(typeof(Item), "FinishCastPrimary")] private class FlareUsePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { if (((Object)__instance).name.ToLower().Contains("flare")) { ManualLogSource logger = ((BaseUnityPlugin)instance).Logger; Character trueHolderCharacter = __instance.trueHolderCharacter; logger.LogInfo((object)("[SafeBeehiveLooting] Flare lit by: " + ((trueHolderCharacter != null) ? ((Object)trueHolderCharacter).name : null))); StartFlareCycle(((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(BeeSwarm), "DisperseRPC")] private class BeeSwarmDispersePatch { [HarmonyPrefix] private static bool Prefix(BeeSwarm __instance) { ((MonoBehaviour)__instance).StartCoroutine(CustomDisperseRoutine(__instance)); return false; } } [CompilerGenerated] private sealed class <CheckFlareHeldState>d__12 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GameObject flare; public SafeBeehiveLooting <>4__this; private float <timer>5__1; private HashSet<Transform> <preSmokes>5__2; private IEnumerable<Transform> <newSmokes>5__3; private IEnumerator<Transform> <>s__4; private Transform <smoke>5__5; private Item <item>5__6; private bool <held>5__7; private IEnumerable<Transform> <rescanSmokes>5__8; private IEnumerator<Transform> <>s__9; private Transform <smoke>5__10; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CheckFlareHeldState>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <preSmokes>5__2 = null; <newSmokes>5__3 = null; <>s__4 = null; <smoke>5__5 = null; <item>5__6 = null; <rescanSmokes>5__8 = null; <>s__9 = null; <smoke>5__10 = null; <>1__state = -2; } private bool MoveNext() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <timer>5__1 = 0f; <>4__this.flareHeldLastFrame = false; <preSmokes>5__2 = new HashSet<Transform>(from t in Object.FindObjectsByType<Transform>((FindObjectsSortMode)0) where ((Object)t).name.Contains("VFX_FlareSmoke") select t); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; <newSmokes>5__3 = from t in Object.FindObjectsByType<Transform>((FindObjectsSortMode)0) where ((Object)t).name.Contains("VFX_FlareSmoke") select t; <>s__4 = <newSmokes>5__3.GetEnumerator(); try { while (<>s__4.MoveNext()) { <smoke>5__5 = <>s__4.Current; if (!<preSmokes>5__2.Contains(<smoke>5__5)) { <>4__this.trackedSmokeTransform = <smoke>5__5; break; } <smoke>5__5 = null; } } finally { if (<>s__4 != null) { <>s__4.Dispose(); } } <>s__4 = null; break; case 2: <>1__state = -1; <item>5__6 = null; break; } if (<timer>5__1 < 60f) { <item>5__6 = flare.GetComponent<Item>(); if ((Object)(object)<item>5__6 != (Object)null) { <held>5__7 = (Object)(object)<item>5__6.trueHolderCharacter != (Object)null; if (<held>5__7 != <>4__this.flareHeldLastFrame) { <>4__this.flareHeldLastFrame = <held>5__7; if (!<held>5__7 && !<>4__this.hasRescannedForSmoke) { <>4__this.hasRescannedForSmoke = true; <rescanSmokes>5__8 = from t in Object.FindObjectsByType<Transform>((FindObjectsSortMode)0) where ((Object)t).name.Contains("VFX_FlareSmoke") select t; <>s__9 = <rescanSmokes>5__8.GetEnumerator(); try { while (<>s__9.MoveNext()) { <smoke>5__10 = <>s__9.Current; if (!<preSmokes>5__2.Contains(<smoke>5__10)) { <>4__this.trackedSmokeTransform = <smoke>5__10; break; } <smoke>5__10 = null; } } finally { if (<>s__9 != null) { <>s__9.Dispose(); } } <>s__9 = null; <rescanSmokes>5__8 = null; } } } <timer>5__1 += 1f; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; 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 <CheckNearbyBees>d__13 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public SafeBeehiveLooting <>4__this; private float <timer>5__1; private float <timeInRange>5__2; private Vector3 <smokePosition>5__3; private bool <swarmInRange>5__4; private BeeSwarm[] <>s__5; private int <>s__6; private BeeSwarm <swarm>5__7; private float <dist>5__8; private BeeSwarm[] <>s__9; private int <>s__10; private BeeSwarm <swarm>5__11; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CheckNearbyBees>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__5 = null; <swarm>5__7 = null; <>s__9 = null; <swarm>5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <timer>5__1 = 0f; <timeInRange>5__2 = 0f; break; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } if (<timer>5__1 < 60f) { if ((Object)(object)<>4__this.trackedSmokeTransform == (Object)null) { <timer>5__1 += 1f; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } <smokePosition>5__3 = <>4__this.trackedSmokeTransform.position; <swarmInRange>5__4 = false; <>s__5 = Object.FindObjectsByType<BeeSwarm>((FindObjectsSortMode)0); for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++) { <swarm>5__7 = <>s__5[<>s__6]; <dist>5__8 = Vector3.Distance(((Component)<swarm>5__7).transform.position, <smokePosition>5__3); if (<dist>5__8 < instance.beeCheckRadiusConfig.Value) { <swarmInRange>5__4 = true; break; } <swarm>5__7 = null; } <>s__5 = null; if (<swarmInRange>5__4) { <timeInRange>5__2 += 1f; if (<timeInRange>5__2 >= instance.smokeProximityTimeConfig.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)"[SafeBeehiveLooting] Dispersing bees!"); <>s__9 = Object.FindObjectsByType<BeeSwarm>((FindObjectsSortMode)0); for (<>s__10 = 0; <>s__10 < <>s__9.Length; <>s__10++) { <swarm>5__11 = <>s__9[<>s__10]; if (Vector3.Distance(((Component)<swarm>5__11).transform.position, <smokePosition>5__3) < instance.beeCheckRadiusConfig.Value) { ((MonoBehaviourPun)<swarm>5__11).photonView.RPC("DisperseRPC", (RpcTarget)0, Array.Empty<object>()); } <swarm>5__11 = null; } <>s__9 = null; StopRunningCoroutines(); return false; } } else { <timeInRange>5__2 = 0f; } <timer>5__1 += 1f; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } ((BaseUnityPlugin)instance).Logger.LogInfo((object)"[SafeBeehiveLooting] Bee check coroutine completed"); 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 <CustomDisperseRoutine>d__17 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public BeeSwarm swarm; private float <totalDuration>5__1; private float <expandDuration>5__2; private float <fadeDuration>5__3; private float <elapsed>5__4; private ParticleSystem <ps>5__5; private EmissionModule <emission>5__6; private ShapeModule <shape>5__7; private bool <hasPS>5__8; private float <initialEmissionRate>5__9; private float <initialRadius>5__10; private ParticleSystemForceField <ff>5__11; private bool <hasFF>5__12; private float <initialGravityMin>5__13; private float <initialGravityMax>5__14; private AudioSource <angry>5__15; private AudioSource <idle>5__16; private float <phase2>5__17; private float <t>5__18; private float <min>5__19; private float <max>5__20; private float <t>5__21; private float <min>5__22; private float <max>5__23; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CustomDisperseRoutine>d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) <ps>5__5 = null; <emission>5__6 = default(EmissionModule); <shape>5__7 = default(ShapeModule); <ff>5__11 = null; <angry>5__15 = null; <idle>5__16 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a7: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) MinMaxCurve gravity; switch (<>1__state) { default: return false; case 0: <>1__state = -1; <totalDuration>5__1 = 4f; <expandDuration>5__2 = 0.85f; <fadeDuration>5__3 = 2.5f; <elapsed>5__4 = 0f; if (Object.op_Implicit((Object)(object)swarm.stingerField)) { Object.Destroy((Object)(object)((Component)swarm.stingerField).gameObject); } <ps>5__5 = swarm.beeParticles; <emission>5__6 = default(EmissionModule); <shape>5__7 = default(ShapeModule); <hasPS>5__8 = (Object)(object)<ps>5__5 != (Object)null; <initialEmissionRate>5__9 = 0f; <initialRadius>5__10 = 0f; if (<hasPS>5__8) { <emission>5__6 = <ps>5__5.emission; <shape>5__7 = <ps>5__5.shape; <initialEmissionRate>5__9 = ((EmissionModule)(ref <emission>5__6)).rateOverTimeMultiplier; <initialRadius>5__10 = ((ShapeModule)(ref <shape>5__7)).radius; } <ff>5__11 = swarm.beeForceField; <hasFF>5__12 = (Object)(object)<ff>5__11 != (Object)null; <initialGravityMin>5__13 = 0f; <initialGravityMax>5__14 = 0f; if (<hasFF>5__12) { gravity = <ff>5__11.gravity; <initialGravityMin>5__13 = ((MinMaxCurve)(ref gravity)).constantMin; gravity = <ff>5__11.gravity; <initialGravityMax>5__14 = ((MinMaxCurve)(ref gravity)).constantMax; } <angry>5__15 = swarm.beeAngryLoop; <idle>5__16 = swarm.beeIdleLoop; goto IL_0378; case 1: <>1__state = -1; goto IL_0378; case 2: <>1__state = -1; goto IL_0543; case 3: { <>1__state = -1; break; } IL_0543: if (<phase2>5__17 < <fadeDuration>5__3) { <t>5__21 = Mathf.Clamp01(<phase2>5__17 / <fadeDuration>5__3); if (<hasPS>5__8) { ((ShapeModule)(ref <shape>5__7)).radius = Mathf.Lerp(((ShapeModule)(ref <shape>5__7)).radius, <initialRadius>5__10 + 3.5f, EaseOutCubic(<t>5__21)); ((EmissionModule)(ref <emission>5__6)).rateOverTimeMultiplier = Mathf.Lerp(((EmissionModule)(ref <emission>5__6)).rateOverTimeMultiplier, 0f, <t>5__21); } if (<hasFF>5__12) { gravity = <ff>5__11.gravity; <min>5__22 = Mathf.Lerp(((MinMaxCurve)(ref gravity)).constantMin, 0f, <t>5__21); gravity = <ff>5__11.gravity; <max>5__23 = Mathf.Lerp(((MinMaxCurve)(ref gravity)).constantMax, 0f, <t>5__21); <ff>5__11.gravity = new MinMaxCurve(<min>5__22, <max>5__23); } if (Object.op_Implicit((Object)(object)<angry>5__15)) { <angry>5__15.volume = Mathf.Lerp(<angry>5__15.volume, 0f, Time.deltaTime * 2f); } if (Object.op_Implicit((Object)(object)<idle>5__16)) { <idle>5__16.volume = Mathf.Lerp(<idle>5__16.volume, 0.4f, Time.deltaTime * 2f); } <phase2>5__17 += Time.deltaTime; <>2__current = null; <>1__state = 2; return true; } break; IL_0378: if (<elapsed>5__4 < <expandDuration>5__2) { <t>5__18 = Mathf.Clamp01(<elapsed>5__4 / <expandDuration>5__2); if (<hasPS>5__8) { ((ShapeModule)(ref <shape>5__7)).radius = Mathf.Lerp(<initialRadius>5__10, <initialRadius>5__10 + 2f, EaseOutCubic(<t>5__18)); ((EmissionModule)(ref <emission>5__6)).rateOverTimeMultiplier = Mathf.Lerp(<initialEmissionRate>5__9, <initialEmissionRate>5__9 * 0.8f, <t>5__18); } if (<hasFF>5__12) { <min>5__19 = Mathf.Lerp(<initialGravityMin>5__13, Mathf.Max(<initialGravityMin>5__13 - 0.2f, 0f), <t>5__18); <max>5__20 = Mathf.Lerp(<initialGravityMax>5__14, Mathf.Max(<initialGravityMax>5__14 - 0.2f, 0f), <t>5__18); <ff>5__11.gravity = new MinMaxCurve(<min>5__19, <max>5__20); } if (Object.op_Implicit((Object)(object)<angry>5__15)) { <angry>5__15.volume = Mathf.Lerp(<angry>5__15.volume, 0.3f, Time.deltaTime * 3f); } if (Object.op_Implicit((Object)(object)<idle>5__16)) { <idle>5__16.volume = Mathf.Lerp(<idle>5__16.volume, 0.6f, Time.deltaTime * 2f); } <elapsed>5__4 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } <phase2>5__17 = 0f; goto IL_0543; } if (<elapsed>5__4 + <phase2>5__17 < <totalDuration>5__1) { <elapsed>5__4 += Time.deltaTime; <>2__current = null; <>1__state = 3; return true; } if (((MonoBehaviourPun)swarm).photonView.IsMine) { PhotonNetwork.Destroy(((Component)swarm).gameObject); } 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 SafeBeehiveLooting instance; private Harmony harmony; private Coroutine flareCheckCoroutine; private Coroutine beeCheckCoroutine; private GameObject activeFlare; private Transform trackedSmokeTransform; private bool flareHeldLastFrame = false; private bool hasRescannedForSmoke = false; private ConfigEntry<float> beeCheckRadiusConfig; private ConfigEntry<float> smokeProximityTimeConfig; public void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown instance = this; harmony = new Harmony("tony4twentys.safe_beehive_looting"); harmony.PatchAll(); ((BaseUnityPlugin)instance).Logger.LogInfo((object)"[SafeBeehiveLooting] Loaded"); beeCheckRadiusConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BeeCheckRadius", 12f, "Distance from smoke to bees required to trigger dispersal."); smokeProximityTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SmokeProximityTime", 3f, "Seconds smoke must remain near bees before dispersal."); } public static void StartFlareCycle(GameObject flare) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)"[SafeBeehiveLooting] Starting flare cycle"); StopRunningCoroutines(); instance.activeFlare = flare; instance.hasRescannedForSmoke = false; instance.flareCheckCoroutine = ((MonoBehaviour)instance).StartCoroutine(instance.CheckFlareHeldState(flare)); instance.beeCheckCoroutine = ((MonoBehaviour)instance).StartCoroutine(instance.CheckNearbyBees()); } [IteratorStateMachine(typeof(<CheckFlareHeldState>d__12))] private IEnumerator CheckFlareHeldState(GameObject flare) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CheckFlareHeldState>d__12(0) { <>4__this = this, flare = flare }; } [IteratorStateMachine(typeof(<CheckNearbyBees>d__13))] private IEnumerator CheckNearbyBees() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CheckNearbyBees>d__13(0) { <>4__this = this }; } private static void StopRunningCoroutines() { ((BaseUnityPlugin)instance).Logger.LogInfo((object)"[SafeBeehiveLooting] Stopping all coroutines"); if (instance.flareCheckCoroutine != null) { ((MonoBehaviour)instance).StopCoroutine(instance.flareCheckCoroutine); } if (instance.beeCheckCoroutine != null) { ((MonoBehaviour)instance).StopCoroutine(instance.beeCheckCoroutine); } instance.flareCheckCoroutine = null; instance.beeCheckCoroutine = null; instance.activeFlare = null; instance.trackedSmokeTransform = null; instance.hasRescannedForSmoke = false; } [IteratorStateMachine(typeof(<CustomDisperseRoutine>d__17))] private static IEnumerator CustomDisperseRoutine(BeeSwarm swarm) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CustomDisperseRoutine>d__17(0) { swarm = swarm }; } private static float EaseOutCubic(float x) { x = Mathf.Clamp01(x); return 1f - Mathf.Pow(1f - x, 3f); } }