Decompiled source of dressgirl reskin v1.0.0

GhostGirlReskin.dll

Decompiled 11 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GhostGirlReskin.Patches;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GhostGirlReskin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GhostGirlReskin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b5d208b7-a6cc-48c2-9bab-b44057886cb4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace GhostGirlReskin
{
	[BepInPlugin("meltyjpg.dressgirlreskin", "Dress Girl Reskin", "1.0.0")]
	public class DressGirlRSKN : BaseUnityPlugin
	{
		private const string modGUID = "meltyjpg.dressgirlreskin";

		private const string modName = "Dress Girl Reskin";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("meltyjpg.dressgirlreskin");

		private static DressGirlRSKN Instance;

		internal ManualLogSource mls;

		internal static AssetBundle girl1bundle;

		public static GameObject girl1prefab;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			girl1bundle = AssetBundle.LoadFromFile(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("GhostGirlReskin.dll".ToCharArray()) + "ggirlrskin");
			girl1prefab = girl1bundle.LoadAsset<GameObject>("Assets/BundleAssets/girlc.prefab");
			mls = Logger.CreateLogSource("meltyjpg.dressgirlreskin");
			mls.LogInfo((object)"lol!");
			harmony.PatchAll(typeof(DressGirlRSKN));
			harmony.PatchAll(typeof(DressGirlPatch));
		}
	}
}
namespace GhostGirlReskin.Patches
{
	[HarmonyPatch(typeof(DressGirlAI))]
	internal class DressGirlPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void dgirlUpdatePatch(DressGirlAI __instance)
		{
			int num = 1;
			if (__instance.timesSeenByPlayer >= 3 || __instance.timesStared - __instance.timesSeenByPlayer > 2)
			{
				num = 2;
			}
			if (((EnemyAI)__instance).currentBehaviourStateIndex == 1)
			{
				num = 3;
			}
			if (!__instance.enemyMeshEnabled)
			{
				num = 4;
			}
			SkinnedMeshRenderer val = ((EnemyAI)__instance).skinnedMeshRenderers[((EnemyAI)__instance).skinnedMeshRenderers.Count() - 1];
			SkinnedMeshRenderer val2 = ((EnemyAI)__instance).skinnedMeshRenderers[((EnemyAI)__instance).skinnedMeshRenderers.Count() - 2];
			SkinnedMeshRenderer val3 = ((EnemyAI)__instance).skinnedMeshRenderers[((EnemyAI)__instance).skinnedMeshRenderers.Count() - 3];
			switch (num)
			{
			case 1:
				((Renderer)val3).enabled = true;
				((Renderer)val2).enabled = false;
				((Renderer)val).enabled = false;
				break;
			case 2:
				((Renderer)val3).enabled = false;
				((Renderer)val2).enabled = true;
				((Renderer)val).enabled = false;
				break;
			case 3:
				((Renderer)val3).enabled = false;
				((Renderer)val2).enabled = false;
				((Renderer)val).enabled = true;
				break;
			case 4:
				((Renderer)val3).enabled = false;
				((Renderer)val2).enabled = false;
				((Renderer)val).enabled = false;
				break;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void dgirlStartPatch(DressGirlAI __instance)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = ((Component)__instance).transform.Find("DressGirlModel");
			Transform val = obj.Find("AnimContainer").Find("metarig");
			SkinnedMeshRenderer component = ((Component)obj.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
			if ((Object)(object)component != (Object)null && ((Renderer)component).enabled)
			{
				((Renderer)component).enabled = false;
				MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Renderer)componentsInChildren[i]).enabled = false;
				}
			}
			GameObject val2 = Object.Instantiate<GameObject>(DressGirlRSKN.girl1prefab);
			val2.transform.SetParent(((Component)__instance).transform);
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.identity;
			List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
			SkinnedMeshRenderer[] skinnedMeshRenderers = ((EnemyAI)__instance).skinnedMeshRenderers;
			SkinnedMeshRenderer[] array = skinnedMeshRenderers;
			foreach (SkinnedMeshRenderer item in array)
			{
				list.Add(item);
			}
			list.Add(((Component)val2.transform.Find("girl1-mesh")).GetComponent<SkinnedMeshRenderer>());
			list.Add(((Component)val2.transform.Find("girl2-mesh")).GetComponent<SkinnedMeshRenderer>());
			list.Add(((Component)val2.transform.Find("girl3-mesh")).GetComponent<SkinnedMeshRenderer>());
			foreach (SkinnedMeshRenderer item2 in list)
			{
				((Component)item2).gameObject.layer = ((Component)skinnedMeshRenderers[0]).gameObject.layer;
			}
			((EnemyAI)__instance).skinnedMeshRenderers = list.ToArray();
			((EnemyAI)__instance).creatureAnimator = val2.GetComponent<Animator>();
		}
	}
}