Decompiled source of HappyBirthdayMod v1.0.2

HappyBirthday.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HappyBirthday.Patches;
using HarmonyLib;
using LethalLib.Modules;
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("HappyBirthday")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HappyBirthday")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("24eff77f-407d-4ea0-92a8-d5b123da354d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HappyBirthday
{
	[BepInPlugin("EveryDayUser.HappyBirthdayMod", "Happy Birthday Mod", "1.0.0.0")]
	public class HappyBirthdayBase : BaseUnityPlugin
	{
		private const string modGUID = "EveryDayUser.HappyBirthdayMod";

		private const string modName = "Happy Birthday Mod";

		private const string modeVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("EveryDayUser.HappyBirthdayMod");

		private static HappyBirthdayBase Instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("EveryDayUser.HappyBirthdayMod");
			mls.LogInfo((object)"Happy Birthday :) ");
			harmony.PatchAll(typeof(HappyBirthdayBase));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("HappyBirthday.ddl".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "birthday-party-horn");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Successfully Loaded Happy Birthday Sound Asset Bundle");
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed To Load Happy Birthday Sound Asset Bundle");
				mls.LogError((object)location);
				mls.LogError((object)Bundle);
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "birthdaycakeitems");
			mls.LogInfo((object)text);
			AssetBundle val = AssetBundle.LoadFromFile(text);
			mls.LogInfo((object)text);
			Item val2 = val.LoadAsset<Item>("Assets/models/Items/BirthdayCake/BirthdayCakeItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 200, (LevelTypes)(-1));
			TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
			val3.clearPreviousText = true;
			val3.displayText = "A really great looking cake!\n\n";
			Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, 0);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Happy Birthday Items Patched");
		}
	}
}
namespace HappyBirthday.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			__instance.shipIntroSpeechSFX = HappyBirthdayBase.SoundFX[0];
		}
	}
}