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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPO_HunterAduioMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("微软中国")]
[assembly: AssemblyProduct("REPO_HunterAduioMod")]
[assembly: AssemblyCopyright("Copyright © 微软中国 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("43c1c24b-9c92-4e35-aa94-8027e3ab041d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace REPO_HunterAudioMod;
[BepInPlugin("com.XiaohaiMod.REPO.HunterAudioMod", "HunterAudioMod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <LoadAB>d__6 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private string <dllDirectory>5__1;
private string <bundlePath>5__2;
private AssetBundleCreateRequest <request>5__3;
private AudioClip[] <clips>5__4;
private AudioClip[] <>s__5;
private int <>s__6;
private AudioClip <clip>5__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAB>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<dllDirectory>5__1 = null;
<bundlePath>5__2 = null;
<request>5__3 = null;
<clips>5__4 = null;
<>s__5 = null;
<clip>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<dllDirectory>5__1 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
<bundlePath>5__2 = Path.Combine(<dllDirectory>5__1, "HunterAudioModAB");
<request>5__3 = AssetBundle.LoadFromFileAsync(<bundlePath>5__2);
<>2__current = <request>5__3;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
audioBundle = <request>5__3.assetBundle;
if ((Object)(object)audioBundle == (Object)null)
{
Logger.LogError((object)"AssetBundle加载失败!");
return false;
}
HunterRoamClips.Clear();
HunterAngryClips.Clear();
<clips>5__4 = audioBundle.LoadAllAssets<AudioClip>();
<>s__5 = <clips>5__4;
for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
{
<clip>5__7 = <>s__5[<>s__6];
if (((Object)<clip>5__7).name.Contains("Angry"))
{
HunterAngryClips.Add(<clip>5__7);
}
else if (((Object)<clip>5__7).name.Contains("Roam"))
{
HunterRoamClips.Add(<clip>5__7);
}
<clip>5__7 = null;
}
<>s__5 = null;
Logger.LogInfo((object)$"音效加载完毕: 漫游{HunterRoamClips.Count}个, 生气{HunterAngryClips.Count}个");
new Harmony("com.XiaohaiMod.REPO.HunterAudioMod").PatchAll();
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();
}
}
public static ManualLogSource Logger;
public static Plugin instance;
private static AssetBundle audioBundle;
public static List<AudioClip> HunterRoamClips = new List<AudioClip>();
public static List<AudioClip> HunterAngryClips = new List<AudioClip>();
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"HunterAudioMod is loaded,小海男枪音频MOD已加载!");
instance = this;
((MonoBehaviour)this).StartCoroutine(LoadAB());
}
[IteratorStateMachine(typeof(<LoadAB>d__6))]
private static IEnumerator LoadAB()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAB>d__6(0);
}
}
[HarmonyPatch(typeof(EnemyHunter))]
public static class PatchEnemyHunter
{
private const float FadeSpeed = 2f;
private static AudioClip[] defaulSounds;
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void AwakePatch(EnemyHunter __instance)
{
defaulSounds = __instance.soundShoot.Sounds;
Plugin.Logger.LogInfo((object)"!!枪男来啦!");
}
[HarmonyPatch("UpdateState")]
[HarmonyPrefix]
public static void UpdateStatePatch(EnemyHunter __instance, ref State _state)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
bool flag = (int)_state == 2;
bool flag2 = (int)_state == 3;
bool flag3 = (int)_state == 4;
bool flag4 = (int)_state == 5;
bool flag5 = (int)_state == 9;
if (flag || flag5)
{
__instance.soundShoot.Sounds = Plugin.HunterRoamClips.ToArray();
__instance.soundShoot.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
else if (flag2 || flag3 || flag4)
{
__instance.soundShoot.Sounds = Plugin.HunterAngryClips.ToArray();
__instance.soundShoot.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
else
{
__instance.soundShoot.Sounds = defaulSounds;
}
}
}