plugins/AUU.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using ULTRAKILL.Portal;
using ULTRAKILL.Portal.Geometry;
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("AUU")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AUU")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51A6E9E2-CCF2-4A4D-A4EA-2A3A97C9C851")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AUU
{
	public static class AssetBundleUtils
	{
		private static Dictionary<string, AssetBundle> LoadedBundles = new Dictionary<string, AssetBundle>();

		private static AssetBundle LoadAssetBundleFromFile(string path)
		{
			AssetBundle val = AssetBundle.LoadFromFile(path);
			if ((Object)(object)val == (Object)null)
			{
				string text = "Failed to load Asset Bundle: " + path;
				MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("<color=red>" + text + "</color>", "", "", 0, false, false, true);
				return null;
			}
			return val;
		}

		public static AssetBundle LoadAssetBundle(string bundlePath, string bundleName)
		{
			string path = Path.Combine(bundlePath, bundleName);
			if (!LoadedBundles.ContainsKey(bundleName))
			{
				AssetBundle value = LoadAssetBundleFromFile(path);
				LoadedBundles.Add(bundleName, value);
			}
			return LoadedBundles[bundleName];
		}

		public static void UnloadAssetBundle(string key, bool removeFromList = true)
		{
			if (LoadedBundles.TryGetValue(key, out var value))
			{
				value.Unload(false);
				if (removeFromList)
				{
					LoadedBundles.Remove(key);
				}
			}
		}

		public static void UnloadAllAssetBundles()
		{
			foreach (KeyValuePair<string, AssetBundle> loadedBundle in LoadedBundles)
			{
				UnloadAssetBundle(loadedBundle.Key, removeFromList: false);
			}
			LoadedBundles.Clear();
		}
	}
	public static class BalancingManager
	{
		internal static readonly List<DisableRankReason> DisableRankReasons = new List<DisableRankReason>();

		public static DisableRankReason DisableRankSubmission(string reason, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(reason))
			{
				return null;
			}
			DisableRankReason disableRankReason = new DisableRankReason(reason, color);
			foreach (DisableRankReason disableRankReason2 in DisableRankReasons)
			{
				if (string.Equals(disableRankReason2.Reason, reason, StringComparison.Ordinal))
				{
					return null;
				}
			}
			DisableRankReasons.Add(disableRankReason);
			return disableRankReason;
		}

		public static void ReenableRankSubmission(DisableRankReason reason)
		{
			if (DisableRankReasons.Contains(reason))
			{
				DisableRankReasons.Remove(reason);
			}
		}
	}
	public class DisableRankReason
	{
		public Color TextColor;

		public string Reason;

		public DisableRankReason(string reason, Color textColor)
		{
			//IL_0010: 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)
			Reason = reason;
			TextColor = textColor;
		}

		public override string ToString()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return "<color=white>-</color> <color=#" + ColorUtility.ToHtmlStringRGB(TextColor) + ">" + Reason + "</color>\n";
		}
	}
	public static class EnemyUtils
	{
		public static readonly List<EnemyType> LightEnemies = new List<EnemyType>
		{
			(EnemyType)1,
			(EnemyType)3,
			(EnemyType)14,
			(EnemyType)15,
			(EnemyType)13,
			(EnemyType)6
		};

		public static readonly List<EnemyType> CorpseTypes = new List<EnemyType>
		{
			(EnemyType)1,
			(EnemyType)4,
			(EnemyType)5,
			(EnemyType)33,
			(EnemyType)9,
			(EnemyType)2
		};

		public static bool IsLightEnemy(EnemyType enemy)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return LightEnemies.Contains(enemy);
		}

		public static bool SpawnsUnhookableCorpse(EnemyType enemy)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return LightEnemies.Contains(enemy);
		}
	}
	[BepInPlugin("com.averyocean65.utils", "AUU", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static class PluginInfo
		{
			public const string GUID = "com.averyocean65.utils";

			public const string NAME = "AUU";

			public const string VERSION = "1.0.0";
		}

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("com.averyocean65.utils");
			val.PatchAll();
			SceneManager.sceneLoaded += delegate
			{
				BalancingManager.DisableRankReasons.Clear();
			};
		}
	}
	public static class SceneUtils
	{
		public static bool IsInLevel()
		{
			return SceneHelper.CurrentScene != "Intro" && SceneHelper.CurrentScene != "Main Menu";
		}
	}
}
namespace AUU.Portals
{
	public class PortalParameters
	{
		public bool AllowCameraTraversals = true;

		public bool CanSeeItself = true;

		public bool CanSeePortals = true;

		public bool ConsumeAudio = true;

		public bool CanHearAudio = true;

		public bool InfiniteRecursions = false;

		public bool AppearsInRecursions = true;

		public bool IsMirror = false;

		public int MaxRecursionCount = 3;

		public float MinimumEntrySpeed = 0f;

		public float MinimumExitSpeed = 0f;

		public Vector2 Size = Vector2.one;
	}
	public static class PortalSpawner
	{
		private const int PortalLayer = 30;

		public static Portal CreatePortal(string name, Transform entry, Transform exit, PortalParameters parameters)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_00b2: 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)
			GameObject val = new GameObject(name);
			val.gameObject.layer = 30;
			Portal val2 = val.AddComponent<Portal>();
			val2.entry = entry;
			val2.exit = exit;
			val2.allowCameraTraversals = parameters.AllowCameraTraversals;
			val2.canSeeItself = parameters.CanSeeItself;
			val2.canSeePortalLayer = parameters.CanSeePortals;
			val2.consumeAudio = parameters.ConsumeAudio;
			val2.canHearAudio = parameters.CanHearAudio;
			val2.supportInfiniteRecursion = parameters.InfiniteRecursions;
			val2.appearsInRecursions = parameters.AppearsInRecursions;
			val2.maxRecursions = parameters.MaxRecursionCount;
			val2.minimumEntrySideSpeed = parameters.MinimumEntrySpeed;
			val2.minimumExitSideSpeed = parameters.MinimumExitSpeed;
			val2.mirror = parameters.IsMirror;
			val2.shape = (IPortalShape)(object)new PlaneShape
			{
				width = parameters.Size.x,
				height = parameters.Size.y
			};
			return val2;
		}
	}
}
namespace AUU.Patches
{
	[HarmonyPatch]
	public static class LevelPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(FinalRank), "SetInfo")]
		private static void SetInfoPatch(ref FinalRank __instance, int restarts, bool damage, bool majorUsed, bool cheatsUsed)
		{
			foreach (DisableRankReason disableRankReason in BalancingManager.DisableRankReasons)
			{
				TMP_Text extraInfo = __instance.extraInfo;
				extraInfo.text += disableRankReason.ToString();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameProgressSaver), "SaveRank")]
		private static void SaveRankPatch(ref bool __runOriginal)
		{
			if (BalancingManager.DisableRankReasons.Count > 0)
			{
				__runOriginal = false;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(FinalCyberRank), "GameOver")]
		private static void GameOverPatch()
		{
			if (BalancingManager.DisableRankReasons.Count > 0)
			{
				MonoSingleton<StatsManager>.Instance.majorUsed = true;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")]
		private static void SubmitLevelScorePatch(ref bool __runOriginal)
		{
			if (BalancingManager.DisableRankReasons.Count > 0)
			{
				__runOriginal = false;
			}
		}
	}
}