using System; using System.Collections; 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.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Skeleton_Jumpscare")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+e8ff94832e56c6c212510bab4ef421a5ce50fe2d")] [assembly: AssemblyProduct("Skeleton_Jumpscare")] [assembly: AssemblyTitle("Skeleton_Jumpscare")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ClungoGit/skeleton_jumpscare")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Skeleton_Jumpscare { [BepInPlugin("io.github.ClungoGit.skeleton_jumpscare", "Skeleton_Jumpscare", "1.0.4")] public class Skeleton_JumpscarePlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__14 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string path; public Skeleton_JumpscarePlugin <>4__this; private UnityWebRequest 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Invalid comparison between Unknown and I4 bool result; try { int num = <>1__state; Skeleton_JumpscarePlugin skeleton_JumpscarePlugin = <>4__this; switch (num) { default: result = false; break; case 0: <>1__state = -1; if (!File.Exists(path)) { ((BaseUnityPlugin)skeleton_JumpscarePlugin).Logger.LogError((object)("Audio file not found: " + path)); result = false; break; } 5__2 = UnityWebRequestMultimedia.GetAudioClip("file://" + path, (AudioType)20); <>1__state = -3; <>2__current = 5__2.SendWebRequest(); <>1__state = 1; result = true; break; case 1: <>1__state = -3; if ((int)5__2.result == 1) { if ((Object)(object)skeleton_JumpscarePlugin.audioSource != (Object)null) { skeleton_JumpscarePlugin.audioSource.clip = DownloadHandlerAudioClip.GetContent(5__2); ((BaseUnityPlugin)skeleton_JumpscarePlugin).Logger.LogInfo((object)"Loaded jumpscare audio."); } } else { ((BaseUnityPlugin)skeleton_JumpscarePlugin).Logger.LogError((object)("Audio load failed: " + 5__2.error)); } 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 (5__2 != null) { ((IDisposable)5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private readonly List frames = new List(); private int currentFrame; private bool isPlaying; private float frameTimer; private const float FramesPerSecond = 60f; private AudioSource? audioSource; private readonly Random rng = new Random(); private ConfigEntry averageSecondsBetweenTriggers; public const string Id = "io.github.ClungoGit.skeleton_jumpscare"; public static string Name => "Skeleton_Jumpscare"; public static string Version => "1.0.4"; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string framesFolder = Path.Combine(directoryName, "Frames"); string path = Path.Combine(directoryName, "bad.wav"); LoadFrames(framesFolder); GameObject val = new GameObject("SkeletonJumpscareAudio"); Object.DontDestroyOnLoad((Object)(object)val); audioSource = val.AddComponent(); ((MonoBehaviour)this).StartCoroutine(LoadAudio(path)); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Loaded {frames.Count} jumpscare frames."); averageSecondsBetweenTriggers = ((BaseUnityPlugin)this).Config.Bind("General", "AverageSecondsBetweenTriggers", 250f, "Average number of seconds between random running skeleton events."); } private void Update() { if (Input.GetKeyDown((KeyCode)287)) { PlayJumpscare(); } if (isPlaying) { frameTimer += Time.deltaTime; float num = 1f / 60f; while (frameTimer >= num) { frameTimer -= num; currentFrame++; if (currentFrame >= frames.Count) { StopJumpscare(); break; } } } else { float num2 = Mathf.Max(0.01f, averageSecondsBetweenTriggers.Value); float num3 = Time.deltaTime / num2; if (rng.NextDouble() < (double)num3) { PlayJumpscare(); } } } private void OnGUI() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (isPlaying && frames.Count != 0 && currentFrame < frames.Count) { Texture2D val = frames[currentFrame]; GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)val, (ScaleMode)1, true); } } private void PlayJumpscare() { if (frames.Count == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No frames loaded."); return; } currentFrame = 0; frameTimer = 0f; isPlaying = true; AudioSource? obj = audioSource; if ((Object)(object)((obj != null) ? obj.clip : null) != (Object)null) { audioSource.Stop(); audioSource.Play(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Playing jumpscare."); } private void StopJumpscare() { isPlaying = false; currentFrame = 0; frameTimer = 0f; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Jumpscare finished."); } private void LoadFrames(string framesFolder) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (!Directory.Exists(framesFolder)) { ((BaseUnityPlugin)this).Logger.LogError((object)("Frames folder not found: " + framesFolder)); return; } string[] files = Directory.GetFiles(framesFolder, "*.png"); Array.Sort(files); string[] array = files; foreach (string text in array) { try { byte[] array2 = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array2); frames.Add(val); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to load frame {text}: {arg}"); } } } [IteratorStateMachine(typeof(d__14))] private IEnumerator LoadAudio(string path) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { <>4__this = this, path = path }; } } }