Decompiled source of Custom Death Screens v1.0.3

customdeath.dll

Decompiled 3 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("customdeath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("customdeath")]
[assembly: AssemblyTitle("customdeath")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Ultrapit;

[BepInPlugin("CustomDeath.draghtnim.ultrakill", "CustomDeath", "1.0")]
public class Plugin : BaseUnityPlugin
{
	private AssetBundle terminal;

	public static bool IsCustomLevel = false;

	private Scene scene;

	private GameObject pitobj;

	private GameObject newpitobj;

	private AssetBundle bundlepit;

	private static Plugin _instance;

	private PluginConfigurator config;

	private static string assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	private static AssetBundle PitBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "CustomDeath0.resource"));

	private static AssetBundle PitBundleCustom = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "CustomDeath1.resource"));

	private static GameObject[] prefabsBuiltIn = PitBundle.LoadAllAssets<GameObject>();

	private static GameObject[] prefabsCustom = PitBundleCustom.LoadAllAssets<GameObject>();

	private static GameObject[] prefabs = prefabsBuiltIn.Union(prefabsCustom).ToArray();

	private int i = 0;

	public static BoolField[] Values = (BoolField[])(object)new BoolField[prefabs.Length];

	public static Plugin Instance => _instance;

	private async void Awake()
	{
		Harmony harmony = new Harmony("customDeath");
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)prefabsBuiltIn.Length);
		((BaseUnityPlugin)this).Logger.LogInfo((object)prefabsCustom.Length);
		((BaseUnityPlugin)this).Logger.LogInfo((object)prefabs.Length);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"  @@@@@                                       @@@@@  ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)" @@   @@@       @@@@@@@       @@@@@@@       @@@   @@ ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"@@     @@     @@@     @@     @@     @@@     @@     @@");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"@@     @@     @@       @@   @@       @@@    @@     @@");
		((BaseUnityPlugin)this).Logger.LogInfo((object)" @@   @@@    @@     @@@@@   @@     @@@@@    @@@   @@ ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"  @@@@@      @@   @@@  @@   @@  @@@   @@      @@@@   ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"             @@@@@     @@   @@@@@     @@             ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"              @@       @@   @@       @@              ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"              @@@     @@     @@     @@@              ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"                @@@@@@@       @@@@@@@                ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)" ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Prepare for a bunch of errors dont worry bout that");
		((BaseUnityPlugin)this).Logger.LogInfo((object)" ");
		_instance = this;
		config = PluginConfigurator.Create("Custom Death", "ConfigCustomDeath");
		config.SetIconWithURL(Path.Combine(assemblyLocation, "icon.png"));
		config.presetButtonHidden = true;
		GameObject[] array = prefabs;
		foreach (GameObject pref in array)
		{
			Values[this.i] = new BoolField(config.rootPanel, ((Object)pref).name, ((Object)pref).name, true);
			this.i++;
		}
		PitBundle.Unload(false);
		PitBundleCustom.Unload(false);
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		if (!(SceneHelper.CurrentScene != "Bootstrap"))
		{
			GameObject val = new GameObject();
			val.AddComponent<DeathSequence>();
		}
	}
}
[HarmonyPatch]
public class Deathpatch
{
	private static string assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	private static AssetBundle PitBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "CustomDeath0.resource"));

	private static AssetBundle PitBundleCustom = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "CustomDeath1.resource"));

	private static GameObject[] prefabsBuiltIn = PitBundle.LoadAllAssets<GameObject>();

	private static GameObject[] prefabsCustom = PitBundleCustom.LoadAllAssets<GameObject>();

	private static GameObject[] prefabs = prefabsBuiltIn.Union(prefabsCustom).ToArray();

	[HarmonyPatch(typeof(DeathSequence), "OnDisable")]
	[HarmonyPostfix]
	public static void OnDisablePatch(DeathSequence __instance)
	{
		MonoSingleton<TimeController>.instance.RestoreTime();
	}

	[HarmonyPatch(typeof(DeathSequence), "Update")]
	[HarmonyPrefix]
	public static void DeathPatch(DeathSequence __instance)
	{
		if (((Object)((Component)__instance).transform.parent).name == "Canvas" && ((Component)__instance).transform.childCount < 2)
		{
			List<GameObject> list = prefabs.ToList();
			__instance.EndSequence();
			__instance.deathScreen.SetActive(false);
			((Behaviour)((Component)__instance).GetComponent<AudioSource>()).enabled = false;
			((Component)((Component)__instance).transform.GetChild(0)).gameObject.SetActive(false);
			__instance.sequenceOver = true;
			for (int num = Plugin.Values.Length - 1; num >= 0; num--)
			{
				if (!Plugin.Values[num].value)
				{
					list.RemoveAt(num);
				}
			}
			Debug.LogWarning((object)("okay the path is: " + assemblyLocation));
			int index = Random.Range(0, list.Count);
			GameObject val = list[index];
			Debug.LogWarning((object)"your random gameobject");
			Debug.LogWarning((object)((Object)val).name);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			val2.transform.parent = ((Component)__instance).transform;
			val2.AddComponent<DestroyOnCheckpointRestart>();
			if (Object.op_Implicit((Object)(object)((Component)((Component)__instance).transform.GetChild(1)).GetComponent<SpeedWeed>()))
			{
				MonoSingleton<TimeController>.instance.HitStop(6666f);
			}
		}
		if (!(SceneHelper.CurrentScene != "Bootstrap"))
		{
		}
	}
}