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 VeryScaryJumpScare v1.0.1
baer1.VeryScaryJumpScare.dll
Decompiled 9 months agousing System; using System.Collections; 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 BepInEx.Logging; using HarmonyLib; using LethalModUtils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; [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: AssemblyCompany("baer1.VeryScaryJumpScare")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+1ced648c28ce198b6960041e6ef978b06cb27102")] [assembly: AssemblyProduct("LethalJumpscare")] [assembly: AssemblyTitle("baer1.VeryScaryJumpScare")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 LethalJumpscare { [BepInPlugin("baer1.VeryScaryJumpScare", "LethalJumpscare", "1.0.1")] public class LethalJumpscare : BaseUnityPlugin { [HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")] internal static class OpeningDoorsSequencePatch { private static void Postfix(ref StartOfRound __instance) { timerRandom = new Random(__instance.randomMapSeed); Timer = timerRandom.Next(MinTimer, MaxTimer); Logger.LogDebug((object)$"<< OpeningDoorsSequencePatch({__instance}) seed:{__instance.randomMapSeed} Timer:{Timer}"); } } [HarmonyPatch(typeof(StartOfRound), "Update")] internal static class UpdatePatch { private static Random walkingRandom = new Random(); private static void Postfix(ref StartOfRound __instance) { if (!__instance.inShipPhase && !((Object)(object)__instance.localPlayerController == (Object)null) && !__instance.localPlayerController.isPlayerDead && !__instance.localPlayerController.inSpecialInteractAnimation && !__instance.firingPlayersCutsceneRunning && jumpscare == null) { if (Timer < 0f) { a(ref __instance); } else { Timer -= Time.deltaTime; } } } private static void a(ref StartOfRound __instance) { Logger.LogDebug((object)$">> a({__instance}) isWalking:{__instance.localPlayerController.isWalking}"); if (!__instance.localPlayerController.isWalking) { Timer = (float)walkingRandom.NextDouble() * 2f; return; } Timer = timerRandom.Next(MinTimer, MaxTimer); jumpscare = ((MonoBehaviour)__instance.localPlayerController).StartCoroutine(Jumpscare()); } } private const int MIN_TIMER = 60; private const int MAX_TIMER = 7200; private ConfigEntry<int>? minTimer; private ConfigEntry<int>? maxTimer; private const string FLASHBANG_SOUND = "Sounds/flashbang.ogg"; private const string JUMPSCARE_IMAGE = "Images/jumpscare.png"; private static Random timerRandom = null; private static Coroutine? jumpscare; public static LethalJumpscare Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } public static int MinTimer => Instance.minTimer?.Value ?? 60; public static int MaxTimer => Instance.maxTimer?.Value ?? 7200; public static AudioClip? FlashbangSound { get; private set; } public static Texture2D? JumpscareImage { get; private set; } public static float Timer { get; private set; } = -1f; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; minTimer = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinTimer", 60, "What the minimum waiting time should be for a jumpscare (after landing on a moon)"); maxTimer = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxTimer", 7200, "What the maximum waiting time should be for a jumpscare (after landing on a moon)"); FlashbangSound = Audio.TryLoad(rel("Sounds/flashbang.ogg"), (TimeSpan?)TimeSpan.FromSeconds(10.0)); a(); Patch(); Logger.LogInfo((object)"baer1.VeryScaryJumpScare v1.0.1 has loaded!"); 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("baer1.VeryScaryJumpScare"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } async void a() { JumpscareImage = await Image.TryLoadAsync(rel("Images/jumpscare.png"), (TimeSpan?)null); } } private static IEnumerator Jumpscare() { try { Logger.LogDebug((object)(">> Jumpscare() FlashbangSound:" + (((object)FlashbangSound)?.ToString() ?? "null"))); AudioClip? flashbangSound = FlashbangSound; AudioPlayer player = ((flashbangSound != null) ? Audio.Play(flashbangSound, (Action<AudioPlayer>)null) : null); ((Behaviour)GameNetworkManager.Instance.localPlayerController.gameplayCamera).enabled = false; Logger.LogDebug((object)(" waiting... player:" + (((object)player)?.ToString() ?? "null"))); Graphics.Blit((Texture)(object)(JumpscareImage ?? Texture2D.whiteTexture), GameNetworkManager.Instance.localPlayerController.gameplayCamera.targetTexture); yield return (object)((player == null) ? new WaitForSeconds(5f) : new WaitUntil((Func<bool>)(() => (int)player.State > 0))); Logger.LogDebug((object)"<< Jumpscare"); ((Behaviour)GameNetworkManager.Instance.localPlayerController.gameplayCamera).enabled = true; AudioPlayer obj = player; if (obj != null) { obj.Cancel(); } } finally { jumpscare = null; } } private static IEnumerator LoadImage(Uri uri, Action<Texture2D> success, Action<string>? error = null) { string path = Path.GetFullPath(uri.AbsolutePath); Logger.LogDebug((object)$">> LoadImage({path}, {success}, {error})"); UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(path); yield return webRequest.SendWebRequest(); if ((int)webRequest.result != 1) { Logger.LogError((object)("Error loading " + path + ": " + webRequest.error)); error?.Invoke(webRequest.error); yield break; } Texture2D texture2d = DownloadHandlerTexture.GetContent(webRequest); if (Object.op_Implicit((Object)(object)texture2d)) { Logger.LogInfo((object)("Loaded " + Path.GetFileName(path))); success(texture2d); } else { Logger.LogWarning((object)("Error loading " + path)); error?.Invoke(string.Empty); } } private Uri rel(string path) { return new Uri(Path.Combine(Path.GetDirectoryName(((object)this).GetType().Assembly.Location) ?? string.Empty, path)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "baer1.VeryScaryJumpScare"; public const string PLUGIN_NAME = "LethalJumpscare"; public const string PLUGIN_VERSION = "1.0.1"; } }