Decompiled source of LegoGnomes v1.0.2

GnomeLegoBreakMod.dll

Decompiled a month 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 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("GnomeLegoBreakMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GnomeLegoBreakMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("181d68d9-b8f0-46ac-acb9-aa87936fbf55")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GnomeLegoBreakMod
{
	[BepInPlugin("ColtG5.LegoGnomes", "LegoGnomes", "1.0.2")]
	public class GnomeLegoBreakMod : BaseUnityPlugin
	{
		private const string modGUID = "ColtG5.LegoGnomes";

		private const string modName = "LegoGnomes";

		private const string modVersion = "1.0.2";

		private readonly Harmony harmony = new Harmony("ColtG5.LegoGnomes");

		internal static GnomeLegoBreakMod instance;

		internal ManualLogSource logger;

		internal static List<AudioClip> newBreakSound;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			logger = Logger.CreateLogSource("ColtG5.LegoGnomes");
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("GnomeLegoBreakMod.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "coltg5-gnome-sounds");
			if ((Object)(object)Bundle != (Object)null)
			{
				newBreakSound = Bundle.LoadAllAssets<AudioClip>().ToList();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Asset bundle loaded!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!");
			}
			logger.LogInfo((object)"GnomeLegoBreakMod loaded!");
		}
	}
}
namespace GnomeLegoBreakMod.Patches
{
	[HarmonyPatch(typeof(EnemyGnome))]
	internal class EnemyGnomePatch
	{
		private static GnomeLegoBreakMod Instance = GnomeLegoBreakMod.instance;

		private static ManualLogSource Logger => Instance.logger;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void PatchEnemyGnomeAnimAwake(EnemyGnome __instance)
		{
			__instance.soundDeath.Sounds = GnomeLegoBreakMod.newBreakSound.ToArray();
			__instance.soundDeath.Volume = 2f;
		}
	}
}