help in code c#
Published: 2022-08-23 15:11:47

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;

namespace unknown
{
	// Token: 0x02000329 RID: 809
	public class PixelSearcher
	{
		// Token: 0x06000698 RID: 1688
		[DllImport("user32.dll")]
		private static extern short GetAsyncKeyState(int int_7);

		// Token: 0x06000699 RID: 1689 RVA: 0x0000CF10 File Offset: 0x0000B110
		public PixelSearcher()
		{
			Thread thread = new Thread(new ThreadStart(this.method_6));
			Thread thread2 = new Thread(new ThreadStart(this.method_7));
			thread2.Start();
			thread.Start();
		}

		// Token: 0x0600069A RID: 1690 RVA: 0x0000CF5C File Offset: 0x0000B15C
		private void method_0()
		{
			if (Config.FritzDotStatus)
			{
				int config = Config.GetConfig(Settings.CONFIG.CHEST_RESOLUTION_X, Config.currentMode);
				int config2 = Config.GetConfig(Settings.CONFIG.CHEST_RESOLUTION_Y, Config.currentMode);
				int config3 = Config.GetConfig(Settings.CONFIG.FRITZDOT_FOVX, Config.currentMode);
				int config4 = Config.GetConfig(Settings.CONFIG.FRITZDOT_FOVY, Config.currentMode);
				Point[] result = this.PixelSearch(new Rectangle((config - config4) / 2, (config2 - config3) / 2, config4, config3)).GetAwaiter().GetResult();
				if (result != null && result.Length != 0)
				{
					this.ArduinoAdsMove(0, 0, true);
				}
			}
		}

		// Token: 0x0600069B RID: 1691 RVA: 0x0000CFE8 File Offset: 0x0000B1E8
		private void method_1()
		{
			if (Config.RedDotStatus)
			{
				if (!Config.SHITRECStatus)
				{
					if (PixelSearcher.int_3 != 0)
					{
						PixelSearcher.int_3 = 0;
					}
					if (PixelSearcher.bool_0)
					{
						PixelSearcher.bool_0 = false;
						PixelSearcher.int_1 = 0;
						PixelSearcher.int_3 = 0;
						PixelSearcher.int_2 = 0;
					}
				}
				else if (PixelSearcher.GetAsyncKeyState(1) != 0)
				{
					PixelSearcher.bool_0 = true;
					PixelSearcher.int_1++;
					if (PixelSearcher.int_1 >= Config.GetConfig(Settings.CONFIG.SHITREC_HOLDINGTIME, Config.currentMode))
					{
						PixelSearcher.int_2++;
					}
					if (PixelSearcher.int_2 >= 1 && PixelSearcher.int_3 != Config.GetConfig(Settings.CONFIG.SHITREC_MAX_RECOIL, Config.currentMode))
					{
						if (PixelSearcher.int_3 <= Config.GetConfig(Settings.CONFIG.SHITREC_MAX_RECOIL, Config.currentMode))
						{
							PixelSearcher.int_3 += Config.GetConfig(Settings.CONFIG.SHITREC_MULTIPLIER, Config.currentMode);
						}
						PixelSearcher.int_2 = 0;
					}
				}
				else if (PixelSearcher.bool_0)
				{
					PixelSearcher.bool_0 = false;
					PixelSearcher.int_1 = 0;
					PixelSearcher.int_3 = 0;
					PixelSearcher.int_2 = 0;
				}
			}
		}

		// Token: 0x0600069C RID: 1692 RVA: 0x0000D100 File Offset: 0x0000B300
		private void method_2(int int_7, int int_8)
		{
			int config = Config.GetConfig(Settings.CONFIG.FUCKALOT_FOV_X, Config.currentMode);
			int config2 = Config.GetConfig(Settings.CONFIG.FUCKALOT_FOV_Y, Config.currentMode);
			int config3 = Config.GetConfig(Settings.CONFIG.FUCKALOT_MAX_COUNT, Config.currentMode);
			int config4 = Config.GetConfig(Settings.CONFIG.FUCKALOT_HEADSHOT_OFFSET, Config.currentMode);
			float num = (float)Config.GetConfig(Settings.CONFIG.FUCKALOT_SPEED_X, Config.currentMode) / 100f;
			float num2 = (float)Config.GetConfig(Settings.CONFIG.FUCKALOT_SPEED_Y, Config.currentMode) / 100f;
			Point[] result = this.PixelSearch(new Rectangle((int_7 - config2) / 2, (int_8 - config) / 2, config2, config)).GetAwaiter().GetResult();
			if (result != null && result.Length != 0)
			{
				Point[] array = (from t in result
				orderby t.Y
				select t).ToArray<Point>();
				List<Vector2> list = new List<Vector2>();
				float num3 = 0f;
				for (int i = 0; i < array.Length; i++)
				{
					Vector2 current = new Vector2((float)array[i].X, (float)array[i].Y);
					if (num3 <= current.Y)
					{
						num3 = current.Y;
						if ((from t in list
						where (t - current).Length() < 60f || Math.Abs(t.X - current.X) < 60f
						select t).Count<Vector2>() < 1)
						{
							list.Add(current);
							if (list.Count > config3)
							{
								break;
							}
						}
					}
				}
				Vector2 vector = (from t in list
				select t - new Vector2((float)(int_7 / 2), (float)(int_8 / 2)) into t
				orderby t.Length()
				select t).FirstOrDefault<Vector2>() + new Vector2(1f, (float)(config4 + PixelSearcher.int_3));
				this.ArduinoAdsMove((int)(vector.X * num), (int)(vector.Y * num2), false);
			}
		}

		// Token: 0x0600069D RID: 1693 RVA: 0x0000D318 File Offset: 0x0000B518
		private void method_3(int int_7, int int_8)
		{
			if (Config.RedDotStatus)
			{
				int config = Config.GetConfig(Settings.CONFIG.REDDOT_MAX_COUNT, Config.currentMode);
				int config2 = Config.GetConfig(Settings.CONFIG.REDDOT_HEADSHOT_OFFSET, Config.currentMode);
				int config3 = Config.GetConfig(Settings.CONFIG.REDDOT_ANTI_SHAKE, Config.currentMode);
				float num = (float)Config.GetConfig(Settings.CONFIG.REDDOT_SPEED_X, Config.currentMode) / 100f;
				float num2 = (float)Config.GetConfig(Settings.CONFIG.REDDOT_SPEED_Y, Config.currentMode) / 100f;
				int config4 = Config.GetConfig(Settings.CONFIG.REDDOT_FOV_X, Config.currentMode);
				int config5 = Config.GetConfig(Settings.CONFIG.REDDOT_FOV_Y, Config.currentMode);
				bool shot = false;
				Point[] result = this.PixelSearch(new Rectangle((int_7 - config5) / 2, (int_8 - config4) / 2, config5, config4)).GetAwaiter().GetResult();
				if (result != null && result.Length != 0)
				{
					Point[] array = (from t in result
					orderby t.Y
					select t).ToArray<Point>();
					List<Vector2> list = new List<Vector2>();
					for (int i = 0; i < array.Length; i++)
					{
						Vector2 current = new Vector2((float)array[i].X, (float)array[i].Y);
						if ((from t in list
						where (t - current).Length() < 60f || Math.Abs(t.X - current.X) < 60f
						select t).Count<Vector2>() < 1)
						{
							list.Add(current);
							if (list.Count > config)
							{
								break;
							}
						}
					}
					Vector2 vector = (from t in list
					select t - new Vector2((float)(int_7 / 2), (float)(int_8 / 2)) into t
					orderby t.Length()
					select t).FirstOrDefault<Vector2>() + new Vector2(1f, (float)(config2 + PixelSearcher.int_3));
					if ((vector.X > (float)config3 || vector.X < (float)(-(float)config3)) && (vector.Y > (float)config3 || vector.Y < (float)(-(float)config3)))
					{
						this.ArduinoAdsMove((int)(vector.X * num), (int)(vector.Y * num2), shot);
					}
				}
			}
		}

		// Token: 0x0600069E RID: 1694 RVA: 0x0000D554 File Offset: 0x0000B754
		private void method_4()
		{
			int screenWidth = Config.GetConfig(Settings.CONFIG.CHEST_RESOLUTION_X, Config.currentMode);
			int screenHeight = Config.GetConfig(Settings.CONFIG.CHEST_RESOLUTION_Y, Config.currentMode);
			int config = Config.GetConfig(Settings.CONFIG.FLICK_FOV_X, Config.currentMode);
			int config2 = Config.GetConfig(Settings.CONFIG.FLICK_FOV_Y, Config.currentMode);
			Point[] result = this.PixelSearch(new Rectangle((screenWidth - config2) / 2, (screenHeight - config) / 2, config2, config)).GetAwaiter().GetResult();
			if (result != null && result.Length != 0)
			{
				int config3 = Config.GetConfig(Settings.CONFIG.REDDOT_MAX_COUNT, Config.currentMode);
				int config4 = Config.GetConfig(Settings.CONFIG.FLICK_HEADSHOT_OFFSET, Config.currentMode);
				int config5 = Config.GetConfig(Settings.CONFIG.FLICK_FOLLOW_TIME, Config.currentMode);
				float num = (float)Config.GetConfig(Settings.CONFIG.FLICK_SPEED_X, Config.currentMode) / 100f;
				float num2 = (float)Config.GetConfig(Settings.CONFIG.FLICK_SPEED_Y, Config.currentMode) / 100f;
				bool flag = Convert.ToBoolean(Config.GetConfig(Settings.CONFIG.FLICK_INSTANT, Config.currentMode));
				Point[] array = (from t in result
				orderby t.Y
				select t).ToArray<Point>();
				List<Vector2> list = new List<Vector2>();
				float num3 = 0f;
				for (int i = 0; i < array.Length; i++)
				{
					Vector2 current = new Vector2((float)array[i].X, (float)array[i].Y);
					if (num3 <= current.Y)
					{
						num3 = current.Y;
						if ((from t in list
						where (t - current).Length() < 60f || Math.Abs(t.X - current.X) < 60f
						select t).Count<Vector2>() < 1)
						{
							list.Add(current);
							if (list.Count > config3)
							{
								break;
							}
						}
					}
				}
				Vector2 vector = (from t in list
				select t - new Vector2((float)(screenWidth / 2), (float)(screenHeight / 2)) into t
				orderby t.Length()
				select t).FirstOrDefault<Vector2>() + new Vector2(1f, (float)config4);
				if (config5 != 0 && this.int_5 <= config5)
				{
					this.int_5++;
				}
				if (this.int_5 <= config5)
				{
					if (flag)
					{
						this.ArduinoAdsMove((int)vector.X, (int)vector.Y, false);
					}
					else
					{
						this.ArduinoAdsMove((int)(vector.X * num), (int)(vector.Y * num2), false);
					}
				}
			}
		}

		// Token: 0x0600069F RID: 1695 RVA: 0x0000D7EC File Offset: 0x0000B9EC
		private void method_5(Point[] point_0)
		{
			Point[] array = point_0.OrderBy(delegate(Point t)
			{
				Point point = t;
				return point.Y;
			}).ToArray<Point>();
			List<Vector2> list = new List<Vector2>();
			for (int i = 0; i < array.Length; i++)
			{
				if (Config.ESPStatus)
				{
					int num = 60;
					int height = 160;
					Color color = Color.FromArgb(255, 0, 0);
					Pen pen = new Pen(color)
					{
						Width = 2f
					};
					using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
					{
						graphics.DrawRectangle(pen, array[i].X - num / 2, array[i].Y - 10, num, height);
					}
				}
				Vector2 current = new Vector2((float)array[i].X, (float)array[i].Y);
				if (!(from t in list
				where (t - current).Length() < 60f || Math.Abs(t.X - current.X) < 60f
				select t).Any<Vector2>())
				{
					list.Add(current);
					if (list.Count > 0)
					{
						break;
					}
				}
			}
		}

		// Token: 0x060006A0 RID: 1696 RVA: 0x0000D92C File Offset: 0x0000BB2C
		public void ArduinoAdsMove(int xDelta, int yDelta, bool shot = false)
		{
			if (shot)
			{
				if (DateTime.Now.Subtract(PixelSearcher.dateTime_0).TotalMilliseconds < (double)Config.GetConfig(Settings.CONFIG.FRITZDOT_DELAY, Config.currentMode))
				{
					shot = false;
				}
				else
				{
					PixelSearcher.dateTime_0 = DateTime.Now;
				}
			}
			MainScreen._arduino.Move(xDelta, yDelta, shot);
		}

		// Token: 0x060006A1 RID: 1697 RVA: 0x0000D984 File Offset: 0x0000BB84
		[DebuggerStepThrough]
		public Task<Point[]> PixelSearch(Rectangle rect)
		{
			PixelSearcher.<PixelSearch> <PixelSearch>d__ = new PixelSearcher.<PixelSearch>;
			<PixelSearch>d__.<>t__builder = AsyncTaskMethodBuilder<Point[]>.Create();
			<PixelSearch>d__.<>4__this = this;
			<PixelSearch>d__.rect = rect;
			<PixelSearch>d__.<>1__state = -1;
			<PixelSearch>d__.<>t__builder.Start<PixelSearcher.<PixelSearch>d__19>(<PixelSearch>d__);
			return <PixelSearch>d__.<>t__builder.Task;
		}

		// Token: 0x060006A2 RID: 1698 RVA: 0x0000D9D0 File Offset: 0x0000BBD0
		public bool IsPurpleColor(int red, int green, int blue)
		{
			bool result;
			if (green >= 170)
			{
				result = false;
			}
			else if (green >= 120)
			{
				result = (Math.Abs(red - blue) <= 8 && red - green >= 50 && blue - green >= 50 && red >= 105 && blue >= 105);
			}
			else
			{
				result = (Math.Abs(red - blue) <= 13 && red - green >= 60 && blue - green >= 60 && red >= 110 && blue >= 100);
			}
			return result;
		}

		// Token: 0x060006A4 RID: 1700 RVA: 0x0000DAA4 File Offset: 0x0000BCA4
		[CompilerGenerated]
		private void method_6()
		{
			for (;;)
			{
				int config = Config.GetConfig(Settings.CONFIG.FRITZDOT_HOTKEY, Config.currentMode);
				if (PixelSearcher.GetAsyncKeyState(PixelSearcher.int_6[config]) != 0)
				{
					if (!PixelSearcher.bool_1)
					{
						PixelSearcher.bool_1 = true;
					}
				}
				else if (PixelSearcher.bool_1)
				{
					PixelSearcher.bool_1 = false;
					this.int_5 = 0;
				}
				if (Config.FritzDotStatus)
				{
					if (Config.TriggerRedDot && PixelSearcher.GetAsyncKeyState(PixelSearcher.int_6[config]) != 0)
					{
						this.method_4();
					}
					if (PixelSearcher.GetAsyncKeyState(PixelSearcher.int_6[config]) != 0)
					{
						this.method_0();
					}
				}
				Thread.Sleep(1);
			}
		}

		// Token: 0x060006A5 RID: 1701 RVA: 0x0000DB44 File Offset: 0x0000BD44
		[CompilerGenerated]
		private void method_7()
		{
			for (;;)
			{
				int config = Config.GetConfig(Settings.CONFIG.CHEST_RESOLUTION_X, Config.currentMode);
				int config2 = Config.GetConfig(Settings.CONFIG.CHEST_RESOLUTION_Y, Config.currentMode);
				int config3 = Config.GetConfig(Settings.CONFIG.FRITZDOT_HOTKEY, Config.currentMode);
				int config4 = Config.GetConfig(Settings.CONFIG.REDDOT_HOTKEY, Config.currentMode);
				if (Config.SHITRECStatus)
				{
					this.method_1();
				}
				if (Config.FuckALotStatus && PixelSearcher.GetAsyncKeyState(PixelSearcher.int_6[config3]) == 0)
				{
					this.method_2(config, config2);
				}
				if (PixelSearcher.GetAsyncKeyState(PixelSearcher.int_6[config4]) != 0)
				{
					this.method_3(config, config2);
				}
				Thread.Sleep(1);
			}
		}

		// Token: 0x0400007E RID: 126
		private const int int_0 = 60;

		// Token: 0x0400007F RID: 127
		private static int int_1 = 0;

		// Token: 0x04000080 RID: 128
		private static int int_2 = 0;

		// Token: 0x04000081 RID: 129
		private static int int_3 = 0;

		// Token: 0x04000082 RID: 130
		private static int int_4 = 0;

		// Token: 0x04000083 RID: 131
		private static bool bool_0 = false;

		// Token: 0x04000084 RID: 132
		private static bool bool_1 = false;

		// Token: 0x04000085 RID: 133
		private int int_5 = 0;

		// Token: 0x04000086 RID: 134
		private static DateTime dateTime_0 = DateTime.Now;

		// Token: 0x04000087 RID: 135
		private static int[] int_6 = new int[]
		{
			1,
			2,
			4,
			5,
			6,
			16,
			18,
			17,
			20
		};
	}
}

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9fv8kxc8h3l3x9mxaf9.PNG)