Decompiled source of SpringtrapMask v1.0.0

SpringtrapMask.dll

Decompiled a year ago
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("SpringtrapMask")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpringtrapMask")]
[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 SpringtrapMask
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SpringtrapMask";

		public const string PLUGIN_NAME = "SpringtrapMask";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("SpringtrapMask", "SpringtrapMask", "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 SpringtrapMask 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 SpringtrapMask.Patches
{
	[HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")]
	internal class MaskedPlayerEnemyPatch
	{
		private static void Postfix(MaskedPlayerEnemy __instance)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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);
				}
			}
		}
	}
	[HarmonyPatch(typeof(HauntedMaskItem), "Update")]
	internal class HauntedMaskItemPatch
	{
		private static void Postfix(HauntedMaskItem __instance)
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_00fd: 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);
				}
			}
			((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText = "Vintage Mascot Head";
			((GrabbableObject)__instance).itemProperties.itemName = "Vintage Mascot Head";
			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);
		}
	}
}