Decompiled source of FoxyJumpscare v1.2.1

FoxyJumpscare.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("FoxyJumpscare")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FoxyJumpscare")]
[assembly: AssemblyTitle("FoxyJumpscare")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FoxyJumpscare
{
	[BepInPlugin("FoxyJumpscare", "FoxyJumpscare", "1.0.0")]
	public class FoxyJumpscare : BaseUnityPlugin
	{
		public static List<Sprite> Tiles = new List<Sprite>();

		public static Image Foxy;

		public static AudioSource Sounder;

		public static AudioClip Sound;

		public static float Fps = 1f;

		public static int CurrentFrame = 14;

		public static float TimeSinceJump = 2.1474836E+09f;

		public static int floorvalue = 0;

		public static bool started = false;

		public static int Rng = 0;

		public static bool ShouldCrash = false;

		public static bool CrashWindow = false;

		private PluginConfigurator config;

		private static IntField Chanceval;

		public static FoxyJumpscare Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"FoxyJumpscare v1.0.0 has loaded!");
			config = PluginConfigurator.Create("FoxyJumpscare", "FoxyJumpscare");
			IntField val = new IntField(config.rootPanel, "Chance", "chance", 2000);
			BoolField val2 = new BoolField(config.rootPanel, "Crash on scare", "crashonscare", false);
			val2.defaultValue = false;
			Rng = val.value;
			ShouldCrash = val2.value;
			Chanceval = val;
			if (val2.value)
			{
				val.value = Mathf.Clamp(val.value, 500, int.MaxValue);
				Rng = Mathf.Clamp(val.value, 500, int.MaxValue);
			}
			val.onValueChange += new IntValueChangeEventDelegate(updaterng);
			val2.onValueChange += new BoolValueChangeEventDelegate(updatecrash);
		}

		private static void updaterng(IntValueChangeEvent a)
		{
			if (ShouldCrash)
			{
				Rng = Mathf.Clamp(a.value, 500, int.MaxValue);
			}
			Rng = a.value;
		}

		private static void updatecrash(BoolValueChangeEvent Crashable)
		{
			ShouldCrash = Crashable.value;
			if (ShouldCrash)
			{
				Rng = Mathf.Clamp(Chanceval.value, 500, int.MaxValue);
			}
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("FoxyJumpscare");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FoxyJumpscare";

		public const string PLUGIN_NAME = "FoxyJumpscare";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace FoxyJumpscare.Patches
{
	[HarmonyPatch(typeof(CanvasController))]
	public class FindCanvas
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void Create(CanvasController __instance)
		{
			if (!FoxyJumpscare.started)
			{
				FoxyJumpscare.started = true;
				string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "foxy");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile000.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile001.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile002.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile003.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile004.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile005.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile006.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile007.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile008.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile009.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile010.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile011.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile012.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/tile013.png"));
				FoxyJumpscare.Tiles.Add(val.LoadAsset<Sprite>("Assets/blank.png"));
				FoxyJumpscare.Sound = val.LoadAsset<AudioClip>("Assets/sound.mp3");
				GameObject val2 = val.LoadAsset<GameObject>("Assets/Canvas.prefab");
				GameObject val3 = Object.Instantiate<GameObject>(val2, (Transform)null);
				Object.DontDestroyOnLoad((Object)(object)val3);
				val3.GetComponent<Canvas>().sortingOrder = 2599;
				FoxyJumpscare.Sounder = val3.GetComponentInChildren<AudioSource>();
				FoxyJumpscare.Foxy = val3.GetComponentInChildren<Image>();
				FoxyJumpscare.Foxy.sprite = FoxyJumpscare.Tiles[14];
				((Behaviour)FoxyJumpscare.Foxy).enabled = false;
			}
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	public class Jumper
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void Jumpscare()
		{
			if (FoxyJumpscare.floorvalue < Mathf.FloorToInt(Time.realtimeSinceStartup))
			{
				int num = Random.Range(1, FoxyJumpscare.Rng);
				if (num == 1)
				{
					FoxyJumpscare.CurrentFrame = 0;
					FoxyJumpscare.TimeSinceJump = Time.realtimeSinceStartup;
					FoxyJumpscare.CrashWindow = true;
				}
			}
			FoxyJumpscare.floorvalue = Mathf.FloorToInt(Time.realtimeSinceStartup);
			if (!((double)Time.realtimeSinceStartup > (double)FoxyJumpscare.TimeSinceJump + (double)FoxyJumpscare.CurrentFrame * 0.05928571429))
			{
				return;
			}
			if (FoxyJumpscare.ShouldCrash & FoxyJumpscare.CrashWindow)
			{
				Time.timeScale = 0f;
			}
			if (FoxyJumpscare.CurrentFrame == 0)
			{
				FoxyJumpscare.Sounder.PlayOneShot(FoxyJumpscare.Sound);
			}
			FoxyJumpscare.Foxy.sprite = FoxyJumpscare.Tiles[Mathf.Clamp(FoxyJumpscare.CurrentFrame, 0, 14)];
			if (!((FoxyJumpscare.CurrentFrame == 13) & ((double)Time.realtimeSinceStartup > (double)FoxyJumpscare.TimeSinceJump + 1.2)))
			{
				FoxyJumpscare.CurrentFrame = Mathf.Clamp(FoxyJumpscare.CurrentFrame + 1, 0, 14);
			}
			if (FoxyJumpscare.CurrentFrame == 14)
			{
				((Behaviour)FoxyJumpscare.Foxy).enabled = false;
				if (FoxyJumpscare.ShouldCrash & FoxyJumpscare.CrashWindow)
				{
					Time.timeScale = 0f;
					Application.Quit();
				}
				FoxyJumpscare.CrashWindow = false;
			}
			else
			{
				((Behaviour)FoxyJumpscare.Foxy).enabled = true;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}