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 BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Video;
[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("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4247eae4b81cc1423970370465980f9d0841d4e8")]
[assembly: AssemblyProduct("Sledding")]
[assembly: AssemblyTitle("Sledding")]
[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 Omniscye.EmpressWait
{
[BepInPlugin("Omniscye.EmpressWait", "EmpressWait", "1.0.1")]
public class EmpressWait : BaseUnityPlugin
{
public const string PluginGuid = "Omniscye.EmpressWait";
public const string PluginName = "EmpressWait";
public const string PluginVersion = "1.0.1";
internal static ConfigEntry<float> CVolume;
private static bool _hasTriggered;
internal static EmpressWait Instance { get; private set; }
internal static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;
private void Awake()
{
Instance = this;
CVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Volume", 1f, "Video volume (0.0 to 1.0)");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
if (!_hasTriggered)
{
_hasTriggered = true;
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string text = Path.Combine(directoryName, "Empress.dat");
if (File.Exists(text))
{
GameObject val = new GameObject("Omniscye.VideoGate");
Object.DontDestroyOnLoad((Object)(object)val);
VideoGate videoGate = val.AddComponent<VideoGate>();
videoGate.SourceFilePath = text;
}
else
{
Log.LogError((object)("Could not find 'Empress.dat' at: " + text));
}
SceneManager.sceneLoaded -= OnSceneLoaded;
}
}
}
internal class VideoGate : MonoBehaviour
{
[CompilerGenerated]
private sealed class <PrepareAndPlay>d__9 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public VideoGate <>4__this;
private float <timeout>5__1;
private byte[] <data>5__2;
private int <i>5__3;
private Exception <e>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PrepareAndPlay>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<data>5__2 = null;
<e>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this._tempVideoPath = Path.GetTempFileName().Replace(".tmp", ".mp4");
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
try
{
<data>5__2 = File.ReadAllBytes(<>4__this.SourceFilePath);
<i>5__3 = 0;
while (<i>5__3 < <data>5__2.Length)
{
<data>5__2[<i>5__3] ^= 90;
<i>5__3++;
}
File.WriteAllBytes(<>4__this._tempVideoPath, <data>5__2);
<data>5__2 = null;
}
catch (Exception ex)
{
<e>5__4 = ex;
EmpressWait.Log.LogError((object)("Video load failed: " + <e>5__4.Message));
<>4__this.CleanupAndResume();
return false;
}
<>4__this._renderTexture = new RenderTexture(Screen.width, Screen.height, 0);
<>4__this._renderTexture.Create();
<>4__this._videoPlayer = ((Component)<>4__this).gameObject.AddComponent<VideoPlayer>();
<>4__this._audioSource = ((Component)<>4__this).gameObject.AddComponent<AudioSource>();
<>4__this._videoPlayer.playOnAwake = false;
<>4__this._videoPlayer.renderMode = (VideoRenderMode)2;
<>4__this._videoPlayer.targetTexture = <>4__this._renderTexture;
<>4__this._videoPlayer.source = (VideoSource)1;
<>4__this._videoPlayer.url = "file://" + <>4__this._tempVideoPath;
<>4__this._videoPlayer.audioOutputMode = (VideoAudioOutputMode)1;
<>4__this._videoPlayer.SetTargetAudioSource((ushort)0, <>4__this._audioSource);
<>4__this._audioSource.volume = EmpressWait.CVolume.Value;
<>4__this._videoPlayer.timeReference = (VideoTimeReference)0;
<>4__this._videoPlayer.Prepare();
<timeout>5__1 = Time.realtimeSinceStartup + 10f;
break;
case 2:
<>1__state = -1;
break;
}
if (!<>4__this._videoPlayer.isPrepared)
{
if (Time.realtimeSinceStartup > <timeout>5__1)
{
<>4__this.CleanupAndResume();
return false;
}
<>2__current = null;
<>1__state = 2;
return true;
}
<>4__this._videoPlayer.Play();
<>4__this._isPlaying = true;
<>4__this._isPrepared = true;
<>4__this._videoPlayer.loopPointReached += new EventHandler(<>4__this.OnVideoFinished);
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();
}
}
internal string SourceFilePath = string.Empty;
private VideoPlayer _videoPlayer = null;
private AudioSource _audioSource = null;
private RenderTexture _renderTexture = null;
private string _tempVideoPath = string.Empty;
private float _prevTimeScale;
private bool _isPlaying;
private bool _isPrepared = false;
private void Start()
{
_prevTimeScale = Time.timeScale;
Time.timeScale = 0f;
AudioListener.pause = false;
((MonoBehaviour)this).StartCoroutine(PrepareAndPlay());
}
[IteratorStateMachine(typeof(<PrepareAndPlay>d__9))]
private IEnumerator PrepareAndPlay()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PrepareAndPlay>d__9(0)
{
<>4__this = this
};
}
private void OnVideoFinished(VideoPlayer vp)
{
CleanupAndResume();
}
private void OnGUI()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
GUI.depth = -9999;
if (_isPlaying && (Object)(object)_renderTexture != (Object)null)
{
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.blackTexture);
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_renderTexture, (ScaleMode)2);
}
else if (!_isPlaying && !_isPrepared)
{
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.blackTexture);
GUIStyle val = new GUIStyle();
val.fontSize = 24;
val.normal.textColor = Color.white;
val.alignment = (TextAnchor)4;
GUI.Label(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), "Initialising MerryDemo...", val);
}
}
private void CleanupAndResume()
{
if (!_isPlaying && !_isPrepared)
{
return;
}
_isPlaying = false;
_isPrepared = false;
if ((Object)(object)_videoPlayer != (Object)null)
{
_videoPlayer.Stop();
}
if ((Object)(object)_renderTexture != (Object)null)
{
_renderTexture.Release();
}
Time.timeScale = _prevTimeScale;
if (File.Exists(_tempVideoPath))
{
try
{
File.Delete(_tempVideoPath);
}
catch
{
}
}
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}