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("FaraonuTutankamon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FaraonuTutankamon")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1fe7bd31-3013-457a-b6d6-c828ad9462c0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("Faraonu.Tutankamon", "Faraonu - Tutankamon", "1.0.3")]
public class BoomboxModifier : BaseUnityPlugin
{
public void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("BoomboxModifier").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Faraonu - Tutankamon loaded and patched.");
}
}
[HarmonyPatch(typeof(ValuableBoombox))]
[HarmonyPatch("Start")]
public class TutankamonPatch
{
[CompilerGenerated]
private sealed class <LoadExternalAudioAndReplace>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ValuableBoombox boombox;
private Stream <stream>5__2;
private UnityWebRequest <www>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadExternalAudioAndReplace>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if ((uint)(num - -4) <= 1u || num == 1)
{
try
{
if (num == -4 || num == 1)
{
try
{
}
finally
{
<>m__Finally2();
}
}
}
finally
{
<>m__Finally1();
}
}
<stream>5__2 = null;
<www>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Invalid comparison between Unknown and I4
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
goto end_IL_0000;
case 0:
{
<>1__state = -1;
string text = "FaraonuTutankamon.Resources.Sound.FaraonuTutankamonOficial.mp3";
Assembly executingAssembly = Assembly.GetExecutingAssembly();
<stream>5__2 = executingAssembly.GetManifestResourceStream(text);
<>1__state = -3;
if (<stream>5__2 == null)
{
Debug.LogError((object)("Embedded resource not found: " + text));
result = false;
break;
}
byte[] bytes;
using (MemoryStream memoryStream = new MemoryStream())
{
<stream>5__2.CopyTo(memoryStream);
bytes = memoryStream.ToArray();
}
string text2 = Path.Combine(Application.temporaryCachePath, "FaraonuTutankamonOficial.mp3");
File.WriteAllBytes(text2, bytes);
<www>5__3 = UnityWebRequestMultimedia.GetAudioClip("file://" + text2, (AudioType)13);
<>1__state = -4;
<>2__current = <www>5__3.SendWebRequest();
<>1__state = 1;
result = true;
goto end_IL_0000;
}
case 1:
{
<>1__state = -4;
if ((int)<www>5__3.result != 1)
{
Debug.LogError((object)("[FaraonuTutankamon] Failed to load audio: " + <www>5__3.error));
result = false;
goto IL_016a;
}
AudioClip content = DownloadHandlerAudioClip.GetContent(<www>5__3);
Sound soundBoomboxMusic = boombox.soundBoomboxMusic;
if (soundBoomboxMusic == null || soundBoomboxMusic.Sounds == null || soundBoomboxMusic.Sounds.Length == 0)
{
Debug.LogWarning((object)"[FaraonuTutankamon] Boombox sound component is missing.");
result = false;
goto IL_016a;
}
soundBoomboxMusic.Sounds[0] = content;
<>m__Finally2();
<www>5__3 = null;
<>m__Finally1();
<stream>5__2 = null;
result = false;
goto end_IL_0000;
}
IL_016a:
<>m__Finally2();
break;
}
<>m__Finally1();
end_IL_0000:;
}
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 (<stream>5__2 != null)
{
((IDisposable)<stream>5__2).Dispose();
}
}
private void <>m__Finally2()
{
<>1__state = -3;
if (<www>5__3 != null)
{
((IDisposable)<www>5__3).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static void Postfix(ValuableBoombox __instance)
{
((MonoBehaviour)__instance).StartCoroutine(LoadExternalAudioAndReplace(__instance));
}
[IteratorStateMachine(typeof(<LoadExternalAudioAndReplace>d__1))]
private static IEnumerator LoadExternalAudioAndReplace(ValuableBoombox boombox)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadExternalAudioAndReplace>d__1(0)
{
boombox = boombox
};
}
}