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 LethalBotsNames v1.5.0
BepInEx/plugins/ibecoding1-LethalBotsNames/LethalBotsNames.dll
Decompiled 8 hours agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using LethalBots.AI; using LethalBots.Managers; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Erskine.LethalBotsNames; [BepInPlugin("Erskine.LethalBotsNames", "LethalBotsNames", "1.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "Erskine.LethalBotsNames"; public const string NAME = "LethalBotsNames"; public const string VERSION = "1.5.0"; internal static ManualLogSource Log; internal static bool Enabled; private static FieldInfo _billboardField; private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show each bot's identity name ('Mission Control', 'Scavenger', ...) on its floating nametag and in the TAB scoreboard. LethalBots normally leaves these blank. Turn off if you'd rather bots stay nameless.").Value; if (!Enabled) { Log.LogInfo((object)"LethalBotsNames is disabled in config."); return; } GameObject val = new GameObject("LethalBotsNames_Runner"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<NameSync>(); Log.LogInfo((object)"LethalBotsNames v1.5.0 active — syncing bot nametags (light periodic)."); } internal static void ApplyName(LethalBotAI b) { if ((Object)(object)b == (Object)null || b.LethalBotIdentity == null) { return; } string name = b.LethalBotIdentity.Name; if (string.IsNullOrEmpty(name)) { return; } PlayerControllerB val = ((b.NpcController == null) ? null : b.NpcController.Npc); if ((Object)(object)val == (Object)null) { return; } if (val.playerUsername != name) { val.playerUsername = name; } if (_billboardField == null) { _billboardField = typeof(PlayerControllerB).GetField("usernameBillboardText"); } Object val2 = (Object)((!(_billboardField != null)) ? null : /*isinst with value type is only supported in some contexts*/); if (!(val2 != (Object)null)) { return; } PropertyInfo property = ((object)val2).GetType().GetProperty("text"); if (property != null) { string text = property.GetValue(val2) as string; if (string.IsNullOrEmpty(text) || text.IndexOf(name, StringComparison.Ordinal) < 0) { property.SetValue(val2, name); } } } } public class NameSync : MonoBehaviour { private float _next; private void Update() { if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 2f; try { LethalBotManager instance = LethalBotManager.Instance; if ((Object)(object)instance == (Object)null) { return; } LethalBotAI[] lethalBotAIs = instance.GetLethalBotAIs(); if (lethalBotAIs != null) { LethalBotAI[] array = lethalBotAIs; foreach (LethalBotAI b in array) { Plugin.ApplyName(b); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("name sync: " + ex.Message)); } } }