Decompiled source of WarlockRevive v1.0.2

RepoWarlockReviveMod.dll

Decompiled 3 months ago
using System;
using System.Collections;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoWarlockReviveMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RepoWarlockReviveMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1d9f9dba-2b0e-4503-8fd1-e71d22b1f0b3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.homeboyyosh.WarlockRevive", "REPO Warlock Revive", "1.0.2")]
public class WarlockRevive : BaseUnityPlugin
{
	public static AudioClip customClip;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.homeboyyosh.WarlockRevive");
		val.PatchAll();
		string path = Path.Combine(Paths.PluginPath, "HomeboyYosh-WarlockRevive", "WarlockReviveSound.wav");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO Mod Loaded 1");
		((MonoBehaviour)this).StartCoroutine(LoadCustomSound(path));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO Mod Loaded 2");
	}

	private IEnumerator LoadCustomSound(string path)
	{
		string uri = "file://" + path;
		UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(uri, (AudioType)20);
		try
		{
			yield return www.SendWebRequest();
			if ((int)www.result != 1)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("[WarlockRevive] Failed to load audio: " + www.error));
				yield break;
			}
			customClip = DownloadHandlerAudioClip.GetContent(www);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[WarlockRevive] Successfully loaded custom revive sound.");
		}
		finally
		{
			((IDisposable)www)?.Dispose();
		}
	}
}
[HarmonyPatch(typeof(PlayerReviveEffects), "Trigger")]
public static class ReviveSoundPatch
{
	private static void Prefix(PlayerReviveEffects __instance)
	{
		Logger.CreateLogSource("WarlockRevive").LogInfo((object)"Trigger patch fired");
		if ((Object)(object)WarlockRevive.customClip != (Object)null)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerReviveEffects), "reviveSound");
			object value = fieldInfo.GetValue(__instance);
			FieldInfo fieldInfo2 = AccessTools.Field(value.GetType(), "Sounds");
			fieldInfo2.SetValue(value, new AudioClip[1] { WarlockRevive.customClip });
			__instance.reviveSound.Volume = 1f;
		}
	}
}