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 HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dfac42fb-57d9-4196-bce6-a4d1c3bf70cf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.tintinp.piratadeathplayers", "PirataDeathPlayersOnly", "1.1.1")]
public class PirataDeathPlayersOnly : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <LoadAudio>d__3 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PirataDeathPlayersOnly <>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 <LoadAudio>d__3(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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Invalid comparison between Unknown and I4
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Invalid comparison between Unknown and I4
bool result;
try
{
int num = <>1__state;
PirataDeathPlayersOnly pirataDeathPlayersOnly = <>4__this;
switch (num)
{
default:
result = false;
break;
case 0:
{
<>1__state = -1;
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)pirataDeathPlayersOnly).Info.Location), "piratita.ogg");
string text2 = "file://" + text;
<www>5__2 = UnityWebRequestMultimedia.GetAudioClip(text2, (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 == 2 || (int)<www>5__2.result == 3)
{
((BaseUnityPlugin)pirataDeathPlayersOnly).Logger.LogError((object)("Error loading piratita.ogg: " + <www>5__2.error));
result = false;
<>m__Finally1();
}
else
{
deathClip = DownloadHandlerAudioClip.GetContent(<www>5__2);
<>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();
}
}
private static AudioClip deathClip;
private static float lastPlayTime = -10f;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogInfo((object)"PirataDeathPlayersOnly Plugin Loaded.");
((MonoBehaviour)this).StartCoroutine(LoadAudio());
new Harmony("com.tintinp.piratadeathplayers").PatchAll();
}
[IteratorStateMachine(typeof(<LoadAudio>d__3))]
private IEnumerator LoadAudio()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAudio>d__3(0)
{
<>4__this = this
};
}
public static void PlayCorrido()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
if (!((Object)(object)deathClip == (Object)null) && !(Time.time - lastPlayTime < 5f))
{
lastPlayTime = Time.time;
GameObject val = new GameObject("PirataDeathAudioPlayer");
Object.DontDestroyOnLoad((Object)val);
AudioSource obj = val.AddComponent<AudioSource>();
obj.clip = deathClip;
obj.spatialBlend = 0f;
obj.loop = false;
obj.priority = 0;
obj.volume = 1f;
obj.Play();
Object.Destroy((Object)val, deathClip.length + 1f);
}
}
}
[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")]
public class PlayerDeathPatch0
{
private static void Postfix()
{
PirataDeathPlayersOnly.PlayCorrido();
}
}
[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathRPC")]
public class PlayerDeathPatch1
{
private static void Postfix()
{
PirataDeathPlayersOnly.PlayCorrido();
}
}
[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathDone")]
public class PlayerDeathPatch2
{
private static void Postfix()
{
PirataDeathPlayersOnly.PlayCorrido();
}
}
[HarmonyPatch(typeof(PlayerHealth), "Death")]
public class PlayerDeathPatch3
{
private static void Postfix()
{
PirataDeathPlayersOnly.PlayCorrido();
}
}