Decompiled source of THERESNOTHINGLEFT v1.1.0

THERESNOTHINGLEFT.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[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("THERESNOTHINGLEFT")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("THERESNOTHINGLEFT")]
[assembly: AssemblyTitle("THERESNOTHINGLEFT")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 THERESNOTHINGLEFT
{
	[BepInPlugin("doomahreal.ultrakill.theresnothingleft", "THERESNOTHINGLEFT", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private AssetBundle _bundle;

		private Texture2D _surpriseTex;

		private AudioClip _reconstructClip;

		private void Awake()
		{
			LoadEmbeddedBundle();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			AssetBundle bundle = _bundle;
			if (bundle != null)
			{
				bundle.Unload(false);
			}
		}

		private void LoadEmbeddedBundle()
		{
			using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("THERESNOTHINGLEFT.chickenbutt.bundle");
			if (stream != null)
			{
				_bundle = AssetBundle.LoadFromStream(stream);
				if (!((Object)(object)_bundle == (Object)null))
				{
					_surpriseTex = _bundle.LoadAsset<Texture2D>("Assets/Custom/chickenbutt/suprise.png");
					_reconstructClip = _bundle.LoadAsset<AudioClip>("Assets/Custom/chickenbutt/reconstruct.mp3");
				}
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (!(SceneHelper.CurrentScene != "Level 4-4"))
			{
				Transform root = FindInactive("8 - Outro");
				Transform val = FindInactive("PlayerReactivator", root);
				FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS = ((Component)val).gameObject.AddComponent<FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS>();
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.reconstructClip = _reconstructClip;
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.surpriseTex = _surpriseTex;
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.delay = 1.1f;
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.oneTime = true;
			}
		}

		private Transform FindInactive(string name, Transform root = null)
		{
			if ((Object)(object)root == (Object)null)
			{
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				foreach (GameObject val in array)
				{
					if (((Object)val).name == name)
					{
						return val.transform;
					}
				}
				return null;
			}
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if (((Object)val2).name == name)
				{
					return val2;
				}
			}
			return null;
		}
	}
	public class FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <PlayAndFlash>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS <>4__this;

			private GameObject <audioGO>5__1;

			private AudioSource <src>5__2;

			private AudioMixerController <mixer>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PlayAndFlash>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<audioGO>5__1 = null;
				<src>5__2 = null;
				<mixer>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<audioGO>5__1 = new GameObject("tnl_reconstruct_audio");
					<audioGO>5__1.transform.SetParent(((Component)<>4__this).transform, false);
					<src>5__2 = <audioGO>5__1.AddComponent<AudioSource>();
					<src>5__2.spatialBlend = 0f;
					<src>5__2.dopplerLevel = 0f;
					<src>5__2.volume = 1f;
					<src>5__2.pitch = 1f;
					<src>5__2.playOnAwake = false;
					<src>5__2.clip = <>4__this.reconstructClip;
					<mixer>5__3 = MonoSingleton<AudioMixerController>.Instance;
					<src>5__2.outputAudioMixerGroup = <mixer>5__3.musicGroup;
					<src>5__2.Play();
					if (<>4__this.delay > 0f)
					{
						<>2__current = (object)new WaitForSeconds(<>4__this.delay);
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				<>4__this.ShowFlash(<>4__this.surpriseTex);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public AudioClip reconstructClip;

		public Texture2D surpriseTex;

		public float delay = 1.5f;

		public bool oneTime = true;

		public float fadeSpeed = 1f;

		private bool _activated;

		private void OnTriggerEnter(Collider other)
		{
			if ((!_activated || !oneTime) && ((Component)other).CompareTag("Player"))
			{
				_activated = true;
				((MonoBehaviour)this).StartCoroutine(PlayAndFlash());
			}
		}

		[IteratorStateMachine(typeof(<PlayAndFlash>d__7))]
		private IEnumerator PlayAndFlash()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PlayAndFlash>d__7(0)
			{
				<>4__this = this
			};
		}

		private void ShowFlash(Texture2D tex)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			GameObject val = new GameObject("tnl_flash_canvas");
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 9999;
			val.AddComponent<CanvasScaler>();
			val.AddComponent<GraphicRaycaster>();
			GameObject val3 = new GameObject("tnl_flash_image");
			val3.transform.SetParent(val.transform, false);
			RawImage val4 = val3.AddComponent<RawImage>();
			val4.texture = (Texture)(object)tex;
			((Graphic)val4).color = Color.white;
			((Graphic)val4).canvasRenderer.SetAlpha(1f);
			((Graphic)val4).rectTransform.anchorMin = Vector2.zero;
			((Graphic)val4).rectTransform.anchorMax = Vector2.one;
			((Graphic)val4).rectTransform.anchoredPosition = Vector2.zero;
			((Graphic)val4).rectTransform.sizeDelta = Vector2.zero;
			float num = Mathf.Max(0.01f, fadeSpeed);
			((Graphic)val4).CrossFadeAlpha(0f, num, false);
			Object.Destroy((Object)(object)val, num);
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "doomahreal.ultrakill.theresnothingleft";

		public const string PLUGIN_NAME = "THERESNOTHINGLEFT";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}