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 AxelBracken.Patches;
using BepInEx;
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("AxelBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AxelBracken")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a33961ad-dede-40d6-9b07-3330d6473c69")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AxelBracken
{
[BepInPlugin("LOKYOL.AxelBracken", "AxelBracken", "1.0.0")]
public class AxelBrackenModBase : BaseUnityPlugin
{
private const string modGUID = "LOKYOL.AxelBracken";
private const string modName = "AxelBracken";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("LOKYOL.AxelBracken");
private static AxelBrackenModBase Instance;
internal static ManualLogSource mls;
internal static List<AudioClip> SoundFX;
internal static AssetBundle Bundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("LOKYOL.AxelBracken");
mls.LogInfo((object)"Axel devient le bracken !");
harmony.PatchAll(typeof(AxelBrackenModBase));
SoundFX = new List<AudioClip>();
string text = ((BaseUnityPlugin)this).Info.Location.TrimEnd("AxelBracken.dll".ToCharArray());
Bundle = AssetBundle.LoadFromFile(text + "axelbracken");
if ((Object)(object)Bundle != (Object)null)
{
SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
string text2 = $"Successfully loaded asset bundle\nfound {SoundFX.Count} sounds :\n";
foreach (AudioClip item in SoundFX)
{
text2 = text2 + "-" + ((Object)item).name + "\n";
}
mls.LogInfo((object)text2);
}
else
{
mls.LogError((object)"Failed to load asset bundle");
}
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(BrackenSoundPatch));
}
}
}
namespace AxelBracken.Patches
{
[HarmonyPatch(typeof(FlowermanAI))]
internal class BrackenSoundPatch
{
private const string AngerSoundName = "Anger";
private const string FleeSoundName = "Flee";
private const string CrackNeckSoundName = "NeckCracking";
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Init(FlowermanAI __instance)
{
foreach (AudioClip item in AxelBrackenModBase.SoundFX)
{
switch (((Object)item).name)
{
case "Anger":
__instance.creatureAngerVoice.clip = item;
break;
case "NeckCracking":
__instance.crackNeckSFX = item;
break;
case "Flee":
((EnemyAI)__instance).enemyBehaviourStates[1].VoiceClip = item;
break;
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRoundPatch
{
private const string IntroSoundName = "Intro";
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void OverrideAudio(StartOfRound __instance)
{
AudioClip val = AxelBrackenModBase.SoundFX.Find((AudioClip clip) => ((Object)clip).name == "Intro");
if ((Object)(object)val != (Object)null)
{
__instance.shipIntroSpeechSFX = val;
AxelBrackenModBase.mls.LogInfo((object)"Axel devient l'intro !");
return;
}
string text = "Cant find intro sound named 'Intro'\nAll sounds :\n";
foreach (AudioClip item in AxelBrackenModBase.SoundFX)
{
text = text + "\t-" + ((Object)item).name + "\n";
}
AxelBrackenModBase.mls.LogError((object)text);
}
}
}