Decompiled source of AccurateDpsMeter v1.0.0

BepInEx/plugins/AccurateDpsMeter.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReckssBlade")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReckssBlade")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0f16d5df-974c-48ba-a098-e46d8fe08611")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.reckss.erenshor.dpsmeter", "Party DPS Meter (Themed & Gradient)", "1.0.0")]
public class DPSMeterMod : BaseUnityPlugin
{
	private ConfigEntry<bool> showMeter;

	private ConfigEntry<float> pauseThreshold;

	private ConfigEntry<float> holdDuration;

	private ConfigEntry<float> expireAfter;

	private ConfigEntry<int> fontSize;

	private ConfigEntry<float> posX;

	private ConfigEntry<float> posY;

	private ConfigEntry<float> winW;

	private ConfigEntry<float> winH;

	private ConfigEntry<KeyCode> toggleKey;

	private ConfigEntry<float> updateInterval;

	private ConfigEntry<Color> panelColor;

	private ConfigEntry<Color> shadowColor;

	private ConfigEntry<Color> borderColor;

	private ConfigEntry<Color> textColor;

	private ConfigEntry<Color> barBgColor;

	private ConfigEntry<Color> gradientStart;

	private ConfigEntry<Color> gradientEnd;

	private readonly Dictionary<Character, List<Tuple<float, float>>> logs = new Dictionary<Character, List<Tuple<float, float>>>();

	private float lastHitTime;

	private float combatStartTime;

	private float pauseStartTime = -1f;

	private bool inCombat;

	private float currentAlpha = 1f;

	private GUIStyle style;

	private Rect rect;

	private Texture2D barBgTex;

	private Texture2D gradientTex;

	private Texture2D maskTex;

	private GUIStyle panelStyle;

	private const int Corner = 8;

	private bool dragging;

	private bool resizing;

	private Vector2 dragOffset;

	private Vector2 resizeOffset;

	private float nextUpdateTime;

	private string cachedHeader;

	private List<Tuple<string, float>> cachedMembers = new List<Tuple<string, float>>();

	private float cachedMaxDps;

	private float cachedTextW;

	private static DPSMeterMod _instance;

	public static DPSMeterMod Instance => _instance ?? (_instance = Object.FindObjectOfType<DPSMeterMod>());

	private void Awake()
	{
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Expected O, but got Unknown
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Expected O, but got Unknown
		//IL_036f: 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_03a0: Expected O, but got Unknown
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Expected O, but got Unknown
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Expected O, but got Unknown
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_046e: Expected O, but got Unknown
		showMeter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowMeter", true, "Enable DPS meter");
		pauseThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PauseThreshold", 3f, "Seconds no-damage before pause");
		holdDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HoldDuration", 10f, "Seconds to hold frozen display");
		expireAfter = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ExpireAfter", 5f, "Fade-out seconds after hold");
		fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FontSize", 18, "Font size");
		toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)283, "Show/hide key");
		updateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "UpdateInterval", 0.5f, "Seconds between DPS updates");
		posX = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "X", 10f, "HUD X");
		posY = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "Y", 10f, "HUD Y");
		winW = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "W", 240f, "HUD Width");
		winH = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "H", 200f, "HUD Height");
		panelColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "PanelColor", new Color(0f, 0f, 0f, 0.6f), "Panel fill");
		shadowColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "ShadowColor", new Color(0f, 0f, 0f, 0.3f), "Drop-shadow");
		borderColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "BorderColor", Color.red, "Border");
		textColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "TextColor", Color.white, "Text");
		barBgColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "BarBgColor", new Color(0.1f, 0.1f, 0.1f), "Bar background");
		gradientStart = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "BarGradientStart", new Color(0.2f, 0.8f, 0.2f), "Bar gradient start");
		gradientEnd = ((BaseUnityPlugin)this).Config.Bind<Color>("Theme", "BarGradientEnd", new Color(1f, 0.8f, 0.2f), "Bar gradient end");
		GUIStyle val = new GUIStyle
		{
			fontSize = fontSize.Value
		};
		val.normal.textColor = textColor.Value;
		style = val;
		rect = new Rect(posX.Value, posY.Value, winW.Value, winH.Value);
		barBgTex = new Texture2D(1, 1);
		barBgTex.SetPixel(0, 0, barBgColor.Value);
		barBgTex.Apply();
		((Texture)barBgTex).filterMode = (FilterMode)0;
		gradientTex = new Texture2D(2, 1);
		gradientTex.SetPixel(0, 0, gradientStart.Value);
		gradientTex.SetPixel(1, 0, gradientEnd.Value);
		gradientTex.Apply();
		((Texture)gradientTex).filterMode = (FilterMode)1;
		maskTex = GenerateRoundedMask(32, 8);
		panelStyle = new GUIStyle();
		panelStyle.normal.background = maskTex;
		panelStyle.border = new RectOffset(8, 8, 8, 8);
		new Harmony("com.reckss.erenshor.dpsmeter").Patch((MethodBase)AccessTools.Method(typeof(Character), "CreditDPS", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(DPSMeterMod), "OnCreditDPS", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static void OnCreditDPS(Character __instance, int _incDmg)
	{
		//IL_00d0: 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)
		if (_incDmg <= 0)
		{
			return;
		}
		DPSMeterMod instance = Instance;
		if (!instance.showMeter.Value)
		{
			return;
		}
		Character val = GameData.PlayerControl?.Myself;
		Character val2 = GameData.GroupMember1?.MyStats?.Myself;
		Character val3 = GameData.GroupMember2?.MyStats?.Myself;
		Character val4 = GameData.GroupMember3?.MyStats?.Myself;
		if ((Object)(object)__instance != (Object)(object)val && (Object)(object)__instance != (Object)(object)val2 && (Object)(object)__instance != (Object)(object)val3 && (Object)(object)__instance != (Object)(object)val4)
		{
			return;
		}
		Scene activeScene = SceneManager.GetActiveScene();
		string name = ((Scene)(ref activeScene)).name;
		if (!(name == "Main") && !(name == "LoadScene"))
		{
			float item = (instance.lastHitTime = Time.time);
			if (!instance.inCombat)
			{
				instance.inCombat = true;
				instance.logs.Clear();
				instance.currentAlpha = 1f;
				instance.combatStartTime = item;
				instance.pauseStartTime = -1f;
			}
			if (!instance.logs.TryGetValue(__instance, out var value))
			{
				value = (instance.logs[__instance] = new List<Tuple<float, float>>());
			}
			value.Add(Tuple.Create(item, (float)_incDmg));
		}
	}

	private void Update()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(toggleKey.Value))
		{
			showMeter.Value = !showMeter.Value;
		}
		if (!showMeter.Value)
		{
			return;
		}
		float time = Time.time;
		float num = time - lastHitTime;
		if (num < pauseThreshold.Value)
		{
			inCombat = true;
			currentAlpha = 1f;
			pauseStartTime = -1f;
			return;
		}
		inCombat = false;
		if (pauseStartTime < 0f)
		{
			pauseStartTime = lastHitTime + pauseThreshold.Value;
		}
		float num2 = time - pauseStartTime;
		if (num2 < holdDuration.Value)
		{
			currentAlpha = 1f;
			return;
		}
		float num3 = num2 - holdDuration.Value;
		currentAlpha = Mathf.Clamp01(1f - num3 / expireAfter.Value);
	}

	private void OnGUI()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		if (!showMeter.Value || logs.Count == 0 || currentAlpha <= 0f)
		{
			return;
		}
		Scene activeScene = SceneManager.GetActiveScene();
		string name = ((Scene)(ref activeScene)).name;
		if (!(name == "Main") && !(name == "LoadScene"))
		{
			style.fontSize = fontSize.Value;
			style.normal.textColor = textColor.Value * currentAlpha;
			if (inCombat && Time.time >= nextUpdateTime)
			{
				RecalculateCache();
				nextUpdateTime = Time.time + updateInterval.Value;
			}
			DrawWindow();
		}
	}

	private void RecalculateCache()
	{
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Expected O, but got Unknown
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Expected O, but got Unknown
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		float elapsed = Mathf.Max(Time.time - combatStartTime, 0.01f);
		Character val = GameData.PlayerControl?.Myself;
		List<Character> source = ((IEnumerable<Character>)(object)new Character[4]
		{
			val,
			GameData.GroupMember1?.MyStats?.Myself,
			GameData.GroupMember2?.MyStats?.Myself,
			GameData.GroupMember3?.MyStats?.Myself
		}).Where((Character c) => (Object)(object)c != (Object)null).ToList();
		List<Tuple<float, float>> value;
		Dictionary<Character, float> dictionary = source.ToDictionary((Character ch) => ch, (Character ch) => logs.TryGetValue(ch, out value) ? (value.Sum((Tuple<float, float> e) => e.Item2) / elapsed) : 0f);
		if (dictionary.Count == 0)
		{
			return;
		}
		float num = dictionary.Values.Sum();
		List<KeyValuePair<Character, float>> list = dictionary.OrderByDescending((KeyValuePair<Character, float> kv) => kv.Value).ToList();
		cachedHeader = $"Party DPS ({elapsed:F1}s): {num:F1}";
		cachedMembers.Clear();
		foreach (KeyValuePair<Character, float> item in list)
		{
			cachedMembers.Add(Tuple.Create($"{((Object)item.Key).name}: {item.Value:F1}", item.Value));
		}
		cachedMaxDps = list[0].Value;
		cachedTextW = style.CalcSize(new GUIContent(cachedHeader)).x;
		foreach (Tuple<string, float> cachedMember in cachedMembers)
		{
			cachedTextW = Mathf.Max(cachedTextW, style.CalcSize(new GUIContent(cachedMember.Item1)).x);
		}
		float num2 = style.lineHeight + 6f;
		((Rect)(ref rect)).height = (float)(1 + cachedMembers.Count) * num2 + 12f;
		((Rect)(ref rect)).width = Mathf.Max(((Rect)(ref rect)).width, cachedTextW + 80f);
	}

	private void DrawWindow()
	{
		//IL_001c: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		Event current = Event.current;
		HandleDragResize(current);
		Clamp();
		GUI.color = shadowColor.Value * currentAlpha;
		GUI.Box(new Rect(((Rect)(ref rect)).x + 4f, ((Rect)(ref rect)).y + 4f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), GUIContent.none, panelStyle);
		GUI.color = panelColor.Value * currentAlpha;
		GUI.Box(rect, GUIContent.none, panelStyle);
		DrawBorder(rect, 2f, borderColor.Value * currentAlpha);
		GUI.color = textColor.Value * currentAlpha;
		float num = ((Rect)(ref rect)).y + 6f;
		GUI.Label(new Rect(((Rect)(ref rect)).x + 6f, num, ((Rect)(ref rect)).width, style.lineHeight), cachedHeader, style);
		num += style.lineHeight + 6f;
		float num2 = ((Rect)(ref rect)).width - cachedTextW - 30f;
		foreach (Tuple<string, float> cachedMember in cachedMembers)
		{
			cachedMember.Deconstruct(out var item, out var item2);
			string text = item;
			float num3 = item2;
			float num4 = ((cachedMaxDps > 0f) ? (num3 / cachedMaxDps * num2) : 0f);
			GUI.color = barBgColor.Value * currentAlpha;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 6f + cachedTextW + 10f, num + 2f, num2, style.lineHeight), (Texture)(object)barBgTex);
			GUI.color = Color.white * currentAlpha;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 6f + cachedTextW + 10f, num + 2f, num4, style.lineHeight), (Texture)(object)gradientTex);
			GUI.color = textColor.Value * currentAlpha;
			GUI.Label(new Rect(((Rect)(ref rect)).x + 6f, num, ((Rect)(ref rect)).width, style.lineHeight), text, style);
			num += style.lineHeight + 6f;
		}
		GUI.color = Color.white;
	}

	private void HandleDragResize(Event evt)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Invalid comparison between Unknown and I4
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Invalid comparison between Unknown and I4
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Invalid comparison between Unknown and I4
		//IL_007a: 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_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: 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_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_00e4: 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_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		Rect val = new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width - 8f, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - 8f, 8f, 8f);
		bool flag = ((Rect)(ref val)).Contains(evt.mousePosition);
		if ((int)evt.type == 0)
		{
			if (evt.button == 2 && ((Rect)(ref rect)).Contains(evt.mousePosition))
			{
				dragging = true;
				dragOffset = evt.mousePosition - new Vector2(((Rect)(ref rect)).x, ((Rect)(ref rect)).y);
				evt.Use();
			}
			else if (evt.button == 1 && flag)
			{
				resizing = true;
				resizeOffset = evt.mousePosition - new Vector2(((Rect)(ref rect)).width, ((Rect)(ref rect)).height);
				evt.Use();
			}
		}
		else if ((int)evt.type == 3)
		{
			if (dragging)
			{
				((Rect)(ref rect)).position = evt.mousePosition - dragOffset;
				evt.Use();
			}
			else if (resizing)
			{
				Vector2 val2 = evt.mousePosition - resizeOffset;
				((Rect)(ref rect)).width = Mathf.Max(100f, val2.x);
				((Rect)(ref rect)).height = Mathf.Max(50f, val2.y);
				evt.Use();
			}
		}
		else if ((int)evt.type == 1 && (dragging || resizing))
		{
			dragging = (resizing = false);
			Clamp();
			posX.Value = ((Rect)(ref rect)).x;
			posY.Value = ((Rect)(ref rect)).y;
			winW.Value = ((Rect)(ref rect)).width;
			winH.Value = ((Rect)(ref rect)).height;
			((BaseUnityPlugin)this).Config.Save();
			evt.Use();
		}
	}

	private void DrawBorder(Rect r, float t, Color c)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		Color color = GUI.color;
		GUI.color = c;
		GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), (Texture)(object)barBgTex);
		GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height - t, ((Rect)(ref r)).width, t), (Texture)(object)barBgTex);
		GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)barBgTex);
		GUI.DrawTexture(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)barBgTex);
		GUI.color = color;
	}

	private void Clamp()
	{
		((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, 0f, (float)Screen.width - ((Rect)(ref rect)).width);
		((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, 0f, (float)Screen.height - ((Rect)(ref rect)).height);
	}

	private static Texture2D GenerateRoundedMask(int sz, int r)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_002f: 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_0126: 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_0069: 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_00a1: 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_00de: 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)
		Texture2D val = new Texture2D(sz, sz, (TextureFormat)5, false);
		for (int i = 0; i < sz; i++)
		{
			for (int j = 0; j < sz; j++)
			{
				bool flag = ((j < r && i < r) ? (Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)r, (float)r)) <= (float)r) : ((j < r && i >= sz - r) ? (Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)r, (float)(sz - r - 1))) <= (float)r) : ((j >= sz - r && i < r) ? (Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)(sz - r - 1), (float)r)) <= (float)r) : (j < sz - r || i < sz - r || Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)(sz - r - 1), (float)(sz - r - 1))) <= (float)r))));
				val.SetPixel(j, i, (Color)(flag ? Color.white : new Color(1f, 1f, 1f, 0f)));
			}
		}
		val.Apply();
		return val;
	}
}