Decompiled source of ULTRASKID v1.0.0

ULTRASKID/ULTRASKID.dll

Decompiled 3 weeks 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 BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ULTRASKID")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ULTRASKID")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ebc4f568-d5f3-41db-8a59-b64e8a5a0eef")]
[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")]
namespace ULTRASKID;

[BepInPlugin("gdnick.ultraskid", "ULTRASKID", "1.1.0")]
[BepInProcess("ULTRAKILL.exe")]
public class USKID : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Gabriel), "Start")]
	internal class Patch_GabrielLogic
	{
		private static void Postfix(Gabriel __instance)
		{
			Traverse obj = Traverse.Create((object)__instance);
			obj.Field("intro1").SetValue((object)LoadAudio("Gab_1intro_ULTRASKID.wav"));
			obj.Field("intro2").SetValue((object)LoadAudio("Gab_2intro_ULTRASKID.wav"));
			obj.Field("intro3").SetValue((object)LoadAudio("Gab_BEHOLD_ULTRASKID.wav"));
			obj.Field("death").SetValue((object)LoadAudio("Gab_DEATH_ULTRASKID.wav"));
			obj.Field("teleportOut").SetValue((object)LoadAudio("Gab_teleporting_away_ULTRASKID.wav"));
			obj.Field("enough").SetValue((object)LoadAudio("Gav_ENOUGH_ULTRASKID.wav"));
		}
	}

	[HarmonyPatch(typeof(GabrielVoice), "Start")]
	internal class Patch_GabrielVoice
	{
		private static void Postfix(GabrielVoice __instance)
		{
			if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<Gabriel>()))
			{
				Traverse val = Traverse.Create((object)__instance);
				AudioClip[] array = (AudioClip[])(object)new AudioClip[12];
				string[] array2 = new string[12];
				for (int i = 0; i < 12; i++)
				{
					array[i] = LoadAudio($"Gab_taunt{i + 1}_ULTRASKID.wav");
					array2[i] = "...";
				}
				__instance.taunt = array;
				__instance.tauntSecondPhase = array;
				val.Field("taunts").SetValue((object)array2);
				val.Field("tauntsSecondPhase").SetValue((object)array2);
				AudioClip[] array3 = (AudioClip[])(object)new AudioClip[4];
				for (int j = 0; j < 4; j++)
				{
					array3[j] = LoadAudio($"Gab_hurt{j + 1}_ULTRASKID.wav");
				}
				__instance.hurt = array3;
				__instance.phaseChange = LoadAudio("Gav_ENOUGH_ULTRASKID.wav");
			}
		}
	}

	[HarmonyPatch(typeof(MinosPrime), "Start")]
	internal class Patch_MinosCombat
	{
		private static void Postfix(MinosPrime __instance)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			__instance.dropkickVoice = (AudioClip[])(object)new AudioClip[1] { LoadAudio("judgement.ogg") };
			__instance.comboVoice = (AudioClip[])(object)new AudioClip[1] { LoadAudio("prepare.ogg") };
			__instance.boxingVoice = (AudioClip[])(object)new AudioClip[1] { LoadAudio("thyend.ogg") };
			__instance.riderKickVoice = (AudioClip[])(object)new AudioClip[1] { LoadAudio("diee.ogg") };
			__instance.dropAttackVoice = (AudioClip[])(object)new AudioClip[1] { LoadAudio("crush.ogg") };
			__instance.phaseChangeVoice = LoadAudio("useless.ogg");
			try
			{
				Renderer component = ((Component)((Component)__instance).transform.Find("Model").Find("MinosPrime_Body.001")).GetComponent<Renderer>();
				Material val = new Material(component.material);
				Texture2D val2 = LoadTexture("ChoPrime.png");
				if ((Object)(object)val2 != (Object)null)
				{
					val.mainTexture = (Texture)(object)val2;
					component.sharedMaterial = val;
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed Minos texture: " + ex.Message));
			}
		}
	}

	[HarmonyPatch(typeof(SisyphusPrime), "Start")]
	internal class Patch_SisyphusCombat
	{
		private static void Postfix(SisyphusPrime __instance)
		{
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			__instance.clapVoice = (AudioClip[])(object)new AudioClip[2]
			{
				LoadAudio("Sp_begone.mp3"),
				LoadAudio("Sp_begone2.mp3")
			};
			__instance.explosionVoice = (AudioClip[])(object)new AudioClip[1] { LoadAudio("Sp_thiswillhurt.mp3") };
			__instance.tauntVoice = (AudioClip[])(object)new AudioClip[2]
			{
				LoadAudio("Sp_nicetry.mp3"),
				LoadAudio("Sp_nicetry2.mp3")
			};
			__instance.stompComboVoice = (AudioClip[])(object)new AudioClip[2]
			{
				LoadAudio("Sp_youcantescape.mp3"),
				LoadAudio("Sp_youcantescape2.mp3")
			};
			__instance.uppercutComboVoice = (AudioClip[])(object)new AudioClip[2]
			{
				LoadAudio("Sp_destroy.mp3"),
				LoadAudio("Sp_destroy2.mp3")
			};
			__instance.phaseChangeVoice = LoadAudio("Sp_yesthatsit.mp3");
			try
			{
				Transform obj = ((Component)__instance).transform.Find("Sisyphus (1)");
				Transform val = obj.Find("Sisyphus_Head");
				Transform val2 = obj.Find("Sisyphus_Hair");
				Transform val3 = obj.Find("Sisyphus_Beard");
				Texture2D val4 = LoadTexture("SkidFace.png");
				if (!((Object)(object)val4 != (Object)null))
				{
					return;
				}
				ChangeMaterials component = ((Component)val).GetComponent<ChangeMaterials>();
				if ((Object)(object)component != (Object)null)
				{
					for (int i = 0; i < component.materials.Length; i++)
					{
						Material val5 = new Material(component.materials[i]);
						val5.mainTexture = (Texture)(object)val4;
						component.materials[i] = val5;
					}
				}
				Renderer component2 = ((Component)val).GetComponent<Renderer>();
				Material val6 = new Material(component2.material);
				val6.mainTexture = (Texture)(object)val4;
				component2.sharedMaterial = val6;
				if ((Object)(object)val3 != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val3).gameObject);
				}
				if ((Object)(object)val2 != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed Sisyphus texture: " + ex.Message));
			}
		}
	}

	[HarmonyPatch(typeof(StockMapInfo), "Awake")]
	internal class Patch_GlobalScanner
	{
		private static void Postfix()
		{
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
			foreach (AudioSource val in array)
			{
				if (!((Object)(object)val.clip == (Object)null))
				{
					switch (((Object)val.clip).name)
					{
					case "mp_intro2":
						val.clip = LoadAudio("intro.ogg");
						break;
					case "mp_outro":
						val.clip = LoadAudio("outro.ogg");
						break;
					case "mp_deathscream":
						val.clip = LoadAudio("death.ogg");
						break;
					case "sp_thisprison":
						val.clip = LoadAudio("SP_thisAEK.mp3");
						break;
					case "sp_intro":
						val.clip = LoadAudio("Sp_intro.mp3");
						break;
					case "sp_outro":
						val.clip = LoadAudio("Ps_outro.mp3");
						break;
					case "sp_keepthemcoming":
						val.clip = LoadAudio("Ps_keepthemcoming.mp3");
						break;
					case "gab_Intro1d":
						val.clip = LoadAudio("Gab_1intro_ULTRASKID.wav");
						break;
					case "gab_Intro2b":
						val.clip = LoadAudio("Gab_2intro_ULTRASKID.wav");
						break;
					case "gab_Behold":
						val.clip = LoadAudio("Gab_BEHOLD_ULTRASKID.wav");
						break;
					case "gab_Insignificant2b":
						val.clip = LoadAudio("Gab_DEATH_ULTRASKID.wav");
						break;
					case "gab_enough":
						val.clip = LoadAudio("Gav_ENOUGH_ULTRASKID.wav");
						break;
					case "gab_Woes":
						val.clip = LoadAudio("Gab_teleporting_away_ULTRASKID.wav");
						break;
					}
				}
			}
			SkinnedMeshRenderer[] array2 = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val2 in array2)
			{
				if (((Object)((Component)val2).gameObject).name == "MinosPrime_Body.001")
				{
					Texture2D val3 = LoadTexture("ChoPrime.png");
					if ((Object)(object)val3 != (Object)null)
					{
						Material val4 = new Material(((Renderer)val2).material);
						val4.mainTexture = (Texture)(object)val3;
						((Renderer)val2).sharedMaterial = val4;
					}
				}
				if (((Object)((Component)val2).gameObject).name == "Sisyphus_Head")
				{
					Texture2D val5 = LoadTexture("SkidFace.png");
					if ((Object)(object)val5 != (Object)null)
					{
						Material val6 = new Material(((Renderer)val2).material);
						val6.mainTexture = (Texture)(object)val5;
						((Renderer)val2).sharedMaterial = val6;
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Graphic), "OnEnable")]
	internal class Patch_LogoInterceptor
	{
		private static void Postfix(Graphic __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null)
			{
				return;
			}
			switch (((Object)((Component)__instance).gameObject).name)
			{
			case "Logo":
			case "TextmodeLogo":
			case "Main Logo":
			{
				Image val = (Image)(object)((__instance is Image) ? __instance : null);
				if (val != null)
				{
					val.sprite = LoadLogoSprite();
					break;
				}
				RawImage val2 = (RawImage)(object)((__instance is RawImage) ? __instance : null);
				if (val2 != null)
				{
					Sprite val3 = LoadLogoSprite();
					if ((Object)(object)val3 != (Object)null)
					{
						val2.texture = (Texture)(object)val3.texture;
					}
				}
				break;
			}
			}
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class Patch_AudioClipSetter
	{
		private static void Prefix(AudioSource __instance, ref AudioClip value)
		{
			if (!((Object)(object)value == (Object)null))
			{
				switch (((Object)value).name)
				{
				case "mp_intro2":
					value = LoadAudio("intro.ogg");
					break;
				case "mp_outro":
					value = LoadAudio("outro.ogg");
					break;
				case "mp_deathscream":
					value = LoadAudio("death.ogg");
					break;
				case "sp_thisprison":
					value = LoadAudio("SP_thisAEK.mp3");
					break;
				case "sp_intro":
					value = LoadAudio("Sp_intro.mp3");
					break;
				case "sp_outro":
					value = LoadAudio("Ps_outro.mp3");
					break;
				case "sp_keepthemcoming":
					value = LoadAudio("Ps_keepthemcoming.mp3");
					break;
				case "sp_deathscream":
					value = LoadAudio("Sp_gurt.mp3");
					break;
				case "gab_Intro1d":
					value = LoadAudio("Gab_1intro_ULTRASKID.wav");
					break;
				case "gab_Intro2b":
					value = LoadAudio("Gab_2intro_ULTRASKID.wav");
					break;
				case "gab_Behold":
					value = LoadAudio("Gab_BEHOLD_ULTRASKID.wav");
					break;
				case "gab_Insignificant2b":
					value = LoadAudio("Gab_DEATH_ULTRASKID.wav");
					break;
				case "gab_enough":
					value = LoadAudio("Gav_ENOUGH_ULTRASKID.wav");
					break;
				case "gab_Woes":
					value = LoadAudio("Gab_teleporting_away_ULTRASKID.wav");
					break;
				}
			}
		}
	}

	[HarmonyPatch(typeof(BossHealthBar), "Awake")]
	internal class Patch_BossBar
	{
		private static void Prefix(BossHealthBar __instance)
		{
			if (__instance.bossName.Contains("MINOS"))
			{
				__instance.bossName = "VELIKIY CHO PRIME";
			}
			if (__instance.bossName.Contains("SISYPHUS"))
			{
				__instance.bossName = "SKIDICH PRIME";
			}
			if (__instance.bossName.Contains("GABRIEL"))
			{
				__instance.bossName = "KOSTYA, CREATOR OF AEK";
			}
		}
	}

	[HarmonyPatch(typeof(LevelNamePopup), "Start")]
	internal class Patch_LevelNames
	{
		private static void Postfix(LevelNamePopup __instance)
		{
			Traverse val = Traverse.Create((object)__instance).Field("nameString");
			if (val.GetValue() is string text)
			{
				if (text.Contains("SOUL SURVIVOR"))
				{
					val.SetValue((object)"GREAT GRAVE");
				}
				if (text.Contains("WAIT OF THE WORLD"))
				{
					val.SetValue((object)"I WON'T BE SAD");
				}
			}
		}
	}

	private static Harmony harmony;

	internal static ManualLogSource Log;

	private static Dictionary<string, AudioClip> cachedClips = new Dictionary<string, AudioClip>();

	private static Sprite cachedLogo;

	internal static string ModPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static string DataFolder => Path.Combine(ModPath, "data");

	private void Awake()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"--- ULTRASKID INITIALIZING ---");
		harmony = new Harmony("gdnick.ultraskid");
		try
		{
			Type type = AccessTools.TypeByName("LevelSelectPanel");
			if (type != null)
			{
				MethodInfo method = type.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method != null)
				{
					harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(USKID), "Manual_MenuLevelNames_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}
		catch
		{
		}
		harmony.PatchAll();
		Log.LogInfo((object)"--- ULTRASKID READY ---");
	}

	public static AudioClip LoadAudio(string fileName)
	{
		//IL_0031: 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_0069: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Invalid comparison between Unknown and I4
		if (cachedClips.ContainsKey(fileName))
		{
			return cachedClips[fileName];
		}
		string text = Path.Combine(DataFolder, fileName);
		if (!File.Exists(text))
		{
			return null;
		}
		AudioType val = (AudioType)14;
		if (fileName.ToLower().EndsWith(".mp3"))
		{
			val = (AudioType)13;
		}
		else if (fileName.ToLower().EndsWith(".wav"))
		{
			val = (AudioType)20;
		}
		UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, val);
		try
		{
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			if ((int)audioClip.result != 1)
			{
				return null;
			}
			AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
			((Object)content).name = fileName;
			cachedClips[fileName] = content;
			return content;
		}
		finally
		{
			((IDisposable)audioClip)?.Dispose();
		}
	}

	public static Sprite LoadLogoSprite()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_005e: 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)
		if ((Object)(object)cachedLogo != (Object)null)
		{
			return cachedLogo;
		}
		string path = Path.Combine(DataFolder, "MenuLogo.png");
		if (!File.Exists(path))
		{
			return null;
		}
		byte[] array = File.ReadAllBytes(path);
		Texture2D val = new Texture2D(2, 2);
		if (ImageConversion.LoadImage(val, array))
		{
			cachedLogo = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			return cachedLogo;
		}
		return null;
	}

	public static Texture2D LoadTexture(string fileName)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		string path = Path.Combine(DataFolder, fileName);
		if (!File.Exists(path))
		{
			return null;
		}
		byte[] array = File.ReadAllBytes(path);
		Texture2D val = new Texture2D(2, 2);
		if (ImageConversion.LoadImage(val, array))
		{
			return val;
		}
		return null;
	}

	public static void Manual_MenuLevelNames_Postfix(Component __instance)
	{
		Component[] componentsInChildren = __instance.GetComponentsInChildren<Component>(true);
		foreach (Component val in componentsInChildren)
		{
			if (!((Object)(object)val == (Object)null) && ((object)val).GetType().Name.Contains("TextMeshPro"))
			{
				Traverse val2 = Traverse.Create((object)val).Property("text", (object[])null);
				string text = val2.GetValue() as string;
				if (text == "SOUL SURVIVOR")
				{
					val2.SetValue((object)"GREAT GRAVE");
				}
				else if (text == "WAIT OF THE WORLD")
				{
					val2.SetValue((object)"I WON'T BE SAD");
				}
			}
		}
	}
}