using System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalBots.AI; using LethalBots.Managers; using LethalBots.Utils.Helpers; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Erskine.LethalBotsCommands; [BepInPlugin("Erskine.LethalBotsCommands", "LethalBotsCommands", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "Erskine.LethalBotsCommands"; public const string NAME = "LethalBotsCommands"; public const string VERSION = "1.1.0"; internal static ManualLogSource Log; private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigEntry val = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Adds the 'report' bot command: look at a bot and say/type 'report' and it tells you the total scrap value on the ship plus your quota progress. Turn off to remove the command."); if (!val.Value) { Log.LogInfo((object)"LethalBotsCommands is disabled in config — not registering commands."); return; } try { Harmony val2 = new Harmony("Erskine.LethalBotsCommands"); MethodInfo methodInfo = AccessTools.Method(typeof(LethalBotManager), "RegisterCustomCommands", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogError((object)"Couldn't find LethalBotManager.RegisterCustomCommands — no commands registered."); return; } HarmonyMethod val3 = new HarmonyMethod(typeof(Plugin).GetMethod("RegisterMyCommands", BindingFlags.Static | BindingFlags.NonPublic)); MethodInfo methodInfo2 = methodInfo; HarmonyMethod val4 = val3; val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"LethalBotsCommands v1.1.0 ready — will register commands when LethalBots initializes."); } catch (Exception ex) { Log.LogError((object)("Setup failed: " + ex)); } } private static void RegisterMyCommands() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown try { ChatCommandsManager.RegisterGlobalCommand(new ChatCommand("report", (Func)ReportHandler)); Log.LogInfo((object)"Registered bot command: 'report'."); } catch (Exception ex) { Log.LogWarning((object)("Failed to register commands: " + ex)); } } private static bool ReportHandler(AIState state, LethalBotAI ai, PlayerControllerB sender, string message, bool isVoice) { try { PlayerControllerB val = default(PlayerControllerB); if (state.IsBotBeingAddressed(sender, ref val, isVoice, false)) { int valueOfAllScrapOnShip = LethalBotManager.GetValueOfAllScrapOnShip(ai, true); TimeOfDay instance = TimeOfDay.Instance; string text = ((!((Object)(object)instance != (Object)null)) ? $"Ship scrap: ${valueOfAllScrapOnShip}." : $"Ship scrap: ${valueOfAllScrapOnShip}. Quota: ${instance.quotaFulfilled}/${instance.profitQuota}."); ai.SendChatMessage(text, false); } } catch (Exception ex) { Log.LogWarning((object)("report handler error: " + ex)); } return true; } }