Decompiled source of Foxy Jumpscare v1.0.0

BepInEx/plugins/WKFoxyJumpscare.dll

Decompiled 3 days 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 BepInEx.Configuration;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WKFoxyJumpscare")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WKFoxyJumpscare")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("B90710F9-F914-4634-883D-014E4DAA218F")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WKFoxyJumpscare;

public class FoxyJumpscare : MonoBehaviour
{
	private VideoPlayer videoPlayer;

	private RawImage rawImage;

	private void Awake()
	{
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		videoPlayer = ((Component)this).GetComponentInChildren<VideoPlayer>();
		rawImage = ((Component)this).GetComponentInChildren<RawImage>();
		if ((Object)(object)videoPlayer != (Object)null && (Object)(object)rawImage != (Object)null)
		{
			((Behaviour)rawImage).enabled = false;
			if ((Object)(object)videoPlayer.targetTexture != (Object)null)
			{
				videoPlayer.targetTexture.Release();
			}
			videoPlayer.prepareCompleted += new EventHandler(OnVideoReady);
			videoPlayer.loopPointReached += new EventHandler(OnVideoEnded);
			videoPlayer.Prepare();
		}
		else
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private void OnVideoReady(VideoPlayer vp)
	{
		((Behaviour)rawImage).enabled = true;
		vp.Play();
	}

	private void OnVideoEnded(VideoPlayer vp)
	{
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
[BepInPlugin("com.xironix.wkfoxyjumpscare", "WKFoxyJumpscare", "1.0.0")]
public class WKFoxyJumpscarePlugin : BaseUnityPlugin
{
	public static AssetBundle assetBundle;

	public static GameObject FoxyJumpscarePrefab;

	public static ConfigEntry<float> chance;

	public static ConfigEntry<float> interval;

	private float stopwatch;

	public void Awake()
	{
		((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"WKFoxyJumpscare is waking up...");
		chance = ((BaseUnityPlugin)this).Config.Bind<float>("Main", "Chance", 0.0001f, "Probability of jumpscare triggering every interval.");
		interval = ((BaseUnityPlugin)this).Config.Bind<float>("Main", "Interval", 1f, "Time in seconds between chance rolls.");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string name = "WKFoxyJumpscare.bundle";
		Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(name);
		if (manifestResourceStream != null)
		{
			assetBundle = AssetBundle.LoadFromStream(manifestResourceStream);
			if ((Object)(object)assetBundle != (Object)null)
			{
				FoxyJumpscarePrefab = assetBundle.LoadAsset<GameObject>("FoxyJumpscare");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded prefab");
			}
		}
	}

	public void Update()
	{
		stopwatch += Time.unscaledDeltaTime;
		if (stopwatch >= interval.Value)
		{
			stopwatch = 0f;
			if (Random.value <= chance.Value && (Object)(object)FoxyJumpscarePrefab != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Jumpscare triggered");
				GameObject val = Object.Instantiate<GameObject>(FoxyJumpscarePrefab);
				val.AddComponent<FoxyJumpscare>();
			}
		}
	}
}