Decompiled source of ReZeroReturnByDeathSound v1.0.0

ReturnByDeathSound.dll

Decompiled a day 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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ReturnByDeathSound")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReturnByDeathSound")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("905b4050-2770-4076-91bc-7a5ed725a540")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(PlayerReviveEffects), "Trigger")]
public static class ReviveSoundPatch
{
	private static void Prefix(PlayerReviveEffects __instance)
	{
		Logger.CreateLogSource("ReturnByDeathSound").LogInfo((object)"Trigger patch fired");
		if ((Object)(object)ReturnByDeathSound.customClip != (Object)null)
		{
			object value = AccessTools.Field(typeof(PlayerReviveEffects), "reviveSound").GetValue(__instance);
			AccessTools.Field(value.GetType(), "Sounds").SetValue(value, new AudioClip[1] { ReturnByDeathSound.customClip });
			__instance.reviveSound.Volume = 1f;
		}
	}
}
[BepInPlugin("com.jeanporte.rbd", "REPO Return By Death Sound", "1.0.0")]
public class ReturnByDeathSound : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <LoadCustomSound>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public string path;

		public ReturnByDeathSound <>4__this;

		private UnityWebRequest <www>5__2;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			int num = <>1__state;
			if (num == -3 || num == 1)
			{
				try
				{
				}
				finally
				{
					<>m__Finally1();
				}
			}
			<www>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			bool result;
			try
			{
				int num = <>1__state;
				ReturnByDeathSound returnByDeathSound = <>4__this;
				switch (num)
				{
				default:
					result = false;
					break;
				case 0:
				{
					<>1__state = -1;
					string text = "file://" + path;
					<www>5__2 = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)14);
					<>1__state = -3;
					<>2__current = <www>5__2.SendWebRequest();
					<>1__state = 1;
					result = true;
					break;
				}
				case 1:
					<>1__state = -3;
					if ((int)<www>5__2.result != 1)
					{
						((BaseUnityPlugin)returnByDeathSound).Logger.LogError((object)("[ReturnByDeathSound] Failed to load audio: " + <www>5__2.error));
						result = false;
						<>m__Finally1();
					}
					else
					{
						customClip = DownloadHandlerAudioClip.GetContent(<www>5__2);
						((BaseUnityPlugin)returnByDeathSound).Logger.LogInfo((object)"[ReturnByDeathSound] Successfully loaded custom revive sound.");
						<>m__Finally1();
						<www>5__2 = null;
						result = false;
					}
					break;
				}
			}
			catch
			{
				//try-fault
				((IDisposable)this).Dispose();
				throw;
			}
			return result;
		}

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

		private void <>m__Finally1()
		{
			<>1__state = -1;
			if (<www>5__2 != null)
			{
				((IDisposable)<www>5__2).Dispose();
			}
		}

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

	public static AudioClip customClip;

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("com.jeanporte.rbd").PatchAll();
		string path = Path.Combine(Paths.PluginPath, "JeanPorte-ReZeroReturnByDeathSound", "ReturnByDeath.ogg");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO Mod Loaded 1");
		((MonoBehaviour)this).StartCoroutine(LoadCustomSound(path));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO Mod Loaded 2");
	}

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