Decompiled source of JacBracken v1.0.5

BepInEx/plugins/JacBracken.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using JacBracken.Patches;
using UnityEngine;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("JacBracken")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JacBracken")]
[assembly: AssemblyTitle("JacBracken")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace JacBracken
{
	[BepInPlugin("JacBracken", "Jac Bracken", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "JacBracken";

		private const string PLUGIN_NAME = "Jac Bracken";

		private const string PLUGIN_VERSION = "1.0.5";

		private readonly Harmony harmony = new Harmony("JacBracken");

		public static Plugin Instance;

		internal ManualLogSource logger;

		internal static List<AudioClip> soundFX;

		internal static List<VideoClip> videos;

		internal static List<GameObject> gameObjs;

		internal static AudioClip what;

		internal static AudioClip sus;

		internal static AudioClip library;

		internal static AudioClip screech;

		internal static GameObject jac;

		internal static AssetBundle bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("JacBracken");
			logger.LogInfo((object)"Plugin JacBracken is loaded!");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("JacBracken.dll".ToCharArray());
			bundle = AssetBundle.LoadFromFile(location + "jac");
			if ((Object)(object)bundle != (Object)null)
			{
				soundFX = bundle.LoadAllAssets<AudioClip>().ToList();
				foreach (AudioClip item in soundFX)
				{
					logger.LogInfo((object)("Got sound " + item.GetName()));
					if (item.GetName().Equals("what"))
					{
						what = item;
					}
					else if (item.GetName().Equals("sus"))
					{
						sus = item;
					}
					else if (item.GetName().Equals("library"))
					{
						library = item;
					}
					else if (item.GetName().Equals("screech"))
					{
						screech = item;
					}
				}
				videos = bundle.LoadAllAssets<VideoClip>().ToList();
				gameObjs = bundle.LoadAllAssets<GameObject>().ToList();
				foreach (GameObject gameObj in gameObjs)
				{
					logger.LogInfo((object)("Got game obj " + ((Object)gameObj).name));
					if (((Object)gameObj).name.Equals("Jac"))
					{
						jac = gameObj;
					}
				}
				logger.LogInfo((object)"Successfully loaded asset bundle");
			}
			else
			{
				logger.LogError((object)"Failed to load asset bundle");
			}
			PatchAll();
		}

		private void PatchAll()
		{
			harmony.PatchAll(typeof(EnemyTypes));
			harmony.PatchAll(typeof(TerminalPatches));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "JacBracken";

		public const string PLUGIN_NAME = "JacBracken";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace JacBracken.Patches
{
	[HarmonyPatch]
	internal class EnemyTypes
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		public static void SummonJac(FlowermanAI __instance)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			PlayAudioAnimationEvent component = ((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel").Find("AnimContainer")).GetComponent<PlayAudioAnimationEvent>();
			__instance.creatureAngerVoice.clip = Plugin.library;
			__instance.crackNeckSFX = Plugin.what;
			__instance.crackNeckAudio.clip = Plugin.what;
			((EnemyAI)__instance).enemyType.hitBodySFX = Plugin.screech;
			component.audioClip = Plugin.sus;
			Object.Destroy((Object)(object)((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel").Find("LOD1")).gameObject.GetComponent<SkinnedMeshRenderer>());
			GameObject val = Object.Instantiate<GameObject>(Plugin.jac, ((Component)__instance).gameObject.transform);
			val.transform.localPosition = new Vector3(0f, 1.5f, 0f);
		}
	}
	[HarmonyPatch]
	internal class TerminalPatches
	{
		[HarmonyPatch(typeof(Terminal), "Awake")]
		[HarmonyPostfix]
		public static void EditTerminal(Terminal __instance)
		{
			__instance.enemyFiles[1].displayVideo = Plugin.videos[0];
		}
	}
}