Decompiled source of Tyler1Goo v1.0.0

Tyler1Goo.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Tyler1Goo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tyler1Goo")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8e27ef8c-cc5e-4425-8fe6-0a33cf628868")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Tyler1Goo
{
	[BepInPlugin("SteamBlizzard.Tyler1Goo", "Tyler1Goo", "1.0.0")]
	public class Tyler1GooBase : BaseUnityPlugin
	{
		public const string modGUID = "SteamBlizzard.Tyler1Goo";

		public const string modName = "Tyler1Goo";

		public const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("SteamBlizzard.Tyler1Goo");

		private static Tyler1GooBase Instance;

		public static ManualLogSource logger;

		public static AudioClip audioClip;

		public void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("SteamBlizzard.Tyler1Goo");
			string text = "file://" + Paths.PluginPath + "\\SteamBlizzard-Tyler1Goo\\tyler1_help.mp3";
			UnityWebRequest val = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)13);
			val.SendWebRequest();
			while (!val.isDone)
			{
			}
			audioClip = DownloadHandlerAudioClip.GetContent(val);
			logger.LogInfo((object)"Tyler1Goo Loaded.");
			harmony.PatchAll();
		}
	}
}
namespace Tyler1Goo.SteamBlizzard.Patches
{
	[HarmonyPatch(typeof(Bot_Jelly))]
	internal class JellyUpdatePatch
	{
		private class JellyAudioInfo
		{
			public bool IsPlaying { get; set; }

			public AudioSource AudioSource { get; set; }
		}

		private static readonly Random random = new Random();

		private static readonly Dictionary<Bot_Jelly, JellyAudioInfo> jellyAudioInfoMap = new Dictionary<Bot_Jelly, JellyAudioInfo>();

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(Bot_Jelly __instance, ref Player ___jellyPlayer)
		{
			if (!jellyAudioInfoMap.TryGetValue(__instance, out var value))
			{
				value = new JellyAudioInfo
				{
					IsPlaying = false,
					AudioSource = ((Component)__instance).gameObject.AddComponent<AudioSource>()
				};
				value.AudioSource.spatialBlend = 1f;
				value.AudioSource.dopplerLevel = 1f;
				value.AudioSource.rolloffMode = (AudioRolloffMode)0;
				value.AudioSource.minDistance = 5f;
				value.AudioSource.maxDistance = 50f;
				value.AudioSource.volume = 0.8f;
				jellyAudioInfoMap[__instance] = value;
			}
			if (!value.IsPlaying && (Object)(object)___jellyPlayer != (Object)null)
			{
				value.IsPlaying = true;
				value.AudioSource.clip = Tyler1GooBase.audioClip;
				value.AudioSource.PlayOneShot(Tyler1GooBase.audioClip);
			}
		}

		[HarmonyPatch("RPCA_DropAndFlee")]
		[HarmonyPostfix]
		public static void DropAndFleePatch(Bot_Jelly __instance)
		{
			if (jellyAudioInfoMap.TryGetValue(__instance, out var value))
			{
				value.IsPlaying = false;
				value.AudioSource.Stop();
			}
		}

		[HarmonyPatch(typeof(DivingBell), "RPC_GoToSurface")]
		[HarmonyPostfix]
		public static void EndOfRoundCleanUp()
		{
			Tyler1GooBase.logger.LogWarning((object)"Clearing `jellyInfoMap`...");
			jellyAudioInfoMap.Clear();
		}
	}
}