Decompiled source of ContentMiniMap v1.0.2

CWMapMod.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CWMapMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CWMapMod")]
[assembly: AssemblyTitle("CWMapMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.cwmap.mod", "ContentMiniMap", "1.0.1")]
public class CWMapMod : BaseUnityPlugin
{
	private Texture2D whiteTexture;

	private Texture2D terrainTexture;

	private GUIStyle itemLabelStyle;

	private GUIStyle headerStyle;

	private GUIStyle footerStyle;

	private const float MAP_SIZE = 220f;

	private const float BORDER = 2f;

	private const float HEADER_H = 22f;

	private const float FOOTER_H = 18f;

	private const float MARGIN = 16f;

	private Rect panelRect;

	private Rect mapRect;

	private float radarRange = 50f;

	private const float RANGE_MIN = 15f;

	private const float RANGE_MAX = 150f;

	private float heightTolerance = 5f;

	private Color colBackground = new Color(0.035f, 0.03f, 0.025f, 0.95f);

	private Color colBorder = new Color(0.847f, 0.741f, 0.561f, 1f);

	private Color colTerrain = new Color(0.35f, 0.3f, 0.22f, 1f);

	private Color colEmpty = new Color(0.05f, 0.045f, 0.035f, 0.5f);

	private Color colScanLine = new Color(0.847f, 0.741f, 0.561f, 0.15f);

	private Color colPlayer = new Color(0.95f, 0.85f, 0.65f, 1f);

	private Color colMonster = new Color(0.9f, 0.25f, 0.2f, 1f);

	private Color colMonsterHigh = new Color(1f, 0.75f, 0.2f, 1f);

	private Color colMonsterLow = new Color(0.75f, 0.25f, 0.8f, 1f);

	private Color colItem = new Color(0.35f, 1f, 0.45f, 1f);

	private Color colHeader = new Color(0.847f, 0.741f, 0.561f, 1f);

	private Color colFooter = new Color(0.65f, 0.55f, 0.4f, 1f);

	private LayerMask terrainMask;

	private int scanFrame = 0;

	private const int SCAN_INTERVAL = 2;

	private int MAP_TEXTURE_SIZE = 96;

	private bool indoorMode = false;

	private const float OUTDOOR_ORIGIN = 50f;

	private const float OUTDOOR_REACH = 100f;

	private const float INDOOR_ORIGIN = 8f;

	private const float INDOOR_REACH = 12f;

	private const float INDOOR_ROOF_CAP = -1f;

	private float scanLineY = 0f;

	private float targetRadarRange = 50f;

	private float zoomSpeed = 5f;

	private AudioSource audioSource;

	private AudioClip clipBeep;

	private float beepTimer = 0f;

	private bool beepsEnabled = true;

	private const float BEEP_FAST_DIST = 9f;

	private const float BEEP_MEDIUM_DIST = 14f;

	private const float BEEP_SLOW_DIST = 25f;

	private const float FRONT_ANGLE = 75f;

	private float borderFlashAlpha = 0f;

	private const float FLASH_DIST = 10f;

	private void Awake()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00de: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"CW Radar Loaded");
		whiteTexture = MakeTex(1, 1, Color.white);
		itemLabelStyle = new GUIStyle();
		itemLabelStyle.fontSize = 9;
		itemLabelStyle.fontStyle = (FontStyle)1;
		itemLabelStyle.normal.textColor = colItem;
		itemLabelStyle.alignment = (TextAnchor)4;
		headerStyle = new GUIStyle();
		headerStyle.fontSize = 11;
		headerStyle.fontStyle = (FontStyle)1;
		headerStyle.normal.textColor = colHeader;
		headerStyle.alignment = (TextAnchor)3;
		footerStyle = new GUIStyle();
		footerStyle.fontSize = 10;
		footerStyle.normal.textColor = colFooter;
		footerStyle.alignment = (TextAnchor)3;
		terrainMask = LayerMask.op_Implicit(-1);
		terrainTexture = new Texture2D(MAP_TEXTURE_SIZE, MAP_TEXTURE_SIZE, (TextureFormat)4, false);
		((Texture)terrainTexture).filterMode = (FilterMode)1;
		ClearTerrainTexture();
		RecalcRects();
	}

	private void Start()
	{
		audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
		audioSource.spatialBlend = 0f;
		audioSource.volume = 1f;
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		string text = Path.Combine(directoryName, "Sounds");
		((BaseUnityPlugin)this).Logger.LogInfo((object)("DLL location: " + ((BaseUnityPlugin)this).Info.Location));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Sounds folder: " + text));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Sounds folder exists: " + Directory.Exists(text)));
		if (Directory.Exists(text))
		{
			string[] files = Directory.GetFiles(text);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Files in Sounds folder: " + files.Length));
			string[] array = files;
			foreach (string text2 in array)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("  -> " + text2));
			}
		}
		((MonoBehaviour)this).StartCoroutine(LoadClip(Path.Combine(text, "Beep.wav"), delegate(AudioClip c)
		{
			clipBeep = c;
		}));
	}

	private IEnumerator LoadClip(string path, Action<AudioClip> onLoaded)
	{
		string uri = "file:///" + path.Replace("\\", "/");
		UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(uri, (AudioType)20);
		try
		{
			yield return www.SendWebRequest();
			if ((int)www.result == 1)
			{
				onLoaded(DownloadHandlerAudioClip.GetContent(www));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("SUCCESS SUCCESS SUCCESS: " + path));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("SUCCESS SUCCESS SUCCESS: " + path));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("SUCCESS SUCCESS SUCCESS: " + path));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("FAILED FAILED FAILED: " + path + " — " + www.error));
				((BaseUnityPlugin)this).Logger.LogWarning((object)("FAILED FAILED FAILED: " + path + " — " + www.error));
				((BaseUnityPlugin)this).Logger.LogWarning((object)("FAILED FAILED FAILED: " + path + " — " + www.error));
			}
		}
		finally
		{
			((IDisposable)www)?.Dispose();
		}
	}

	private void RecalcRects()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		float num = 224f;
		float num2 = 264f;
		float num3 = (float)Screen.width - num - 16f;
		float num4 = ((float)Screen.height - num2) / 2f;
		panelRect = new Rect(num3, num4, num, num2);
		mapRect = new Rect(((Rect)(ref panelRect)).x + 2f, ((Rect)(ref panelRect)).y + 2f + 22f, 220f, 220f);
	}

	private Texture2D MakeTex(int w, int h, Color c)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Expected O, but got Unknown
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(w, h);
		Color[] array = (Color[])(object)new Color[w * h];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = c;
		}
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private void ClearTerrainTexture()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		Color[] array = (Color[])(object)new Color[MAP_TEXTURE_SIZE * MAP_TEXTURE_SIZE];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = colEmpty;
		}
		terrainTexture.SetPixels(array);
		terrainTexture.Apply();
	}

	private void Update()
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = (((Object)(object)SimplePlayer.localPlayer != (Object)null) ? ((Component)SimplePlayer.localPlayer).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero));
		bool flag = val.y < -5f;
		if (flag != indoorMode)
		{
			indoorMode = flag;
			targetRadarRange = (indoorMode ? 35f : 75f);
			((BaseUnityPlugin)this).Logger.LogInfo((object)(indoorMode ? "Indoor mode" : "Outdoor mode"));
		}
		if (Input.GetKeyDown((KeyCode)98))
		{
			beepsEnabled = !beepsEnabled;
		}
		radarRange = Mathf.Lerp(radarRange, targetRadarRange, Time.deltaTime * zoomSpeed);
		scanLineY += Time.deltaTime * 0.4f;
		if (scanLineY > 1f)
		{
			scanLineY = 0f;
		}
		scanFrame++;
		if (scanFrame >= 2)
		{
			scanFrame = 0;
			ScanTerrain(val);
		}
		UpdateBeeps(val);
		borderFlashAlpha = Mathf.Max(0f, borderFlashAlpha - Time.deltaTime * 3f);
	}

	private void UpdateBeeps(Vector3 playerPos)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return;
		}
		Vector3 forward = ((Component)main).transform.forward;
		forward.y = 0f;
		((Vector3)(ref forward)).Normalize();
		float num = float.MaxValue;
		bool flag = false;
		Bot[] array = Object.FindObjectsByType<Bot>((FindObjectsSortMode)0);
		Bot[] array2 = array;
		foreach (Bot val in array2)
		{
			if ((Object)(object)val == (Object)null || (Object)(object)val.centerTransform == (Object)null)
			{
				continue;
			}
			float num2 = Mathf.Abs(val.centerTransform.position.y - playerPos.y);
			if (!(num2 > heightTolerance))
			{
				float num3 = Vector3.Distance(val.centerTransform.position, playerPos);
				Vector3 val2 = val.centerTransform.position - playerPos;
				val2.y = 0f;
				((Vector3)(ref val2)).Normalize();
				float num4 = Vector3.Angle(forward, val2);
				if (num4 > 75f && num3 < 25f)
				{
					num = Mathf.Min(num, num3);
				}
				if (num3 < 10f)
				{
					flag = true;
				}
			}
		}
		if (flag)
		{
			borderFlashAlpha = 1f;
		}
		AudioClip val3 = null;
		float num5 = float.MaxValue;
		float pitch = 1f;
		if (num <= 9f)
		{
			val3 = clipBeep;
			num5 = 0.1f;
		}
		else if (num <= 14f)
		{
			val3 = clipBeep;
			num5 = 0.5f;
		}
		else if (num <= 25f)
		{
			val3 = clipBeep;
			num5 = 1f;
		}
		if ((Object)(object)val3 != (Object)null && beepsEnabled)
		{
			beepTimer -= Time.deltaTime;
			if (beepTimer <= 0f)
			{
				audioSource.pitch = pitch;
				audioSource.PlayOneShot(val3);
				beepTimer = num5;
			}
		}
		else
		{
			beepTimer = 0f;
			audioSource.pitch = 1f;
		}
	}

	private void ScanTerrain(Vector3 playerPos)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: 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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		Color[] array = (Color[])(object)new Color[MAP_TEXTURE_SIZE * MAP_TEXTURE_SIZE];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = colEmpty;
		}
		float num;
		float num2;
		if (indoorMode)
		{
			num = Mathf.Min(playerPos.y + 8f, -1f);
			num2 = 12f;
		}
		else
		{
			num = playerPos.y + 50f;
			num2 = 100f;
		}
		Vector3 val = default(Vector3);
		RaycastHit val2 = default(RaycastHit);
		for (int j = 0; j < MAP_TEXTURE_SIZE; j++)
		{
			for (int k = 0; k < MAP_TEXTURE_SIZE; k++)
			{
				float num3 = (((float)j + 0.5f) / (float)MAP_TEXTURE_SIZE * 2f - 1f) * radarRange;
				float num4 = (((float)k + 0.5f) / (float)MAP_TEXTURE_SIZE * 2f - 1f) * radarRange;
				((Vector3)(ref val))..ctor(playerPos.x + num3, num, playerPos.z + num4);
				if (Physics.Raycast(val, Vector3.down, ref val2, num2, LayerMask.op_Implicit(terrainMask)) && Mathf.Abs(((RaycastHit)(ref val2)).point.y - playerPos.y) <= heightTolerance)
				{
					float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) / radarRange;
					Color val3 = Color.Lerp(new Color(0.28f, 0.36f, 0.5f, 1f), colTerrain, num5);
					array[k * MAP_TEXTURE_SIZE + j] = val3;
				}
			}
		}
		terrainTexture.SetPixels(array);
		terrainTexture.Apply();
	}

	private void OnGUI()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: 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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_062d: Unknown result type (might be due to invalid IL or missing references)
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_064b: Unknown result type (might be due to invalid IL or missing references)
		//IL_067b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0509: Unknown result type (might be due to invalid IL or missing references)
		//IL_050b: Unknown result type (might be due to invalid IL or missing references)
		//IL_071d: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_052b: Unknown result type (might be due to invalid IL or missing references)
		//IL_052c: Unknown result type (might be due to invalid IL or missing references)
		//IL_052e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0571: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Unknown result type (might be due to invalid IL or missing references)
		//IL_0584: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: 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_05ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)main).transform.position;
		RecalcRects();
		Color color = ((borderFlashAlpha > 0f) ? Color.Lerp(colBorder, new Color(1f, 0.1f, 0.1f, 1f), borderFlashAlpha) : colBorder);
		GUI.color = color;
		GUI.DrawTexture(panelRect, (Texture)(object)whiteTexture);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(((Rect)(ref panelRect)).x + 2f, ((Rect)(ref panelRect)).y + 2f, ((Rect)(ref panelRect)).width - 4f, ((Rect)(ref panelRect)).height - 4f);
		GUI.color = colBackground;
		GUI.DrawTexture(val, (Texture)(object)whiteTexture);
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(((Rect)(ref panelRect)).x + 2f + 6f, ((Rect)(ref panelRect)).y + 2f, 214f, 22f);
		GUI.color = Color.white;
		string text = (indoorMode ? "[IN]" : "[OUT]");
		GUI.Label(val2, "◈  RADAR - Zoom Mode: " + text, headerStyle);
		GUI.color = new Color(colBorder.r, colBorder.g, colBorder.b, 0.4f);
		GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x, ((Rect)(ref mapRect)).y - 1f, 220f, 1f), (Texture)(object)whiteTexture);
		GUI.color = Color.white;
		GUI.DrawTexture(mapRect, (Texture)(object)terrainTexture);
		Vector2 center = default(Vector2);
		((Vector2)(ref center))..ctor(((Rect)(ref mapRect)).x + ((Rect)(ref mapRect)).width / 2f, ((Rect)(ref mapRect)).y + ((Rect)(ref mapRect)).height / 2f);
		float num = ((Rect)(ref mapRect)).y + scanLineY * 220f;
		GUI.color = colScanLine;
		GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x, num, 220f, 3f), (Texture)(object)whiteTexture);
		GUI.color = Color.white;
		Bot[] array = Object.FindObjectsByType<Bot>((FindObjectsSortMode)0);
		Bot[] array2 = array;
		foreach (Bot val3 in array2)
		{
			if ((Object)(object)val3 == (Object)null || (Object)(object)val3.centerTransform == (Object)null)
			{
				continue;
			}
			Vector3 position2 = val3.centerTransform.position;
			float num2 = position2.y - position.y;
			if (Mathf.Abs(num2) > heightTolerance)
			{
				continue;
			}
			float num3 = Vector3.Distance(position2, position);
			if (num3 > radarRange)
			{
				continue;
			}
			Vector2 val4 = WorldToRadar(position2, position, center);
			if (!((Rect)(ref mapRect)).Contains(val4))
			{
				continue;
			}
			float num4 = Mathf.Clamp(1f - num3 / radarRange, 0.2f, 1f);
			Color val5 = colMonster;
			if (num2 > 1f)
			{
				val5 = colMonsterHigh;
			}
			if (num2 < -1f)
			{
				val5 = colMonsterLow;
			}
			DrawDot(val4, val5, 7f);
			string text2 = "?";
			DummyMonsterContentProvider val6 = null;
			float num5 = 3f;
			DummyMonsterContentProvider[] array3 = Object.FindObjectsByType<DummyMonsterContentProvider>((FindObjectsSortMode)0);
			foreach (DummyMonsterContentProvider val7 in array3)
			{
				float num6 = Vector3.Distance(((Component)val7).transform.position, val3.centerTransform.position);
				if (num6 < num5)
				{
					num5 = num6;
					val6 = val7;
				}
			}
			if ((Object)(object)val6 != (Object)null)
			{
				text2 = ((object)Unsafe.As<Monster, Monster>(ref val6.State)/*cast due to .constrained prefix*/).ToString();
			}
			GUI.color = new Color(val5.r, val5.g, val5.b, num4 * 0.85f);
			GUI.Label(new Rect(val4.x - 40f, val4.y + 5f, 80f, 14f), text2, itemLabelStyle);
		}
		ItemInstance[] array4 = Object.FindObjectsByType<ItemInstance>((FindObjectsSortMode)0);
		ItemInstance[] array5 = array4;
		foreach (ItemInstance val8 in array5)
		{
			if ((Object)(object)val8 == (Object)null)
			{
				continue;
			}
			Vector3 position3 = ((Component)val8).transform.position;
			float num7 = position3.y - position.y;
			if (Mathf.Abs(num7) > heightTolerance)
			{
				continue;
			}
			float num8 = Vector3.Distance(position3, position);
			if (num8 > radarRange)
			{
				continue;
			}
			Vector2 val9 = WorldToRadar(position3, position, center);
			if (((Rect)(ref mapRect)).Contains(val9))
			{
				float num9 = Mathf.Clamp(1f - num8 / radarRange, 0.2f, 1f);
				Color color2 = colItem;
				color2.a = num9;
				DrawDot(val9, color2, 5f);
				if ((Object)(object)val8.item != (Object)null)
				{
					GUI.color = new Color(colItem.r, colItem.g, colItem.b, num9 * 0.85f);
					GUI.Label(new Rect(val9.x - 40f, val9.y + 5f, 80f, 14f), ((Object)val8.item).name, itemLabelStyle);
				}
			}
		}
		GUI.color = Color.white;
		float y = ((Component)main).transform.eulerAngles.y;
		DrawPlayerArrow(center, y);
		GUI.color = new Color(colBorder.r, colBorder.g, colBorder.b, 0.4f);
		GUI.DrawTexture(new Rect(((Rect)(ref mapRect)).x, ((Rect)(ref mapRect)).y + 220f, 220f, 1f), (Texture)(object)whiteTexture);
		GUI.color = Color.white;
		Rect val10 = default(Rect);
		((Rect)(ref val10))..ctor(((Rect)(ref panelRect)).x + 2f + 6f, ((Rect)(ref mapRect)).y + 220f + 2f, 220f, 18f);
		string text3 = (beepsEnabled ? " ♪" : " ✕");
		GUI.Label(val10, "Y " + Mathf.Round(position.y).ToString("+0;-0;0") + "   RNG " + (int)radarRange + "m         V: 1.0.1      [B] Beeps:" + text3, footerStyle);
	}

	private Vector3 RadarToWorld(Vector2 radarPos, Vector3 player, Vector2 center)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		float num = player.x + (radarPos.x - center.x) / (((Rect)(ref mapRect)).width / 2f) * radarRange;
		float num2 = player.z - (radarPos.y - center.y) / (((Rect)(ref mapRect)).height / 2f) * radarRange;
		return new Vector3(num, player.y, num2);
	}

	private Vector2 WorldToRadar(Vector3 world, Vector3 player, Vector2 center)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = world - player;
		float num = center.x + val.x / radarRange * (((Rect)(ref mapRect)).width / 2f);
		float num2 = center.y - val.z / radarRange * (((Rect)(ref mapRect)).height / 2f);
		return new Vector2(num, num2);
	}

	private void DrawDot(Vector2 position, Color color, float size)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		GUI.color = color;
		GUI.DrawTexture(new Rect(position.x - size / 2f, position.y - size / 2f, size, size), (Texture)(object)whiteTexture);
		GUI.color = Color.white;
	}

	private Vector2 RotateAround(Vector2 point, Vector2 pivot, float angleDeg)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		float num = angleDeg * (MathF.PI / 180f);
		float num2 = Mathf.Cos(num);
		float num3 = Mathf.Sin(num);
		Vector2 val = point - pivot;
		return new Vector2(pivot.x + val.x * num2 - val.y * num3, pivot.y + val.x * num3 + val.y * num2);
	}

	private void DrawPlayerArrow(Vector2 center, float yawDeg)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		Vector2 point = center + new Vector2(0f, -13f);
		Vector2 point2 = center + new Vector2(-9f, 11f);
		Vector2 point3 = center + new Vector2(9f, 11f);
		Vector2 point4 = center + new Vector2(0f, 5f);
		point = RotateAround(point, center, yawDeg);
		point2 = RotateAround(point2, center, yawDeg);
		point3 = RotateAround(point3, center, yawDeg);
		point4 = RotateAround(point4, center, yawDeg);
		Color color = default(Color);
		((Color)(ref color))..ctor(0.05f, 0.15f, 0.25f, 1f);
		GUI.color = color;
		DrawLineWidth(point, point2, 3f);
		DrawLineWidth(point2, point4, 3f);
		DrawLineWidth(point4, point3, 3f);
		DrawLineWidth(point3, point, 3f);
		GUI.color = colPlayer;
		DrawLineWidth(point, point2, 2f);
		DrawLineWidth(point2, point4, 2f);
		DrawLineWidth(point4, point3, 2f);
		DrawLineWidth(point3, point, 2f);
		GUI.color = Color.white;
	}

	private void DrawLineWidth(Vector2 start, Vector2 end, float width)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = end - start;
		float magnitude = ((Vector2)(ref val)).magnitude;
		float num = Mathf.Atan2(val.y, val.x) * 57.29578f;
		GUIUtility.RotateAroundPivot(num, start);
		GUI.DrawTexture(new Rect(start.x, start.y - width / 2f, magnitude, width), (Texture)(object)whiteTexture);
		GUIUtility.RotateAroundPivot(0f - num, start);
	}
}