Decompiled source of FlandreGhostGirl v1.0.0

FlandreGhostGirl.dll

Decompiled 11 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 FlandreGhost;
using FlandreGhost.Patches;
using FlandreGhostGirl;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FlandreGhostGirl")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FlandreGhostGirl")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e1710e76-dd91-4dde-8fbc-72a3ad3bda2d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FlandreGhostGirl
{
	[BepInPlugin("Cat.FlandreGhost", "Flandre Scarlet Ghost Girl", "1.0.0")]
	public class GhostGirl : BaseUnityPlugin
	{
		private const string modGUID = "Cat.FlandreGhost";

		private const string modName = "Flandre Scarlet Ghost Girl";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Cat.FlandreGhost");

		public static GhostGirl Instance;

		internal static AssetBundle flandreBundle;

		public static GameObject flandreMesh;

		public static Material originalGirlMaterial;

		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;
			}
			FlandreConfig.ConfigSettings();
			log = Logger.CreateLogSource("Cat.FlandreGhost");
			log.LogInfo((object)"Flandre Ghost loaded");
			flandreBundle = AssetBundle.LoadFromFile(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("FlandreGhost.dll".ToCharArray()) + "Flandre");
			if ((Object)(object)flandreBundle != (Object)null)
			{
				flandreMesh = flandreBundle.LoadAsset<GameObject>("Assets/Bundles/Flandre2/Flandre.prefab");
				originalGirlMaterial = flandreBundle.LoadAsset<Material>("Assets/Bundles/Flandre2/Materials/FlandreUnlit.mat");
				log.LogInfo((object)"Asset bundle loaded");
			}
			else
			{
				log.LogError((object)"Asset bundle not loaded");
			}
			harmony.PatchAll(typeof(DressGirlAIPatch));
		}
	}
}
namespace FlandreGhost
{
	public class FlandreConfig
	{
		public static ConfigEntry<bool> useOriginalShader;

		public static ConfigEntry<bool> useOriginalSound;

		public static void ConfigSettings()
		{
			useOriginalShader = ((BaseUnityPlugin)GhostGirl.Instance).Config.Bind<bool>("Shaders", "Use Original Shaders", true, "glow in the dark appearance.");
		}
	}
}
namespace FlandreGhost.Patches
{
	[HarmonyPatch(typeof(DressGirlAI))]
	internal class DressGirlAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPatch(DressGirlAI __instance)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Renderer)componentsInChildren[i]).enabled = false;
				}
				GameObject obj = Object.Instantiate<GameObject>(GhostGirl.flandreMesh);
				obj.transform.SetParent(val);
				obj.transform.localPosition = Vector3.zero;
				obj.transform.localRotation = Quaternion.identity;
				obj.transform.localScale = Vector3.one;
				Transform val3 = obj.transform.Find("metarig");
				val3.SetParent(val2.parent, true);
				((Component)val3).transform.localScale = ((Component)val2).transform.localScale;
				((Component)val3).transform.localRotation = ((Component)val2).transform.localRotation;
				((Component)val3).transform.localPosition = ((Component)val2).transform.localPosition;
				SkinnedMeshRenderer component2 = ((Component)obj.transform.Find("Body")).GetComponent<SkinnedMeshRenderer>();
				component2.rootBone = val3;
				((Component)component2).gameObject.tag = "DoNotSet";
				if (FlandreConfig.useOriginalShader.Value)
				{
					((Renderer)component2).material = GhostGirl.originalGirlMaterial;
				}
				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";
			}
		}
	}
}