Decompiled source of NephilimGhostLC v1.0.3

LCNephilimGhost.dll

Decompiled 4 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LCNephilimGhost.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: AssemblyTitle("LCNephilimGhost")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCNephilimGhost")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("650ce902-cf29-4d4c-ad22-dcd3eff248af")]
[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 LCNephilimGhost
{
	internal class NephConfig
	{
		public static ConfigEntry<bool> useOriginalShader;

		public static ConfigEntry<bool> useOriginalSound;

		public static void ConfigSettings()
		{
			useOriginalShader = ((BaseUnityPlugin)LCModBase.Instance).Config.Bind<bool>("Shaders", "Use Original Shaders", false, "Enable this to make Nephilim use the original unlit shaders to give her the same \"glow-in-the-dark\" appearance as the Ghost Girl.");
			useOriginalSound = ((BaseUnityPlugin)LCModBase.Instance).Config.Bind<bool>("Audio", "Use Original Audio", false, "Enable this to make Nephilim use the original sound effects of the Ghost Girl");
		}
	}
	[BepInPlugin("Xeno.LCNephilimGhost", "LC Nephilim Ghost", "1.0.0.0")]
	public class LCModBase : BaseUnityPlugin
	{
		private const string modGUID = "Xeno.LCNephilimGhost";

		private const string modName = "LC Nephilim Ghost";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Xeno.LCNephilimGhost");

		public static LCModBase Instance;

		internal static AssetBundle NephBundle;

		public static GameObject NephilimMesh;

		public static AudioClip NephilimAudio;

		public static Material NephilimMaterial;

		public static ManualLogSource log;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				Instance = this;
			}
			NephConfig.ConfigSettings();
			log = Logger.CreateLogSource("Xeno.LCNephilimGhost");
			log.LogInfo((object)"Nephilim Ghost loaded");
			string text = ((BaseUnityPlugin)Instance).Info.Location.TrimEnd("NephGhost.dll".ToCharArray());
			NephBundle = AssetBundle.LoadFromFile(text + "nephilim");
			if ((Object)(object)NephBundle != (Object)null)
			{
				NephilimMesh = NephBundle.LoadAsset<GameObject>("Assets/Nephilim/NephilimGhostAtlas.prefab");
				NephilimAudio = NephBundle.LoadAsset<AudioClip>("Assets/Nephilim/heartbeatMusic.wav");
				NephilimMaterial = NephBundle.LoadAsset<Material>("Assets/Nephilim/NephAtlas.mat");
				log.LogInfo((object)"Asset bundle loaded");
			}
			else
			{
				log.LogError((object)"Asset bundle not loaded");
			}
			harmony.PatchAll(typeof(DressGirlAIPatch));
		}
	}
}
namespace LCNephilimGhost.Patches
{
	[HarmonyPatch(typeof(DressGirlAI))]
	internal class DressGirlAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPatch(DressGirlAI __instance)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).transform.Find("DressGirlModel");
			Transform val2 = val.Find("AnimContainer").Find("metarig");
			SkinnedMeshRenderer component = ((Component)val.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
			if ((Object)(object)component != (Object)null && ((Renderer)component).enabled)
			{
				((Renderer)component).enabled = false;
				MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>();
				foreach (MeshRenderer val3 in componentsInChildren)
				{
					((Renderer)val3).enabled = false;
				}
				GameObject val4 = Object.Instantiate<GameObject>(LCModBase.NephilimMesh);
				val4.transform.SetParent(val);
				val4.transform.localPosition = Vector3.zero;
				val4.transform.localRotation = Quaternion.identity;
				val4.transform.localScale = Vector3.one;
				Transform val5 = val4.transform.Find("metarig");
				val5.SetParent(val2.parent, true);
				((Component)val5).transform.localScale = ((Component)val2).transform.localScale;
				((Component)val5).transform.localRotation = ((Component)val2).transform.localRotation;
				((Component)val5).transform.localPosition = ((Component)val2).transform.localPosition;
				Transform val6 = val4.transform.Find("Body");
				SkinnedMeshRenderer component2 = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
				component2.rootBone = val5;
				((Component)component2).gameObject.tag = "DoNotSet";
				if (!NephConfig.useOriginalSound.Value)
				{
					__instance.heartbeatMusic.clip = LCModBase.NephilimAudio;
					__instance.heartbeatMusic.pitch = 1f;
					__instance.heartbeatMusic.Play();
				}
				if (NephConfig.useOriginalShader.Value)
				{
					((Renderer)component2).material = LCModBase.NephilimMaterial;
				}
				List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
				SkinnedMeshRenderer[] skinnedMeshRenderers = ((EnemyAI)__instance).skinnedMeshRenderers;
				foreach (SkinnedMeshRenderer item in skinnedMeshRenderers)
				{
					list.Add(item);
				}
				list.Add(component2);
				((EnemyAI)__instance).skinnedMeshRenderers = list.ToArray();
				((Object)val2).name = "old_metarig";
			}
		}
	}
}