using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PlanctonHoarder.Patches;
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("PlanctonHoarder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlanctonHoarder")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c0ec2f48-6a6c-432d-be83-6767dd7292bd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PlanctonHoarder
{
[BepInPlugin("Ex.PlanktonHoarder", "Ex Plankton Hoarder Replacement Mod", "1.0.0")]
public class PlanctonHoarderBase : BaseUnityPlugin
{
private const string modGUID = "Ex.PlanktonHoarder";
private const string modName = "Ex Plankton Hoarder Replacement Mod";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Ex.PlanktonHoarder");
private static PlanctonHoarderBase Instance;
internal ManualLogSource mls;
internal static AudioClip newDieSFX;
internal static AudioClip newAngerSFX;
internal static AudioClip newhitPlayerSFX;
internal static GameObject planctonModel;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Ex.PlanktonHoarder");
mls.LogInfo((object)"Hoarder replacement mod has initiated");
string location = ((BaseUnityPlugin)Instance).Info.Location;
string text = "PlanctonHoarder.dll";
string text2 = location.TrimEnd(text.ToCharArray());
string text3 = text2 + "planctonassets";
string text4 = text2 + "plancmodel";
AssetBundle val = AssetBundle.LoadFromFile(text3);
AssetBundle val2 = AssetBundle.LoadFromFile(text4);
if ((Object)(object)val == (Object)null)
{
mls.LogError((object)"Failed to load audio assets!");
return;
}
newhitPlayerSFX = val.LoadAsset<AudioClip>("Assets/HAttack.mp3");
newAngerSFX = val.LoadAsset<AudioClip>("Assets/HAnger.mp3");
newDieSFX = val.LoadAsset<AudioClip>("Assets/HDie.mp3");
planctonModel = val2.LoadAsset<GameObject>("Assets/Plancton.prefab");
harmony.PatchAll(typeof(PlanctonHoarderBase));
harmony.PatchAll(typeof(HoarderPatch));
mls.LogInfo((object)"Hoarder replacement mod has loaded.");
}
}
}
namespace PlanctonHoarder.Patches
{
[HarmonyPatch(typeof(HoarderBugAI))]
internal class HoarderPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void HoarderModelPatch(HoarderBugAI __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).gameObject.transform.Find("HoarderBugModel");
Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
Renderer[] array2 = array;
foreach (Renderer val2 in array2)
{
Debug.Log((object)val2);
val2.enabled = false;
}
GameObject val3 = Object.Instantiate<GameObject>(PlanctonHoarderBase.planctonModel);
val3.transform.SetParent(val);
val3.transform.localPosition = Vector3.zero;
val3.transform.localRotation = Quaternion.identity;
val3.transform.localScale = Vector3.one;
((Renderer)val3.GetComponentInChildren<MeshRenderer>()).enabled = true;
Debug.Log((object)val3);
__instance.angryVoiceSFX = PlanctonHoarderBase.newAngerSFX;
__instance.hitPlayerSFX = PlanctonHoarderBase.newhitPlayerSFX;
}
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
public static void HoarderDeadPatch(HoarderBugAI __instance)
{
((EnemyAI)__instance).dieSFX = PlanctonHoarderBase.newDieSFX;
((EnemyAI)__instance).creatureVoice.PlayOneShot(((EnemyAI)__instance).dieSFX);
}
}
}