Decompiled source of ThiccCoilHead v1.2.2

ThiccCoilHead.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using ThiccCoilHead.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ThiccCoilHead
{
	[BepInPlugin("ThiccCoilHead", "ThiccCoilHead", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		public static GameObject Visuals;

		public static AudioClip Audio;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin ThiccCoilHead is loaded!");
			Harmony.CreateAndPatchAll(typeof(SpringManPatch), (string)null);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "ThiccCoilHead.bundle"));
			Visuals = val.LoadAsset<GameObject>("assets/prefabs/ThiccCoilHead.prefab");
			if ((Object)(object)Visuals == (Object)null)
			{
				Debug.LogError((object)"could not loadThiccCoilHead assetbundle");
			}
			Renderer[] componentsInChildren = Visuals.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ThiccCoilHead";

		public const string PLUGIN_NAME = "ThiccCoilHead";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace ThiccCoilHead.Patches
{
	internal class SpringManPatch
	{
		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPostfix]
		private static void StartPostfix(EnemyAI __instance)
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			if (!(__instance is SpringManAI))
			{
				return;
			}
			Debug.Log((object)"ThiccCoilHead spawned");
			if ((Object)(object)Plugin.Visuals != (Object)null)
			{
				Transform val = ((Component)__instance).transform.Find("SpringManModel");
				SkinnedMeshRenderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val.Find("Body")).GetComponent<SkinnedMeshRenderer>() : null);
				if ((Object)(object)val2 != (Object)null && ((Renderer)val2).enabled)
				{
					((Renderer)val2).enabled = false;
					MeshRenderer component = ((Component)val.Find("Head")).GetComponent<MeshRenderer>();
					Transform val3 = val.Find("AnimContainer").Find("metarig");
					((Renderer)component).enabled = false;
					GameObject val4 = Object.Instantiate<GameObject>(Plugin.Visuals);
					val4.transform.SetParent(val);
					val4.transform.localPosition = Vector3.zero;
					val4.transform.localRotation = Quaternion.identity;
					val4.transform.localScale = Vector3.one;
					Transform val5 = val4.transform.Find("Container/ThiccCoilMesh");
					Transform val6 = val4.transform.Find("Container/metarig");
					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)val3).name = "old-metarig";
				}
				else
				{
					Debug.LogError((object)"ThiccCoilHead could not find SkinnerMeshRenderer on original Coil Head (could also be disabled)");
				}
			}
			else
			{
				Debug.LogError((object)"ThiccCoilHead new Coil Head asset missing");
			}
		}
	}
}