Decompiled source of ForestGiantSoundNew v0.0.1

ForestGiantSoundNew.dll

Decompiled 2 months ago
using System;
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 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("ForestGiantSoundNew")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ForestGiantSoundNew")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("215de8be-fcab-4daa-9f1f-25c4fa27c65b")]
[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 NevinMod
{
	[BepInPlugin("nevinture.ForestGiantSound", "ForestGiantSound", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "nevinture.ForestGiantSound";

		private const string NAME = "ForestGiantSound";

		private const string VERSION = "0.0.1";

		public static Plugin instance;

		private readonly Harmony harmony = new Harmony("nevinture.ForestGiantSound");

		public static AudioClip[] eggsSFX;

		public static Random random = new Random();

		public static ManualLogSource logger = Logger.CreateLogSource("nevinture.ForestGiantSound");

		public static Dictionary<ForestGiantAI, VariableStore> dict = new Dictionary<ForestGiantAI, VariableStore>();

		private void Awake()
		{
			instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"nevinture.ForestGiantSound start loading");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "forest_giant");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load assets!");
			}
			eggsSFX = val.LoadAssetWithSubAssets<AudioClip>("Assets/Sounds/eggs_cut_extended.mp3");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched method names:");
			foreach (MethodBase patchedMethod in harmony.GetPatchedMethods())
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)patchedMethod.Name);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"plugin loaded successfully!");
		}
	}
	public class VariableStore
	{
		public DateTime dateTime = DateTime.Now;
	}
}
namespace NevinMod.Patches
{
	[HarmonyPatch(typeof(ForestGiantAI))]
	[HarmonyPatch("Start")]
	internal class ForestGiantStartPatch
	{
		private static void Postfix(ForestGiantAI __instance)
		{
			if (((object)__instance).GetType() == typeof(ForestGiantAI))
			{
				Plugin.dict.Add(__instance, new VariableStore());
			}
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	[HarmonyPatch("Update")]
	internal class ForestGiantAudioPlayPatch
	{
		private static void Postfix(ForestGiantAI __instance)
		{
			if (((object)__instance).GetType() == typeof(ForestGiantAI))
			{
				DateTime now = DateTime.Now;
				if (DateTime.Compare(Plugin.dict[__instance].dateTime, now) < 0)
				{
					__instance.giantBurningAudio.volume = 1f;
					__instance.giantBurningAudio.PlayOneShot(Plugin.eggsSFX[0]);
					Plugin.dict[__instance].dateTime = now.AddSeconds(Plugin.random.Next(6, 15));
				}
			}
		}
	}
}