Decompiled source of Gnomed v1.0.0

Gnomed.dll

Decompiled a day 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 Gnomed.Patches;
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("Gnomed")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Gnomed")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b341e39e-d45a-4c59-9698-f62a219bd14f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Gnomed
{
	[BepInPlugin("pudack.Gnomed", "Gnomed", "1.0.0")]
	public class GnomedBase : BaseUnityPlugin
	{
		private const string modGUID = "pudack.Gnomed";

		private const string modName = "Gnomed";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("pudack.Gnomed");

		internal static GnomedBase instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> sounds;

		internal static List<AudioClip> rick;

		internal static AssetBundle bundle;

		public void Awake()
		{
			if (instance == null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("pudack.Gnomed");
			mls.LogInfo((object)"Gnomed Loading...");
			harmony.PatchAll(typeof(GnomedBase));
			harmony.PatchAll(typeof(EnemyGnomeAnimPatch));
			sounds = new List<AudioClip>();
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("Gnomed.dll".ToCharArray());
			bundle = AssetBundle.LoadFromFile(location + "gnomefx");
			if (bundle == null)
			{
				mls.LogError((object)"Failed to load audio asset!");
				return;
			}
			sounds = bundle.LoadAllAssets<AudioClip>().ToList();
			mls.LogInfo((object)"pudack.gnomed is loaded");
			harmony.PatchAll(typeof(MusicBoxMusicPatch));
			rick = new List<AudioClip>();
			location = location.TrimEnd("Gnomed.dll".ToCharArray());
			bundle = AssetBundle.LoadFromFile(location + "rick");
			if (bundle == null)
			{
				mls.LogError((object)"Failed to load rick!");
			}
			else
			{
				rick = bundle.LoadAllAssets<AudioClip>().ToList();
			}
		}
	}
}
namespace Gnomed.Patches
{
	[HarmonyPatch(typeof(EnemyGnomeAnim))]
	internal class EnemyGnomeAnimPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void ReplaceAudio(EnemyGnomeAnim __instance)
		{
			__instance.soundNotice.Sounds = GnomedBase.sounds.ToArray();
		}
	}
	[HarmonyPatch(typeof(MusicBoxTrap))]
	internal class MusicBoxMusicPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void ReplaceAudio(MusicBoxTrap __instance)
		{
			__instance.MusicBoxMusic.Sounds = GnomedBase.rick.ToArray();
		}
	}
}