Decompiled source of TouchMeDuckFromGhostStories v1.0.0

BepInEx/plugins/Krild-Sounds/DuckTouchMe.dll

Decompiled 3 weeks ago
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 BepInEx;
using BepInEx.Logging;
using DuckTouchMe.Patch;
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("DuckTouchMe")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DuckTouchMe")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d2afc2ad-8455-402e-988b-ff7abcd3ac95")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DuckTouchMe
{
	[BepInPlugin("KrildDuck", "DuckTouchMe", "1.0.0.0")]
	public class Krild : BaseUnityPlugin
	{
		private const string modGUID = "KrildDuck";

		private const string modName = "DuckTouchMe";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("KrildDuck");

		internal static Krild current;

		internal ManualLogSource log;

		internal static List<AudioClip> sounds;

		internal static AssetBundle bundle;

		private void Awake()
		{
			if ((Object)(object)current == (Object)null)
			{
				current = this;
			}
			log = Logger.CreateLogSource("KrildDuck");
			harmony.PatchAll(typeof(Krild));
			harmony.PatchAll(typeof(DuckLearnsToSayTouchMe));
			string location = ((BaseUnityPlugin)current).Info.Location;
			location = location.TrimEnd("DuckTouchMe.dll".ToCharArray());
			bundle = AssetBundle.LoadFromFile(location + "ducktouchme");
			if ((Object)(object)bundle == (Object)null)
			{
				log.LogError((object)"Failed to load asset bundle!. Is the soundfile maybe in a different location than the .dll file?");
				return;
			}
			sounds = new List<AudioClip>();
			sounds = bundle.LoadAllAssets<AudioClip>().ToList();
			log.LogInfo((object)"Krildiger TouchMe Sound geladen :3");
		}
	}
}
namespace DuckTouchMe.Patch
{
	[HarmonyPatch(typeof(EnemyDuckAnim))]
	internal class DuckLearnsToSayTouchMe
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void ReplaceAudio(EnemyDuckAnim __instance)
		{
			__instance.noticeSound.Sounds = Krild.sounds.ToArray();
		}

		[HarmonyPatch("Quack")]
		[HarmonyPrefix]
		private static bool PlayRandom(EnemyDuckAnim __instance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (Random.Range(1, 10) < 4)
			{
				__instance.noticeSound.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
				return false;
			}
			return true;
		}
	}
}