using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("FNaFEndoCoilhead")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FNaFEndoCoilhead")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ff34eb67-3d0a-4bb2-aef9-43bedc4dc294")]
[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 FNaFEndoCoilhead
{
[BepInPlugin("FNaFEndoCoilhead", "FNaFEndoCoilhead", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public static GameObject Visuals;
public static AudioClip Audio;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FNaFEndoCoilhead is loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "endo.bundle");
AssetBundle val = AssetBundle.LoadFromFile(text);
Visuals = val.LoadAsset<GameObject>("assets/prefabs/endo.prefab");
Audio = val.LoadAsset<AudioClip>("assets/prefabs/audio.wav");
Renderer[] componentsInChildren = Visuals.GetComponentsInChildren<Renderer>(true);
foreach (Renderer val2 in componentsInChildren)
{
((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "FNaFEndoCoilhead";
public const string PLUGIN_NAME = "FNaFEndoCoilhead";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace FNaFEndoCoilhead.Patches
{
[HarmonyPatch(typeof(EnemyAI), "Start")]
internal class SpringManPatch
{
private static void Postfix(EnemyAI __instance)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
if (__instance is SpringManAI && !((Object)(object)Plugin.Visuals == (Object)null))
{
Transform val = ((Component)__instance).transform.Find("SpringManModel");
SkinnedMeshRenderer val2 = ((val != null) ? ((Component)val.Find("Body")).GetComponent<SkinnedMeshRenderer>() : null);
((Renderer)val2).enabled = false;
MeshRenderer val3 = ((val != null) ? ((Component)val.Find("Head")).GetComponent<MeshRenderer>() : null);
Transform val4 = ((val != null) ? val.Find("AnimContainer").Find("metarig") : null);
((Object)val4).name = "old-metarig";
((Renderer)val3).enabled = false;
GameObject val5 = Object.Instantiate<GameObject>(Plugin.Visuals);
val5.transform.SetParent(val);
val5.transform.localPosition = Vector3.zero;
val5.transform.localRotation = Quaternion.identity;
val5.transform.localScale = Vector3.one;
Transform val6 = val5.transform.Find("Container/RIG_Endo.001");
Transform val7 = val5.transform.Find("Container/metarig");
val7.SetParent(val4.parent, true);
((Component)val7).transform.localScale = ((Component)val4).transform.localScale;
((Component)val7).transform.localRotation = ((Component)val4).transform.localRotation;
((Component)val7).transform.localPosition = ((Component)val4).transform.localPosition;
SkinnedMeshRenderer component = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
component.rootBone = val7;
((Object)val7).name = "metarig";
((Component)__instance).GetComponent<SpringManAI>().springNoises = (AudioClip[])(object)new AudioClip[1];
((Component)__instance).GetComponent<SpringManAI>().springNoises[0] = Plugin.Audio;
}
}
}
}