using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ChanovMod.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("YippeeMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YippeeMod")]
[assembly: AssemblyTitle("YippeeMod")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ChanovMod
{
[BepInPlugin("Mallifrey.ChanovMod", "Chanov Mod", "1.2.0")]
public class ChanovModBase : BaseUnityPlugin
{
private const string modGUID = "Mallifrey.ChanovMod";
private const string modName = "Chanov Mod";
private const string modVersion = "1.2.0";
private readonly Harmony harmony = new Harmony("Mallifrey.ChanovMod");
private static ChanovModBase Instance;
public static ManualLogSource mls;
public static AudioClip[] ChitterSFX;
public static AudioClip[] AngrySFX;
public static AudioClip[] HitSFX;
public static AssetBundle AssetBundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Chanov Mod");
mls.LogInfo((object)"Chanov Mod [1.2.0] is loading.");
string location = ((BaseUnityPlugin)Instance).Info.Location;
string text = location.Remove(location.LastIndexOf('\\') + 1);
AssetBundle = AssetBundle.LoadFromFile(text + "sounds");
if ((Object)(object)AssetBundle == (Object)null)
{
mls.LogError((object)"Failed to load audio assets!");
return;
}
if (!LoadSFXs())
{
mls.LogError((object)"Failed to load some of the audio!");
return;
}
harmony.PatchAll(typeof(HoarderBugPatch));
mls.LogInfo((object)"Chanov Mod is loaded. Chanov pico!!!");
}
private bool LoadSFXs()
{
return LoadAssetWithName("co_zkousis.mp3", out ChitterSFX) && LoadAssetWithName("proc_uklizite.mp3", out AngrySFX) && LoadAssetWithName("ty_zmrde.mp3", out HitSFX);
}
private static bool LoadAssetWithName(string filename, out AudioClip[] audioClips)
{
string text = "Assets/Sounds/" + filename;
if (!AssetBundle.Contains(text))
{
mls.LogError((object)("Failed to load '" + text + "' audio!"));
audioClips = (AudioClip[])(object)new AudioClip[0];
return false;
}
audioClips = AssetBundle.LoadAssetWithSubAssets<AudioClip>(text);
return audioClips != null && audioClips.Length != 0;
}
}
}
namespace ChanovMod.Patches
{
[HarmonyPatch(typeof(HoarderBugAI))]
internal class HoarderBugPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void hoarderBugAudioPatch(ref AudioClip[] ___chitterSFX, ref AudioClip[] ___angryScreechSFX)
{
___chitterSFX = ChanovModBase.ChitterSFX;
___angryScreechSFX = ChanovModBase.AngrySFX;
ChanovModBase.mls.LogInfo((object)"Replacing Hoarding Bug Sounds!");
}
[HarmonyPatch("HitEnemy")]
[HarmonyPostfix]
public static void hoarderBugHit(HoarderBugAI __instance)
{
if (!((EnemyAI)__instance).isEnemyDead)
{
PlayHitSound(__instance);
}
}
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
public static void hoarderBugDie(HoarderBugAI __instance)
{
PlayHitSound(__instance);
}
public static void PlayHitSound(HoarderBugAI instance)
{
ChanovModBase.mls.LogInfo((object)"Playing Hoarding Bug Hit Sound!");
((EnemyAI)instance).creatureVoice.PlayOneShot(ChanovModBase.HitSFX[0]);
}
}
}