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.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MikuMikuBeamer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MikuMikuBeamer")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("64FC1DDA-0C76-4A36-8CA4-748E1ED61D7B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace mikumikubeamer;
public static class Common
{
public static bool initialized = false;
public static AudioClip attackLoopClip;
public static AudioClip attackIntroClip;
public static Dictionary<EnemyBeamer, Sound> beamerIntroSounds = new Dictionary<EnemyBeamer, Sound>();
public static void SetupSoundsForEnemy(EnemyBeamer enemy)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)enemy == (Object)null)
{
return;
}
if ((Object)(object)attackLoopClip != (Object)null)
{
try
{
Sound val = new Sound();
if ((Object)(object)enemy.anim != (Object)null && enemy.anim.soundAttackIntro != null)
{
Sound.CopySound(enemy.anim.soundAttackLoop, val);
}
else
{
val.Type = (AudioType)9;
val.VolumeRandom = 0.1f;
val.Pitch = 1f;
val.PitchRandom = 0.1f;
val.SpatialBlend = 1f;
val.Doppler = 1f;
val.ReverbMix = 1f;
}
val.Volume = 1f;
val.PitchRandom = 0f;
val.Sounds = (AudioClip[])(object)new AudioClip[1] { attackLoopClip };
if (enemy.anim.soundAttackLoop != null)
{
enemy.anim.soundAttackLoop.Sounds = (AudioClip[])(object)new AudioClip[1] { attackLoopClip };
}
}
catch (Exception)
{
}
}
if (!((Object)(object)attackIntroClip != (Object)null) || beamerIntroSounds.ContainsKey(enemy))
{
return;
}
try
{
Sound val2 = new Sound();
if ((Object)(object)enemy.anim != (Object)null && enemy.anim.soundAttackIntro != null)
{
Sound.CopySound(enemy.anim.soundAttackIntro, val2);
}
else
{
val2.Type = (AudioType)9;
val2.Volume = 0.7f;
val2.VolumeRandom = 0.1f;
val2.Pitch = 1f;
val2.PitchRandom = 0f;
val2.SpatialBlend = 1f;
val2.Doppler = 1f;
val2.ReverbMix = 1f;
}
val2.Volume = 0.7f;
val2.Sounds = (AudioClip[])(object)new AudioClip[1] { attackIntroClip };
beamerIntroSounds[enemy] = val2;
}
catch (Exception)
{
}
}
}
[BepInPlugin("com.whale.repo.MikuMikuBeamer", "MikuMikuBeamer", "1.0.0")]
public class MikuMikuBeamer : BaseUnityPlugin
{
[HarmonyPatch(typeof(EnemyBeamer), "Awake")]
public class EnemyBeamerAwakePatch
{
public static void Postfix(EnemyBeamer __instance)
{
Common.SetupSoundsForEnemy(__instance);
}
}
[HarmonyPatch(typeof(EnemyBeamerAnim), "AttackIntro")]
public class AttackIntroPatch
{
public static void Postfix(EnemyBeamerAnim __instance)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Common.attackIntroClip == (Object)null)
{
return;
}
EnemyBeamer controller = __instance.controller;
if ((Object)(object)controller == (Object)null)
{
return;
}
if (!Common.beamerIntroSounds.TryGetValue(controller, out var value))
{
Common.SetupSoundsForEnemy(controller);
if (!Common.beamerIntroSounds.TryGetValue(controller, out value))
{
return;
}
}
value.Play(((Component)__instance).transform.position, 1f, 1f, 1f, 1f);
}
}
[CompilerGenerated]
private sealed class <LoadAudioClips>d__7 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public MikuMikuBeamer <>4__this;
private string <introAudioPath>5__2;
private UnityWebRequest <loopRequest>5__3;
private UnityWebRequest <introRequest>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAudioClips>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<introAudioPath>5__2 = null;
<loopRequest>5__3 = null;
<introRequest>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Invalid comparison between Unknown and I4
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Invalid comparison between Unknown and I4
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MikuMikuBeamer mikuMikuBeamer = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
Common.initialized = true;
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MikuMikuBeamer");
<introAudioPath>5__2 = Path.Combine(path, "attackintro.wav");
string text = Path.Combine(path, "beamloop.wav");
((BaseUnityPlugin)mikuMikuBeamer).Logger.LogInfo((object)("Trying to load audio from: " + text + ", " + <introAudioPath>5__2));
bool num2 = File.Exists(text);
bool flag = File.Exists(<introAudioPath>5__2);
if (!num2 || !flag)
{
((BaseUnityPlugin)mikuMikuBeamer).Logger.LogError((object)"Not all sound files found. Aborting.");
return false;
}
<loopRequest>5__3 = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)20);
<>2__current = <loopRequest>5__3.SendWebRequest();
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
if ((int)<loopRequest>5__3.result != 1)
{
((BaseUnityPlugin)mikuMikuBeamer).Logger.LogError((object)("Error loading loop audio: " + <loopRequest>5__3.error));
}
else
{
Common.attackLoopClip = ((DownloadHandlerAudioClip)<loopRequest>5__3.downloadHandler).audioClip;
}
<introRequest>5__4 = UnityWebRequestMultimedia.GetAudioClip("file://" + <introAudioPath>5__2, (AudioType)20);
<>2__current = <introRequest>5__4.SendWebRequest();
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
if ((int)<introRequest>5__4.result != 1)
{
((BaseUnityPlugin)mikuMikuBeamer).Logger.LogError((object)("Error loading intro audio: " + <introRequest>5__4.error));
}
else
{
Common.attackIntroClip = ((DownloadHandlerAudioClip)<introRequest>5__4.downloadHandler).audioClip;
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private ConfigEntry<bool> enableMod;
private const string PLUGIN_NAME = "MikuMikuBeamer";
public static MikuMikuBeamer Instance { get; private set; }
private void Awake()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enable or disable the mod");
if (enableMod.Value)
{
if (!Common.initialized)
{
((MonoBehaviour)this).StartCoroutine(LoadAudioClips());
}
new Harmony("com.whale.repo.MikuMikuBeamer").PatchAll(Assembly.GetExecutingAssembly());
((BaseUnityPlugin)this).Logger.LogInfo((object)"MikuMikuBeamer loaded");
}
}
[IteratorStateMachine(typeof(<LoadAudioClips>d__7))]
private IEnumerator LoadAudioClips()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAudioClips>d__7(0)
{
<>4__this = this
};
}
}