Decompiled source of FlandreGhostGirlUpdated v1.0.0

FlandreGhostGirlUpdated.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FlandreGhostGirlUpdated.patch;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("qwcan")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9e2f50b8fa52cc7d88765af001b460dd0faac420")]
[assembly: AssemblyProduct("FlandreGhostGirlUpdated")]
[assembly: AssemblyTitle("FlandreGhostGirlUpdated")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 FlandreGhostGirlUpdated
{
	[BepInPlugin("FlandreGhostGirlUpdated", "FlandreGhostGirlUpdated", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "FlandreGhostGirlUpdated";

		private readonly Harmony _harmony = new Harmony("FlandreGhostGirlUpdated");

		public static GameObject flandreMesh;

		public static Material originalGirlMaterial;

		public static Plugin Instance { get; set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		public Plugin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Instance = this;
		}

		private void Awake()
		{
			Log.LogInfo((object)"Applying patches...");
			ApplyPluginPatch();
			Log.LogInfo((object)"Patches applied");
		}

		private void ApplyPluginPatch()
		{
			AssetBundle val = AssetBundle.LoadFromFile(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("FlandreGhostGirlUpdated.dll".ToCharArray()) + "Flandre");
			if ((Object)(object)val != (Object)null)
			{
				flandreMesh = val.LoadAsset<GameObject>("Assets/Bundles/Flandre2/Flandre.prefab");
				originalGirlMaterial = val.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(GhostGirlPatch));
		}
	}
}
namespace FlandreGhostGirlUpdated.patch
{
	[HarmonyPatch(typeof(DressGirlAI))]
	public class GhostGirlPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPatch(DressGirlAI __instance)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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 = false;
				MeshRenderer[] meshRenderers = ((EnemyAI)__instance).meshRenderers;
				foreach (MeshRenderer val3 in meshRenderers)
				{
					((Renderer)val3).enabled = false;
				}
				((EnemyAI)__instance).meshRenderers = Array.Empty<MeshRenderer>();
				MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					((Renderer)componentsInChildren[j]).enabled = false;
				}
				GameObject val4 = Object.Instantiate<GameObject>(Plugin.flandreMesh, val, true);
				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;
				SkinnedMeshRenderer component2 = ((Component)val4.transform.Find("Body")).GetComponent<SkinnedMeshRenderer>();
				component2.rootBone = val5;
				((Component)component2).gameObject.tag = "DoNotSet";
				((Renderer)component2).material = Plugin.originalGirlMaterial;
				((EnemyAI)__instance).skinnedMeshRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[1] { component2 };
				((Object)val2).name = "old_metarig";
			}
		}
	}
}