Decompiled source of StaminaOnReticle v1.0.0

BepInEx/plugins/StaminaOnReticle.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StaminaOnReticle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StaminaOnReticle")]
[assembly: AssemblyTitle("StaminaOnReticle")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StaminaOnReticle
{
	[BepInPlugin("com.staminaonreticle.peak", "Stamina On Reticle", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.staminaonreticle.peak";

		public const string PluginName = "Stamina On Reticle";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> HideWhenFull;

		internal static ConfigEntry<bool> ShowExtraStamina;

		internal static ConfigEntry<bool> ShowStats;

		internal static ConfigEntry<bool> PulseWhenLow;

		internal static ConfigEntry<float> LowStaminaThreshold;

		internal static ConfigEntry<float> Diameter;

		internal static ConfigEntry<float> Thickness;

		internal static ConfigEntry<float> ExtraThickness;

		internal static ConfigEntry<float> OffsetX;

		internal static ConfigEntry<float> OffsetY;

		internal static ConfigEntry<string> FullColor;

		internal static ConfigEntry<string> LowColor;

		internal static ConfigEntry<string> ExtraColor;

		internal static ConfigEntry<string> PuckColor;

		internal static ConfigEntry<string> TrackColor;

		private GameObject overlayObject;

		private void Awake()
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show the circular stamina ring around the crosshair.");
			HideWhenFull = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide When Full", false, "Fade the ring out while stamina is at its maximum.");
			ShowExtraStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Extra Stamina", true, "Draw a second outer ring for the morale-boost (extra) stamina bar.");
			ShowStats = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Stats", true, "Draw the active status effects as coloured arcs on the ring, using each status' own colour.");
			PulseWhenLow = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Pulse When Low", true, "Gently pulse the ring when stamina drops below the low threshold. Disabled automatically by the in-game photosensitivity setting.");
			LowStaminaThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Low Stamina Threshold", 0.25f, new ConfigDescription("Stamina ratio below which the ring uses the low color and pulses.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Diameter = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "Diameter", 46f, "Outer diameter of the stamina ring in pixels at 1080p.");
			Thickness = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "Thickness", 3.5f, "Line thickness of the stamina ring in pixels at 1080p.");
			ExtraThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "Extra Thickness", 2.5f, "Line thickness of the extra-stamina ring in pixels at 1080p.");
			OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "Offset X", 0f, "Horizontal screen offset in pixels at 1080p. Positive moves right.");
			OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "Offset Y", 0f, "Vertical screen offset in pixels at 1080p. Positive moves up.");
			FullColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Full Color", "#4CD137", "Color of the ring at full stamina (hex, e.g. #4CD137).");
			LowColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Low Color", "#4CD137", "Color of the ring when stamina is low (hex).");
			ExtraColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Extra Color", "#8CE06A", "Color of the outer extra-stamina ring (hex).");
			PuckColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Center Color", "#EAFFE6", "Color of the small dot in the middle of the ring (hex).");
			TrackColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Track Color", "#00000059", "Color of the dim ring behind the stamina fill (hex with alpha).");
			((BaseUnityPlugin)this).Config.Save();
			overlayObject = new GameObject("StaminaOnReticle", new Type[1] { typeof(RectTransform) });
			Object.DontDestroyOnLoad((Object)(object)overlayObject);
			overlayObject.AddComponent<ReticleOverlay>();
			Log.LogInfo((object)"Stamina On Reticle v1.0.0 loaded.");
		}
	}
	internal class ReticleOverlay : MonoBehaviour
	{
		private const int TextureSize = 512;

		private const float OuterRadiusFraction = 0.48f;

		private Canvas canvas;

		private RectTransform container;

		private Image trackRing;

		private Image staminaRing;

		private Image extraRing;

		private Image centerPuck;

		private readonly List<Image> statArcs = new List<Image>();

		private Sprite ringSprite;

		private Sprite extraSprite;

		private Sprite discSprite;

		private float cachedDiameter = -1f;

		private float cachedThickness = -1f;

		private float cachedExtraThickness = -1f;

		private float displayStamina = 1f;

		private float displayAlpha = 1f;

		private float pulseTime;

		private void Awake()
		{
			BuildCanvas();
		}

		private void BuildCanvas()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			canvas = ((Component)this).gameObject.AddComponent<Canvas>();
			canvas.renderMode = (RenderMode)0;
			canvas.sortingOrder = 32000;
			CanvasScaler obj = ((Component)this).gameObject.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)1;
			obj.referenceResolution = new Vector2(1920f, 1080f);
			obj.screenMatchMode = (ScreenMatchMode)0;
			obj.matchWidthOrHeight = 0.5f;
			GameObject val = new GameObject("Container", new Type[1] { typeof(RectTransform) });
			container = val.GetComponent<RectTransform>();
			((Transform)container).SetParent(((Component)this).transform, false);
			container.anchorMin = new Vector2(0.5f, 0.5f);
			container.anchorMax = new Vector2(0.5f, 0.5f);
			container.pivot = new Vector2(0.5f, 0.5f);
			container.anchoredPosition = Vector2.zero;
			container.sizeDelta = Vector2.zero;
			trackRing = CreateImage("Track", Color.white);
			staminaRing = CreateImage("Stamina", Color.white);
			extraRing = CreateImage("ExtraStamina", Color.white);
			centerPuck = CreateImage("Center", Color.white);
			staminaRing.type = (Type)3;
			staminaRing.fillMethod = (FillMethod)4;
			staminaRing.fillOrigin = 2;
			staminaRing.fillClockwise = true;
			extraRing.type = (Type)3;
			extraRing.fillMethod = (FillMethod)4;
			extraRing.fillOrigin = 0;
			extraRing.fillClockwise = false;
			centerPuck.type = (Type)0;
		}

		private Image CreateImage(string name, Color color)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_007b: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).SetParent((Transform)(object)container, false);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(64f, 64f);
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = color;
			((Graphic)component2).raycastTarget = false;
			return component2;
		}

		private void Update()
		{
			if ((Object)(object)canvas == (Object)null)
			{
				return;
			}
			if (!Plugin.Enabled.Value)
			{
				((Behaviour)canvas).enabled = false;
				return;
			}
			Character localCharacter = Character.localCharacter;
			GUIManager instance = GUIManager.instance;
			bool flag = (Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.data != (Object)null && localCharacter.refs != null && !localCharacter.data.dead && !localCharacter.data.fullyPassedOut && ((Object)(object)instance == (Object)null || !instance.windowBlockingInput);
			((Behaviour)canvas).enabled = flag;
			if (!flag)
			{
				displayStamina = 1f;
				displayAlpha = 1f;
				return;
			}
			EnsureSprites();
			try
			{
				UpdateReticle(localCharacter, instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				((Behaviour)canvas).enabled = false;
			}
		}

		private void UpdateReticle(Character character, GUIManager gui)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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)
			//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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(character.GetMaxStamina(), 0.0001f);
			float num2 = Mathf.Clamp01(character.data.currentStamina);
			float num3 = Mathf.Clamp01(num2 / num);
			float num4 = Mathf.Clamp01(character.data.extraStamina);
			float num5 = Time.deltaTime * 14f;
			displayStamina = Mathf.Lerp(displayStamina, num2, num5);
			float value = Plugin.LowStaminaThreshold.Value;
			Color val = ParseColor(Plugin.LowColor.Value, new Color(0.3f, 0.82f, 0.22f));
			Color val2 = ParseColor(Plugin.FullColor.Value, new Color(0.3f, 0.82f, 0.22f));
			Color val3 = ParseColor(Plugin.PuckColor.Value, new Color(0.92f, 1f, 0.9f));
			Color color = ParseColor(Plugin.TrackColor.Value, new Color(0f, 0f, 0f, 0.35f));
			Color color2 = ParseColor(Plugin.ExtraColor.Value, new Color(0.55f, 0.88f, 0.42f));
			float num6 = Mathf.InverseLerp(value * 0.5f, value * 1.5f, num3);
			Color color3 = Color.Lerp(val, val2, Mathf.SmoothStep(0f, 1f, num6));
			float num7 = ((Plugin.HideWhenFull.Value && num3 >= 0.999f) ? 0f : 1f);
			displayAlpha = Mathf.MoveTowards(displayAlpha, num7, Time.deltaTime * 3f);
			if (num3 < value && Plugin.PulseWhenLow.Value && !IsPhotosensitivityEnabled(gui))
			{
				pulseTime += Time.deltaTime;
				color3.a *= 0.72f + 0.28f * Mathf.Sin(pulseTime * 6f);
			}
			else
			{
				pulseTime = 0f;
			}
			color3.a *= displayAlpha;
			val3.a *= displayAlpha;
			color.a *= displayAlpha;
			((Graphic)trackRing).color = color;
			((Graphic)staminaRing).color = color3;
			staminaRing.fillAmount = displayStamina;
			((Graphic)centerPuck).color = color3;
			UpdateStatArcs(character, gui);
			bool flag = Plugin.ShowExtraStamina.Value && num4 > 0.01f;
			((Component)extraRing).gameObject.SetActive(flag);
			if (flag)
			{
				color2.a = displayAlpha;
				((Graphic)extraRing).color = color2;
				extraRing.fillAmount = num4;
			}
		}

		private void UpdateStatArcs(Character character, GUIManager gui)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.ShowStats.Value || (Object)(object)gui == (Object)null || (Object)(object)gui.bar == (Object)null)
			{
				HideStatArcs(0);
				return;
			}
			CharacterAfflictions afflictions = character.refs.afflictions;
			BarAffliction[] afflictions2 = gui.bar.afflictions;
			if ((Object)(object)afflictions == (Object)null || afflictions2 == null || afflictions2.Length == 0)
			{
				HideStatArcs(0);
				return;
			}
			EnsureStatArcs(afflictions2.Length);
			float num = Mathf.Clamp01(displayStamina);
			int num2 = 0;
			for (int i = 0; i < afflictions2.Length; i++)
			{
				if (num2 >= statArcs.Count)
				{
					break;
				}
				BarAffliction val = afflictions2[i];
				if ((Object)(object)val == (Object)null || (Object)(object)val.icon == (Object)null)
				{
					continue;
				}
				float num3 = (val.isPetrify ? Mathf.Clamp01((float)character.data.petrifyAmount / 100f) : Mathf.Clamp01(afflictions.GetCurrentStatus(val.afflictionType)));
				if (!(num3 <= 0.005f))
				{
					float num4 = 1f - num;
					if (num4 <= 0.0005f)
					{
						break;
					}
					float num5 = Mathf.Min(num3, num4);
					Image obj = statArcs[num2];
					num2++;
					((Component)obj).gameObject.SetActive(true);
					obj.fillAmount = num5;
					((Transform)((Graphic)obj).rectTransform).localEulerAngles = new Vector3(0f, 0f, (0f - num) * 360f);
					Color color = ((Graphic)val.icon).color;
					color.a = displayAlpha;
					((Graphic)obj).color = color;
					num += num5;
				}
			}
			HideStatArcs(num2);
		}

		private void HideStatArcs(int from)
		{
			for (int i = from; i < statArcs.Count; i++)
			{
				if ((Object)(object)statArcs[i] != (Object)null)
				{
					((Component)statArcs[i]).gameObject.SetActive(false);
				}
			}
		}

		private void EnsureStatArcs(int count)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			while (statArcs.Count < count)
			{
				Image val = CreateImage("Status" + statArcs.Count, Color.white);
				val.type = (Type)3;
				val.fillMethod = (FillMethod)4;
				val.fillOrigin = 2;
				val.fillClockwise = true;
				if ((Object)(object)ringSprite != (Object)null)
				{
					val.sprite = ringSprite;
				}
				if (cachedDiameter > 0f)
				{
					SetSize(((Graphic)val).rectTransform, cachedDiameter);
				}
				((Component)val).gameObject.SetActive(false);
				statArcs.Add(val);
			}
		}

		private void EnsureSprites()
		{
			float num = Mathf.Max(8f, Plugin.Diameter.Value);
			float num2 = Mathf.Max(1f, Plugin.Thickness.Value);
			float num3 = Mathf.Max(1f, Plugin.ExtraThickness.Value);
			if ((Object)(object)ringSprite != (Object)null && Mathf.Approximately(num, cachedDiameter) && Mathf.Approximately(num2, cachedThickness) && Mathf.Approximately(num3, cachedExtraThickness))
			{
				ApplyLayout(num, num3);
				return;
			}
			cachedDiameter = num;
			cachedThickness = num2;
			cachedExtraThickness = num3;
			DestroySprite(ref ringSprite);
			DestroySprite(ref extraSprite);
			DestroySprite(ref discSprite);
			float radius = 245.76f;
			float thickness = Mathf.Max(1f, num2 / num * 512f);
			ringSprite = CreateRingSprite(512, radius, thickness);
			extraSprite = CreateRingSprite(512, radius, ExtraRingThicknessPx(num3, num));
			discSprite = CreateDiscSprite(512);
			trackRing.sprite = ringSprite;
			staminaRing.sprite = ringSprite;
			extraRing.sprite = extraSprite;
			centerPuck.sprite = discSprite;
			foreach (Image statArc in statArcs)
			{
				if ((Object)(object)statArc != (Object)null)
				{
					statArc.sprite = ringSprite;
				}
			}
			ApplyLayout(num, num3);
		}

		private static float ExtraRingThicknessPx(float extraThickness, float diameter)
		{
			float num = diameter + 2f * (extraThickness + 4f);
			return Mathf.Max(1f, extraThickness / num * 512f);
		}

		private void ApplyLayout(float diameter, float extraThickness)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.height / 1080f;
			container.anchoredPosition = new Vector2(Plugin.OffsetX.Value * num, Plugin.OffsetY.Value * num);
			SetSize(((Graphic)trackRing).rectTransform, diameter);
			SetSize(((Graphic)staminaRing).rectTransform, diameter);
			foreach (Image statArc in statArcs)
			{
				if ((Object)(object)statArc != (Object)null)
				{
					SetSize(((Graphic)statArc).rectTransform, diameter);
				}
			}
			float size = diameter + 2f * (extraThickness + 4f);
			SetSize(((Graphic)extraRing).rectTransform, size);
			SetSize(((Graphic)centerPuck).rectTransform, Mathf.Max(2.5f, diameter * 0.075f));
		}

		private static void SetSize(RectTransform rect, float size)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			rect.sizeDelta = new Vector2(size, size);
		}

		private bool IsPhotosensitivityEnabled(GUIManager gui)
		{
			if ((Object)(object)gui != (Object)null)
			{
				return gui.photosensitivity;
			}
			return false;
		}

		private static Color ParseColor(string hex, Color fallback)
		{
			//IL_0019: 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)
			Color result = default(Color);
			if (!string.IsNullOrEmpty(hex) && ColorUtility.TryParseHtmlString(hex.Trim(), ref result))
			{
				return result;
			}
			return fallback;
		}

		private static void DestroySprite(ref Sprite sprite)
		{
			if (!((Object)(object)sprite == (Object)null))
			{
				Texture2D texture = sprite.texture;
				Object.Destroy((Object)(object)sprite);
				if ((Object)(object)texture != (Object)null)
				{
					Object.Destroy((Object)(object)texture);
				}
				sprite = null;
			}
		}

		private static Sprite CreateRingSprite(int size, float radius, float thickness)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			Color32[] array = (Color32[])(object)new Color32[size * size];
			float num = (float)(size - 1) * 0.5f;
			float num2 = thickness * 0.5f;
			float num3 = radius - num2;
			float num4 = radius + num2;
			for (int i = 0; i < size; i++)
			{
				float num5 = (float)i - num;
				for (int j = 0; j < size; j++)
				{
					float num6 = (float)j - num;
					float num7 = Mathf.Sqrt(num6 * num6 + num5 * num5);
					byte b = (byte)(Mathf.Clamp01(Mathf.Clamp01(num4 - num7 + 0.5f) * Mathf.Clamp01(num7 - num3 + 0.5f)) * 255f);
					array[i * size + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
		}

		private static Sprite CreateDiscSprite(int size)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			Color32[] array = (Color32[])(object)new Color32[size * size];
			float num = (float)(size - 1) * 0.5f;
			float num2 = num * 0.92f;
			for (int i = 0; i < size; i++)
			{
				float num3 = (float)i - num;
				for (int j = 0; j < size; j++)
				{
					float num4 = (float)j - num;
					float num5 = Mathf.Sqrt(num4 * num4 + num3 * num3);
					byte b = (byte)(Mathf.Clamp01(Mathf.Clamp01(num2 - num5 + 0.5f)) * 255f);
					array[i * size + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
		}
	}
}