Decompiled source of Yippee Enemies v1.0.2

plugins/YippeeEnemies/YippeeDeath.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("YippeeDeath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YippeeDeath")]
[assembly: AssemblyTitle("YippeeDeath")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace YippeeDeath;

[BepInPlugin("Oreowich.YippeeDeath", "YippeeDeath", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch]
	internal class Patch_EnemyIdentifierDeath
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(EnemyIdentifier), "Death", Type.EmptyTypes, (Type[])null);
		}

		private static void Postfix(EnemyIdentifier __instance)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject.GetComponent<YippeeFlag>() != (Object)null))
			{
				((Component)__instance).gameObject.AddComponent<YippeeFlag>();
				PlayYippeeSound(((Component)__instance).transform.position, ((Object)__instance).name);
			}
		}
	}

	public class YippeeAutoDestroy : MonoBehaviour
	{
		private float lifetime;

		public void Init(float time)
		{
			lifetime = time;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((MonoBehaviour)this).StartCoroutine(DestroyAfterTime());
		}

		private IEnumerator DestroyAfterTime()
		{
			yield return (object)new WaitForSeconds(lifetime + 0.1f);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private static Harmony harmony;

	internal static AssetBundle YippeDeath;

	private void Awake()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		Assembly.GetExecutingAssembly();
		string path = "yippeeyay";
		YippeDeath = AssetBundle.LoadFromFile(Path.Combine(ModPath(), path));
		harmony = new Harmony("ltg.Minos");
		harmony.PatchAll();
	}

	public static string ModPath()
	{
		return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar));
	}

	public static void PlayYippeeSound(Vector3 position, string name)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		AudioClip val = YippeDeath.LoadAsset<AudioClip>("yippee.ogg");
		Vector3 val2 = position;
		Debug.Log((object)("Playing Yippee at " + ((object)(Vector3)(ref val2)).ToString() + " for: " + name));
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogError((object)"YippeeDeath: Failed to load sound.");
			return;
		}
		GameObject val3 = new GameObject("YippeeSound");
		val3.transform.position = position;
		AudioSource val4 = val3.AddComponent<AudioSource>();
		val4.clip = val;
		val4.spatialBlend = 1f;
		val4.loop = false;
		val4.loop = false;
		val4.playOnAwake = false;
		val4.Play();
		val3.AddComponent<YippeeAutoDestroy>().Init(val.length);
	}
}
public class YippeeFlag : MonoBehaviour
{
}