Decompiled source of Darnell v1.2.0

GhostDarnell.dll

Decompiled 3 hours 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 BepInEx.Logging;
using GhostDarnell.Patches;
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("GhostDarnell")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GhostDarnell")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d496501c-4dbd-4bcb-afdf-5bc9dcb68f4b")]
[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 GhostDarnell
{
	[BepInPlugin("Yellowguy08.GhostDarnell", "GhostDarnell", "1.0.0")]
	public class GhostDarnellBase : BaseUnityPlugin
	{
		private const string modGUID = "Yellowguy08.GhostDarnell";

		private const string modName = "GhostDarnell";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Yellowguy08.GhostDarnell");

		public static AssetBundle girlBundle;

		public static GameObject girlObj;

		private static GhostDarnellBase Instance;

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Yellowguy08.GhostDarnell");
			mls.LogInfo((object)"Don't worry about Darnell, he's just your wife's personal trainer.");
			girlBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "animateddarnell"));
			girlObj = girlBundle.LoadAsset<GameObject>("Assets/animatedDarnell.prefab");
			if ((Object)(object)girlObj == (Object)null)
			{
				mls.LogInfo((object)"Obj is null.");
			}
			harmony.PatchAll(typeof(GhostDarnellBase));
			harmony.PatchAll(typeof(DressGirlPatch));
		}
	}
}
namespace GhostDarnell.Patches
{
	[HarmonyPatch(typeof(DressGirlAI), "Start")]
	internal class DressGirlPatch : MonoBehaviour
	{
		public static void PrintChildren(Transform item, string indents)
		{
			GhostDarnellBase.mls.LogInfo((object)(indents + ((Object)item).name + ":"));
			if (item.childCount > 0)
			{
				for (int i = 0; i < item.childCount; i++)
				{
					PrintChildren(item.GetChild(i), indents + "\t");
				}
			}
		}

		public static void PrintComponents(Transform item, string indents)
		{
			Component[] components = ((Component)item).GetComponents<Component>();
			foreach (Component val in components)
			{
				GhostDarnellBase.mls.LogInfo((object)("c: " + ((object)val).ToString()));
			}
		}

		[HarmonyPatch(typeof(DressGirlAI), "Start")]
		[HarmonyPostfix]
		public static void GirlSwap(DressGirlAI __instance)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)__instance).transform.Find("DressGirlModel");
			HideGirl(__instance);
			GameObject val = Object.Instantiate<GameObject>(GhostDarnellBase.girlObj);
			val.transform.SetParent(parent);
			((Object)val).name = "Darnell";
			val.transform.localPosition = new Vector3(0f, 0f, 0f);
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one * 1.5f;
			GhostDarnellBase.mls.LogInfo((object)"Instantiated new model.");
			HideDarnell(__instance);
		}

		[HarmonyPatch(typeof(DressGirlAI), "SetHauntStarePosition")]
		[HarmonyPostfix]
		public static void ShowDarnell(DressGirlAI __instance)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			HideGirl(__instance);
			Transform val = ((Component)__instance).transform.Find("DressGirlModel/Darnell");
			SkinnedMeshRenderer component = ((Component)val.Find("Mesh_0")).GetComponent<SkinnedMeshRenderer>();
			if (!((Object)component != (Object)null))
			{
				GhostDarnellBase.mls.LogInfo((object)("'Mesh_0' is null: " + !((Object)component != (Object)null)));
				return;
			}
			if (((Renderer)component).enabled)
			{
				GhostDarnellBase.mls.LogInfo((object)"Component is enabled.");
				return;
			}
			((Renderer)component).enabled = true;
			SkinnedMeshRenderer component2 = ((Component)val.Find("Mesh_0.001")).GetComponent<SkinnedMeshRenderer>();
			if (!((Object)component2 != (Object)null))
			{
				GhostDarnellBase.mls.LogInfo((object)("'Mesh_0.001' is null: " + !((Object)component != (Object)null)));
				return;
			}
			if (((Renderer)component2).enabled)
			{
				GhostDarnellBase.mls.LogInfo((object)"Component2 is enabled.");
				return;
			}
			((Renderer)component2).enabled = true;
			Animator component3 = ((Component)val).GetComponent<Animator>();
			component3.Play("Base Layer.idle");
		}

		[HarmonyPatch(typeof(DressGirlAI), "DisappearDuringHaunt")]
		[HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")]
		[HarmonyPatch(typeof(DressGirlAI), "StopChasing")]
		[HarmonyPostfix]
		public static void HideDarnell(DressGirlAI __instance)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			GhostDarnellBase.mls.LogInfo((object)"Hiding Darnell");
			Transform val = ((Component)__instance).transform.Find("DressGirlModel/Darnell");
			SkinnedMeshRenderer component = ((Component)val.Find("Mesh_0")).GetComponent<SkinnedMeshRenderer>();
			if (!((Object)component != (Object)null))
			{
				GhostDarnellBase.mls.LogInfo((object)("'Darnell' is null: " + !((Object)component != (Object)null)));
				return;
			}
			if (!((Renderer)component).enabled)
			{
				GhostDarnellBase.mls.LogInfo((object)"Component is disabled.");
				return;
			}
			((Renderer)component).enabled = false;
			SkinnedMeshRenderer component2 = ((Component)val.Find("Mesh_0.001")).GetComponent<SkinnedMeshRenderer>();
			if (!((Object)component2 != (Object)null))
			{
				GhostDarnellBase.mls.LogInfo((object)("'Darnell' is null: " + !((Object)component != (Object)null)));
				return;
			}
			if (!((Renderer)component2).enabled)
			{
				GhostDarnellBase.mls.LogInfo((object)"Component2 is disabled.");
				return;
			}
			((Renderer)component2).enabled = false;
			((Behaviour)((Component)val.Find("Sun")).GetComponent<Light>()).enabled = false;
		}

		[HarmonyPatch(typeof(DressGirlAI), "SetHauntStarePosition")]
		[HarmonyPostfix]
		public static void HideGirl(DressGirlAI __instance)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			GhostDarnellBase.mls.LogInfo((object)"Hiding Girl");
			Transform val = ((Component)__instance).transform.Find("DressGirlModel");
			SkinnedMeshRenderer component = ((Component)val.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
			GhostDarnellBase.mls.LogInfo((object)("Component: " + ((object)component).ToString()));
			if (!((Object)component != (Object)null))
			{
				GhostDarnellBase.mls.LogInfo((object)("'basemesh' is null: " + !((Object)component != (Object)null)));
			}
			else
			{
				((Renderer)component).enabled = false;
			}
		}

		[HarmonyPatch(typeof(DressGirlAI), "BeginChasing")]
		[HarmonyPatch(typeof(DressGirlAI), "FindPositionOutOfLOS")]
		[HarmonyPostfix]
		public static void DarnellRun(DressGirlAI __instance)
		{
			Transform val = ((Component)__instance).transform.Find("DressGirlModel");
			((Component)val.Find("Darnell")).gameObject.GetComponent<Animator>().Play("Base Layer.walking");
		}
	}
}