using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AutoSoundReplacements.Patches;
using BepInEx;
using BepInEx.Configuration;
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("AutoSoundReplacements")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoSoundReplacements")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e958401d-9927-4fc3-a8c7-40c0cbad0710")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoSoundReplacements
{
[BepInPlugin("AutoBans.SoundReplacementsMod", "Auto Sound Replacements", "1.4.3")]
public class AutoSoundBase : BaseUnityPlugin
{
private const string modGUID = "AutoBans.SoundReplacementsMod";
private const string modName = "Auto Sound Replacements";
private const string modVersion = "1.4.3";
private readonly Harmony harmony = new Harmony("AutoBans.SoundReplacementsMod");
private static AutoSoundBase Instance;
internal ManualLogSource mls;
private ConfigEntry<bool> toggleHoardingBugSFXReplacement;
private ConfigEntry<bool> toggleBeeHiveDropSFXReplacement;
private ConfigEntry<bool> toggleDropshipDeliverySFXReplacement;
private ConfigEntry<bool> toggleAngryBrackenSFXReplacement;
private ConfigEntry<bool> toggleNewEyelessDogLungeSFXReplacement;
private ConfigEntry<bool> toggleNewButlerUntuckKnifeSFXReplacement;
private ConfigEntry<bool> toggleNewGiantEatingSFXReplacement;
private ConfigEntry<bool> toggleNewDieFromFallDamageSFXReplacement;
private ConfigEntry<bool> toggleTeleporterSpinInverseSFXReplacementPyro;
private ConfigEntry<bool> toggleCompanyBuildingMusicSFXReplacementPyro;
private ConfigEntry<bool> toggleJesterPopSFXReplacementPyro;
internal static AudioClip[] newYippeeSFX;
internal static AudioClip[] newBeeHiveDropSFX;
internal static AudioClip[] newDropshipDeliverySFX;
internal static AudioClip[] newAngryBrackenSFX;
internal static AudioClip[] newEyelessDogLungeSFX;
internal static AudioClip[] newButlerUntuckKnifeSFX;
internal static AudioClip[] newGiantEatingSFX;
internal static AudioClip[] newDieFromFallDamageSFX;
internal static AudioClip[] newTeleporterSpinInversePyroSFX;
internal static AudioClip[] newCompanyBuildingMusicPyroSFX;
internal static AudioClip[] newJesterPopPyroSFX;
private void Awake()
{
Instance = this;
mls = ((BaseUnityPlugin)this).Logger;
mls.LogInfo((object)"AutoBansSoundReplacements is getting ready to game!");
toggleHoardingBugSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle HoardingBugChitter Audio Replacement", true, "Enable/Disable the audio replacement for the HoardingBugChitter sound");
toggleBeeHiveDropSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle BeeHiveDrop Audio Replacement", true, "Enable/Disable the audio replacement for the BeeHiveDrop sound");
toggleDropshipDeliverySFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle DropshipDeliveryMusic Audio Replacement", true, "Enable/Disable the audio replacement for the DropshipDeliveryMusic sound");
toggleAngryBrackenSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle AngryBracken Audio Replacement", true, "Enable/Disable the audio replacement for the AngryBracken sound");
toggleNewEyelessDogLungeSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle EyelessDogLunge Audio Replacement", true, "Enable/Disable the audio replacement for the EyelessDogLunge sound");
toggleNewButlerUntuckKnifeSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle ButlerUntuckKnife Audio Replacement", false, "Enable/Disable the audio replacement for the ButlerUntuckKnife sound");
toggleNewGiantEatingSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle ForestGiantEating Audio Replacement", true, "Enable/Disable the audio replacement for the ForestGiantEating sound.");
toggleNewDieFromFallDamageSFXReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements", "Toggle DieFromFallDamage Audio Replacement", true, "Enable/Disable the audio replacement for the DieFromFallDamage sound.");
toggleTeleporterSpinInverseSFXReplacementPyro = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements for Pyro", "Toggle TeleporterSpin Audio Replacement", true, "Enable/Disable the audio replacement for the TeleporterSpinPyro sound");
toggleCompanyBuildingMusicSFXReplacementPyro = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements for Pyro", "Toggle CompanyBuildingMusic Audio Replacement", true, "Enable/Disable the audio replacement for the CompanyBuildingMusicPyro sound");
toggleJesterPopSFXReplacementPyro = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoBans Sound Replacements for Pyro", "Toggle JesterPop Audio Replacement", true, "Enable/Disable the audio replacement for the JesterPopPyro sound");
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "autosounds");
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
mls.LogError((object)"Audio Assets failed to load :(");
return;
}
newYippeeSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/auto-yippee.ogg");
newBeeHiveDropSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/headshotsayingpenis.ogg");
newDropshipDeliverySFX = val.LoadAssetWithSubAssets<AudioClip>("assets/headshotsinging.ogg");
newAngryBrackenSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/omegafreddykrueger.ogg");
newEyelessDogLungeSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/omegabarking.ogg");
newButlerUntuckKnifeSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/creepylaughing.ogg");
newGiantEatingSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/omegagiantnom.ogg");
newDieFromFallDamageSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/autowhyyoudie.ogg");
newTeleporterSpinInversePyroSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/pyrogettingscared.ogg");
newCompanyBuildingMusicPyroSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/pyrosingingtwinkle.ogg");
newJesterPopPyroSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/pyrohellocompany.ogg");
AudioClip[][] array = new AudioClip[11][]
{
newYippeeSFX, newBeeHiveDropSFX, newDropshipDeliverySFX, newAngryBrackenSFX, newEyelessDogLungeSFX, newButlerUntuckKnifeSFX, newGiantEatingSFX, newDieFromFallDamageSFX, newTeleporterSpinInversePyroSFX, newCompanyBuildingMusicPyroSFX,
newJesterPopPyroSFX
};
if (Array.Exists(array, (AudioClip[] clip) => clip == null))
{
mls.LogError((object)"Failed to load one or more sound assets from the bundle sadge.");
return;
}
LogLoadedAudioClips("AutoYippee", newYippeeSFX);
LogLoadedAudioClips("NewBeehiveDrop", newBeeHiveDropSFX);
LogLoadedAudioClips("DropshipDelivery", newDropshipDeliverySFX);
LogLoadedAudioClips("NewAngryBracken", newAngryBrackenSFX);
LogLoadedAudioClips("NewEyelessDogLunge", newEyelessDogLungeSFX);
LogLoadedAudioClips("NewButlerUntuckKnife", newButlerUntuckKnifeSFX);
LogLoadedAudioClips("NewGiantEating", newGiantEatingSFX);
LogLoadedAudioClips("NewDieFromFallDamage", newDieFromFallDamageSFX);
LogLoadedAudioClips("PyroGettingScared", newTeleporterSpinInversePyroSFX);
LogLoadedAudioClips("PyroSingingTwinkle", newCompanyBuildingMusicPyroSFX);
LogLoadedAudioClips("PyroHelloCompany", newJesterPopPyroSFX);
ToggleSoundReplacement(toggleHoardingBugSFXReplacement.Value, typeof(HoarderBugPatch), "HoardingBugChitter");
ToggleSoundReplacement(toggleBeeHiveDropSFXReplacement.Value, typeof(NewBeeHiveDropSoundSFX), "BeeHiveDrop");
ToggleSoundReplacement(toggleDropshipDeliverySFXReplacement.Value, typeof(NewDropshipDeliverySFX), "DropshipDeliveryMusic");
ToggleSoundReplacement(toggleAngryBrackenSFXReplacement.Value, typeof(NewAngryBrackenGrowlSFX), "AngryBracken");
ToggleSoundReplacement(toggleNewEyelessDogLungeSFXReplacement.Value, typeof(NewEyelessDogLungeSFX), "EyelessDogLunge");
ToggleSoundReplacement(toggleNewButlerUntuckKnifeSFXReplacement.Value, typeof(NewButlerUntuckKnifeSFX), "ButlerUntuckKnife");
ToggleSoundReplacement(toggleNewGiantEatingSFXReplacement.Value, typeof(NewGiantEatingSFX), "GiantEating");
ToggleSoundReplacement(toggleNewDieFromFallDamageSFXReplacement.Value, typeof(NewDieFromFallDamageSFX), "DieFromFallDamage");
ToggleSoundReplacement(toggleTeleporterSpinInverseSFXReplacementPyro.Value, typeof(NewTeleporterSpinInverseSFXPyro), "TeleporterSpinPyro");
ToggleSoundReplacement(toggleCompanyBuildingMusicSFXReplacementPyro.Value, typeof(NewCompanyBuildingMusicSFXPyro), "CompanyBuildingMusicPyro");
ToggleSoundReplacement(toggleJesterPopSFXReplacementPyro.Value, typeof(NewJesterPopSoundSFXPyro), "JesterPopPyro");
mls.LogInfo((object)"AutoSoundReplacements has loaded!");
}
private void ToggleSoundReplacement(bool toggleValue, Type patchType, string soundName)
{
if (toggleValue)
{
harmony.PatchAll(patchType);
mls.LogInfo((object)(soundName + " sound replacement enabled."));
}
else
{
mls.LogInfo((object)(soundName + " sound replacement disabled."));
}
}
private void LogLoadedAudioClips(string soundType, AudioClip[] clips)
{
if (clips != null && clips.Length != 0)
{
foreach (AudioClip val in clips)
{
mls.LogInfo((object)("Loaded " + soundType + " sound file: " + ((Object)val).name));
}
}
else
{
mls.LogWarning((object)("No " + soundType + " sound files were loaded from the asset bundle."));
}
}
}
}
namespace AutoSoundReplacements.Patches
{
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewTeleporterSpinInverseSFXPyro
{
[HarmonyPrefix]
public static bool NewShipteleporterInverseSpinAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "ShipTeleporterSpinInverse")
{
AudioClip[] newTeleporterSpinInversePyroSFX = AutoSoundBase.newTeleporterSpinInversePyroSFX;
if (newTeleporterSpinInversePyroSFX != null && newTeleporterSpinInversePyroSFX.Length != 0)
{
clip = newTeleporterSpinInversePyroSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class NewCompanyBuildingMusicSFXPyro
{
[HarmonyPatch("openingDoorsSequence")]
[HarmonyPostfix]
private static void NewCompanyBuildingMusicPyro(StartOfRound __instance)
{
__instance.companyVisitMusic = AutoSoundBase.newCompanyBuildingMusicPyroSFX[0];
}
}
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewJesterPopSoundSFXPyro
{
[HarmonyPrefix]
public static bool NewJesterPopAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "Pop1")
{
AudioClip[] newJesterPopPyroSFX = AutoSoundBase.newJesterPopPyroSFX;
if (newJesterPopPyroSFX != null && newJesterPopPyroSFX.Length != 0)
{
clip = newJesterPopPyroSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(HoarderBugAI))]
internal class HoarderBugPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void HoarderBugAudioPatch(ref AudioClip[] ___chitterSFX)
{
AudioClip[] newYippeeSFX = AutoSoundBase.newYippeeSFX;
___chitterSFX = newYippeeSFX;
}
}
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewAngryBrackenGrowlSFX
{
[HarmonyPrefix]
public static bool NewAngryBrackenAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "Found1")
{
AudioClip[] newAngryBrackenSFX = AutoSoundBase.newAngryBrackenSFX;
if (newAngryBrackenSFX != null && newAngryBrackenSFX.Length != 0)
{
clip = newAngryBrackenSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewBeeHiveDropSoundSFX
{
[HarmonyPrefix]
public static bool ReplaceBeeHiveDropAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "BeeHiveDrop")
{
AudioClip[] newBeeHiveDropSFX = AutoSoundBase.newBeeHiveDropSFX;
if (newBeeHiveDropSFX != null && newBeeHiveDropSFX.Length != 0)
{
clip = newBeeHiveDropSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewButlerUntuckKnifeSFX
{
[HarmonyPrefix]
public static bool NewButlerUntuckKnifeSFXAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "ButlerUntuckKnifeSFX")
{
AudioClip[] newButlerUntuckKnifeSFX = AutoSoundBase.newButlerUntuckKnifeSFX;
if (newButlerUntuckKnifeSFX != null && newButlerUntuckKnifeSFX.Length != 0)
{
clip = newButlerUntuckKnifeSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewDieFromFallDamageSFX
{
[HarmonyPrefix]
public static bool NewDieFromFallDamageSFXAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "DieFromFallDamageSFX1")
{
AudioClip[] newDieFromFallDamageSFX = AutoSoundBase.newDieFromFallDamageSFX;
if (newDieFromFallDamageSFX != null && newDieFromFallDamageSFX.Length != 0)
{
clip = newDieFromFallDamageSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(ItemDropship))]
internal class NewDropshipDeliverySFX
{
[HarmonyPatch("ShipLandedAnimationEvent")]
[HarmonyPostfix]
private static void NewDropshipAudioSFX(ItemDropship __instance)
{
AudioClip[] newDropshipDeliverySFX = AutoSoundBase.newDropshipDeliverySFX;
if (newDropshipDeliverySFX.Length != 0)
{
AudioClip clip = newDropshipDeliverySFX[0];
Transform val = ((Component)__instance).transform.Find("Music");
AudioSource[] componentsInChildren = ((Component)val).GetComponentsInChildren<AudioSource>();
AudioSource[] array = componentsInChildren;
foreach (AudioSource val2 in array)
{
val2.clip = clip;
}
}
else
{
Debug.LogWarning((object)"No dropship delivery SFX found go fix code.");
}
}
}
[HarmonyPatch(typeof(AudioSource), "Play", new Type[] { })]
internal class NewEyelessDogLungeSFX
{
[HarmonyPrefix]
public static bool NewEyelessDogLungeSFXAudio(AudioSource __instance)
{
if ((Object)(object)__instance.clip != (Object)null && ((Object)__instance.clip).name == "Lunge1")
{
AudioClip[] newEyelessDogLungeSFX = AutoSoundBase.newEyelessDogLungeSFX;
if (newEyelessDogLungeSFX != null && newEyelessDogLungeSFX.Length != 0)
{
__instance.clip = newEyelessDogLungeSFX[0];
}
}
return true;
}
}
[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
internal class NewGiantEatingSFX
{
[HarmonyPrefix]
public static bool NewGiantEatingSFXAudio(ref AudioClip clip)
{
if ((Object)(object)clip != (Object)null && ((Object)clip).name == "FGiantEatPlayerSFX")
{
AudioClip[] newGiantEatingSFX = AutoSoundBase.newGiantEatingSFX;
if (newGiantEatingSFX != null && newGiantEatingSFX.Length != 0)
{
clip = newGiantEatingSFX[0];
}
}
return true;
}
}
}