Decompiled source of Vergil Bracken v1.0.0

VergilBracken.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("VergilBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VergilBracken")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2491103b-45b3-4a1b-af0b-8ccc8655c98a")]
[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 VergilBracken
{
	[BepInPlugin("Vergil.Bracken", "Vergil Bracken", "1.0.0")]
	public class BasePlugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "Vergil.Bracken";

		public const string PLUGIN_NAME = "Vergil Bracken";

		public const string PLUGIN_VERSION = "1.0.0";

		public static GameObject vergilPrefab;

		public static AudioClip mainTheme;

		public static AudioClip crackNeckSound;

		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "dmc5");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			vergilPrefab = val.LoadAsset<GameObject>("assets/vergil/prefabs/vergil.prefab");
			mainTheme = val.LoadAsset<AudioClip>("assets/vergil/audios/theme.wav");
			crackNeckSound = val.LoadAsset<AudioClip>("assets/vergil/audios/powerQuote.wav");
			SkinnedMeshRenderer[] componentsInChildren = vergilPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val2 in array)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
		}
	}
}
namespace VergilBracken.Patches
{
	[HarmonyPatch]
	internal class BrackenPatch
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		private static void addController(FlowermanAI __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((Component)__instance).gameObject.AddComponent<VergilController>();
		}
	}
	internal class VergilController : MonoBehaviour
	{
		private FlowermanAI FlowermanAI { get; set; }

		private AudioSource AudioSource { get; set; }

		private void LoadAudio()
		{
			FlowermanAI.crackNeckSFX = BasePlugin.crackNeckSound;
			AudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			AudioSource.clip = BasePlugin.mainTheme;
			AudioSource.spatialBlend = 1f;
			AudioSource.minDistance = 1f;
			AudioSource.maxDistance = 14f;
			AudioSource.rolloffMode = (AudioRolloffMode)1;
			AudioSource.loop = true;
			AudioSource.volume = 0.5f;
			AudioSource.Play();
		}

		private void HideFlowermanModel()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = ((Component)((Component)FlowermanAI).transform.Find("FlowermanModel")).GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
		}

		private void Start()
		{
			FlowermanAI = ((Component)this).GetComponent<FlowermanAI>();
			LoadAudio();
			HideFlowermanModel();
			Object.Instantiate<GameObject>(BasePlugin.vergilPrefab, ((Component)this).gameObject.transform);
		}
	}
}