Decompiled source of THERESNOTHINGLEFT v1.0.0

THERESNOTHINGLEFT.dll

Decompiled 12 hours 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;
			if ((Object)(object)_bundle != (Object)null)
			{
				_bundle.Unload(false);
			}
		}

		private void LoadEmbeddedBundle()
		{
			Assembly assembly = typeof(Plugin).Assembly;
			using (Stream stream = assembly.GetManifestResourceStream("THERESNOTHINGLEFT.chickenbutt.bundle"))
			{
				if (stream == null)
				{
					return;
				}
				_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)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneHelper.CurrentScene != "Level 4-4"))
			{
				GameObject val = FindInactive("8 - Outro");
				Transform val2 = FindInactive("PlayerReactivator", val.transform);
				Vector3 position = val2.position;
				GameObject val3 = new GameObject("tnl_reconstruct_audio");
				val3.transform.position = position;
				AudioSource val4 = val3.AddComponent<AudioSource>();
				val4.spatialBlend = 0f;
				val4.playOnAwake = false;
				val4.clip = _reconstructClip;
				FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS = ((Component)val2).gameObject.AddComponent<FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS>();
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.reconstructClip = _reconstructClip;
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.surpriseTex = _surpriseTex;
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.delay = 1.1f;
				fUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS.oneTime = true;
			}
		}

		private GameObject FindInactive(string name)
		{
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			return null;
		}

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

			private object <>2__current;

			public GameObject canvasGO;

			public float duration;

			public FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(duration);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Object.Destroy((Object)(object)canvasGO);
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <PlayAndFlash>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public FUCKYOUUNITYEVENTSIHATEYOUWHYCANTIASSIGNNEWCALLSIFICOULDIWOULDNTHAVETODOTHIS <>4__this;

			private AudioSource <src>5__1;

			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()
			{
				<src>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Expected O, but got Unknown
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)<>4__this.reconstructClip != (Object)null)
					{
						<src>5__1 = ((Component)<>4__this).GetComponent<AudioSource>() ?? ((Component)<>4__this).gameObject.AddComponent<AudioSource>();
						<src>5__1.spatialBlend = 0f;
						<src>5__1.dopplerLevel = 0f;
						<src>5__1.volume = 1f;
						<src>5__1.pitch = 1f;
						<src>5__1.playOnAwake = false;
						<src>5__1.clip = <>4__this.reconstructClip;
						<src>5__1.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.Instance.allGroup;
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 1;
						return true;
					}
					goto IL_0121;
				case 1:
					<>1__state = -1;
					<src>5__1.Play();
					<src>5__1 = null;
					goto IL_0121;
				case 2:
					{
						<>1__state = -1;
						if ((Object)(object)<>4__this.surpriseTex != (Object)null)
						{
							<>4__this.ShowFlash(<>4__this.surpriseTex);
						}
						return false;
					}
					IL_0121:
					<>2__current = (object)new WaitForSeconds(<>4__this.delay);
					<>1__state = 2;
					return true;
				}
			}

			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 ((!oneTime || !_activated) && ((Component)other).gameObject.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);
			((MonoBehaviour)this).StartCoroutine(FadeAndDestroy(val, num));
		}

		[IteratorStateMachine(typeof(<FadeAndDestroy>d__9))]
		private IEnumerator FadeAndDestroy(GameObject canvasGO, float duration)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeAndDestroy>d__9(0)
			{
				<>4__this = this,
				canvasGO = canvasGO,
				duration = duration
			};
		}
	}
	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";
	}
}