Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FairButler v1.0.0
FairButler.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace FairButler; [BepInPlugin("fairbutler.butlerbees", "FairButler", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "fairbutler.butlerbees"; public const string PluginName = "FairButler"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<float> LeashRadius; internal static ConfigEntry<float> WanderRadius; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; LeashRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LeashRadius", 20f, "Bees stop chasing a player who is farther than this from the dead butler's body."); WanderRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WanderRadius", 6f, "While not chasing, the bees hover randomly within this distance of the body."); try { BeePatches.Apply("fairbutler.butlerbees"); Log.LogInfo((object)"FairButler 1.0.0 loaded."); } catch (Exception ex) { Log.LogError((object)("FairButler failed to patch: " + ex.Message)); } } } public class BeeState { public Vector3 Anchor; public float NextWander; } public static class BeePatches { private static readonly Dictionary<ButlerBeesEnemyAI, BeeState> States = new Dictionary<ButlerBeesEnemyAI, BeeState>(); public static void Apply(string guid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown Harmony val = new Harmony(guid); BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; MethodInfo method = typeof(ButlerBeesEnemyAI).GetMethod("Start", bindingAttr); MethodInfo method2 = typeof(ButlerBeesEnemyAI).GetMethod("DoAIInterval", bindingAttr); if (method == null || method2 == null) { Plugin.Log.LogError((object)"ButlerBeesEnemyAI.Start / DoAIInterval not found; the mod will do nothing."); return; } val.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(BeePatches).GetMethod("StartPost", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)method2, (HarmonyMethod)null, new HarmonyMethod(typeof(BeePatches).GetMethod("AIPost", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void StartPost(ButlerBeesEnemyAI __instance) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) try { List<ButlerBeesEnemyAI> list = new List<ButlerBeesEnemyAI>(); foreach (KeyValuePair<ButlerBeesEnemyAI, BeeState> state in States) { if ((Object)(object)state.Key == (Object)null) { list.Add(state.Key); } } for (int i = 0; i < list.Count; i++) { States.Remove(list[i]); } BeeState beeState = new BeeState(); beeState.Anchor = ((Component)__instance).transform.position; States[__instance] = beeState; } catch (Exception ex) { Plugin.Log.LogWarning((object)("StartPost: " + ex.Message)); } } public static void AIPost(ButlerBeesEnemyAI __instance) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) try { if (((EnemyAI)__instance).isEnemyDead || ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.allPlayersDead) || !States.TryGetValue(__instance, out var value)) { return; } if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && Vector3.Distance(((Component)((EnemyAI)__instance).targetPlayer).transform.position, value.Anchor) > Plugin.LeashRadius.Value) { ((EnemyAI)__instance).targetPlayer = null; ((EnemyAI)__instance).movingTowardsTargetPlayer = false; } if (!((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null)) { if (__instance.searchForPlayers != null && __instance.searchForPlayers.inProgress) { ((EnemyAI)__instance).StopSearch(__instance.searchForPlayers, true); } float value2 = Plugin.WanderRadius.Value; if (Vector3.Distance(((Component)__instance).transform.position, value.Anchor) > value2 * 2f || Time.time >= value.NextWander) { value.NextWander = Time.time + Random.Range(2f, 5f); Vector3 randomNavMeshPositionInRadius = RoundManager.Instance.GetRandomNavMeshPositionInRadius(value.Anchor, value2, RoundManager.Instance.navHit); ((EnemyAI)__instance).SetDestinationToPosition(randomNavMeshPositionInRadius, false); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("AIPost: " + ex.Message)); } } }