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 Xray v1.1.0
Xray.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Zebai; [BepInPlugin("com.zebai.xray", "Zebai - Xray", "1.2.2")] public class XrayPlugin : BaseUnityPlugin { private const float ScanInterval = 0.5f; internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> ToggleKey; internal static ConfigEntry<Color> BoxColor; internal static ConfigEntry<bool> ShowName; internal static ConfigEntry<bool> ShowDistance; internal static ConfigEntry<float> BoxWidth; internal static ConfigEntry<float> BoxHeight; internal static ConfigEntry<bool> ShowPlayers; internal static ConfigEntry<Color> PlayerColor; internal static ConfigEntry<bool> ShowCheckpoints; internal static ConfigEntry<Color> CheckpointColor; private bool _enabled = true; private Texture2D _whiteTex; private GUIStyle _labelStyle; private readonly List<Enemy> _enemies = new List<Enemy>(); private readonly List<PlayerAvatar> _players = new List<PlayerAvatar>(); private readonly List<ExtractionPoint> _checkpoints = new List<ExtractionPoint>(); private float _nextScan = 0f; private static readonly Dictionary<string, string> NameMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Apex Predator", "顶级掠食者" }, { "Animal", "动物" }, { "Banger", "爆炸骷髅" }, { "Beamer", "光束怪" }, { "Bella", "贝拉" }, { "Birthday Boy", "生日男孩" }, { "Bomb Thrower", "炸弹投掷者" }, { "Bowtie", "领结怪" }, { "Chef", "厨师" }, { "Cleanup Crew", "清洁员" }, { "Clown", "小丑" }, { "Duck", "鸭子" }, { "Elsa", "艾尔莎" }, { "Floater", "漂浮者" }, { "Gambit", "博弈者" }, { "Gnome", "侏儒" }, { "Headgrab", "抓头怪" }, { "Headman", "斩首者" }, { "Heart Hugger", "抱心者" }, { "Hidden", "潜伏者" }, { "Huntsman", "猎人" }, { "Hunter", "猎人" }, { "Loom", "隐现怪" }, { "Mentalist", "精神控制者" }, { "Oogly", "丑怪" }, { "Peeper", "窥视者" }, { "Reaper", "收割者" }, { "Robe", "长袍怪" }, { "Rugrat", "婴儿怪" }, { "Shadow", "暗影" }, { "Shadow Child", "影童" }, { "Spewer", "喷吐者" }, { "Tick", "蜱虫" }, { "Trudge", "重步怪" }, { "Tricycle", "三轮车" }, { "Upscream", "上行尖叫" } }; private void Awake() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("常规", "开关热键", (KeyCode)287, "开关 Xray 的按键"); BoxColor = ((BaseUnityPlugin)this).Config.Bind<Color>("视觉", "敌人方框颜色", new Color(1f, 0.2f, 0.2f, 1f), "敌人方框的颜色"); ShowName = ((BaseUnityPlugin)this).Config.Bind<bool>("视觉", "显示敌人名字", true, "是否显示敌人名称"); ShowDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("视觉", "显示距离", true, "是否显示距离(米)"); BoxWidth = ((BaseUnityPlugin)this).Config.Bind<float>("视觉", "方框宽度", 60f, "方框宽度(像素)"); BoxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("视觉", "方框高度", 90f, "方框高度(像素)"); ShowPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("视觉", "显示其他玩家", true, "是否在其他玩家身上画框"); PlayerColor = ((BaseUnityPlugin)this).Config.Bind<Color>("视觉", "玩家方框颜色", new Color(1f, 0.92f, 0.15f, 1f), "玩家方框颜色(黄色)"); ShowCheckpoints = ((BaseUnityPlugin)this).Config.Bind<bool>("视觉", "显示检查点", true, "是否显示上交物资的检查点"); CheckpointColor = ((BaseUnityPlugin)this).Config.Bind<Color>("视觉", "检查点颜色", new Color(0.2f, 0.55f, 1f, 1f), "检查点标记颜色(蓝色)"); _whiteTex = Texture2D.whiteTexture; _labelStyle = new GUIStyle(); _labelStyle.normal.textColor = Color.white; _labelStyle.fontSize = 12; _labelStyle.alignment = (TextAnchor)1; Log.LogInfo((object)string.Concat("Xray loaded. Press ", ToggleKey.Value, " to toggle.")); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(ToggleKey.Value)) { _enabled = !_enabled; Log.LogInfo((object)("Xray " + (_enabled ? "ON" : "OFF"))); } if (_enabled && Time.time > _nextScan) { ScanEnemies(); _nextScan = Time.time + 0.5f; } } private void ScanEnemies() { _enemies.Clear(); Enemy[] array = Object.FindObjectsOfType<Enemy>(); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && ((Component)array[i]).gameObject.activeInHierarchy) { _enemies.Add(array[i]); } } _players.Clear(); PlayerAvatar[] array2 = Object.FindObjectsOfType<PlayerAvatar>(); for (int i = 0; i < array2.Length; i++) { if ((Object)(object)array2[i] != (Object)null && ((Component)array2[i]).gameObject.activeInHierarchy) { _players.Add(array2[i]); } } _checkpoints.Clear(); ExtractionPoint[] array3 = Object.FindObjectsOfType<ExtractionPoint>(); for (int i = 0; i < array3.Length; i++) { if ((Object)(object)array3[i] != (Object)null && ((Component)array3[i]).gameObject.activeInHierarchy) { _checkpoints.Add(array3[i]); } } } private void OnGUI() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) if (!_enabled) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Transform val = PlayerTransform(); Color color = GUI.color; float num = 2f; Rect val5 = default(Rect); for (int num2 = _enemies.Count - 1; num2 >= 0; num2--) { Enemy val2 = _enemies[num2]; if ((Object)(object)val2 == (Object)null) { _enemies.RemoveAt(num2); } else { Transform val3 = val2.CenterTransform; if ((Object)(object)val3 == (Object)null) { val3 = ((Component)val2).transform; } Vector3 position = val3.position; Vector3 val4 = main.WorldToScreenPoint(position); if (!(val4.z < 0.1f)) { float x = val4.x; float num3 = (float)Screen.height - val4.y; float value = BoxWidth.Value; float value2 = BoxHeight.Value; ((Rect)(ref val5))..ctor(x - value / 2f, num3 - value2 / 2f, value, value2); GUI.color = BoxColor.Value; GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMin, ((Rect)(ref val5)).yMin, value, num), (Texture)(object)_whiteTex); GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMin, ((Rect)(ref val5)).yMax - num, value, num), (Texture)(object)_whiteTex); GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMin, ((Rect)(ref val5)).yMin, num, value2), (Texture)(object)_whiteTex); GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMax - num, ((Rect)(ref val5)).yMin, num, value2), (Texture)(object)_whiteTex); string text = ""; if (ShowName.Value) { text += GetEnemyName(val2); } if (ShowDistance.Value && (Object)(object)val != (Object)null) { float num4 = Vector3.Distance(val.position, position); if (text.Length > 0) { text += " "; } text = text + "(" + num4.ToString("0") + "m)"; } if (text.Length > 0) { GUI.Label(new Rect(((Rect)(ref val5)).xMin - 40f, ((Rect)(ref val5)).yMax + 2f, value + 80f, 20f), text, _labelStyle); } } } } if (ShowPlayers.Value) { for (int num2 = _players.Count - 1; num2 >= 0; num2--) { PlayerAvatar val6 = _players[num2]; if ((Object)(object)val6 == (Object)null) { _players.RemoveAt(num2); } else if (!IsLocalPlayer(val6)) { Transform val7 = val6.playerTransform; if ((Object)(object)val7 == (Object)null) { val7 = ((Component)val6).transform; } Vector3 position = val7.position + new Vector3(0f, 1f, 0f); Vector3 val4 = main.WorldToScreenPoint(position); if (!(val4.z < 0.1f)) { float x = val4.x; float num3 = (float)Screen.height - val4.y; float value = BoxWidth.Value; float value2 = BoxHeight.Value; ((Rect)(ref val5))..ctor(x - value / 2f, num3 - value2 / 2f, value, value2); GUI.color = PlayerColor.Value; GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMin, ((Rect)(ref val5)).yMin, value, num), (Texture)(object)_whiteTex); GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMin, ((Rect)(ref val5)).yMax - num, value, num), (Texture)(object)_whiteTex); GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMin, ((Rect)(ref val5)).yMin, num, value2), (Texture)(object)_whiteTex); GUI.DrawTexture(new Rect(((Rect)(ref val5)).xMax - num, ((Rect)(ref val5)).yMin, num, value2), (Texture)(object)_whiteTex); string text = GetPlayerName(val6); if (ShowDistance.Value && (Object)(object)val != (Object)null) { float num4 = Vector3.Distance(val.position, position); if (text.Length > 0) { text += " "; } text = text + "(" + num4.ToString("0") + "m)"; } if (text.Length > 0) { GUI.Label(new Rect(((Rect)(ref val5)).xMin - 40f, ((Rect)(ref val5)).yMax + 2f, value + 80f, 20f), text, _labelStyle); } } } } } if (ShowCheckpoints.Value) { Rect val10 = default(Rect); for (int num2 = _checkpoints.Count - 1; num2 >= 0; num2--) { ExtractionPoint val8 = _checkpoints[num2]; if ((Object)(object)val8 == (Object)null) { _checkpoints.RemoveAt(num2); } else { Transform val9 = (((Object)(object)val8.platform != (Object)null) ? val8.platform : ((Component)val8).transform); Vector3 position = val9.position + new Vector3(0f, 1f, 0f); Vector3 val4 = main.WorldToScreenPoint(position); if (!(val4.z < 0.1f)) { float x = val4.x; float num3 = (float)Screen.height - val4.y; float num5 = 10f; ((Rect)(ref val10))..ctor(x - num5 / 2f, num3 - num5 / 2f, num5, num5); GUI.color = CheckpointColor.Value; GUI.DrawTexture(val10, (Texture)(object)_whiteTex); string text = "检查点"; if (ShowDistance.Value && (Object)(object)val != (Object)null) { text = text + "(" + Vector3.Distance(val.position, position).ToString("0") + "m)"; } GUI.Label(new Rect(x - 40f, num3 + 8f, 80f, 20f), text, _labelStyle); } } } } GUI.color = color; } private static bool IsLocalPlayer(PlayerAvatar p) { try { FieldInfo field = typeof(PlayerAvatar).GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return false; } return (bool)field.GetValue(p); } catch { return false; } } private static string GetPlayerName(PlayerAvatar p) { try { FieldInfo field = typeof(PlayerAvatar).GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return "Player"; } object value = field.GetValue(p); if (value == null) { return "Player"; } return value.ToString(); } catch { return "Player"; } } private static string GetEnemyName(Enemy e) { try { FieldInfo field = typeof(Enemy).GetField("EnemyParent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return ((Object)((Component)e).gameObject).name; } object value = field.GetValue(e); if (value == null) { return ((Object)((Component)e).gameObject).name; } FieldInfo field2 = value.GetType().GetField("enemyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null) { return ((Object)((Component)e).gameObject).name; } object value2 = field2.GetValue(value); if (value2 == null) { return ((Object)((Component)e).gameObject).name; } string text = value2.ToString(); if (NameMap.TryGetValue(text, out var value3)) { return value3; } return text; } catch { return ((Object)((Component)e).gameObject).name; } } private Transform PlayerTransform() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) try { Type type = Type.GetType("PlayerController, Assembly-CSharp"); if (type == null) { return null; } FieldInfo field = type.GetField("instance", BindingFlags.Static | BindingFlags.Public); if (field == null) { return null; } object value = field.GetValue(null); if (value == null) { return null; } return ((Component)value).transform; } catch { return null; } } }