Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of jumpscareFoxy v1.5.0
jumpscareFoxy.dll
Decompiled a year agousing 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 Microsoft.CodeAnalysis; 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("olivr")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("jumpscareFoxy")] [assembly: AssemblyTitle("jumpscareFoxy")] [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 JumpscareFoxy { public class UIManager : MonoBehaviour { [CompilerGenerated] private sealed class <Initialize>d__8 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public UIManager <>4__this; private string <pluginBase>5__1; private string[] <dirs>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Initialize>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <pluginBase>5__1 = null; <dirs>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; <pluginBase>5__1 = Paths.PluginPath; <dirs>5__2 = Directory.GetDirectories(<pluginBase>5__1, "assets", SearchOption.AllDirectories); <>4__this.assetsRoot = <dirs>5__2.FirstOrDefault(); if (<>4__this.assetsRoot == null) { Plugin.Log.LogError((object)"Assets folder not found. The mod will not work correctly."); return false; } Plugin.Log.LogInfo((object)("Assets root directory detected: " + <>4__this.assetsRoot)); <>4__this.CreateUI(); <>4__this.LoadAssets(); <>4__this.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__13 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int fps; public Action onComplete; public UIManager <>4__this; private float <delay>5__1; private List<Sprite>.Enumerator <>s__2; private Sprite <frame>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <JumpscareSequence>d__13(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(); } } <>s__2 = default(List<Sprite>.Enumerator); <frame>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = <>4__this.LoadAndPlayAudio(); <>1__state = 1; return true; case 1: <>1__state = -1; if (<>4__this.frames.Count > 0) { <delay>5__1 = 1f / (float)fps; <>s__2 = <>4__this.frames.GetEnumerator(); <>1__state = -3; goto IL_0109; } Plugin.Log.LogWarning((object)"No frames available, using fallback"); <>2__current = (object)new WaitForSeconds(2f); <>1__state = 3; return true; case 2: <>1__state = -3; <frame>5__3 = null; goto IL_0109; case 3: { <>1__state = -1; break; } IL_0109: if (<>s__2.MoveNext()) { <frame>5__3 = <>s__2.Current; <>4__this.imageComponent.sprite = <frame>5__3; <>2__current = (object)new WaitForSeconds(<delay>5__1); <>1__state = 2; return true; } <>m__Finally1(); <>s__2 = default(List<Sprite>.Enumerator); break; } ((Graphic)<>4__this.imageComponent).color = new Color(1f, 1f, 1f, 0f); 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)<>s__2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadAndPlayAudio>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public UIManager <>4__this; private string <soundPath>5__1; 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__14(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(); } } <soundPath>5__1 = null; <www>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; <soundPath>5__1 = Path.Combine(<>4__this.assetsRoot, "jumpscare.wav"); if (!File.Exists(<soundPath>5__1)) { Plugin.Log.LogError((object)("Audio file not found: " + <soundPath>5__1)); result = false; break; } <www>5__2 = new WWW("file://" + <soundPath>5__1); <>1__state = -3; <>2__current = <www>5__2; <>1__state = 1; result = true; break; case 1: <>1__state = -3; if (!string.IsNullOrEmpty(<www>5__2.error)) { Plugin.Log.LogError((object)("Audio load error: " + <www>5__2.error)); } else { <>4__this.audioSource.clip = <www>5__2.GetAudioClip(false, false, (AudioType)20); if ((Object)(object)<>4__this.audioSource.clip != (Object)null) { <>4__this.audioSource.Play(); Plugin.Log.LogInfo((object)"Playing jumpscare sound"); } else { Plugin.Log.LogError((object)"Failed to create audio clip"); } } result = false; <>m__Finally1(); break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } 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 string assetsRoot; public UIManager() { Plugin.Log.LogInfo((object)"Creating UI Manager"); Plugin.Instance.StartManagedCoroutine(Initialize()); } [IteratorStateMachine(typeof(<Initialize>d__8))] private IEnumerator Initialize() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Initialize>d__8(0) { <>4__this = this }; } private void CreateUI() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00f7: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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; Plugin.Log.LogInfo((object)"UI created successfully"); } private void LoadAssets() { Plugin.Log.LogInfo((object)"Loading assets..."); LoadAnimationFrames(); assetsLoaded = true; } private void LoadAnimationFrames() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(assetsRoot, "frames"); if (!Directory.Exists(text)) { Plugin.Log.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) { Plugin.Log.LogError((object)"No animation frames found!"); return; } Plugin.Log.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) { Plugin.Log.LogError((object)("Error loading frame: " + ex.Message)); } } Plugin.Log.LogInfo((object)$"Loaded {frames.Count} frames"); } public void PlayJumpscare(int fps, Action onComplete) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!initialized || !assetsLoaded) { Plugin.Log.LogWarning((object)"UI not ready or assets not loaded"); return; } if ((Object)(object)imageComponent == (Object)null) { Plugin.Log.LogError((object)"Image component missing"); return; } ((Graphic)imageComponent).color = Color.white; Plugin.Instance.StartManagedCoroutine(JumpscareSequence(fps, onComplete)); } [IteratorStateMachine(typeof(<JumpscareSequence>d__13))] private IEnumerator JumpscareSequence(int fps, Action onComplete) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <JumpscareSequence>d__13(0) { <>4__this = this, fps = fps, onComplete = onComplete }; } [IteratorStateMachine(typeof(<LoadAndPlayAudio>d__14))] private IEnumerator LoadAndPlayAudio() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAndPlayAudio>d__14(0) { <>4__this = this }; } } 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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(); Plugin.Log.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_0014: 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) { Plugin.Log.LogInfo((object)"Triggering jumpscare"); isJumpscarePlaying = true; uiManager.PlayJumpscare(config.AnimationFPS, delegate { isJumpscarePlaying = false; Plugin.Log.LogInfo((object)"Jumpscare completed"); }); } } } [BepInPlugin("com.olivr.jumpscareFoxy", "JumpscareFoxy", "1.3.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static string PluginFolderName = "olivr-jumpscareFoxy"; private JumpscareManager jumpscareManager; private Configuration config; public static Plugin Instance { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)("Initializing Jumpscare Mod (Folder: " + PluginFolderName + ")")); config = new Configuration(((BaseUnityPlugin)this).Config); if (config.Enabled) { jumpscareManager = new JumpscareManager(config); } } private void Update() { jumpscareManager?.Update(); } public Coroutine StartManagedCoroutine(IEnumerator coroutine) { return ((MonoBehaviour)this).StartCoroutine(coroutine); } } }