using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("olivr")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("1/1000 chance for Foxy jumpscare every second")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyInformationalVersion("1.6.0+9cdbd932022d8a0744b9292f738a1a214ff1039a")]
[assembly: AssemblyProduct("jumpscareFoxy")]
[assembly: AssemblyTitle("jumpscareFoxy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.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 jumpscareFoxy
{
[BepInPlugin("com.olivr.jumpscareFoxy", "JumpscareFoxy", "1.6.2")]
public class jumpscareFoxy : BaseUnityPlugin
{
private JumpscareManager? jumpscareManager;
private Configuration? config;
internal static jumpscareFoxy Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Logger.LogInfo((object)"Initializing Jumpscare Mod");
config = new Configuration(((BaseUnityPlugin)this).Config);
if (config.Enabled)
{
jumpscareManager = new JumpscareManager(config);
}
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0025: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
jumpscareManager?.Update();
}
public Coroutine StartManagedCoroutine(IEnumerator coroutine)
{
return ((MonoBehaviour)this).StartCoroutine(coroutine);
}
}
public class Configuration
{
public bool Enabled { get; }
public int Probability { get; }
public bool ManualTriggerEnabled { get; }
public KeyCode TriggerKey { get; }
public int AnimationFPS { get; }
public Configuration(ConfigFile config)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
Enabled = config.Bind<bool>("General", "Enabled", true, "Enable/disable the mod").Value;
Probability = config.Bind<int>("General", "Probability", 1000, new ConfigDescription("1/X chance per second", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100000), Array.Empty<object>())).Value;
ManualTriggerEnabled = config.Bind<bool>("Controls", "ManualTrigger", true, "Enable manual trigger").Value;
TriggerKey = config.Bind<KeyCode>("Controls", "TriggerKey", (KeyCode)106, "Manual trigger key").Value;
AnimationFPS = config.Bind<int>("Animation", "FPS", 15, new ConfigDescription("Animation speed", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 60), Array.Empty<object>())).Value;
}
}
public class JumpscareManager
{
private readonly Configuration config;
private readonly Random random = new Random();
private float timer;
private bool isJumpscarePlaying;
private UIManager? uiManager;
public JumpscareManager(Configuration config)
{
this.config = config;
uiManager = new UIManager();
jumpscareFoxy.Logger.LogInfo((object)"Jumpscare manager initialized");
}
public void Update()
{
if (!isJumpscarePlaying)
{
HandleTimedTrigger();
HandleManualTrigger();
}
}
private void HandleTimedTrigger()
{
timer += Time.deltaTime;
if (timer >= 1f)
{
timer = 0f;
if (random.Next(config.Probability) == 0)
{
TriggerJumpscare();
}
}
}
private void HandleManualTrigger()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (config.ManualTriggerEnabled && Input.GetKeyDown(config.TriggerKey))
{
TriggerJumpscare();
}
}
private void TriggerJumpscare()
{
if (!isJumpscarePlaying)
{
jumpscareFoxy.Logger.LogInfo((object)"Triggering jumpscare");
isJumpscarePlaying = true;
uiManager?.PlayJumpscare(config.AnimationFPS, delegate
{
isJumpscarePlaying = false;
jumpscareFoxy.Logger.LogInfo((object)"Jumpscare completed");
});
}
}
}
public class UIManager : MonoBehaviour
{
[CompilerGenerated]
private sealed class <Initialize>d__9 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public UIManager <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Initialize>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
int num = <>1__state;
UIManager uIManager = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForEndOfFrame();
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
string directoryName = Path.GetDirectoryName(typeof(jumpscareFoxy).Assembly.Location);
uIManager.assetsRoot = Path.Combine(directoryName, "assets");
if (!Directory.Exists(uIManager.assetsRoot))
{
jumpscareFoxy.Logger.LogError((object)("Assets folder not found at: " + uIManager.assetsRoot));
jumpscareFoxy.Logger.LogError((object)"The mod will not work correctly. Please ensure the 'assets' folder is in the same directory as the DLL.");
return false;
}
jumpscareFoxy.Logger.LogInfo((object)("Assets root directory detected: " + uIManager.assetsRoot));
uIManager.CreateUI();
uIManager.LoadAssets();
uIManager.initialized = true;
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <JumpscareSequence>d__14 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public UIManager <>4__this;
public int fps;
public Action onComplete;
private float <delay>5__2;
private List<Sprite>.Enumerator <>7__wrap2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <JumpscareSequence>d__14(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 2)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap2 = default(List<Sprite>.Enumerator);
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
try
{
int num = <>1__state;
UIManager uIManager = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = uIManager.LoadAndPlayAudio();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (uIManager.frames.Count > 0)
{
<delay>5__2 = 1f / (float)fps;
<>7__wrap2 = uIManager.frames.GetEnumerator();
<>1__state = -3;
goto IL_00d1;
}
jumpscareFoxy.Logger.LogWarning((object)"No frames available, using fallback");
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 3;
return true;
case 2:
<>1__state = -3;
goto IL_00d1;
case 3:
{
<>1__state = -1;
break;
}
IL_00d1:
if (<>7__wrap2.MoveNext())
{
Sprite current = <>7__wrap2.Current;
uIManager.imageComponent.sprite = current;
<>2__current = (object)new WaitForSeconds(<delay>5__2);
<>1__state = 2;
return true;
}
<>m__Finally1();
<>7__wrap2 = default(List<Sprite>.Enumerator);
break;
}
((Graphic)uIManager.imageComponent).color = new Color(1f, 1f, 1f, 0f);
uIManager.isPlaying = false;
onComplete?.Invoke();
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((IDisposable)<>7__wrap2).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <LoadAndPlayAudio>d__15 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public UIManager <>4__this;
private WWW <www>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAndPlayAudio>d__15(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<www>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
try
{
int num = <>1__state;
UIManager uIManager = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
string text = Path.Combine(uIManager.assetsRoot, "jumpscare.wav");
if (!File.Exists(text))
{
jumpscareFoxy.Logger.LogError((object)("Audio file not found: " + text));
return false;
}
<www>5__2 = new WWW("file://" + text);
<>1__state = -3;
<>2__current = <www>5__2;
<>1__state = 1;
return true;
}
case 1:
<>1__state = -3;
if (!string.IsNullOrEmpty(<www>5__2.error))
{
jumpscareFoxy.Logger.LogError((object)("Audio load error: " + <www>5__2.error));
}
else
{
uIManager.audioSource.clip = <www>5__2.GetAudioClip(false, false, (AudioType)20);
if ((Object)(object)uIManager.audioSource.clip != (Object)null)
{
uIManager.audioSource.Play();
jumpscareFoxy.Logger.LogInfo((object)"Playing jumpscare sound");
}
else
{
jumpscareFoxy.Logger.LogError((object)"Failed to create audio clip");
}
}
<>m__Finally1();
<www>5__2 = null;
return false;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<www>5__2 != null)
{
((IDisposable)<www>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private GameObject? canvasObject;
private Image? imageComponent;
private AudioSource? audioSource;
private List<Sprite> frames = new List<Sprite>();
private bool assetsLoaded;
private bool initialized;
private bool isPlaying;
private string? assetsRoot;
public UIManager()
{
jumpscareFoxy.Logger.LogInfo((object)"Creating UI Manager");
jumpscareFoxy.Instance.StartManagedCoroutine(Initialize());
}
[IteratorStateMachine(typeof(<Initialize>d__9))]
private IEnumerator Initialize()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Initialize>d__9(0)
{
<>4__this = this
};
}
private void CreateUI()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
canvasObject = new GameObject("JumpscareCanvas");
Object.DontDestroyOnLoad((Object)(object)canvasObject);
Canvas val = canvasObject.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 9999;
CanvasScaler val2 = canvasObject.AddComponent<CanvasScaler>();
val2.uiScaleMode = (ScaleMode)1;
val2.referenceResolution = new Vector2(1920f, 1080f);
canvasObject.AddComponent<GraphicRaycaster>();
audioSource = canvasObject.AddComponent<AudioSource>();
audioSource.playOnAwake = false;
audioSource.volume = 1f;
GameObject val3 = new GameObject("JumpscareImage");
val3.transform.SetParent(canvasObject.transform);
imageComponent = val3.AddComponent<Image>();
imageComponent.preserveAspect = true;
((Graphic)imageComponent).color = new Color(1f, 1f, 1f, 0f);
RectTransform component = val3.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
jumpscareFoxy.Logger.LogInfo((object)"UI created successfully");
}
private void LoadAssets()
{
jumpscareFoxy.Logger.LogInfo((object)"Loading assets...");
LoadAnimationFrames();
assetsLoaded = true;
}
private void LoadAnimationFrames()
{
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(assetsRoot, "frames");
if (!Directory.Exists(text))
{
jumpscareFoxy.Logger.LogError((object)("Frames directory not found: " + text));
return;
}
string[] array = (from f in Directory.GetFiles(text, "*.png")
orderby f
select f).ToArray();
if (array.Length == 0)
{
jumpscareFoxy.Logger.LogError((object)"No animation frames found!");
return;
}
jumpscareFoxy.Logger.LogInfo((object)$"Loading {array.Length} animation frames...");
string[] array2 = array;
foreach (string path in array2)
{
try
{
byte[] array3 = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array3))
{
frames.Add(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f));
}
}
catch (Exception ex)
{
jumpscareFoxy.Logger.LogError((object)("Error loading frame: " + ex.Message));
}
}
jumpscareFoxy.Logger.LogInfo((object)$"Loaded {frames.Count} frames");
}
public void PlayJumpscare(int fps, Action onComplete)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
if (!initialized || !assetsLoaded)
{
jumpscareFoxy.Logger.LogWarning((object)"UI not ready or assets not loaded");
}
else if ((Object)(object)imageComponent == (Object)null)
{
jumpscareFoxy.Logger.LogError((object)"Image component missing");
}
else if (!isPlaying)
{
isPlaying = true;
imageComponent.sprite = ((frames.Count > 0) ? frames[0] : null);
((Graphic)imageComponent).color = Color.white;
jumpscareFoxy.Instance.StartManagedCoroutine(JumpscareSequence(fps, onComplete));
}
}
[IteratorStateMachine(typeof(<JumpscareSequence>d__14))]
private IEnumerator JumpscareSequence(int fps, Action onComplete)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <JumpscareSequence>d__14(0)
{
<>4__this = this,
fps = fps,
onComplete = onComplete
};
}
[IteratorStateMachine(typeof(<LoadAndPlayAudio>d__15))]
private IEnumerator LoadAndPlayAudio()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAndPlayAudio>d__15(0)
{
<>4__this = this
};
}
}
}