using System;
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 HarmonyLib;
using MyceliumNetworking;
using SillySoundEffects.Patches;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SillySoundEffects")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SillySoundEffects")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("02e6806f-0f78-447a-bcad-3ed2d16168c1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SillySoundEffects
{
[BepInPlugin("MrChicken.SillySoundEffects", "Silly Sound Effects", "1.0.0.0")]
public class SillySoundsBase : BaseUnityPlugin
{
public const uint modId = 46223934u;
private const string modGUID = "MrChicken.SillySoundEffects";
private const string modName = "Silly Sound Effects";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("MrChicken.SillySoundEffects");
private static SillySoundsBase Instance;
internal ManualLogSource mls;
internal static List<AudioClip> SoundFX;
internal static AssetBundle Bundle;
private void Awake()
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("MrChicken.SillySoundEffects");
mls.LogInfo((object)"SillySoundEffects are being a bit goofy");
harmony.PatchAll(Assembly.GetExecutingAssembly());
SoundFX = new List<AudioClip>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("SillySoundEffects.dll".ToCharArray());
Bundle = AssetBundle.LoadFromFile(location + "sounds");
if ((Object)(object)Bundle != (Object)null)
{
mls.LogInfo((object)"Successfully loaded asset bundle");
SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
}
else
{
mls.LogError((object)"Failed to load asset bundle");
}
GameObject val = new GameObject("SillySoundEffects Persistent");
val.AddComponent<DivingBellPatch>();
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)val);
}
}
}
namespace SillySoundEffects.Patches
{
[HarmonyPatch(typeof(BombItem))]
internal class BombItemPatch
{
private static bool patchedSound;
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void OverrideExplosionSound(BombItem __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
if (!patchedSound)
{
SFX_PlayOneShot component = __instance.explosion.GetComponent<SFX_PlayOneShot>();
SFX_Instance val = new SFX_Instance();
val.clips = (AudioClip[])(object)new AudioClip[1] { SillySoundsBase.SoundFX[0] };
val.settings = new SFX_Settings();
component.sfx = val;
patchedSound = true;
}
}
}
[HarmonyPatch(typeof(DivingBell))]
internal class DivingBellPatch : MonoBehaviour
{
public static Vector3 soundPos;
private SFX_Instance buzzer;
private void Start()
{
MyceliumNetwork.RegisterNetworkObject((object)this, 46223934u, 0);
}
private void OnDestroy()
{
MyceliumNetwork.DeregisterNetworkObject((object)this, 46223934u, 0);
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void UpdateSoundPosOnStart(DivingBell __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
soundPos = ((Component)__instance).transform.position;
}
[HarmonyPatch("RPC_GoToSurface")]
[HarmonyPostfix]
private static void AddIncorrectBuzzerSoundU(DivingBell __instance)
{
if (!(((StateMachine<DivingBellState>)(object)__instance.StateMachine).CurrentState is DivingBellReadyState))
{
MyceliumNetwork.RPC(46223934u, "PlayerBuzzerNoise", (ReliableType)1, Array.Empty<object>());
}
}
[HarmonyPatch("RPC_GoToUnderground")]
[HarmonyPostfix]
private static void AddIncorrectBuzzerSoundD(DivingBell __instance)
{
if (!(((StateMachine<DivingBellState>)(object)__instance.StateMachine).CurrentState is DivingBellReadyState))
{
MyceliumNetwork.RPC(46223934u, "PlayerBuzzerNoise", (ReliableType)1, Array.Empty<object>());
}
}
[CustomRPC]
private void PlayerBuzzerNoise(RPCInfo info)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
buzzer.Play(soundPos, false, 1f, (Transform)null);
}
public DivingBellPatch()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
SFX_Instance val = new SFX_Instance();
val.clips = (AudioClip[])(object)new AudioClip[1] { SillySoundsBase.SoundFX[3] };
val.settings = new SFX_Settings();
buzzer = val;
((MonoBehaviour)this)..ctor();
}
}
[HarmonyPatch(typeof(JumpScareSound))]
internal class JumpScareSoundPatch
{
private static Random rnd = new Random();
[HarmonyPatch("Scare")]
[HarmonyPrefix]
private static void OverrideJumpscareSFX(JumpScareSound __instance)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
int num = rnd.Next(0, 2);
Debug.Log((object)num);
num = ((num == 0) ? 1 : 4);
SFX_Instance val = new SFX_Instance();
val.clips = (AudioClip[])(object)new AudioClip[1] { SillySoundsBase.SoundFX[num] };
val.settings = new SFX_Settings();
__instance.sfx = val;
}
}
[HarmonyPatch(typeof(PlayerCustomizer))]
internal class PlayerCustomizerPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void OverrideSounds(PlayerCustomizer __instance)
{
__instance.applySound.clips = (AudioClip[])(object)new AudioClip[3]
{
SillySoundsBase.SoundFX[2],
__instance.applySound.clips[0],
__instance.applySound.clips[0]
};
}
}
[HarmonyPatch(typeof(PlayerDataSounds))]
internal class PlayerDataSoundsPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void OverrideBedAudio(PlayerDataSounds __instance)
{
__instance.bedOn.clips[0] = SillySoundsBase.SoundFX[8];
__instance.bedOff.clips[0] = SillySoundsBase.SoundFX[7];
__instance.throwEndLvl2.clips[0] = SillySoundsBase.SoundFX[9];
__instance.throwEndLvl2.settings.pitch = 1f;
}
}
[HarmonyPatch(typeof(PlayerRagdoll))]
internal class PlayerRagdollPatch
{
[HarmonyPatch("OnEnable")]
[HarmonyPostfix]
private static void OverrideRagdollAudio(PlayerRagdoll __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
__instance.ragdollSound = (SFX_Instance[])(object)new SFX_Instance[1];
SFX_Instance[] ragdollSound = __instance.ragdollSound;
SFX_Instance val = new SFX_Instance();
val.clips = (AudioClip[])(object)new AudioClip[1] { SillySoundsBase.SoundFX[5] };
val.settings = new SFX_Settings();
ragdollSound[0] = val;
}
}
[HarmonyPatch(typeof(ShockStick))]
internal class ShockStickPatch
{
[HarmonyPatch("ConfigItem")]
[HarmonyPostfix]
private static void OverrideShockImpactSound(ShockStick __instance)
{
__instance.shockImpactSound[0].clips[0] = SillySoundsBase.SoundFX[6];
__instance.shockImpactSound[0].settings.pitch = 1.25f;
}
}
}