Decompiled source of TouhouEnemyModels v1.0.0

TouhouEnemyModels.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using LCSoundTool;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations.Rigging;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TouhouEnemyModels")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+058acb040a2bbc99bb95ca54a9b05dc08dc7be12")]
[assembly: AssemblyProduct("TouhouEnemyModels")]
[assembly: AssemblyTitle("TouhouEnemyModels")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TouhouEnemyModels
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.bean.TouhouEnemyModels";

		public const string PLUGIN_NAME = "TouhouEnemyModels";

		public const string PLUGIN_VERSION = "0.9.5";
	}
	[HarmonyPatch]
	internal class Patches
	{
		[HarmonyPatch(typeof(DeadBodyInfo), "Start")]
		[HarmonyPostfix]
		private static void ReplaceDeadBodySpringModel(DeadBodyInfo __instance)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			if (__instance == null || (Object)(object)TouhouEnemiesPlugin.SekiHeadVisuals == (Object)null || !TouhouEnemiesPlugin.EnableCoilHeadReplace.Value || !TouhouEnemiesPlugin.EnableBodyCoilReplace.Value)
			{
				return;
			}
			try
			{
				Rigidbody[] bodyParts = __instance.bodyParts;
				foreach (Rigidbody val in bodyParts)
				{
					if (((Object)val).name.Contains("Spring"))
					{
						Transform val2 = ((Component)val).transform.Find("spine.001/spine.002/spine.003/spine.004/SpringContainer");
						SkinnedMeshRenderer component = ((Component)val2.Find("Spring.001")).GetComponent<SkinnedMeshRenderer>();
						Transform val3 = val2.Find("SpringMetarig");
						if ((Object)(object)component != (Object)null)
						{
							((Renderer)component).enabled = false;
						}
						GameObject val4 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.SekiHeadVisuals);
						val4.transform.SetParent(val2);
						val4.transform.localPosition = Vector3.zero;
						val4.transform.localRotation = Quaternion.identity;
						val4.transform.localScale = Vector3.one;
						Transform val5 = val4.transform.Find("Head/Body");
						Transform val6 = val4.transform.Find("Head/Armature");
						val6.SetParent(val3.parent, true);
						((Component)val6).transform.localScale = ((Component)val3).transform.localScale;
						((Component)val6).transform.localRotation = ((Component)val3).transform.localRotation;
						((Component)val6).transform.localPosition = ((Component)val3).transform.localPosition;
						SkinnedMeshRenderer component2 = ((Component)val5).GetComponent<SkinnedMeshRenderer>();
						component2.rootBone = val6;
						((Object)val6).name = "SpringMetarig";
						TouhouEnemiesPlugin.Instance.AddLog("Spring model changed.");
					}
				}
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("Failed to replace the spring.");
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPrefix]
		private static void ReplaceEnemyModels(EnemyAI __instance)
		{
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Expected O, but got Unknown
			//IL_11c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_1256: Unknown result type (might be due to invalid IL or missing references)
			//IL_126f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1288: Unknown result type (might be due to invalid IL or missing references)
			//IL_137c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1386: Expected O, but got Unknown
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_0873: Unknown result type (might be due to invalid IL or missing references)
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0906: Unknown result type (might be due to invalid IL or missing references)
			//IL_098c: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b00: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Expected O, but got Unknown
			//IL_0f2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_104f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1062: Unknown result type (might be due to invalid IL or missing references)
			//IL_1075: Unknown result type (might be due to invalid IL or missing references)
			//IL_10aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b4: Expected O, but got Unknown
			//IL_0d5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dfd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea9: Unknown result type (might be due to invalid IL or missing references)
			SpringManAI val = (SpringManAI)(object)((__instance is SpringManAI) ? __instance : null);
			if (val == null)
			{
				NutcrackerEnemyAI val2 = (NutcrackerEnemyAI)(object)((__instance is NutcrackerEnemyAI) ? __instance : null);
				if (val2 == null)
				{
					ForestGiantAI val3 = (ForestGiantAI)(object)((__instance is ForestGiantAI) ? __instance : null);
					if (val3 == null)
					{
						HoarderBugAI val4 = (HoarderBugAI)(object)((__instance is HoarderBugAI) ? __instance : null);
						if (val4 == null)
						{
							SandWormAI val5 = (SandWormAI)(object)((__instance is SandWormAI) ? __instance : null);
							if (val5 == null || !((Object)(object)TouhouEnemiesPlugin.YuyukoVisuals != (Object)null) || !TouhouEnemiesPlugin.EnableSandWormReplace.Value)
							{
								return;
							}
							try
							{
								Animator componentInChildren = ((Component)val5).GetComponentInChildren<Animator>();
								RuntimeAnimatorController runtimeAnimatorController = componentInChildren.runtimeAnimatorController;
								Transform val6 = ((Component)val5).transform.Find("MeshContainer");
								object obj;
								if (val6 == null)
								{
									obj = null;
								}
								else
								{
									Transform obj2 = val6.Find("Renderer");
									obj = ((obj2 != null) ? ((Component)obj2).GetComponent<SkinnedMeshRenderer>() : null);
								}
								SkinnedMeshRenderer val7 = (SkinnedMeshRenderer)obj;
								if ((Object)(object)val7 != (Object)null)
								{
									((Renderer)val7).enabled = false;
								}
								Transform val8 = ((val6 != null) ? val6.Find("Armature").Find("Bone") : null);
								if (!((Object)(object)val8 == (Object)null))
								{
									((Object)val8).name = "old-Bone";
									GameObject val9 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.YuyukoVisuals);
									val9.transform.SetParent(((Component)val5).transform);
									val9.transform.localPosition = Vector3.zero;
									val9.transform.localRotation = Quaternion.identity;
									val9.transform.localScale = Vector3.one;
									Transform val10 = val9.transform.Find("MeshContainer");
									Transform val11 = ((Component)val10).transform.Find("Renderer");
									Transform val12 = ((Component)val10).transform.Find("Armature").Find("Bone");
									val12.SetParent(val8.parent, true);
									((Component)val12).transform.localScale = ((Component)val8).transform.localScale;
									((Component)val12).transform.localRotation = ((Component)val8).transform.localRotation;
									((Component)val12).transform.localPosition = ((Component)val8).transform.localPosition;
									TouhouEnemiesPlugin.Instance.AddLog("SandWorm model changed.");
									Transform parent = ((Component)val12).transform.Find("Bone.001/Bone.003/Bone.002");
									Transform val13 = ((Component)val8).transform.Find("Bone.001/Bone.003/Bone.002/Collider");
									Transform val14 = ((Component)val8).transform.Find("Bone.001/Bone.003/Bone.002/VoiceAudio");
									Transform val15 = ((Component)val8).transform.Find("Bone.001/Bone.003/Bone.002/ScanNode");
									((Component)val15).gameObject.GetComponent<ScanNodeProperties>().headerText = "EaterYuyuko";
									val13.SetParent(parent);
									val14.SetParent(parent);
									val15.SetParent(parent);
									TouhouEnemiesPlugin.Instance.AddLog($"Collider: {(Object)(object)val13 != (Object)null}, " + $"Voice: {(Object)(object)val14 != (Object)null}, " + $"ScanNode: {(Object)(object)val15 != (Object)null}");
									componentInChildren.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(runtimeAnimatorController);
									TouhouEnemiesPlugin.Instance.AddLog("The state of the animator reset.");
								}
								return;
							}
							catch
							{
								TouhouEnemiesPlugin.Instance.AddLog("Failed to replace SandWorm.");
								return;
							}
						}
						if (!((Object)(object)TouhouEnemiesPlugin.MarisaVisuals != (Object)null) || !TouhouEnemiesPlugin.EnableHoarderBugReplace.Value)
						{
							return;
						}
						try
						{
							Animator componentInChildren2 = ((Component)val4).GetComponentInChildren<Animator>();
							RuntimeAnimatorController runtimeAnimatorController2 = componentInChildren2.runtimeAnimatorController;
							Transform val16 = ((Component)val4).transform.Find("HoarderBugModel");
							object obj4;
							if (val16 == null)
							{
								obj4 = null;
							}
							else
							{
								Transform obj5 = val16.Find("Cube");
								obj4 = ((obj5 != null) ? ((Component)obj5).GetComponent<SkinnedMeshRenderer>() : null);
							}
							SkinnedMeshRenderer val17 = (SkinnedMeshRenderer)obj4;
							object obj6;
							if (val16 == null)
							{
								obj6 = null;
							}
							else
							{
								Transform obj7 = val16.Find("Cube.001");
								obj6 = ((obj7 != null) ? ((Component)obj7).GetComponent<SkinnedMeshRenderer>() : null);
							}
							SkinnedMeshRenderer val18 = (SkinnedMeshRenderer)obj6;
							object obj8;
							if (val16 == null)
							{
								obj8 = null;
							}
							else
							{
								Transform obj9 = val16.Find("AnimContainer/Armature/Abdomen/Chest/Head/LeftWing");
								obj8 = ((obj9 != null) ? ((Component)obj9).GetComponent<MeshRenderer>() : null);
							}
							MeshRenderer val19 = (MeshRenderer)obj8;
							object obj10;
							if (val16 == null)
							{
								obj10 = null;
							}
							else
							{
								Transform obj11 = val16.Find("AnimContainer/Armature/Abdomen/Chest/Head/RightWing");
								obj10 = ((obj11 != null) ? ((Component)obj11).GetComponent<MeshRenderer>() : null);
							}
							MeshRenderer val20 = (MeshRenderer)obj10;
							if ((Object)(object)val17 != (Object)null)
							{
								((Renderer)val17).enabled = false;
							}
							if ((Object)(object)val18 != (Object)null)
							{
								((Renderer)val18).enabled = false;
							}
							if ((Object)(object)val19 != (Object)null)
							{
								((Renderer)val19).enabled = false;
							}
							if ((Object)(object)val20 != (Object)null)
							{
								((Renderer)val20).enabled = false;
							}
							Transform val21 = ((val16 != null) ? val16.Find("AnimContainer").Find("Armature") : null);
							if ((Object)(object)val21 == (Object)null)
							{
								return;
							}
							((Object)val21).name = "old-Armature";
							int num = Random.Range(0, 10);
							if (TouhouEnemiesPlugin.BugSpawnRate.Value < num + 1)
							{
								Animator val22 = ((val16 != null) ? ((Component)val16.Find("AnimContainer")).GetComponent<Animator>() : null);
								if ((Object)(object)val22 != (Object)null)
								{
									((Behaviour)val22).enabled = false;
								}
								((Component)((Component)val4).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText = "HoarderMarisa";
								GameObject val23 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.MarisaVisuals);
								Animator component = ((Component)val23.transform.Find("HoarderBugModel")).GetComponent<Animator>();
								((EnemyAI)val4).creatureAnimator = component;
								TouhouEnemiesPlugin.Instance.AddLog("The animator is replaced.");
								val23.transform.SetParent(((Component)val4).transform);
								val23.transform.localPosition = Vector3.zero;
								val23.transform.localRotation = Quaternion.identity;
								val23.transform.localScale = Vector3.one;
								Transform val24 = val23.transform.Find("HoarderBugModel/Cube");
								Transform val25 = val23.transform.Find("HoarderBugModel/Armature");
								val25.SetParent(val21.parent, true);
								((Component)val25).transform.localScale = Vector3.one;
								((Component)val25).transform.localRotation = ((Component)val21).transform.localRotation;
								((Component)val25).transform.localPosition = ((Component)val21).transform.localPosition;
								SkinnedMeshRenderer component2 = ((Component)val24).GetComponent<SkinnedMeshRenderer>();
								component2.rootBone = ((Component)val25).transform.Find("Abdomen");
								((Object)val25).name = "Armature";
								TouhouEnemiesPlugin.Instance.AddLog("HoarderBug model changed.");
								Transform val26 = ((Component)val25).transform.Find("Abdomen/Spine");
								val4.grabTarget.SetParent(val26);
								Transform val27 = ((Component)val26).transform.Find("HoldItemsTarget");
								val4.grabTarget.localScale = val27.localScale;
								val4.grabTarget.localRotation = val27.localRotation;
								val4.grabTarget.localPosition = val27.localPosition;
								TouhouEnemiesPlugin.Instance.AddLog($"GrabTarget: {(Object)(object)val4.grabTarget != (Object)null}");
							}
							else
							{
								((Component)((Component)val4).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText = "KirisameBug";
								GameObject val28 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.BugVisuals);
								val28.transform.SetParent(((Component)val4).transform);
								val28.transform.localPosition = Vector3.zero;
								val28.transform.localRotation = Quaternion.identity;
								val28.transform.localScale = Vector3.one;
								Transform val29 = val28.transform.Find("AnimContainer/Cube");
								Transform val30 = val28.transform.Find("AnimContainer/Armature");
								val30.SetParent(val21.parent, true);
								((Component)val30).transform.localScale = Vector3.one;
								((Component)val30).transform.localRotation = ((Component)val21).transform.localRotation;
								((Component)val30).transform.localPosition = ((Component)val21).transform.localPosition;
								SkinnedMeshRenderer component3 = ((Component)val29).GetComponent<SkinnedMeshRenderer>();
								component3.rootBone = ((Component)val30).transform.Find("Abdomen");
								((Object)val30).name = "Armature";
								TouhouEnemiesPlugin.Instance.AddLog("HoarderBug model changed.");
								Transform val31 = ((Component)val30).transform.Find("Abdomen/Spine");
								val4.grabTarget.SetParent(val31);
								Transform val32 = ((Component)val31).transform.Find("HoldItemsTarget");
								val4.grabTarget.localScale = val32.localScale;
								val4.grabTarget.localRotation = val32.localRotation;
								val4.grabTarget.localPosition = val32.localPosition;
								TouhouEnemiesPlugin.Instance.AddLog($"GrabTarget: {(Object)(object)val4.grabTarget != (Object)null}");
								componentInChildren2.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(runtimeAnimatorController2);
								TouhouEnemiesPlugin.Instance.AddLog("The animator is replaced.");
							}
							return;
						}
						catch
						{
							TouhouEnemiesPlugin.Instance.AddLog("Failed to replace HoarderBug.");
							return;
						}
					}
					if (!((Object)(object)TouhouEnemiesPlugin.SuikaVisuals != (Object)null) || !TouhouEnemiesPlugin.EnableForestGiantReplace.Value)
					{
						return;
					}
					try
					{
						Animator componentInChildren3 = ((Component)val3).GetComponentInChildren<Animator>();
						RuntimeAnimatorController runtimeAnimatorController3 = componentInChildren3.runtimeAnimatorController;
						Transform val33 = ((Component)val3).transform.Find("FGiantModelContainer");
						object obj13;
						if (val33 == null)
						{
							obj13 = null;
						}
						else
						{
							Transform obj14 = val33.Find("BodyLOD0");
							obj13 = ((obj14 != null) ? ((Component)obj14).GetComponent<SkinnedMeshRenderer>() : null);
						}
						SkinnedMeshRenderer val34 = (SkinnedMeshRenderer)obj13;
						object obj15;
						if (val33 == null)
						{
							obj15 = null;
						}
						else
						{
							Transform obj16 = val33.Find("BodyLOD1");
							obj15 = ((obj16 != null) ? ((Component)obj16).GetComponent<SkinnedMeshRenderer>() : null);
						}
						SkinnedMeshRenderer val35 = (SkinnedMeshRenderer)obj15;
						object obj17;
						if (val33 == null)
						{
							obj17 = null;
						}
						else
						{
							Transform obj18 = val33.Find("BodyLOD2");
							obj17 = ((obj18 != null) ? ((Component)obj18).GetComponent<SkinnedMeshRenderer>() : null);
						}
						SkinnedMeshRenderer val36 = (SkinnedMeshRenderer)obj17;
						if ((Object)(object)val34 != (Object)null)
						{
							((Renderer)val34).enabled = false;
						}
						if ((Object)(object)val35 != (Object)null)
						{
							((Renderer)val35).enabled = false;
						}
						if ((Object)(object)val36 != (Object)null)
						{
							((Renderer)val36).enabled = false;
						}
						((Component)((Component)val3).transform.Find("ScanNode (1)")).gameObject.GetComponent<ScanNodeProperties>().headerText = "SuikaGiant";
						Transform val37 = ((val33 != null) ? val33.Find("AnimContainer").Find("metarig") : null);
						if (!((Object)(object)val37 == (Object)null))
						{
							((Object)val37).name = "old-metarig";
							GameObject val38 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.SuikaVisuals);
							val38.transform.SetParent(((Component)val3).transform);
							val38.transform.localPosition = Vector3.zero;
							val38.transform.localRotation = Quaternion.identity;
							val38.transform.localScale = Vector3.one;
							Transform val39 = val38.transform.Find("FGiantModelContainer/BodyLOD0");
							Transform val40 = val38.transform.Find("FGiantModelContainer/metarig");
							val40.SetParent(val37.parent, true);
							((Component)val40).transform.localScale = ((Component)val37).transform.localScale;
							((Component)val40).transform.localRotation = ((Component)val37).transform.localRotation;
							((Component)val40).transform.localPosition = ((Component)val37).transform.localPosition;
							SkinnedMeshRenderer component4 = ((Component)val39).GetComponent<SkinnedMeshRenderer>();
							component4.rootBone = ((Component)val40).transform.Find("spine");
							((Object)val40).name = "metarig";
							TouhouEnemiesPlugin.Instance.AddLog("ForestGiant model changed.");
							Transform val41 = val38.transform.Find("FGiantModelContainer");
							val3.centerPosition.SetParent(val41);
							Transform val42 = ((Component)val41).transform.Find("CenterPosition");
							val3.centerPosition.localScale = val42.localScale;
							val3.centerPosition.localRotation = val42.localRotation;
							val3.centerPosition.localPosition = val42.localPosition;
							val3.handBone = ((Component)val40).transform.Find("spine/spine.003/shoulder.R/upper_arm.R/forearm.R/hand.R");
							val3.holdPlayerPoint.SetParent(val3.handBone);
							Transform val43 = ((Component)val3.handBone).transform.Find("PlayerPoint");
							val3.holdPlayerPoint.localScale = val43.localScale;
							val3.holdPlayerPoint.localRotation = val43.localRotation;
							val3.holdPlayerPoint.localPosition = val43.localPosition;
							TouhouEnemiesPlugin.Instance.AddLog($"CenterPos: {(Object)(object)val3.centerPosition != (Object)null}, " + $"HandBone: {(Object)(object)val3.handBone != (Object)null}, " + $"HoldPoint: {(Object)(object)val3.holdPlayerPoint != (Object)null}");
							((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val3.reachForPlayerRig).data)).root = ((Component)val40).transform.Find("spine/spine.003/shoulder.R/upper_arm.R");
							((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val3.reachForPlayerRig).data)).mid = ((Component)val40).transform.Find("spine/spine.003/shoulder.R/upper_arm.R/forearm.R");
							((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val3.reachForPlayerRig).data)).tip = val3.handBone;
							componentInChildren3.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(runtimeAnimatorController3);
							TouhouEnemiesPlugin.Instance.AddLog("The state of the animator is reset.");
						}
						return;
					}
					catch
					{
						TouhouEnemiesPlugin.Instance.AddLog("Failed to replace ForestGiant.");
						return;
					}
				}
				if (!((Object)(object)TouhouEnemiesPlugin.SatoriVisuals != (Object)null) || !TouhouEnemiesPlugin.EnableNutcrackerReplace.Value)
				{
					return;
				}
				try
				{
					Animator componentInChildren4 = ((Component)val2).GetComponentInChildren<Animator>();
					RuntimeAnimatorController runtimeAnimatorController4 = componentInChildren4.runtimeAnimatorController;
					AudioSource component5 = ((Component)((Component)val2).transform.Find("CreatureVoice")).GetComponent<AudioSource>();
					component5.volume = TouhouEnemiesPlugin.SatoriSFXVolume.Value;
					component5 = ((Component)((Component)val2).transform.Find("LongRangeSFX")).GetComponent<AudioSource>();
					component5.volume = TouhouEnemiesPlugin.SatoriSFXVolume.Value;
					Transform val44 = ((Component)val2).transform.Find("MeshContainer");
					object obj20;
					if (val44 == null)
					{
						obj20 = null;
					}
					else
					{
						Transform obj21 = val44.Find("LOD0");
						obj20 = ((obj21 != null) ? ((Component)obj21).GetComponent<SkinnedMeshRenderer>() : null);
					}
					SkinnedMeshRenderer val45 = (SkinnedMeshRenderer)obj20;
					object obj22;
					if (val44 == null)
					{
						obj22 = null;
					}
					else
					{
						Transform obj23 = val44.Find("LOD1");
						obj22 = ((obj23 != null) ? ((Component)obj23).GetComponent<SkinnedMeshRenderer>() : null);
					}
					SkinnedMeshRenderer val46 = (SkinnedMeshRenderer)obj22;
					object obj24;
					if (val44 == null)
					{
						obj24 = null;
					}
					else
					{
						Transform obj25 = val44.Find("AnimContainer/metarig/spinecontainer/GunAndArmsContainer/GunPoint/GunPointWithOffset/TestShotgun");
						obj24 = ((obj25 != null) ? ((Component)obj25).GetComponent<MeshRenderer>() : null);
					}
					MeshRenderer val47 = (MeshRenderer)obj24;
					object obj26;
					if (val44 == null)
					{
						obj26 = null;
					}
					else
					{
						Transform obj27 = val44.Find("AnimContainer/metarig/spinecontainer/GunAndArmsContainer/GunPoint/GunPointWithOffset/TestShotgun/GunBarrel");
						obj26 = ((obj27 != null) ? ((Component)obj27).GetComponent<MeshRenderer>() : null);
					}
					MeshRenderer val48 = (MeshRenderer)obj26;
					if ((Object)(object)val45 != (Object)null)
					{
						((Renderer)val45).enabled = false;
					}
					if ((Object)(object)val46 != (Object)null)
					{
						((Renderer)val46).enabled = false;
					}
					if ((Object)(object)val47 != (Object)null)
					{
						((Renderer)val47).enabled = false;
					}
					if ((Object)(object)val48 != (Object)null)
					{
						((Renderer)val48).enabled = false;
					}
					((Component)((Component)val2).transform.Find("ScanNode (1)")).gameObject.GetComponent<ScanNodeProperties>().headerText = "NutSatori";
					Transform val49 = ((val44 != null) ? val44.Find("AnimContainer").Find("metarig") : null);
					if (!((Object)(object)val49 == (Object)null))
					{
						((Object)val49).name = "old-metarig";
						GameObject val50 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.SatoriVisuals);
						val50.transform.SetParent(((Component)val2).transform);
						val50.transform.localPosition = Vector3.zero;
						val50.transform.localRotation = Quaternion.identity;
						val50.transform.localScale = Vector3.one;
						Transform val51 = val50.transform.Find("MeshContainer/LOD0");
						Transform val52 = val50.transform.Find("MeshContainer/Armature/metarig");
						val52.SetParent(val49.parent, true);
						((Component)val52).transform.localScale = ((Component)val49).transform.localScale;
						((Component)val52).transform.localRotation = ((Component)val49).transform.localRotation;
						((Component)val52).transform.localPosition = ((Component)val49).transform.localPosition;
						SkinnedMeshRenderer component6 = ((Component)val51).GetComponent<SkinnedMeshRenderer>();
						component6.rootBone = ((Component)val52).transform.Find("spinecontainer/spine");
						((Object)val52).name = "metarig";
						TouhouEnemiesPlugin.Instance.AddLog("Nutcracker model changed.");
						val2.torsoContainer = ((Component)val52).transform.Find("spinecontainer");
						Transform val53 = ((Component)val2.torsoContainer).transform.Find("GunAndArmsContainer/GunPoint");
						val2.gunPoint.SetParent(val53);
						Transform val54 = ((Component)val53).transform.Find("GunPointWithOffset");
						val2.gunPoint.localScale = val54.localScale;
						val2.gunPoint.localRotation = val54.localRotation;
						val2.gunPoint.localPosition = val54.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog($"Torso: {(Object)(object)val2.torsoContainer != (Object)null}, " + $"GunPoint: {(Object)(object)val2.gunPoint != (Object)null}");
						componentInChildren4.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(runtimeAnimatorController4);
						TouhouEnemiesPlugin.Instance.AddLog("The state of the animator is reset.");
					}
					return;
				}
				catch
				{
					TouhouEnemiesPlugin.Instance.AddLog("Failed to replace Nutcracker.");
					return;
				}
			}
			if (!((Object)(object)TouhouEnemiesPlugin.SekiVisuals != (Object)null) || !TouhouEnemiesPlugin.EnableCoilHeadReplace.Value)
			{
				return;
			}
			try
			{
				Animator componentInChildren5 = ((Component)val).GetComponentInChildren<Animator>();
				RuntimeAnimatorController runtimeAnimatorController5 = componentInChildren5.runtimeAnimatorController;
				Transform val55 = ((Component)val).transform.Find("SpringManModel");
				object obj29;
				if (val55 == null)
				{
					obj29 = null;
				}
				else
				{
					Transform obj30 = val55.Find("Body");
					obj29 = ((obj30 != null) ? ((Component)obj30).GetComponent<SkinnedMeshRenderer>() : null);
				}
				SkinnedMeshRenderer val56 = (SkinnedMeshRenderer)obj29;
				if ((Object)(object)val56 != (Object)null)
				{
					((Renderer)val56).enabled = false;
				}
				object obj31;
				if (val55 == null)
				{
					obj31 = null;
				}
				else
				{
					Transform obj32 = val55.Find("Head");
					obj31 = ((obj32 != null) ? ((Component)obj32).GetComponent<MeshRenderer>() : null);
				}
				MeshRenderer val57 = (MeshRenderer)obj31;
				if ((Object)(object)val57 != (Object)null)
				{
					((Renderer)val57).enabled = false;
				}
				((Component)val55.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText = "Coilbanki";
				Transform val58 = val55.Find("AnimContainer").Find("metarig");
				if (!((Object)(object)val58 == (Object)null))
				{
					((Object)val58).name = "old-metarig";
					GameObject val59 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.SekiVisuals);
					val59.transform.SetParent(((Component)val).transform);
					val59.transform.localPosition = Vector3.zero;
					val59.transform.localRotation = Quaternion.identity;
					val59.transform.localScale = Vector3.one;
					Transform val60 = val59.transform.Find("SekibankiModel");
					Transform val61 = ((Component)val60).transform.Find("Body");
					Transform val62 = ((Component)val60).transform.Find("Head");
					Transform val63 = ((Component)val60).transform.Find("AnimContainer");
					val63.SetParent(val58.parent, true);
					((Component)val63).transform.localScale = ((Component)val58).transform.localScale;
					((Component)val63).transform.localRotation = ((Component)val58).transform.localRotation;
					((Component)val63).transform.localPosition = ((Component)val58).transform.localPosition;
					SkinnedMeshRenderer component7 = ((Component)val61).GetComponent<SkinnedMeshRenderer>();
					component7.rootBone = ((Component)val63).transform.Find("spine");
					component7 = ((Component)val62).GetComponent<SkinnedMeshRenderer>();
					component7.rootBone = ((Component)val63).transform.Find("spine");
					((Object)val63).name = "metarig";
					TouhouEnemiesPlugin.Instance.AddLog("SpringMan model changed.");
					componentInChildren5.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(runtimeAnimatorController5);
					TouhouEnemiesPlugin.Instance.AddLog("The state of the animator reset.");
				}
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("Failed to replace SpringMan.");
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "SetAnimationGoClientRpc")]
		[HarmonyPostfix]
		[ClientRpc]
		public static void PlaySekibankiTheme(SpringManAI __instance)
		{
			if (!TouhouEnemiesPlugin.EnableCoilHeadReplace.Value || !TouhouEnemiesPlugin.EnableSekibankiTheme.Value || (Object)(object)TouhouEnemiesPlugin.SekibankiTheme == (Object)null)
			{
				return;
			}
			try
			{
				if ((Object)(object)((EnemyAI)__instance).creatureSFX.clip != (Object)(object)TouhouEnemiesPlugin.SekibankiTheme)
				{
					((EnemyAI)__instance).creatureSFX.clip = TouhouEnemiesPlugin.SekibankiTheme;
					((EnemyAI)__instance).creatureSFX.volume = TouhouEnemiesPlugin.SekibankiSFXVolume.Value;
					((EnemyAI)__instance).creatureSFX.loop = true;
				}
				if (((EnemyAI)__instance).creatureSFX.isPlaying)
				{
					((EnemyAI)__instance).creatureSFX.UnPause();
				}
				else
				{
					((EnemyAI)__instance).creatureSFX.Play();
				}
				WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureSFX, TouhouEnemiesPlugin.SekibankiTheme, TouhouEnemiesPlugin.SekibankiSFXVolume.Value / 2f);
				TouhouEnemiesPlugin.Instance.AddLog("Playing Sekibanki theme.");
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("Play Sekibanki theme failed.");
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "SetAnimationStopClientRpc")]
		[HarmonyPostfix]
		[ClientRpc]
		public static void PauseSekibankiTheme(SpringManAI __instance)
		{
			if (TouhouEnemiesPlugin.EnableCoilHeadReplace.Value && TouhouEnemiesPlugin.EnableSekibankiTheme.Value && !((Object)(object)TouhouEnemiesPlugin.SekibankiTheme == (Object)null) && ((EnemyAI)__instance).creatureSFX.isPlaying)
			{
				((EnemyAI)__instance).creatureSFX.Pause();
				TouhouEnemiesPlugin.Instance.AddLog("Pause Sekibanki theme.");
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")]
		[HarmonyPostfix]
		public static void ReplaceSatoriTheme(NutcrackerEnemyAI __instance)
		{
			if (TouhouEnemiesPlugin.EnableNutcrackerReplace.Value && TouhouEnemiesPlugin.EnableSatoriTheme.Value && !((Object)(object)TouhouEnemiesPlugin.SatoriTheme == (Object)null))
			{
				((EnemyAI)__instance).enemyBehaviourStates[2].VoiceClip = TouhouEnemiesPlugin.SatoriTheme;
				((EnemyAI)__instance).creatureSFX.volume = TouhouEnemiesPlugin.SatoriSFXVolume.Value;
				TouhouEnemiesPlugin.Instance.AddLog("Satori theme Loaded.");
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "SwitchToBehaviourStateOnLocalClient")]
		[HarmonyPostfix]
		[ClientRpc]
		public static void ReplaceSuikaTheme(int stateIndex, EnemyAI __instance)
		{
			try
			{
				if (!(__instance is ForestGiantAI) || !TouhouEnemiesPlugin.EnableForestGiantReplace.Value)
				{
					return;
				}
				if (TouhouEnemiesPlugin.EnableSuikaVoice.Value)
				{
					switch (stateIndex)
					{
					case 0:
						if ((Object)(object)TouhouEnemiesPlugin.SuikaAudios[0] != (Object)null)
						{
							__instance.creatureVoice.PlayOneShot(TouhouEnemiesPlugin.SuikaAudios[0], TouhouEnemiesPlugin.SuikaVoiceVolume.Value);
							WalkieTalkie.TransmitOneShotAudio(__instance.creatureVoice, TouhouEnemiesPlugin.SuikaAudios[0], TouhouEnemiesPlugin.SuikaVoiceVolume.Value / 2f);
						}
						break;
					case 1:
						__instance.creatureVoice.volume = TouhouEnemiesPlugin.SuikaVoiceVolume.Value;
						if ((Object)(object)TouhouEnemiesPlugin.SuikaAudios[2] != (Object)null)
						{
							__instance.creatureVoice.PlayOneShot(TouhouEnemiesPlugin.SuikaAudios[2], TouhouEnemiesPlugin.SuikaVoiceVolume.Value);
							WalkieTalkie.TransmitOneShotAudio(__instance.creatureVoice, TouhouEnemiesPlugin.SuikaAudios[2], TouhouEnemiesPlugin.SuikaVoiceVolume.Value / 2f);
						}
						break;
					case 2:
						if ((Object)(object)TouhouEnemiesPlugin.SuikaAudios[1] != (Object)null && !TouhouEnemiesPlugin.SoundToolGood)
						{
							__instance.creatureVoice.PlayOneShot(TouhouEnemiesPlugin.SuikaAudios[1], TouhouEnemiesPlugin.SuikaVoiceVolume.Value);
							WalkieTalkie.TransmitOneShotAudio(__instance.creatureVoice, TouhouEnemiesPlugin.SuikaAudios[1], TouhouEnemiesPlugin.SuikaVoiceVolume.Value / 2f);
						}
						break;
					default:
						TouhouEnemiesPlugin.Instance.AddLog("Unexpected state for Suika voice.");
						break;
					}
				}
				if (!TouhouEnemiesPlugin.EnableSuikaTheme.Value || (Object)(object)TouhouEnemiesPlugin.SuikaTheme == (Object)null)
				{
					return;
				}
				switch (stateIndex)
				{
				case 0:
					__instance.creatureSFX.Stop();
					TouhouEnemiesPlugin.Instance.AddLog("Stop Suika theme.");
					break;
				case 1:
					if ((Object)(object)__instance.creatureSFX.clip != (Object)(object)TouhouEnemiesPlugin.SuikaTheme)
					{
						__instance.creatureSFX.clip = TouhouEnemiesPlugin.SuikaTheme;
						__instance.creatureSFX.volume = TouhouEnemiesPlugin.SuikaThemeVolume.Value;
						__instance.creatureSFX.loop = true;
						__instance.creatureSFX.spatialBlend = 1f;
					}
					if (__instance.creatureSFX.isPlaying)
					{
						__instance.creatureSFX.UnPause();
					}
					else
					{
						__instance.creatureSFX.Play();
					}
					WalkieTalkie.TransmitOneShotAudio(__instance.creatureSFX, TouhouEnemiesPlugin.SuikaTheme, TouhouEnemiesPlugin.SuikaThemeVolume.Value / 2f);
					TouhouEnemiesPlugin.Instance.AddLog("Playing Suika theme.");
					break;
				case 2:
					__instance.creatureSFX.Pause();
					TouhouEnemiesPlugin.Instance.AddLog("Pause Suika theme.");
					break;
				default:
					TouhouEnemiesPlugin.Instance.AddLog("Unexpected state for Suika theme.");
					break;
				}
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("SwitchToBehaviourStateOnLocalClient failed.");
			}
		}

		[HarmonyPatch(typeof(ForestGiantAI), "BeginEatPlayer")]
		[HarmonyPrefix]
		public static void SuikaEat(ForestGiantAI __instance)
		{
			((EnemyAI)__instance).creatureSFX.Pause();
			if (TouhouEnemiesPlugin.EnableForestGiantReplace.Value && TouhouEnemiesPlugin.EnableSuikaVoice.Value && (Object)(object)TouhouEnemiesPlugin.SuikaAudios[3] != (Object)null && !TouhouEnemiesPlugin.SoundToolGood)
			{
				((EnemyAI)__instance).creatureVoice.PlayOneShot(TouhouEnemiesPlugin.SuikaAudios[3], TouhouEnemiesPlugin.SuikaVoiceVolume.Value);
				WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureVoice, TouhouEnemiesPlugin.SuikaAudios[3], TouhouEnemiesPlugin.SuikaVoiceVolume.Value / 2f);
			}
		}

		[HarmonyPatch(typeof(ForestGiantAI), "KillEnemy")]
		[HarmonyPrefix]
		public static void SuikaLost(ForestGiantAI __instance)
		{
			((EnemyAI)__instance).creatureSFX.Stop();
			if (TouhouEnemiesPlugin.EnableForestGiantReplace.Value)
			{
				if ((Object)(object)TouhouEnemiesPlugin.SuikaVisuals != (Object)null)
				{
					SkinnedMeshRenderer component = ((Component)((Component)__instance).transform.Find("SuikaGiant(Clone)/FGiantModelContainer/BodyLOD0")).GetComponent<SkinnedMeshRenderer>();
					component.SetBlendShapeWeight(3, 100f);
					component.SetBlendShapeWeight(5, 100f);
					TouhouEnemiesPlugin.Instance.AddLog("Suika lost.");
				}
				if (TouhouEnemiesPlugin.EnableSuikaVoice.Value && (Object)(object)TouhouEnemiesPlugin.SuikaAudios[1] != (Object)null && (Object)(object)__instance.giantCry != (Object)(object)TouhouEnemiesPlugin.SuikaAudios[1])
				{
					__instance.giantCry = TouhouEnemiesPlugin.SuikaAudios[1];
				}
				if (TouhouEnemiesPlugin.EnableDeathAudio.Value && (Object)(object)TouhouEnemiesPlugin.LostAudio != (Object)null)
				{
					((EnemyAI)__instance).creatureSFX.PlayOneShot(TouhouEnemiesPlugin.LostAudio, TouhouEnemiesPlugin.DeathAudioVolume.Value);
					WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureSFX, TouhouEnemiesPlugin.LostAudio, TouhouEnemiesPlugin.DeathAudioVolume.Value / 2f);
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		public static void ReplaceMarisaTheme(HoarderBugAI __instance)
		{
			if (!TouhouEnemiesPlugin.EnableHoarderBugReplace.Value)
			{
				return;
			}
			if (((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText == "HoarderMarisa")
			{
				if (TouhouEnemiesPlugin.EnableMarisaVoice.Value)
				{
					if ((Object)(object)TouhouEnemiesPlugin.MarisaAudios[0] != (Object)null)
					{
						__instance.chitterSFX[0] = TouhouEnemiesPlugin.MarisaAudios[0];
					}
					if ((Object)(object)TouhouEnemiesPlugin.MarisaAudios[3] != (Object)null)
					{
						__instance.chitterSFX[1] = TouhouEnemiesPlugin.MarisaAudios[3];
					}
					if ((Object)(object)TouhouEnemiesPlugin.MarisaAudios[7] != (Object)null)
					{
						__instance.chitterSFX[2] = TouhouEnemiesPlugin.MarisaAudios[7];
					}
					if ((Object)(object)TouhouEnemiesPlugin.MarisaAudios[0] != (Object)null)
					{
						__instance.angryScreechSFX[0] = TouhouEnemiesPlugin.MarisaAudios[0];
					}
					if ((Object)(object)TouhouEnemiesPlugin.MarisaAudios[7] != (Object)null)
					{
						__instance.angryScreechSFX[1] = TouhouEnemiesPlugin.MarisaAudios[7];
					}
					if ((Object)(object)TouhouEnemiesPlugin.MarisaAudios[1] != (Object)null)
					{
						__instance.angryVoiceSFX = TouhouEnemiesPlugin.MarisaAudios[1];
					}
					((EnemyAI)__instance).creatureVoice.loop = false;
					((EnemyAI)__instance).creatureVoice.volume = TouhouEnemiesPlugin.MarisaVoiceVolume.Value;
				}
				if (!TouhouEnemiesPlugin.EnableMarisaTheme.Value || (Object)(object)TouhouEnemiesPlugin.MarisaTheme == (Object)null)
				{
					return;
				}
				__instance.bugFlySFX = TouhouEnemiesPlugin.MarisaTheme;
				((EnemyAI)__instance).creatureSFX.volume = TouhouEnemiesPlugin.MarisaSFXVolume.Value;
			}
			else if (((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText == "KirisameBug" && TouhouEnemiesPlugin.EnableBugVoice.Value)
			{
				if ((Object)(object)TouhouEnemiesPlugin.BugAudios[0] != (Object)null)
				{
					__instance.chitterSFX[0] = TouhouEnemiesPlugin.BugAudios[0];
				}
				if ((Object)(object)TouhouEnemiesPlugin.BugAudios[3] != (Object)null)
				{
					__instance.chitterSFX[1] = TouhouEnemiesPlugin.BugAudios[3];
				}
				if ((Object)(object)TouhouEnemiesPlugin.BugAudios[5] != (Object)null)
				{
					__instance.chitterSFX[2] = TouhouEnemiesPlugin.BugAudios[5];
				}
				if ((Object)(object)TouhouEnemiesPlugin.BugAudios[0] != (Object)null)
				{
					__instance.angryScreechSFX[0] = TouhouEnemiesPlugin.BugAudios[0];
				}
				if ((Object)(object)TouhouEnemiesPlugin.BugAudios[5] != (Object)null)
				{
					__instance.angryScreechSFX[1] = TouhouEnemiesPlugin.BugAudios[5];
				}
				if ((Object)(object)TouhouEnemiesPlugin.BugAudios[1] != (Object)null)
				{
					__instance.angryVoiceSFX = TouhouEnemiesPlugin.BugAudios[1];
				}
				((EnemyAI)__instance).creatureVoice.loop = false;
				((EnemyAI)__instance).creatureVoice.volume = TouhouEnemiesPlugin.MarisaVoiceVolume.Value;
			}
			TouhouEnemiesPlugin.Instance.AddLog("Marisa theme Loaded.");
		}

		[HarmonyPatch(typeof(HoarderBugAI), "GrabItem")]
		[HarmonyPostfix]
		public static void MarisaGrab(HoarderBugAI __instance)
		{
			if (TouhouEnemiesPlugin.EnableHoarderBugReplace.Value)
			{
				if (((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText == "HoarderMarisa" && TouhouEnemiesPlugin.EnableMarisaVoice.Value && (Object)(object)TouhouEnemiesPlugin.MarisaAudios[4] != (Object)null)
				{
					((EnemyAI)__instance).creatureVoice.PlayOneShot(TouhouEnemiesPlugin.MarisaAudios[4], TouhouEnemiesPlugin.MarisaVoiceVolume.Value);
					WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureVoice, TouhouEnemiesPlugin.MarisaAudios[4], TouhouEnemiesPlugin.MarisaVoiceVolume.Value / 2f);
				}
				else if (((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText == "KirisameBug" && TouhouEnemiesPlugin.EnableBugVoice.Value && (Object)(object)TouhouEnemiesPlugin.BugAudios[4] != (Object)null)
				{
					((EnemyAI)__instance).creatureVoice.PlayOneShot(TouhouEnemiesPlugin.BugAudios[4], TouhouEnemiesPlugin.MarisaVoiceVolume.Value);
					WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureVoice, TouhouEnemiesPlugin.BugAudios[4], TouhouEnemiesPlugin.MarisaVoiceVolume.Value / 2f);
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "HitEnemy")]
		[HarmonyPostfix]
		public static void MarisaHit(HoarderBugAI __instance)
		{
			if (!((EnemyAI)__instance).isEnemyDead && TouhouEnemiesPlugin.EnableHoarderBugReplace.Value && !(((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText != "HoarderMarisa") && TouhouEnemiesPlugin.EnableMarisaVoice.Value && !((Object)(object)TouhouEnemiesPlugin.MarisaAudios[5] == (Object)null))
			{
				((EnemyAI)__instance).creatureVoice.PlayOneShot(TouhouEnemiesPlugin.MarisaAudios[5], TouhouEnemiesPlugin.MarisaVoiceVolume.Value);
				WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureVoice, TouhouEnemiesPlugin.MarisaAudios[5], TouhouEnemiesPlugin.MarisaVoiceVolume.Value / 2f);
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void MarisaLost(HoarderBugAI __instance)
		{
			if (TouhouEnemiesPlugin.EnableHoarderBugReplace.Value)
			{
				if (((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText == "HoarderMarisa" && TouhouEnemiesPlugin.EnableMarisaVoice.Value && (Object)(object)TouhouEnemiesPlugin.MarisaAudios[2] != (Object)null)
				{
					((EnemyAI)__instance).creatureVoice.PlayOneShot(TouhouEnemiesPlugin.MarisaAudios[2], TouhouEnemiesPlugin.MarisaVoiceVolume.Value);
					WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureVoice, TouhouEnemiesPlugin.SuikaAudios[2], TouhouEnemiesPlugin.MarisaVoiceVolume.Value / 2f);
				}
				else if (((Component)((Component)__instance).transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText == "KirisameBug" && TouhouEnemiesPlugin.EnableBugVoice.Value && (Object)(object)TouhouEnemiesPlugin.BugAudios[2] != (Object)null)
				{
					((EnemyAI)__instance).creatureVoice.PlayOneShot(TouhouEnemiesPlugin.BugAudios[2], TouhouEnemiesPlugin.MarisaVoiceVolume.Value);
					WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureVoice, TouhouEnemiesPlugin.BugAudios[2], TouhouEnemiesPlugin.MarisaVoiceVolume.Value / 2f);
				}
				if (TouhouEnemiesPlugin.EnableDeathAudio.Value && (Object)(object)TouhouEnemiesPlugin.LostAudio != (Object)null)
				{
					((EnemyAI)__instance).creatureSFX.PlayOneShot(TouhouEnemiesPlugin.LostAudio, TouhouEnemiesPlugin.DeathAudioVolume.Value);
					WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureSFX, TouhouEnemiesPlugin.LostAudio, TouhouEnemiesPlugin.DeathAudioVolume.Value / 2f);
				}
			}
		}

		[HarmonyPatch(typeof(SandWormAI), "Start")]
		[HarmonyPostfix]
		public static void ReplaceYuyukoTheme(SandWormAI __instance)
		{
			if (TouhouEnemiesPlugin.EnableSandWormReplace.Value && TouhouEnemiesPlugin.EnableYuyukoTheme.Value && !((Object)(object)TouhouEnemiesPlugin.YuyukoTheme == (Object)null))
			{
				__instance.emergeFromGroundSFX = TouhouEnemiesPlugin.YuyukoTheme;
				((EnemyAI)__instance).creatureSFX.volume = TouhouEnemiesPlugin.YuyukoSFXVolume.Value;
				TouhouEnemiesPlugin.Instance.AddLog("Yuyuko theme Loaded.");
			}
		}
	}
	[HarmonyPatch]
	public static class V50Patches
	{
		private static bool Prepare()
		{
			MethodInfo method = typeof(RoundManager).GetMethod("SpawnNestObjectForOutsideEnemy", BindingFlags.Instance | BindingFlags.Public);
			return method != null;
		}

		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPrefix]
		public static void ReplaceUtsuhoTheme(EnemyAI __instance)
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07af: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Unknown result type (might be due to invalid IL or missing references)
			//IL_0855: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d1: Expected O, but got Unknown
			try
			{
				RadMechAI val = (RadMechAI)(object)((__instance is RadMechAI) ? __instance : null);
				if (val == null)
				{
					ButlerEnemyAI val2 = (ButlerEnemyAI)(object)((__instance is ButlerEnemyAI) ? __instance : null);
					if (val2 != null)
					{
					}
				}
				else
				{
					if (!((Object)(object)TouhouEnemiesPlugin.UtsuhoVisuals != (Object)null) || !TouhouEnemiesPlugin.EnableRadMechReplace.Value)
					{
						return;
					}
					try
					{
						Transform val3 = ((Component)val).transform.Find("MeshContainer");
						if ((Object)(object)val3 == (Object)null)
						{
							return;
						}
						Animator componentInChildren = ((Component)val).GetComponentInChildren<Animator>();
						RuntimeAnimatorController runtimeAnimatorController = componentInChildren.runtimeAnimatorController;
						Transform obj = val3.Find("Body");
						SkinnedMeshRenderer val4 = ((obj != null) ? ((Component)obj).GetComponent<SkinnedMeshRenderer>() : null);
						((Component)val3.Find("ScanNode (1)")).gameObject.GetComponent<ScanNodeProperties>().headerText = "OldUtsuho";
						Transform val5 = val3.Find("AnimContainer").Find("metarig");
						if ((Object)(object)val5 == (Object)null)
						{
							return;
						}
						((Object)val5).name = "old-metarig";
						GameObject val6 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.UtsuhoVisuals);
						val6.transform.SetParent(((Component)val).transform);
						val6.transform.localPosition = Vector3.zero;
						val6.transform.localRotation = Quaternion.identity;
						val6.transform.localScale = Vector3.one;
						Transform val7 = val6.transform.Find("MeshContainer/AnimContainer");
						Transform val8 = ((Component)val7).transform.Find("metarig");
						val8.SetParent(val5.parent, true);
						((Component)val8).transform.localScale = ((Component)val5).transform.localScale;
						((Component)val8).transform.localRotation = ((Component)val5).transform.localRotation;
						((Component)val8).transform.localPosition = ((Component)val5).transform.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog("RadMech model changed.");
						val.torsoContainer = ((Component)val8).transform.Find("TorsoContainer");
						val.torsoDefaultRotation.SetParent(val8);
						Transform val9 = ((Component)val8).transform.Find("TorsoDefaultRotation0");
						val.torsoDefaultRotation.localScale = val9.localScale;
						val.torsoDefaultRotation.localRotation = val9.localRotation;
						val.torsoDefaultRotation.localPosition = val9.localPosition;
						Transform val10 = ((Component)val5).transform.Find("VoiceSFX");
						val10.SetParent(val8);
						Transform val11 = ((Component)val5).transform.Find("3DLradAudio");
						val11.SetParent(val8);
						((Component)val11).GetComponent<AudioSource>().volume = TouhouEnemiesPlugin.UtsuhoSFXVolume.Value;
						Transform val12 = ((Component)val5).transform.Find("3DLradAudio2");
						val12.SetParent(val8);
						((Component)val12).GetComponent<AudioSource>().volume = TouhouEnemiesPlugin.UtsuhoSFXVolume.Value;
						Transform val13 = ((Component)val5).transform.Find("EngineSFX");
						val13.SetParent(val8);
						Transform val14 = ((Component)val5).transform.Find("CreatureSFX");
						val14.SetParent(val8);
						Transform val15 = ((Component)val5).transform.Find("TorsoContainer/Torso");
						Transform val16 = ((Component)val15).transform.Find("FlyingModeEye");
						Transform val17 = ((Component)val15).transform.Find("LightContainer");
						Transform val18 = ((Component)val15).transform.Find("SpotlightOnAudio");
						Transform val19 = ((Component)val8).transform.Find("TorsoContainer/Torso");
						val16.SetParent(val19);
						val17.SetParent(val19);
						val18.SetParent(val19);
						TouhouEnemiesPlugin.Instance.AddLog($"Collider: {(Object)(object)val.ownCollider != (Object)null}, " + $"Torso: {(Object)(object)val.torsoContainer != (Object)null}, " + $"TorsoRotation: {(Object)(object)val.torsoDefaultRotation != (Object)null}");
						Transform parent = ((Component)val8).transform.Find("LegLeft/LegLeft2");
						Transform val20 = ((Component)val5).transform.Find("LegLeft/LegLeft2");
						Transform val21 = ((Component)val20).transform.Find("ShockwaveLeftFoot");
						val21.SetParent(parent);
						Transform val22 = ((Component)val20).transform.Find("SmokeTrail");
						val22.SetParent(parent);
						Transform val23 = ((Component)val20).transform.Find("LeftLegFireContainer");
						val23.SetParent(parent);
						val.leftFootPoint.localScale = val23.localScale;
						val.leftFootPoint.localRotation = val23.localRotation;
						val.leftFootPoint.localPosition = val23.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog($"LeftFoot: {(Object)(object)val.leftFootPoint != (Object)null}");
						Transform parent2 = ((Component)val8).transform.Find("LegRight/LegRight2");
						Transform val24 = ((Component)val5).transform.Find("LegRight/LegRight2");
						Transform val25 = ((Component)val24).transform.Find("ShockwaveRightFoot");
						val25.SetParent(parent2);
						Transform val26 = ((Component)val24).transform.Find("SmokeTrailRightLeg");
						val26.SetParent(parent2);
						Transform val27 = ((Component)val24).transform.Find("RightLegFireContainer");
						val27.SetParent(parent2);
						val.rightFootPoint.localScale = val27.localScale;
						val.rightFootPoint.localRotation = val27.localRotation;
						val.rightFootPoint.localPosition = val27.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog($"RightFoot: {(Object)(object)val.rightFootPoint != (Object)null}");
						Transform val28 = ((Component)val19).transform.Find("LeftUpperArm");
						Transform val29 = ((Component)val28).transform.Find("GunArmDefaultRot0");
						Transform val30 = ((Component)val15).transform.Find("LeftUpperArm");
						Transform val31 = ((Component)val30).transform.Find("GunArmContainer");
						Transform val32 = ((Component)val31).transform.Find("LeftLowerArm");
						val.defaultArmRotation.SetParent(val28);
						val.defaultArmRotation.localScale = val29.localScale;
						val.defaultArmRotation.localRotation = val29.localRotation;
						val.defaultArmRotation.localPosition = val29.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog($"GunArmRotation: {(Object)(object)val.defaultArmRotation != (Object)null}");
						Transform val33 = (val.gunArm = ((Component)val28).transform.Find("GunArmContainer"));
						TouhouEnemiesPlugin.Instance.AddLog($"GunArm: {(Object)(object)val.gunArm != (Object)null}");
						Transform val34 = ((Component)val33).transform.Find("LeftLowerArm");
						Transform val35 = ((Component)val32).transform.Find("BlastParticle");
						Transform val36 = ((Component)val32).transform.Find("BlowtorchAudio");
						Transform val37 = ((Component)val32).transform.Find("FlamethrowerParticle");
						TouhouEnemiesPlugin.Instance.AddLog($"blastParticle: {(Object)(object)val35 != (Object)null}");
						TouhouEnemiesPlugin.Instance.AddLog($"blowtorchAudio: {(Object)(object)val36 != (Object)null}");
						TouhouEnemiesPlugin.Instance.AddLog($"flamethrower: {(Object)(object)val37 != (Object)null}");
						val35.SetParent(val34);
						val36.SetParent(val34);
						val37.SetParent(val34);
						val.gunPoint.SetParent(val34);
						Transform val38 = ((Component)val34).transform.Find("GunPoint0");
						val.gunPoint.localScale = val38.localScale;
						val.gunPoint.localRotation = val38.localRotation;
						val.gunPoint.localPosition = val38.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog($"GunPoint: {(Object)(object)val.gunPoint != (Object)null}");
						Transform val39 = ((Component)val19).transform.Find("RightUpperArm/RightLowerarm");
						val.holdPlayerPoint.SetParent(val39);
						Transform val40 = ((Component)val39).transform.Find("GrabPlayerPoint0");
						val.holdPlayerPoint.localScale = val40.localScale;
						val.holdPlayerPoint.localRotation = val40.localRotation;
						val.holdPlayerPoint.localPosition = val40.localPosition;
						Transform val41 = ((Component)val5).transform.Find("TorsoContainer/Torso/RightUpperArm/RightLowerarm/ClawTrigger");
						val41.SetParent(val39);
						if ((Object)(object)val4 != (Object)null)
						{
							((Renderer)val4).enabled = false;
						}
						TouhouEnemiesPlugin.Instance.AddLog($"HoldPoint: {(Object)(object)val.holdPlayerPoint != (Object)null}");
						Animator component = ((Component)((Component)val7).transform).GetComponent<Animator>();
						AnimatorOverrideController val42 = new AnimatorOverrideController(runtimeAnimatorController);
						Dictionary<string, AnimationClip> dictionary = new Dictionary<string, AnimationClip>();
						AnimationClip[] animationClips = component.runtimeAnimatorController.animationClips;
						foreach (AnimationClip val43 in animationClips)
						{
							dictionary[((Object)val43).name] = val43;
						}
						((Behaviour)component).enabled = false;
						List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>();
						val42.GetOverrides(list);
						for (int j = 0; j < list.Count; j++)
						{
							AnimationClip key = list[j].Key;
							if (dictionary.TryGetValue(((Object)key).name, out var value))
							{
								list[j] = new KeyValuePair<AnimationClip, AnimationClip>(key, value);
							}
						}
						val42.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list);
						componentInChildren.runtimeAnimatorController = (RuntimeAnimatorController)(object)val42;
						TouhouEnemiesPlugin.Instance.AddLog("The animator is replaced.");
						if (TouhouEnemiesPlugin.EnableUtsuhoTheme.Value && !((Object)(object)TouhouEnemiesPlugin.UtsuhoTheme == (Object)null))
						{
							val.LocalLRADAudio.clip = TouhouEnemiesPlugin.UtsuhoTheme;
							((EnemyAI)val).creatureSFX.volume = TouhouEnemiesPlugin.UtsuhoSFXVolume.Value;
							TouhouEnemiesPlugin.Instance.AddLog("Utsuho theme Loaded.");
						}
						return;
					}
					catch
					{
						TouhouEnemiesPlugin.Instance.AddLog("Failed to replace RadMech.");
						return;
					}
				}
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("Maybe lower than V50, ignore.");
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnNestObjectForOutsideEnemy")]
		[HarmonyPostfix]
		public static void ReplaceUtsuhoSpawnNest(RoundManager __instance, EnemyType enemyType)
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			if (enemyType.enemyName != "RadMech" || (Object)(object)TouhouEnemiesPlugin.UtsuhoNestSpawnVisuals == (Object)null || !TouhouEnemiesPlugin.EnableRadMechReplace.Value)
			{
				return;
			}
			try
			{
				Transform val = ((Component)__instance.enemyNestSpawnObjects.Last()).transform.Find("MeshContainer");
				if (!((Object)(object)val == (Object)null))
				{
					Transform obj = val.Find("Body");
					SkinnedMeshRenderer val2 = ((obj != null) ? ((Component)obj).GetComponent<SkinnedMeshRenderer>() : null);
					if ((Object)(object)val2 != (Object)null)
					{
						((Renderer)val2).enabled = false;
					}
					((Component)val.Find("ScanNode (1)")).gameObject.GetComponent<ScanNodeProperties>().headerText = "Old-Bird Utsuho";
					Transform val3 = ((val != null) ? val.Find("AnimContainer").Find("metarig") : null);
					if (!((Object)(object)val3 == (Object)null))
					{
						((Object)val3).name = "old-metarig";
						GameObject val4 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.UtsuhoNestSpawnVisuals);
						val4.transform.SetParent(val);
						val4.transform.localPosition = Vector3.zero;
						val4.transform.localRotation = Quaternion.identity;
						val4.transform.localScale = Vector3.one;
						Transform val5 = val4.transform.Find("MeshContainer/Armature");
						Transform val6 = ((Component)val5).transform.Find("metarig");
						val5.SetParent(val, true);
						((Component)val6).transform.localScale = ((Component)val3).transform.localScale;
						((Component)val6).transform.localRotation = ((Component)val3).transform.localRotation;
						((Component)val6).transform.localPosition = ((Component)val3).transform.localPosition;
						TouhouEnemiesPlugin.Instance.AddLog("RadMechNestSpawnObject model changed.");
					}
				}
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("RadMechNestSpawnObject model change failed.");
			}
		}
	}
	[HarmonyPatch]
	public static class MoreCounterplayPatches
	{
		private static Vector3 position = Vector3.zero;

		[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
		[HarmonyPrefix]
		public static void DecapitateCoilhead(EnemyAI __instance)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (__instance == null || (Object)(object)TouhouEnemiesPlugin.SekiVisuals == (Object)null || (Object)(object)TouhouEnemiesPlugin.SekiHeadVisuals == (Object)null || !TouhouEnemiesPlugin.EnableCoilHeadReplace.Value || !TouhouEnemiesPlugin.MoreCounterplayGood)
			{
				return;
			}
			SpringManAI val = (SpringManAI)(object)((__instance is SpringManAI) ? __instance : null);
			if (val == null)
			{
				return;
			}
			try
			{
				Transform val2 = ((Component)val).transform.Find("Sekibanki(Clone)/SekibankiModel/Head");
				position = ((Component)val2).transform.position;
				((Renderer)((Component)val2).GetComponent<SkinnedMeshRenderer>()).enabled = false;
				((EnemyAI)val).creatureSFX.Stop();
				((Behaviour)((Component)((Component)val).transform.Find("SpringManModel/AnimContainer")).GetComponent<Animator>()).enabled = false;
				TouhouEnemiesPlugin.Instance.AddLog($"Sekibanki head drop at {position}.");
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("Failed to kill Sekibanki.");
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPrefix]
		public static void DecapitateCoilhead(GrabbableObject __instance)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			if (__instance == null || (Object)(object)TouhouEnemiesPlugin.SekiHeadVisuals == (Object)null || !TouhouEnemiesPlugin.EnableCoilHeadReplace.Value || !TouhouEnemiesPlugin.MoreCounterplayGood)
			{
				return;
			}
			try
			{
				Transform transform = ((Component)__instance).transform;
				if (!(((Object)transform).name != "Head(Clone)"))
				{
					__instance.itemProperties.verticalOffset = 0.2f;
					Object.Destroy((Object)(object)((Component)transform).GetComponent<MeshRenderer>());
					transform.position = new Vector3(position.x, position.y + 0.5f, position.z);
					transform.rotation = Quaternion.Euler(180f, 180f, 0f);
					transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
					BoxCollider component = ((Component)transform).GetComponent<BoxCollider>();
					component.center = new Vector3(0.1f, 0.15f, -1f);
					component.size = new Vector3(2.15f, 2.15f, 2.15f);
					Transform val = transform.Find("ScanNode");
					((Component)val).gameObject.GetComponent<ScanNodeProperties>().headerText = "Sekibanki's Head";
					component = ((Component)val).GetComponent<BoxCollider>();
					component.center = new Vector3(0.1f, 0.15f, -1f);
					component.size = new Vector3(2.15f, 2.15f, 2.15f);
					GameObject val2 = Object.Instantiate<GameObject>(TouhouEnemiesPlugin.SekiHeadVisuals);
					val2.transform.SetParent(transform);
					val2.transform.localPosition = new Vector3(-18f, 0f, -1f);
					val2.transform.localRotation = Quaternion.Euler(0f, 0f, 270f);
					val2.transform.localScale = new Vector3(400f, 400f, 400f);
					TouhouEnemiesPlugin.Instance.AddLog("Sekibanki head replaced.");
				}
			}
			catch
			{
				TouhouEnemiesPlugin.Instance.AddLog("Failed to replace Sekibanki head.");
			}
		}
	}
	[BepInPlugin("com.bean.TouhouEnemyModels", "TouhouEnemyModels", "0.9.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TouhouEnemiesPlugin : BaseUnityPlugin
	{
		public static TouhouEnemiesPlugin Instance;

		public static bool SoundToolGood = false;

		public static bool MoreCounterplayGood = false;

		public static AudioClip LostAudio;

		internal static ConfigEntry<bool> EnableDeathAudio;

		internal static ConfigEntry<float> DeathAudioVolume;

		public static GameObject SekiVisuals;

		public static GameObject SekiHeadVisuals;

		public static AudioClip SekibankiTheme;

		internal static ConfigEntry<bool> EnableCoilHeadReplace;

		internal static ConfigEntry<bool> EnableBodyCoilReplace;

		internal static ConfigEntry<bool> EnableSekibankiTheme;

		internal static ConfigEntry<float> SekibankiSFXVolume;

		public static GameObject SatoriVisuals;

		public static AudioClip SatoriTheme;

		internal static ConfigEntry<bool> EnableNutcrackerReplace;

		internal static ConfigEntry<bool> EnableSatoriTheme;

		internal static ConfigEntry<float> SatoriSFXVolume;

		public static GameObject SuikaVisuals;

		public static AudioClip SuikaTheme;

		public static AudioClip[] SuikaAudios = (AudioClip[])(object)new AudioClip[4];

		internal static ConfigEntry<bool> EnableForestGiantReplace;

		internal static ConfigEntry<bool> EnableSuikaTheme;

		internal static ConfigEntry<float> SuikaThemeVolume;

		internal static ConfigEntry<bool> EnableSuikaVoice;

		internal static ConfigEntry<float> SuikaVoiceVolume;

		public static GameObject MarisaVisuals;

		public static GameObject BugVisuals;

		public static AudioClip MarisaTheme;

		public static AudioClip[] MarisaAudios = (AudioClip[])(object)new AudioClip[8];

		public static AudioClip[] BugAudios = (AudioClip[])(object)new AudioClip[6];

		internal static ConfigEntry<bool> EnableHoarderBugReplace;

		internal static ConfigEntry<int> BugSpawnRate;

		internal static ConfigEntry<bool> EnableMarisaTheme;

		internal static ConfigEntry<float> MarisaSFXVolume;

		internal static ConfigEntry<bool> EnableMarisaVoice;

		internal static ConfigEntry<bool> EnableBugVoice;

		internal static ConfigEntry<float> MarisaVoiceVolume;

		public static GameObject UtsuhoVisuals;

		public static GameObject UtsuhoNestSpawnVisuals;

		public static AudioClip UtsuhoTheme;

		internal static ConfigEntry<bool> EnableRadMechReplace;

		internal static ConfigEntry<bool> EnableUtsuhoTheme;

		internal static ConfigEntry<float> UtsuhoSFXVolume;

		public static GameObject YuyukoVisuals;

		public static AudioClip YuyukoTheme;

		internal static ConfigEntry<bool> EnableSandWormReplace;

		internal static ConfigEntry<bool> EnableYuyukoTheme;

		internal static ConfigEntry<float> YuyukoSFXVolume;

		private void Awake()
		{
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"  ______ ____   __  __ __  __ ____   __  __");
			((BaseUnityPlugin)this).Logger.LogInfo((object)" /_  __// __ \\ / / / // / / // __ \\ / / / /");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"  / /  / / / // / / // /_/ // / / // / / / ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)" / /  / /_/ // /_/ // __  // /_/ // /_/ /  ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"/_/   \\____/ \\____//_/ /_/ \\____/ \\____/   ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"");
			EnableDeathAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("0.General", "EnableDeathAudio", false, "Play a death audio when an enemy is killed.");
			DeathAudioVolume = ((BaseUnityPlugin)this).Config.Bind<float>("0.General", "DeathAudioVolume(0.0-1.0)", 0.5f, "Config the volume of the death audio.");
			EnableCoilHeadReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("1.CoilHead", "EnableCoilHead", true, "Replace the model of Coil-Head to Sekibanki.");
			EnableBodyCoilReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("1.CoilHead", "EnableDeadBodyCoil", true, "Replace the coil on the dead body to a head of Sekibanki.");
			EnableSekibankiTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("1.CoilHead", "EnableSekibankiTheme", true, "Replace the step audio to Sekibanki's theme music.");
			SekibankiSFXVolume = ((BaseUnityPlugin)this).Config.Bind<float>("1.CoilHead", "SekibankiSoundVolume(0.0-1.0)", 0.5f, "Config the volume of Sekibanki's sound effect including the theme music.");
			EnableNutcrackerReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("2.Nutcracker", "EnableNutcracker", true, "Replace the model of Nutcracker to NutSatori.");
			EnableSatoriTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("2.Nutcracker", "EnableSatoriTheme", true, "Replace the angry audio to Satori's theme music.");
			SatoriSFXVolume = ((BaseUnityPlugin)this).Config.Bind<float>("2.Nutcracker", "SatoriSoundVolume(0.0-1.0)", 0.5f, "** THIS NOT WORK! ** Config the volume of Satori's sound effect including the theme music.");
			EnableForestGiantReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("3.ForestGiant", "EnableForestGiant", true, "Replace the model of ForestGiant to SuikaGiant.");
			EnableSuikaTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("3.ForestGiant", "EnableSuikaTheme", true, "Play Suika's theme music.");
			SuikaThemeVolume = ((BaseUnityPlugin)this).Config.Bind<float>("3.ForestGiant", "SuikaThemeVolume(0.0-1.0)", 0.5f, "Config the volume of Suika's theme music.");
			EnableSuikaVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("3.ForestGiant", "EnableSuikaVoice", true, "Suika has something to say.");
			SuikaVoiceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("3.ForestGiant", "SuikaVoiceVolume(0.0-1.0)", 1f, "Config the volume of Suika's voice.");
			EnableHoarderBugReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("4.HoarderBug", "EnableHoarderBug", true, "Replace the model of HoarderBug to HoarderMarisa.");
			BugSpawnRate = ((BaseUnityPlugin)this).Config.Bind<int>("4.HoarderBug", "BugSpawnRate(0-10)", 5, "How likely Marisa will be spawn as a bug. HoarderMarisa(0) -> KirisameBug(10) No Sync!");
			EnableMarisaTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("4.HoarderBug", "EnableMarisaTheme", true, "Play Marisa's theme music. Not for the bug.");
			MarisaSFXVolume = ((BaseUnityPlugin)this).Config.Bind<float>("4.HoarderBug", "MarisaSoundVolume(0.0-1.0)", 0.5f, "Config the volume of Marisa's sound effect including the theme music.");
			EnableMarisaVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("4.HoarderBug", "EnableMarisaVoice", true, "Marisa has something to say.");
			EnableBugVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("4.HoarderBug", "EnableBugVoice", true, "It sounds like a Zerg Queen, but only for the bug.");
			MarisaVoiceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("4.HoarderBug", "MarisaVoiceVolume(0.0-1.0)", 1f, "Config the volume of Marisa's voice.");
			EnableRadMechReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("5.RadMech", "EnableRadMech", true, "Replace the model of RadMech to UtsuhoMech.");
			EnableUtsuhoTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("5.RadMech", "EnableUtsuhoTheme", true, "Play Utsuho's theme music.");
			UtsuhoSFXVolume = ((BaseUnityPlugin)this).Config.Bind<float>("5.RadMech", "UtsuhoSoundVolume(0.0-1.0)", 0.5f, "** THIS NOT WORK! ** Config the volume of Utsuho's sound effect including the theme music.");
			EnableSandWormReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("6.SandWorm", "EnableSandWorm", true, "Replace the model of SandWorm to Yuyuko.");
			EnableYuyukoTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("6.SandWorm", "EnableYuyukoTheme", true, "Play Yuyuko's theme music.");
			YuyukoSFXVolume = ((BaseUnityPlugin)this).Config.Bind<float>("6.SandWorm", "YuyukoSoundVolume(0.0-1.0)", 0.5f, "Config the volume of Yuyuko's sound effect including the theme music.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching all functions.");
			MoreCounterplayGood = Chainloader.PluginInfos.ContainsKey("BaronDrakula.MoreCounterplay");
			Instance.AddLog($"MoreCounterplay = {MoreCounterplayGood}");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"All systems ready, begin loading assets.");
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				if (directoryName == null)
				{
					return;
				}
				string text = Path.Combine(directoryName, "touhouenemies");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading asset bundle.");
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				if (EnableDeathAudio.Value)
				{
					LostAudio = val.LoadAsset<AudioClip>("se_pldead00.mp3");
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Load death audio.");
				}
				List<Renderer> list = new List<Renderer>();
				if (EnableCoilHeadReplace.Value)
				{
					SekiVisuals = val.LoadAsset<GameObject>("Sekibanki.prefab");
					list.AddRange(SekiVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load Sekibanki: {(Object)(object)SekiVisuals != (Object)null}");
					if (EnableSekibankiTheme.Value)
					{
						SekibankiTheme = val.LoadAsset<AudioClip>("SekibankiTheme.mp3");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load SekibankiTheme: {(Object)(object)SekibankiTheme != (Object)null}");
					}
					if (EnableBodyCoilReplace.Value)
					{
						SekiHeadVisuals = val.LoadAsset<GameObject>("SekibankiHead.prefab");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load SekibankiHead: {(Object)(object)SekiHeadVisuals != (Object)null}");
					}
				}
				if (EnableNutcrackerReplace.Value)
				{
					SatoriVisuals = val.LoadAsset<GameObject>("NutSatori.prefab");
					list.AddRange(SatoriVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load NutSatori: {(Object)(object)SatoriVisuals != (Object)null}");
					if (EnableSatoriTheme.Value)
					{
						SatoriTheme = val.LoadAsset<AudioClip>("SatoriTheme.mp3");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load SatoriTheme: {(Object)(object)SatoriTheme != (Object)null}");
					}
				}
				if (EnableForestGiantReplace.Value)
				{
					SuikaVisuals = val.LoadAsset<GameObject>("SuikaGiant.prefab");
					list.AddRange(SuikaVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load SuikaGiant: {(Object)(object)SuikaVisuals != (Object)null}");
					if (EnableSuikaTheme.Value)
					{
						SuikaTheme = val.LoadAsset<AudioClip>("SuikaTheme.mp3");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load SuikaTheme: {(Object)(object)SuikaTheme != (Object)null}");
					}
					if (EnableSuikaVoice.Value)
					{
						SuikaAudios[0] = val.LoadAsset<AudioClip>("SuikaAngry.ogg");
						SuikaAudios[1] = val.LoadAsset<AudioClip>("SuikaLost.ogg");
						SuikaAudios[2] = val.LoadAsset<AudioClip>("SuikaHappy.ogg");
						SuikaAudios[3] = val.LoadAsset<AudioClip>("SuikaWarn.ogg");
						((BaseUnityPlugin)this).Logger.LogInfo((object)($"Load SuikaAudio: 0: {(Object)(object)SuikaAudios[0] != (Object)null}, " + $"1: {(Object)(object)SuikaAudios[1] != (Object)null}, 2: {(Object)(object)SuikaAudios[2] != (Object)null}, 3: {(Object)(object)SuikaAudios[3] != (Object)null}"));
					}
				}
				if (EnableHoarderBugReplace.Value)
				{
					MarisaVisuals = val.LoadAsset<GameObject>("HoarderMarisa.prefab");
					BugVisuals = val.LoadAsset<GameObject>("KirisameBug.prefab");
					list.AddRange(MarisaVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					list.AddRange(BugVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load HoarderMarisa: {(Object)(object)MarisaVisuals != (Object)null}");
					if (EnableMarisaTheme.Value)
					{
						MarisaTheme = val.LoadAsset<AudioClip>("MarisaTheme.mp3");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load MarisaTheme: {(Object)(object)MarisaTheme != (Object)null}");
					}
					if (EnableMarisaVoice.Value)
					{
						MarisaAudios[0] = val.LoadAsset<AudioClip>("MarisaAngry.ogg");
						MarisaAudios[1] = val.LoadAsset<AudioClip>("MarisaAttack.ogg");
						MarisaAudios[2] = val.LoadAsset<AudioClip>("MarisaLost.ogg");
						MarisaAudios[3] = val.LoadAsset<AudioClip>("MarisaGreeting.ogg");
						MarisaAudios[4] = val.LoadAsset<AudioClip>("MarisaHappy.ogg");
						MarisaAudios[5] = val.LoadAsset<AudioClip>("MarisaHurt.ogg");
						MarisaAudios[6] = val.LoadAsset<AudioClip>("MarisaMove.ogg");
						MarisaAudios[7] = val.LoadAsset<AudioClip>("MarisaWarn.ogg");
						((BaseUnityPlugin)this).Logger.LogInfo((object)($"Load MarisaAudio: 0: {(Object)(object)MarisaAudios[0] != (Object)null}, " + $"1: {(Object)(object)MarisaAudios[1] != (Object)null}, 2: {(Object)(object)MarisaAudios[2] != (Object)null}, " + $"3: {(Object)(object)MarisaAudios[3] != (Object)null}, 4: {(Object)(object)MarisaAudios[4] != (Object)null}, " + $"5: {(Object)(object)MarisaAudios[5] != (Object)null}, 6: {(Object)(object)MarisaAudios[6] != (Object)null}, " + $"7: {(Object)(object)MarisaAudios[7] != (Object)null}"));
					}
					if (EnableBugVoice.Value)
					{
						BugAudios[0] = val.LoadAsset<AudioClip>("BugAngry.ogg");
						BugAudios[1] = val.LoadAsset<AudioClip>("BugAttack.ogg");
						BugAudios[2] = val.LoadAsset<AudioClip>("BugLost.ogg");
						BugAudios[3] = val.LoadAsset<AudioClip>("BugGreeting.ogg");
						BugAudios[4] = val.LoadAsset<AudioClip>("BugHappy.ogg");
						BugAudios[5] = val.LoadAsset<AudioClip>("BugWarn.ogg");
						((BaseUnityPlugin)this).Logger.LogInfo((object)($"Load MarisaAudio: 0: {(Object)(object)BugAudios[0] != (Object)null}, " + $"1: {(Object)(object)BugAudios[1] != (Object)null}, 2: {(Object)(object)BugAudios[2] != (Object)null}, " + $"3: {(Object)(object)BugAudios[3] != (Object)null}, 4: {(Object)(object)BugAudios[4] != (Object)null}, " + $"5: {(Object)(object)BugAudios[5] != (Object)null}"));
					}
				}
				if (EnableRadMechReplace.Value)
				{
					UtsuhoVisuals = val.LoadAsset<GameObject>("UtsuhoMech.prefab");
					UtsuhoNestSpawnVisuals = val.LoadAsset<GameObject>("UtsuhoMechNestSpawnObject.prefab");
					list.AddRange(UtsuhoVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					list.AddRange(UtsuhoNestSpawnVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load UtsuhoMech: {(Object)(object)UtsuhoVisuals != (Object)null}, NestSpawnObject: {(Object)(object)UtsuhoNestSpawnVisuals != (Object)null}");
					if (EnableUtsuhoTheme.Value)
					{
						UtsuhoTheme = val.LoadAsset<AudioClip>("UtsuhoTheme.mp3");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load UtsuhoTheme: {(Object)(object)UtsuhoTheme != (Object)null}");
					}
				}
				if (EnableSandWormReplace.Value)
				{
					YuyukoVisuals = val.LoadAsset<GameObject>("EaterYuyuko.prefab");
					list.AddRange(YuyukoVisuals.GetComponentsInChildren<Renderer>(true).ToList());
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load EaterYuyuko: {(Object)(object)YuyukoVisuals != (Object)null}");
					if (EnableYuyukoTheme.Value)
					{
						YuyukoTheme = val.LoadAsset<AudioClip>("YuyukoTheme.mp3");
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load YuyukoTheme: {(Object)(object)YuyukoTheme != (Object)null}");
					}
				}
				foreach (Renderer item in list)
				{
					((Component)item).gameObject.layer = LayerMask.NameToLayer("Enemies");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load assetbundle: " + ex.Message));
			}
		}

		private void Start()
		{
			try
			{
				if ((Object)(object)SuikaAudios[1] != (Object)null)
				{
					SoundTool.ReplaceAudioClip("StunGiant", SuikaAudios[1]);
				}
				if ((Object)(object)SuikaAudios[3] != (Object)null)
				{
					SoundTool.ReplaceAudioClip("FGiantEatPlayerSFX", SuikaAudios[3]);
				}
				SoundToolGood = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"SoundTool is good.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("SoundTool not good." + ex.Message));
			}
		}

		public void AddLog(string info)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)info);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TouhouEnemyModels";

		public const string PLUGIN_NAME = "TouhouEnemyModels";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}