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("SpringtrapMaskFixed")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpringtrapMaskFixed")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1f410a44-ee0e-48ca-a39d-cc5b2f33235e")]
[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 SpringtrapMaskFixed
{
[BepInPlugin("SpringtrapMaskFixed", "SpringtrapMaskFixed", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static GameObject Mesh;
public static GameObject MaskMesh;
public static GameObject HeadMaskPrefab;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SpringtrapMaskFixed is loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "springtrap.bundle");
AssetBundle val = AssetBundle.LoadFromFile(text);
Mesh = val.LoadAsset<GameObject>("assets/mesh.prefab");
MaskMesh = val.LoadAsset<GameObject>("assets/maskmesh.prefab");
HeadMaskPrefab = val.LoadAsset<GameObject>("assets/headmaskspringtrap.prefab");
}
}
}
namespace SpringtrapMaskFixed.Patches
{
[HarmonyPatch(typeof(HauntedMaskItem), "Update")]
internal class HauntedMaskItemPatch
{
private static void Postfix(HauntedMaskItem __instance)
{
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.maskEyesFilled == (Object)null || !(((Object)((Component)__instance.maskEyesFilled).gameObject).name != "DebugMaskChange"))
{
return;
}
((Object)((Component)__instance.maskEyesFilled).gameObject).name = "DebugMaskChange";
__instance.headMaskPrefab = Plugin.HeadMaskPrefab;
Renderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
if (((Object)((Component)val).gameObject).name == "MaskMesh")
{
((Object)((Component)val).gameObject).name = "MaskMeshOld";
GameObject val2 = Object.Instantiate<GameObject>(Plugin.MaskMesh, ((Component)val).transform.parent);
val2.transform.localEulerAngles = Vector3.zero;
val2.transform.localPosition = Vector3.zero;
val2.transform.localScale = Vector3.one;
((Component)val).gameObject.SetActive(false);
}
}
BoxCollider component = ((Component)__instance).GetComponent<BoxCollider>();
component.size = new Vector3(component.size.x, component.size.y, 3f);
component.center = new Vector3(component.center.x, component.center.y, -1.17f);
}
}
[HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")]
internal class MaskedPlayerEnemyPatch
{
private static void Postfix(MaskedPlayerEnemy __instance)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
RandomPeriodicAudioPlayer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<RandomPeriodicAudioPlayer>();
RandomPeriodicAudioPlayer[] array = componentsInChildren;
foreach (RandomPeriodicAudioPlayer val in array)
{
Renderer[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Renderer>();
Renderer[] array2 = componentsInChildren2;
foreach (Renderer val2 in array2)
{
if (((Object)((Component)val2).gameObject).name == "Mesh")
{
((Object)((Component)val2).gameObject).name = "MeshOld";
GameObject val3 = Object.Instantiate<GameObject>(Plugin.Mesh, ((Component)val2).transform.parent);
val3.transform.localEulerAngles = Vector3.zero;
val3.transform.localPosition = Vector3.zero;
val3.transform.localScale = Vector3.one;
}
((Component)val2).gameObject.SetActive(false);
}
}
}
}
}