Decompiled source of Curb Your Death v2.1.0

CurbYourDeath.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CurbYourDeath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CurbYourDeath")]
[assembly: AssemblyTitle("CurbYourDeath")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CurbYourDeath;

[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Arbition.CurbYourDeath", "Curb Your Death", "2.1.0")]
public class CurbYourDeath : BaseUnityPlugin
{
	private uint eventId;

	private bool curbPlaying = false;

	public void Awake()
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CurbYourDeath.CYE.bnk"))
		{
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				SoundBanks.Add(array);
			}
			else
			{
				Debug.LogError((object)"CurbYourDeath soundbank fetching failed");
				Object.Destroy((Object)(object)this);
			}
		}
		Run.OnDestroy += (hook_OnDestroy)delegate(orig_OnDestroy orig, Run self)
		{
			AkSoundEngine.StopPlayingID(eventId, 2000);
			curbPlaying = false;
			orig.Invoke(self);
		};
		Run.OnClientGameOver += (hook_OnClientGameOver)delegate(orig_OnClientGameOver orig, Run self, RunReport runReport)
		{
			if (!runReport.gameEnding.isWin)
			{
				eventId = AkSoundEngine.PostEvent(2106046636u, ((Component)this).gameObject);
				curbPlaying = true;
				orig.Invoke(self, runReport);
			}
		};
	}

	public void Update()
	{
		if (curbPlaying && Input.GetKeyDown((KeyCode)27))
		{
			AkSoundEngine.StopPlayingID(eventId, 5);
			curbPlaying = false;
		}
	}
}