using 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.Bootstrap;
using BepInEx.Configuration;
using ComputerysModdingUtilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModMenu.Api;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: StraftatMod(true)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Koki")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c223fa7c716cc7796fc2e7f13094c85afc747e7b")]
[assembly: AssemblyProduct("Jumpscare")]
[assembly: AssemblyTitle("Jumpscare")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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;
}
}
}
internal static class JumpscareTimer
{
internal static bool SkipFirstScene = false;
private static Random _rng = new Random();
private static IEnumerator _timer;
internal static ConfigEntry<float> MaxMinsBtwnJumpscares;
internal static void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name == "MainMenu")
{
if (_timer != null)
{
((MonoBehaviour)JumpscarePlugin.Instance).StopCoroutine(_timer);
}
_timer = null;
}
else if (SkipFirstScene)
{
SkipFirstScene = false;
}
else
{
_timer = JumpscareOnDelay();
((MonoBehaviour)JumpscarePlugin.Instance).StartCoroutine(_timer);
}
}
private static IEnumerator JumpscareOnDelay()
{
yield return (object)new WaitForSeconds((float)(_rng.Next((int)Math.Round(MaxMinsBtwnJumpscares.Value * 60f)) + 1));
JumpscareVideoPlayer.Player.Stop();
JumpscareVideoPlayer.Player.Play();
_timer = JumpscareOnDelay();
((MonoBehaviour)JumpscarePlugin.Instance).StartCoroutine(_timer);
}
internal static void RestartTimer(object sender, EventArgs e)
{
((MonoBehaviour)JumpscarePlugin.Instance).StopCoroutine(_timer);
_timer = JumpscareOnDelay();
((MonoBehaviour)JumpscarePlugin.Instance).StartCoroutine(_timer);
}
}
internal static class JumpscareVideoPlayer
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static EventHandler <>9__3_0;
public static EventHandler <>9__3_1;
internal void <Init>b__3_0(VideoPlayer src)
{
((Behaviour)Image).enabled = true;
}
internal void <Init>b__3_1(VideoPlayer src)
{
((Behaviour)Image).enabled = false;
}
}
private static RawImage Image;
internal static VideoPlayer Player;
internal static void Init(Scene scene, LoadSceneMode mode)
{
if (!Object.op_Implicit((Object)(object)Player) && ((Scene)(ref scene)).name == "MainMenu")
{
Init();
}
}
internal static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
Transform transform = ((Component)Object.FindObjectOfType<PauseManager>()).transform;
GameObject val = new GameObject("Jumpscare");
val.transform.SetParent(transform, false);
RenderTexture val2 = new RenderTexture(1920, 1080, 0);
val2.Create();
Image = val.AddComponent<RawImage>();
Image.texture = (Texture)(object)val2;
RectTransform component = ((Component)Image).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
((Behaviour)Image).enabled = false;
Player = val.AddComponent<VideoPlayer>();
Player.playOnAwake = false;
Player.url = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)JumpscarePlugin.Instance).Info.Location), "jumpscare.mp4");
Player.renderMode = (VideoRenderMode)2;
Player.targetTexture = val2;
VideoPlayer player = Player;
object obj = <>c.<>9__3_0;
if (obj == null)
{
EventHandler val3 = delegate
{
((Behaviour)Image).enabled = true;
};
<>c.<>9__3_0 = val3;
obj = (object)val3;
}
player.started += (EventHandler)obj;
VideoPlayer player2 = Player;
object obj2 = <>c.<>9__3_1;
if (obj2 == null)
{
EventHandler val4 = delegate
{
((Behaviour)Image).enabled = false;
};
<>c.<>9__3_1 = val4;
obj2 = (object)val4;
}
player2.loopPointReached += (EventHandler)obj2;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.koki.jumpscare", "Jumpscare Mod", "1.0.1")]
public class JumpscarePlugin : BaseUnityPlugin
{
internal static JumpscarePlugin Instance;
private Harmony _harmony = new Harmony("com.koki.jumpscare");
private void Awake()
{
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Instance = this;
InitConfig();
if (Chainloader.PluginInfos.ContainsKey("com.koki.lvlreborn"))
{
JumpscareTimer.SkipFirstScene = true;
}
if (Chainloader.PluginInfos.ContainsKey("kestrel.straftat.modmenu"))
{
InitInitModMenu();
}
_harmony.PatchAll();
SceneManager.sceneLoaded += JumpscareVideoPlayer.Init;
SceneManager.sceneLoaded += JumpscareTimer.OnSceneLoad;
}
private void InitConfig()
{
JumpscareTimer.MaxMinsBtwnJumpscares = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Max Time Between Jumpscares (minutes)", 7.5f, "The jumpscare time is chosen between 0 min and this value. The timer only stops and resets when you exit to the main menu.");
JumpscareTimer.MaxMinsBtwnJumpscares.SettingChanged += JumpscareTimer.RestartTimer;
}
private void InitInitModMenu()
{
ModMenuCustomisation.SetPluginDescription("Play random jumpscares.");
ModMenuCustomisation.RegisterContentBuilder((Action<OptionListContext>)InitModMenu);
}
private void InitModMenu(OptionListContext c)
{
c.AppendButton("Jumpscare Video File Location", "Click to copy", (Action)delegate
{
GUIUtility.systemCopyBuffer = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
PauseManager.Instance.WriteOfflineLog("Copied path to clipboard!");
});
c.AppendTextBox("(The file must be exactly named \"jumpscare\".mp4)");
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
SceneManager.sceneLoaded -= JumpscareVideoPlayer.Init;
SceneManager.sceneLoaded -= JumpscareTimer.OnSceneLoad;
}
}
namespace Jumpscare
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.koki.jumpscare";
public const string PLUGIN_NAME = "Jumpscare Mod";
public const string PLUGIN_VERSION = "1.0.1";
}
}