Decompiled source of AllSeeingGod v1.0.4

AllSeeingGod.dll

Decompiled 3 hours 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("AllSeeingGod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("AllSeeingGod")]
[assembly: AssemblyTitle("AllSeeingGod")]
[assembly: AssemblyVersion("1.0.4.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 REPOAllSeeingGod
{
	[BepInPlugin("cn.codex.REPO.AllSeeingGod", "All Seeing God / 全知无敌", "1.0.4")]
	[BepInProcess("REPO.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "cn.codex.REPO.AllSeeingGod";

		public const string Name = "All Seeing God / 全知无敌";

		public const string Version = "1.0.4";

		private const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private const BindingFlags AnyStatic = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		internal static Plugin Instance;

		private Harmony harmony;

		private ConfigEntry<bool> godMode;

		private ConfigEntry<int> maxHealth;

		private ConfigEntry<float> staminaLimit;

		private ConfigEntry<bool> alwaysShowMap;

		private ConfigEntry<bool> showEnemies;

		private ConfigEntry<bool> showValuables;

		private ConfigEntry<float> mapWidth;

		private ConfigEntry<float> mapHeight;

		private ConfigEntry<float> mapZoom;

		private ConfigEntry<float> mapOpacity;

		private ConfigEntry<KeyCode> toggleKey;

		private Type playerHealthType;

		private Type playerControllerType;

		private Type enemyRigidbodyType;

		private Type valuableObjectType;

		private Type mapType;

		private Type mapCustomType;

		private Camera mapCamera;

		private RenderTexture mapTexture;

		private object lastMapInstance;

		private object cachedLocalHealth;

		private object cachedController;

		private int initializedControllerId;

		private float nextScan;

		private bool mapVisible = true;

		private string healthStatus = "等待 PlayerHealth...";

		private float nextMissingHealthLog;

		private Sprite enemySprite;

		private readonly HashSet<int> registeredValuables = new HashSet<int>();

		private readonly HashSet<int> diagnosedHealthObjects = new HashSet<int>();

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			BindConfig();
			ResolveTypes();
			harmony = new Harmony("cn.codex.REPO.AllSeeingGod");
			PatchPlayerHealth();
			enemySprite = CreateCircleSprite(16);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"All Seeing God / 全知无敌 1.0.4 loaded; persistent runner enabled");
		}

		private void BindConfig()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			godMode = ((BaseUnityPlugin)this).Config.Bind<bool>("01-人物", "无敌", true, "阻止本地玩家受到伤害,并持续恢复为满血。");
			maxHealth = ((BaseUnityPlugin)this).Config.Bind<int>("01-人物", "生命上限", 500, new ConfigDescription("本地玩家生命上限。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100000), Array.Empty<object>()));
			staminaLimit = ((BaseUnityPlugin)this).Config.Bind<float>("01-人物", "体力上限", 100f, new ConfigDescription("默认体力约为 40;建议 80-200。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10000f), Array.Empty<object>()));
			alwaysShowMap = ((BaseUnityPlugin)this).Config.Bind<bool>("02-地图", "常显地图", true, "无需按 Tab,在屏幕上常驻显示原生地图。");
			showEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("02-地图", "显示怪物", true, "在地图上用红点标记怪物。");
			showValuables = ((BaseUnityPlugin)this).Config.Bind<bool>("02-地图", "显示宝物", true, "在地图上显示所有宝物。");
			mapWidth = ((BaseUnityPlugin)this).Config.Bind<float>("03-外观", "地图宽度", 360f, new ConfigDescription("像素。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(160f, 900f), Array.Empty<object>()));
			mapHeight = ((BaseUnityPlugin)this).Config.Bind<float>("03-外观", "地图高度", 300f, new ConfigDescription("像素。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(120f, 700f), Array.Empty<object>()));
			mapZoom = ((BaseUnityPlugin)this).Config.Bind<float>("03-外观", "地图缩放", 2.25f, new ConfigDescription("数值越大,显示范围越广。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 12f), Array.Empty<object>()));
			mapOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("03-外观", "地图透明度", 0.9f, new ConfigDescription("0.1-1。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("03-外观", "地图开关键", (KeyCode)289, "临时显示/隐藏常驻地图。");
		}

		private void ResolveTypes()
		{
			playerHealthType = GameType("PlayerHealth");
			playerControllerType = GameType("PlayerController");
			enemyRigidbodyType = GameType("EnemyRigidbody");
			valuableObjectType = GameType("ValuableObject");
			mapType = GameType("Map");
			mapCustomType = GameType("MapCustom");
		}

		private static Type GameType(string name)
		{
			return Type.GetType(name + ", Assembly-CSharp", throwOnError: false);
		}

		private void PatchPlayerHealth()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			if (playerHealthType == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"PlayerHealth type not found; health protection will retry by refill only.");
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(Plugin), "HurtPrefix", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "HealthPostfix", (Type[])null, (Type[])null);
			int num = 0;
			MethodInfo[] methods = playerHealthType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo3 in methods)
			{
				if (methodInfo3.Name == "Hurt" || methodInfo3.Name == "HurtOther")
				{
					harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					num++;
				}
			}
			MethodInfo methodInfo4 = AccessTools.Method(playerHealthType, "Start", (Type[])null, (Type[])null);
			MethodInfo methodInfo5 = AccessTools.Method(playerHealthType, "Update", (Type[])null, (Type[])null);
			if (methodInfo4 != null)
			{
				harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			if (methodInfo5 != null)
			{
				harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("PlayerHealth patches installed: damage=" + num + ", start=" + (methodInfo4 != null) + ", update=" + (methodInfo5 != null)));
		}

		private static bool HurtPrefix(object __instance)
		{
			Plugin instance = Instance;
			if ((Object)(object)instance == (Object)null || !instance.godMode.Value)
			{
				return true;
			}
			return false;
		}

		private static void HealthPostfix(object __instance)
		{
			Plugin instance = Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.ApplyHealthTo(__instance);
			}
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(toggleKey.Value))
			{
				mapVisible = !mapVisible;
			}
			try
			{
				ApplyPlayerStats();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Player stat update failed: " + ex));
			}
			if (Time.unscaledTime >= nextScan)
			{
				nextScan = Time.unscaledTime + 0.35f;
				try
				{
					RefreshMap();
				}
				catch (Exception ex2)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Map update failed: " + ex2));
				}
			}
		}

		private void ApplyPlayerStats()
		{
			if (playerHealthType != null && !IsAliveComponent(cachedLocalHealth))
			{
				cachedLocalHealth = FindAnyPlayerHealth();
			}
			if (cachedLocalHealth != null)
			{
				ApplyHealthTo(cachedLocalHealth);
			}
			else if (playerHealthType != null && Time.unscaledTime >= nextMissingHealthLog)
			{
				nextMissingHealthLog = Time.unscaledTime + 5f;
				healthStatus = "未找到 PlayerHealth";
				((BaseUnityPlugin)this).Logger.LogWarning((object)"No active PlayerHealth found yet. Enter a playable level and check again.");
			}
			if (playerControllerType == null)
			{
				return;
			}
			if (!IsAliveComponent(cachedController))
			{
				cachedController = GetSingleton(playerControllerType, "instance") ?? FindFirst(playerControllerType);
				initializedControllerId = 0;
			}
			object obj = cachedController;
			Component val = (Component)((obj is Component) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool flag = false;
			string[] array = new string[5] { "EnergyMax", "energyMax", "maxEnergy", "EnergyStart", "energyStart" };
			foreach (string name in array)
			{
				flag |= SetNumeric(cachedController, name, staminaLimit.Value);
			}
			int instanceID = ((Object)val).GetInstanceID();
			if (initializedControllerId != instanceID)
			{
				SetNumeric(cachedController, "EnergyCurrent", staminaLimit.Value);
				SetNumeric(cachedController, "energyCurrent", staminaLimit.Value);
				initializedControllerId = instanceID;
				if (!flag)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"No stamina max field exposed; applied one-time high stamina reserve fallback.");
				}
			}
		}

		private void ApplyHealthTo(object healthObject)
		{
			Component val = (Component)((healthObject is Component) ? healthObject : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool flag = SetNumeric(healthObject, "maxHealth", maxHealth.Value);
			bool flag2 = !godMode.Value || SetNumeric(healthObject, "health", maxHealth.Value);
			bool flag3 = SetBoolean(healthObject, "godMode", godMode.Value);
			int instanceID = ((Object)val).GetInstanceID();
			if (diagnosedHealthObjects.Add(instanceID))
			{
				object member = GetMember(healthObject, "health");
				object member2 = GetMember(healthObject, "maxHealth");
				healthStatus = "HP " + member?.ToString() + "/" + member2?.ToString() + "  God=" + (GetMember(healthObject, "godMode") ?? ((object)godMode.Value));
				if (flag && flag2)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Health applied to " + ((Object)val.gameObject).name + ": health=" + member?.ToString() + "/" + member2?.ToString() + ", nativeGodModeField=" + flag3));
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Health fields not compatible. maxHealthFound=" + flag + ", healthFound=" + flag2 + ". Available fields: " + string.Join(", ", GetFieldNames(healthObject.GetType()))));
				}
			}
		}

		private void RefreshMap()
		{
			object obj = GetSingleton(mapType, "Instance") ?? GetSingleton(mapType, "instance");
			if (obj == null)
			{
				return;
			}
			if (lastMapInstance != obj)
			{
				lastMapInstance = obj;
				registeredValuables.Clear();
				mapCamera = null;
				mapTexture = null;
			}
			if (alwaysShowMap.Value)
			{
				Invoke(obj, "ActiveSet", true);
			}
			FindMapCamera();
			if ((Object)(object)mapCamera != (Object)null)
			{
				mapCamera.orthographicSize = mapZoom.Value;
				if ((Object)(object)mapCamera.activeTexture != (Object)null)
				{
					mapTexture = mapCamera.activeTexture;
				}
			}
			if (showValuables.Value)
			{
				RegisterValuables(obj);
			}
			if (showEnemies.Value)
			{
				RegisterEnemies();
			}
		}

		private void FindMapCamera()
		{
			if ((Object)(object)mapCamera != (Object)null)
			{
				return;
			}
			Camera[] array = Resources.FindObjectsOfTypeAll<Camera>();
			foreach (Camera val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name == "Dirt Finder Map Camera")
				{
					mapCamera = val;
					break;
				}
			}
		}

		private void RegisterValuables(object map)
		{
			if (valuableObjectType == null)
			{
				return;
			}
			Object[] array = Object.FindObjectsOfType(valuableObjectType);
			foreach (Object val in array)
			{
				if (!(val == (Object)null) && registeredValuables.Add(val.GetInstanceID()))
				{
					Invoke(map, "AddValuable", val);
				}
			}
		}

		private void RegisterEnemies()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (enemyRigidbodyType == null || mapCustomType == null)
			{
				return;
			}
			Object[] array = Object.FindObjectsOfType(enemyRigidbodyType);
			foreach (Object obj in array)
			{
				Component val = (Component)(object)((obj is Component) ? obj : null);
				if (!((Object)(object)val == (Object)null) && val.gameObject.activeInHierarchy)
				{
					Component val2 = val.GetComponent(mapCustomType);
					if ((Object)(object)val2 == (Object)null)
					{
						val2 = val.gameObject.AddComponent(mapCustomType);
					}
					SetMember(val2, "sprite", enemySprite);
					SetMember(val2, "color", Color.red);
				}
			}
		}

		private void OnGUI()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0110: 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)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			GUI.depth = -10000;
			Color color = GUI.color;
			GUI.color = new Color(0.1f, 0.85f, 0.25f, 1f);
			GUI.Box(new Rect(14f, 14f, 330f, 26f), "All Seeing God v1.0.4 | " + healthStatus);
			GUI.color = color;
			if (alwaysShowMap.Value && mapVisible && !((Object)(object)mapTexture == (Object)null))
			{
				float value = mapWidth.Value;
				float value2 = mapHeight.Value;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)Screen.width - value - 16f, 32f, value, value2);
				Color color2 = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, mapOpacity.Value);
				GUI.DrawTexture(val, (Texture)(object)mapTexture, (ScaleMode)0, false);
				GUI.color = color2;
				GUI.Box(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + value2 + 3f, value, 24f), "红色=怪物   黄色/原生图标=宝物   [" + ((object)toggleKey.Value/*cast due to .constrained prefix*/).ToString() + "] 隐藏地图");
			}
		}

		private object FindAnyPlayerHealth()
		{
			object obj = GetSingleton(playerHealthType, "instance") ?? GetSingleton(playerHealthType, "Instance");
			if (IsAliveComponent(obj))
			{
				return obj;
			}
			Object[] array = Object.FindObjectsOfType(playerHealthType);
			if (array.Length == 0)
			{
				return null;
			}
			return array[0];
		}

		private bool IsLocalPlayerHealth(object health)
		{
			if (!IsAliveComponent(health))
			{
				return false;
			}
			object member = GetMember(health, "isMenuAvatar");
			if (member is bool && (bool)member)
			{
				return false;
			}
			object member2 = GetMember(GetMember(health, "photonView"), "IsMine");
			if (member2 is bool)
			{
				return (bool)member2;
			}
			return true;
		}

		private static bool IsAliveComponent(object value)
		{
			Component val = (Component)((value is Component) ? value : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null)
			{
				return val.gameObject.activeInHierarchy;
			}
			return false;
		}

		private static object FindFirst(Type type)
		{
			if (type == null)
			{
				return null;
			}
			Object[] array = Object.FindObjectsOfType(type);
			if (array.Length == 0)
			{
				return null;
			}
			return array[0];
		}

		private static object GetSingleton(Type type, string name)
		{
			if (type == null)
			{
				return null;
			}
			FieldInfo field = type.GetField(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(null);
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(property != null))
			{
				return null;
			}
			return property.GetValue(null, null);
		}

		private static object GetMember(object target, string name)
		{
			if (target == null)
			{
				return null;
			}
			Type type = target.GetType();
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(target);
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(property != null))
			{
				return null;
			}
			return property.GetValue(target, null);
		}

		private static void SetMember(object target, string name, object value)
		{
			if (target == null)
			{
				return;
			}
			Type type = target.GetType();
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(target, value);
				return;
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.CanWrite)
			{
				property.SetValue(target, value, null);
			}
		}

		private static bool SetNumeric(object target, string name, object value)
		{
			if (target == null)
			{
				return false;
			}
			FieldInfo field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(target, Convert.ChangeType(value, field.FieldType));
				return true;
			}
			PropertyInfo property = target.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.CanWrite)
			{
				property.SetValue(target, Convert.ChangeType(value, property.PropertyType), null);
				return true;
			}
			return false;
		}

		private static bool SetBoolean(object target, string name, bool value)
		{
			if (target == null)
			{
				return false;
			}
			FieldInfo field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && field.FieldType == typeof(bool))
			{
				field.SetValue(target, value);
				return true;
			}
			PropertyInfo property = target.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.CanWrite && property.PropertyType == typeof(bool))
			{
				property.SetValue(target, value, null);
				return true;
			}
			return false;
		}

		private static string[] GetFieldNames(Type type)
		{
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			string[] array = new string[fields.Length];
			for (int i = 0; i < fields.Length; i++)
			{
				array[i] = fields[i].Name;
			}
			return array;
		}

		private static object Invoke(object target, string name, params object[] args)
		{
			if (target == null)
			{
				return null;
			}
			MethodInfo methodInfo = AccessTools.Method(target.GetType(), name, (Type[])null, (Type[])null);
			if (!(methodInfo != null))
			{
				return null;
			}
			return methodInfo.Invoke(target, args);
		}

		private static Sprite CreateCircleSprite(int size)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[size * size];
			float num = (float)(size - 1) * 0.5f;
			float num2 = num * num;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = (float)j - num;
					float num4 = (float)i - num;
					array[i * size + j] = ((num3 * num3 + num4 * num4 <= num2) ? Color.white : Color.clear);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f));
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}