using System.Collections.Generic;
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 BetterGhost.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("BetterGhost")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterGhost")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("93551394-882c-4d1f-9f8f-43e7589d66b2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterGhost
{
[BepInPlugin("lef.cheems.ghostgirl", "CheemsGhostGirl", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "lef.cheems.ghostgirl";
private const string modName = "CheemsGhostGirl";
private const string modVersion = "0.0.1";
private readonly Harmony harmony = new Harmony("lef.cheems.ghostgirl");
private static Plugin Instance;
internal static ManualLogSource mls;
public static AssetBundle cheemsBundle;
public static GameObject cheemsMesh;
public static Material cheemsMaterial;
public void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("lef.cheems.ghostgirl");
mls.LogInfo((object)"CheemsGhostGirlModBase Awake");
string text = ((BaseUnityPlugin)Instance).Info.Location.TrimEnd("BetterGhost.dll".ToCharArray());
mls.LogInfo((object)("Assembly Location: " + text));
cheemsBundle = AssetBundle.LoadFromFile(Path.Combine(text, "modassets"));
if ((Object)(object)cheemsBundle == (Object)null)
{
mls.LogError((object)"Failed to load custom assets.");
return;
}
cheemsMesh = cheemsBundle.LoadAsset<GameObject>("Assets/cheems.prefab");
if ((Object)(object)cheemsMesh == (Object)null)
{
mls.LogError((object)"Failed to load cheems.prefab");
}
else
{
mls.LogInfo((object)"Loaded cheems.fbx.");
}
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(DressGirlAIPatch));
}
}
}
namespace BetterGhost.Patches
{
[HarmonyPatch(typeof(DressGirlAI))]
internal class DressGirlAIPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(DressGirlAI __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
Plugin.mls.LogInfo((object)"DressGirlAI Start Patching");
Transform val = ((Component)__instance).transform.Find("DressGirlModel");
Transform val2 = val.Find("AnimContainer").Find("metarig");
SkinnedMeshRenderer component = ((Component)val.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
if ((Object)component != (Object)null && ((Renderer)component).enabled)
{
Plugin.mls.LogInfo((object)"DressGirlAI Start Patching, Models found");
((Renderer)component).enabled = false;
MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>();
MeshRenderer[] array = componentsInChildren;
foreach (MeshRenderer val3 in array)
{
((Renderer)val3).enabled = false;
}
GameObject val4 = Object.Instantiate<GameObject>(Plugin.cheemsMesh);
Plugin.mls.LogInfo((object)("DressGirlAI Start: cheemsMesh exists:" + (object)val4 != null));
val4.transform.SetParent(val);
val4.transform.localPosition = Vector3.zero;
val4.transform.localPosition = new Vector3(val4.transform.localPosition.x, val4.transform.localPosition.y + 0.734f, val4.transform.localPosition.z);
val4.transform.localRotation = ((Component)val2).transform.localRotation;
val4.transform.Rotate(90f, 0f, 0f);
val4.transform.localScale = val4.transform.localScale * 0.6f;
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";
List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
SkinnedMeshRenderer[] skinnedMeshRenderers = ((EnemyAI)__instance).skinnedMeshRenderers;
SkinnedMeshRenderer[] array2 = skinnedMeshRenderers;
foreach (SkinnedMeshRenderer item in array2)
{
list.Add(item);
}
list.Add(component2);
((EnemyAI)__instance).skinnedMeshRenderers = list.ToArray();
((Object)val2).name = "old_metarig";
}
Plugin.mls.LogInfo((object)"DressGirlAI Start Patched");
}
}
}