using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using ChompChomp.Patches;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ChompChomp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChompChomp")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f243e8f9-cd69-4025-b6e5-7d5920b78357")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ChompChomp
{
[BepInPlugin("mattplays.ChompChomp", "ChompChomp", "1.0.0")]
public class ChompChomp : BaseUnityPlugin
{
private const string modGUID = "mattplays.ChompChomp";
private const string modName = "ChompChomp";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("mattplays.ChompChomp");
private static string[] audioFiles = new string[2] { "scream.mp3", "killPlayer.mp3" };
private static List<AudioClip> clips = new List<AudioClip>();
private static string uPath = Path.Combine(Paths.PluginPath + "\\mattplays-ChompChomp\\");
private static ChompChomp instance;
internal ManualLogSource mls;
internal static AudioClip newScreamSFX;
internal static AudioClip newKillPlayerSFX;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
mls = Logger.CreateLogSource("mattplays.ChompChomp");
mls.LogInfo((object)"ChompChomp Loading...");
string[] array = audioFiles;
foreach (string text in array)
{
LoadAudioClip(uPath + text);
}
newScreamSFX = clips[0];
newKillPlayerSFX = clips[1];
harmony.PatchAll(typeof(MouthDogAIPatch));
mls.LogInfo((object)"ChompChomp Loaded!");
}
private static void LoadAudioClip(string filepath)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Invalid comparison between Unknown and I4
ManualLogSource val = Logger.CreateLogSource("mattplays.ChompChomp");
val.LogInfo((object)("Loading audio clip from " + filepath));
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(filepath, (AudioType)13);
audioClip.SendWebRequest();
while (!audioClip.isDone)
{
}
if (audioClip.error != null)
{
val.LogError((object)"Failed to load audio clip");
}
AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
if (Object.op_Implicit((Object)(object)content) && (int)content.loadState == 2)
{
val.LogInfo((object)"Loaded audio clip successfully!");
clips.Add(content);
}
}
}
}
namespace ChompChomp.Patches
{
[HarmonyPatch(typeof(MouthDogAI))]
internal class MouthDogAIPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void MouthDogAIPatches(ref AudioClip ___screamSFX, ref AudioClip ___killPlayerSFX)
{
___screamSFX = ChompChomp.newScreamSFX;
___killPlayerSFX = ChompChomp.newKillPlayerSFX;
}
}
}