Decompiled source of Aimbot v1.0.0

plugins/Aimbot/Aimbot.dll

Decompiled 2 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Logging;
using Dungeonator;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Aimbot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a745c7ed13a185e906c5e7dc97e3e9634c73fb99")]
[assembly: AssemblyProduct("Aimbot")]
[assembly: AssemblyTitle("Aimbot")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Aimbot;

[BepInPlugin("com.aimbot.etg", "Aimbot", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string PLUGIN_GUID = "com.aimbot.etg";

	public const string PLUGIN_NAME = "Aimbot";

	public const string PLUGIN_VERSION = "1.0.0";

	internal static ManualLogSource Log;

	private bool _aimbotEnabled = true;

	private bool _espEnabled;

	private string _statusMessage = "";

	private float _statusTimer;

	private const float STATUS_DISPLAY_TIME = 2f;

	private Texture2D _boxTexture;

	[DllImport("user32.dll")]
	private static extern bool SetCursorPos(int X, int Y);

	private void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"Aimbot v1.0.0 已加载!");
		_boxTexture = new Texture2D(1, 1);
		_boxTexture.SetPixel(0, 0, Color.white);
		_boxTexture.Apply();
	}

	private void Update()
	{
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)284))
		{
			_aimbotEnabled = !_aimbotEnabled;
			ShowStatus(_aimbotEnabled ? "自瞄: 开启" : "自瞄: 关闭");
			Log.LogInfo((object)(_aimbotEnabled ? "自瞄已开启" : "自瞄已关闭"));
		}
		if (Input.GetKeyDown((KeyCode)285))
		{
			_espEnabled = !_espEnabled;
			ShowStatus(_espEnabled ? "碰撞箱: 显示" : "碰撞箱: 隐藏");
			Log.LogInfo((object)(_espEnabled ? "碰撞箱显示已开启" : "碰撞箱显示已关闭"));
		}
		if (_aimbotEnabled && Application.isFocused && !GameManager.Instance.IsPaused)
		{
			AIActor closestEnemyToPlayer = GetClosestEnemyToPlayer();
			if ((Object)(object)closestEnemyToPlayer != (Object)null)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(((GameActor)closestEnemyToPlayer).CenterPosition.x, ((GameActor)closestEnemyToPlayer).CenterPosition.y, 0f);
				Vector3 val2 = Camera.main.WorldToScreenPoint(val);
				if (val2.z > 0f)
				{
					SetCursorPos((int)val2.x, Screen.height - (int)val2.y);
				}
			}
		}
		if (_statusTimer > 0f)
		{
			_statusTimer -= Time.deltaTime;
		}
	}

	private void OnGUI()
	{
		if (_statusTimer > 0f)
		{
			DrawStatusMessage();
		}
		if (_espEnabled)
		{
			DrawEnemyHitboxes();
		}
	}

	private AIActor GetClosestEnemyToPlayer()
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		List<AIActor> allEnemies = GetAllEnemies();
		if (allEnemies == null)
		{
			return null;
		}
		PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
		if ((Object)(object)primaryPlayer == (Object)null)
		{
			return null;
		}
		AIActor result = null;
		float num = float.MaxValue;
		foreach (AIActor item in allEnemies)
		{
			if (!((Object)(object)item == (Object)null) && !((Object)(object)((BraveBehaviour)item).healthHaver == (Object)null) && !((BraveBehaviour)item).healthHaver.IsDead)
			{
				float num2 = Vector2.Distance(((GameActor)item).CenterPosition, ((GameActor)primaryPlayer).CenterPosition);
				if (num2 < num)
				{
					num = num2;
					result = item;
				}
			}
		}
		return result;
	}

	private void DrawEnemyHitboxes()
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		List<AIActor> allEnemies = GetAllEnemies();
		if (allEnemies == null)
		{
			return;
		}
		foreach (AIActor item in allEnemies)
		{
			if ((Object)(object)item == (Object)null || (Object)(object)((BraveBehaviour)item).healthHaver == (Object)null || ((BraveBehaviour)item).healthHaver.IsDead)
			{
				continue;
			}
			SpeculativeRigidbody specRigidbody = ((BraveBehaviour)item).specRigidbody;
			if ((Object)(object)specRigidbody == (Object)null)
			{
				continue;
			}
			List<PixelCollider> pixelColliders = specRigidbody.PixelColliders;
			if (pixelColliders == null)
			{
				continue;
			}
			foreach (PixelCollider item2 in pixelColliders)
			{
				if (item2 == null)
				{
					continue;
				}
				float num = 16f;
				Vector2 val = new Vector2((float)item2.Min.x, (float)item2.Min.y) / num;
				Vector2 val2 = new Vector2((float)item2.Max.x, (float)item2.Max.y) / num;
				Vector3 val3 = Camera.main.WorldToScreenPoint(new Vector3(val.x, val.y, 0f));
				Vector3 val4 = Camera.main.WorldToScreenPoint(new Vector3(val2.x, val2.y, 0f));
				if (!(val3.z < 0f) && !(val4.z < 0f))
				{
					float num2 = (float)Screen.height - val4.y;
					float num3 = (float)Screen.height - val3.y;
					float x = val3.x;
					float num4 = val4.x - x;
					float num5 = num3 - num2;
					if (!(num4 < 1f) && !(num5 < 1f))
					{
						Color color = new Color(0f, 1f, 0f, 0.8f);
						float num6 = 2f;
						GUI.color = color;
						GUI.DrawTexture(new Rect(x, num2, num4, num6), (Texture)(object)_boxTexture);
						GUI.DrawTexture(new Rect(x, num2 + num5 - num6, num4, num6), (Texture)(object)_boxTexture);
						GUI.DrawTexture(new Rect(x, num2, num6, num5), (Texture)(object)_boxTexture);
						GUI.DrawTexture(new Rect(x + num4 - num6, num2, num6, num5), (Texture)(object)_boxTexture);
						GUI.color = Color.white;
					}
				}
			}
		}
	}

	private List<AIActor> GetAllEnemies()
	{
		if ((Object)(object)GameManager.Instance == (Object)null)
		{
			return null;
		}
		PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
		if ((Object)(object)primaryPlayer == (Object)null || primaryPlayer.CurrentRoom == null)
		{
			return null;
		}
		return primaryPlayer.CurrentRoom.GetActiveEnemies((ActiveEnemyType)1);
	}

	private void ShowStatus(string message)
	{
		_statusMessage = message;
		_statusTimer = 2f;
	}

	private void DrawStatusMessage()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		GUIStyle val = new GUIStyle(GUI.skin.label)
		{
			fontSize = 24,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)4
		};
		val.normal.textColor = Color.black;
		float num = (float)Screen.width / 2f - 150f;
		float num2 = (float)Screen.height / 4f;
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(num, num2, 300f, 40f);
		GUI.Label(new Rect(((Rect)(ref val2)).x - 1f, ((Rect)(ref val2)).y - 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), _statusMessage, val);
		GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y - 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), _statusMessage, val);
		GUI.Label(new Rect(((Rect)(ref val2)).x - 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), _statusMessage, val);
		GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), _statusMessage, val);
		val.normal.textColor = Color.white;
		GUI.Label(val2, _statusMessage, val);
	}
}