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 HarmonyLib;
using HoardingSpeaks.Patches;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HoardingSpeaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a few different voice lines to the loot bug which plays randomly")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HoardingSpeaks")]
[assembly: AssemblyTitle("HoardingSpeaks")]
[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 HoardingSpeaks
{
[BepInPlugin("nordbo.HoardingSpeaks", "Loot Bug Voice Lines", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "nordbo.HoardingSpeaks";
private const string modName = "Loot Bug Voice Lines";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("nordbo.HoardingSpeaks");
internal ManualLogSource mls;
public static Plugin Instance;
internal static AudioClip[] voiceLines;
internal static AssetBundle assetBundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("nordbo.HoardingSpeaks");
mls.LogInfo((object)"Plugin nordbo.HoardingSpeaks is loaded!");
LoadVoiceLines();
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(HoarderBugPatch));
}
private void LoadVoiceLines()
{
assetBundle = LoadAssetBundle("voice_bundle");
if ((Object)(object)assetBundle != (Object)null)
{
voiceLines = (AudioClip[])(object)new AudioClip[20];
for (int i = 0; i < voiceLines.Length; i++)
{
string text = $"voice{i + 1}";
voiceLines[i] = assetBundle.LoadAsset<AudioClip>(text);
if ((Object)(object)voiceLines[i] == (Object)null)
{
mls.LogError((object)("Failed to load audio clip: " + text));
}
else
{
mls.LogInfo((object)("Loaded audio clip: " + text));
}
}
}
else
{
mls.LogError((object)"Failed to load voice bundle!");
}
}
internal static AudioClip GetRandomVoiceLine()
{
return voiceLines[Random.Range(0, voiceLines.Length)];
}
private AssetBundle LoadAssetBundle(string bundleName)
{
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("HoardingSpeaks.dll".ToCharArray());
string text = location + "/" + bundleName;
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
mls.LogError((object)("Failed to load AssetBundle: " + text));
}
else
{
mls.LogInfo((object)("Loaded AssetBundle: " + text));
}
return val;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "HoardingSpeaks";
public const string PLUGIN_NAME = "HoardingSpeaks";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HoardingSpeaks.Patches
{
[HarmonyPatch(typeof(HoarderBugAI))]
internal class HoarderBugPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void HoarderBugAudioPatch(ref AudioClip[] ___chitterSFX)
{
___chitterSFX = Plugin.voiceLines;
}
}
}