using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalMod.Patch;
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("LethalMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3217f241-5371-4b75-baec-ba0caa355ff5")]
[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")]
public static class SoundManager
{
public static void PlayRandomSound(AudioSource audioSource, List<AudioClip> soundList)
{
if (soundList == null || soundList.Count == 0)
{
Debug.LogWarning((object)"No sounds available to play.");
return;
}
int index = Random.Range(0, soundList.Count);
AudioClip clip = soundList[index];
audioSource.clip = clip;
audioSource.Play();
}
}
namespace LethalMod
{
[BepInPlugin("voiceMod", "IUTMod", "1.1.0")]
public class VoiceChangerMod : BaseUnityPlugin
{
private const string modGUID = "voiceMod";
private const string modName = "IUTMod";
private const string modVersion = "1.1.0";
private readonly Harmony harmony = new Harmony("voiceMod");
public static VoiceChangerMod Instance;
public ManualLogSource mls;
internal static AudioClip[] SoundFX;
internal static AudioClip[] DeathSoundFX;
internal static AssetBundle Bundle;
internal static AssetBundle DeathBundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
harmony.PatchAll(typeof(VoiceChangerMod));
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(CreatureSFXPatch));
harmony.PatchAll(typeof(PlayAudioOnParticleDeathPatch));
mls = Logger.CreateLogSource("voiceMod");
mls.LogInfo((object)"VoiceMod as awoke");
mls = ((BaseUnityPlugin)this).Logger;
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("LethalMod.dll".ToCharArray());
Bundle = AssetBundle.LoadFromFile(location + "soundPack");
DeathBundle = AssetBundle.LoadFromFile(location + "deathSoundpack");
if ((Object)(object)Bundle != (Object)null)
{
SoundFX = Bundle.LoadAllAssets<AudioClip>();
AudioClip[] soundFX = SoundFX;
foreach (AudioClip val in soundFX)
{
mls.LogInfo((object)$"Loaded sound: {((Object)val).name}, length: {val.length}");
}
}
if ((Object)(object)DeathBundle != (Object)null)
{
DeathSoundFX = DeathBundle.LoadAllAssets<AudioClip>();
AudioClip[] deathSoundFX = DeathSoundFX;
foreach (AudioClip val2 in deathSoundFX)
{
mls.LogInfo((object)$"Loaded death sound: {((Object)val2).name}, length: {val2.length}");
}
}
}
}
}
namespace LethalMod.Patch
{
[HarmonyPatch(typeof(EnemyAI))]
public static class CreatureSFXPatch
{
[HarmonyPostfix]
[HarmonyPatch("PlayAudioOfCurrentState")]
public static void Postfix(EnemyAI __instance)
{
try
{
if (Random.Range(0, 10) <= 6)
{
return;
}
AudioClip val = VoiceChangerMod.SoundFX[Random.Range(0, VoiceChangerMod.SoundFX.Length)];
if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)__instance.creatureSFX))
{
__instance.currentBehaviourState.SFXClip = val;
VoiceChangerMod.Instance.mls.LogInfo((object)("Assigned random clip: " + ((Object)val).name));
if (__instance.currentBehaviourState.playOneShotSFX)
{
__instance.creatureSFX.PlayOneShot(__instance.currentBehaviourState.SFXClip);
return;
}
__instance.creatureSFX.clip = __instance.currentBehaviourState.SFXClip;
__instance.creatureSFX.Play();
}
else
{
VoiceChangerMod.Instance.mls.LogError((object)"Randomly selected clip is null.");
}
}
catch (Exception ex)
{
VoiceChangerMod.Instance.mls.LogError((object)("Error in CreatureSFXPatch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(PlayAudioOnParticleDeath))]
public static class PlayAudioOnParticleDeathPatch
{
[HarmonyPostfix]
[HarmonyPatch("LateUpdate")]
public static void PatchDeathSound(PlayAudioOnParticleDeath __instance)
{
__instance.particleAudio.clip = VoiceChangerMod.DeathSoundFX[0];
__instance.particleAudio.Play();
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void infiniteSprintPatch(ref float ___sprintMeter)
{
___sprintMeter = 1f;
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void OverrideAudio(StartOfRound __instance)
{
if (VoiceChangerMod.SoundFX.Length != 0)
{
__instance.shipIntroSpeechSFX = VoiceChangerMod.SoundFX[0];
}
}
}
}