Decompiled source of TateBracken v1.0.0

LethalCompanyAndrewTateMod.dll

Decompiled 5 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("LethalCompanyAndrewTateMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalCompanyAndrewTateMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2b7928d2-61f2-43d3-8cbd-a1b103a8cda1")]
[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 LethalCompanyAndrewTateMod
{
	[BepInPlugin("TateBracken", "TateBracken", "1.0.0")]
	public class BasePlugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "TateBracken";

		public const string PLUGIN_NAME = "TateBracken";

		public const string PLUGIN_VERSION = "1.0.0";

		public static GameObject tatePrefab;

		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), "andrewtate");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			tatePrefab = val.LoadAsset<GameObject>("assets/tate/prefab/AnrewTate.prefab");
			mainTheme = val.LoadAsset<AudioClip>("assets/tate/audios/mainTheme.wav");
			crackNeckSound = val.LoadAsset<AudioClip>("assets/tate/audios/bmQuote.wav");
			SkinnedMeshRenderer[] componentsInChildren = tatePrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val2 in array)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
		}
	}
}
namespace LethalCompanyAndrewTateMod.Patches
{
	[HarmonyPatch]
	internal class FlowermanPatch
	{
		[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<TateController>();
		}
	}
	internal class TateController : MonoBehaviour
	{
		private FlowermanAI FlowermanAI { get; set; }

		private Animator Animator { get; set; }

		private AudioSource AudioSource { get; set; }

		private bool IsDead { get; set; }

		private bool IsMoving { get; set; }

		private Vector3 prevPosition { 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.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>();
			Animator = Object.Instantiate<GameObject>(BasePlugin.tatePrefab, ((Component)this).gameObject.transform).GetComponent<Animator>();
			LoadAudio();
			HideFlowermanModel();
		}

		private void Update()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Animator.SetBool("isAngry", ((EnemyAI)FlowermanAI).movingTowardsTargetPlayer);
			Animator.SetBool("isMoving", prevPosition != ((Component)this).transform.position);
			if (((EnemyAI)FlowermanAI).isEnemyDead && !IsDead)
			{
				KillGoku();
			}
			prevPosition = ((Component)this).transform.position;
		}

		private void KillGoku()
		{
			Animator.SetBool("isDead", true);
			AudioSource.Stop();
			IsDead = true;
		}
	}
}