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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.Video;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RalfSchumacherJumpscare")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("RalfSchumacherJumpscare")]
[assembly: AssemblyCopyright("Copyright © HP 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("94bdea84-0f48-4ff2-b20f-6fba05227092")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RalfSchumacherJumpscare;
[BepInPlugin("com.BieberTheThird.ralfschumacherjumpscare", "Ralf Schumacher Jumpscare", "1.0.0")]
public class JumpScareVideoMod : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <RandomCheckCoroutine>d__8 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public JumpScareVideoMod <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RandomCheckCoroutine>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
int num = <>1__state;
JumpScareVideoMod jumpScareVideoMod = <>4__this;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
if ((Object)(object)jumpScareVideoMod.videoPlayer != (Object)null && (Object)(object)jumpScareVideoMod.videoPlayer.targetCamera == (Object)null)
{
Camera main = Camera.main;
if ((Object)(object)main != (Object)null)
{
jumpScareVideoMod.videoPlayer.targetCamera = main;
}
else if (Camera.allCameras != null && Camera.allCameras.Length != 0)
{
jumpScareVideoMod.videoPlayer.targetCamera = Camera.allCameras[0];
}
}
if (jumpScareVideoMod.rng.Next(0, 10000) == 0)
{
jumpScareVideoMod.TriggerJumpScare();
}
}
else
{
<>1__state = -1;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private const int ChanceDenominator = 10000;
private const float CheckIntervalSeconds = 1f;
private GameObject videoObject;
private VideoPlayer videoPlayer;
private Random rng = new Random();
private bool preparedOnce;
private void Start()
{
CreateVideoObjectAndPlayer();
((MonoBehaviour)this).StartCoroutine(RandomCheckCoroutine());
}
private void CreateVideoObjectAndPlayer()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
GameObject val = GameObject.Find("RalfSchumacher_JumpScare_Object");
if ((Object)(object)val != (Object)null)
{
videoObject = val;
videoPlayer = videoObject.GetComponent<VideoPlayer>();
return;
}
videoObject = new GameObject("RalfSchumacher_JumpScare_Object");
Object.DontDestroyOnLoad((Object)(object)videoObject);
videoPlayer = videoObject.AddComponent<VideoPlayer>();
AudioSource val2 = videoObject.AddComponent<AudioSource>();
videoPlayer.playOnAwake = false;
videoPlayer.isLooping = false;
videoPlayer.renderMode = (VideoRenderMode)1;
videoPlayer.audioOutputMode = (VideoAudioOutputMode)1;
videoPlayer.SetTargetAudioSource((ushort)0, val2);
string fullPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "..", "Video", "ralf_schumacher.mp4"));
if (!File.Exists(fullPath))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("RalfSchumacherJumpscare: Video nicht gefunden: " + fullPath));
}
videoPlayer.url = fullPath;
videoPlayer.prepareCompleted += (EventHandler)delegate(VideoPlayer vp)
{
preparedOnce = true;
vp.Play();
((BaseUnityPlugin)this).Logger.LogInfo((object)"RalfSchumacherJumpscare: Video vorbereitet und gestartet!");
};
videoPlayer.errorReceived += (ErrorEventHandler)delegate(VideoPlayer vp, string err)
{
((BaseUnityPlugin)this).Logger.LogError((object)("VideoPlayer Fehler: " + err));
};
}
[IteratorStateMachine(typeof(<RandomCheckCoroutine>d__8))]
private IEnumerator RandomCheckCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RandomCheckCoroutine>d__8(0)
{
<>4__this = this
};
}
private void TriggerJumpScare()
{
if ((Object)(object)videoPlayer == (Object)null || videoPlayer.isPlaying)
{
return;
}
try
{
if (!preparedOnce)
{
videoPlayer.Prepare();
((BaseUnityPlugin)this).Logger.LogInfo((object)"RalfSchumacherJumpscare: Vorbereitung gestartet...");
}
else
{
videoPlayer.Play();
((BaseUnityPlugin)this).Logger.LogInfo((object)"RalfSchumacherJumpscare: Video direkt gestartet.");
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Fehler beim Starten des Jumpscares: " + ex));
}
}
}