using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.0.0")]
public class VoiceChangerMod : BaseUnityPlugin
{
private const string modGUID = "voiceMod";
private const string modName = "IUTMod";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("voiceMod");
public static VoiceChangerMod Instance;
public ManualLogSource mls;
internal static List<AudioClip> SoundFX;
internal static AssetBundle Bundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
harmony.PatchAll(typeof(VoiceChangerMod));
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(CreatureSFXPatch));
mls = Logger.CreateLogSource("voiceMod");
mls.LogInfo((object)"VoiceMod as awoke");
mls = ((BaseUnityPlugin)this).Logger;
SoundFX = new List<AudioClip>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("LethalMod.dll".ToCharArray());
Bundle = AssetBundle.LoadFromFile(location + "soundPack");
if (!((Object)(object)Bundle != (Object)null))
{
return;
}
mls.LogInfo((object)"Successfully loaded asset bundle");
SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
foreach (AudioClip item in SoundFX)
{
mls.LogInfo((object)("Loaded sound: " + ((Object)item).name));
}
Bundle.Unload(false);
}
}
}
namespace LethalMod.Patch
{
[HarmonyPatch(typeof(EnemyAI))]
internal class CreatureSFXPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void PlayRandomCreatureSound(EnemyAI __instance)
{
if ((Object)(object)__instance.creatureVoice != (Object)null)
{
SoundManager.PlayRandomSound(__instance.creatureVoice, VoiceChangerMod.SoundFX);
}
if ((Object)(object)__instance.creatureSFX != (Object)null)
{
SoundManager.PlayRandomSound(__instance.creatureSFX, VoiceChangerMod.SoundFX);
}
}
}
[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.Count > 0)
{
__instance.shipIntroSpeechSFX = VoiceChangerMod.SoundFX[0];
__instance.changeSuitSFX = __instance.airPressureSFX;
}
}
}
}