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 Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("TheaterPlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TheaterPlus")]
[assembly: AssemblyTitle("TheaterPlus")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TheaterPlus
{
public static class Loader
{
public static AssetBundle LoadBundleFromResource(string resourceName)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
Debug.LogError((object)("Failed to load asset bundle from resource: " + resourceName));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return AssetBundle.LoadFromMemory(array);
}
}
public class ClickDetectorCustom : MonoBehaviour
{
public Button folder;
public Button forward;
public Button back;
public Button refresh;
public TextMeshProUGUI nameoffile;
private Plugin pluginInstance;
private void Start()
{
pluginInstance = Object.FindObjectOfType<Plugin>();
((MonoBehaviour)this).Invoke("DelayedStart", 1f);
}
private void DelayedStart()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
((UnityEvent)folder.onClick).AddListener(new UnityAction(DelayedOpenVideosFolder));
((UnityEvent)forward.onClick).AddListener(new UnityAction(WANextFile));
((UnityEvent)back.onClick).AddListener(new UnityAction(WAPreviousFile));
((UnityEvent)refresh.onClick).AddListener(new UnityAction(WARefreshVideoFiles));
UpdateFileName();
}
private void DelayedOpenVideosFolder()
{
if ((Object)(object)pluginInstance != (Object)null)
{
pluginInstance.OpenVideosFolder();
Debug.Log((object)"Folder opened");
}
}
private void WANextFile()
{
((MonoBehaviour)this).Invoke("DelayedNextFile", 0.15f);
}
private void DelayedNextFile()
{
if ((Object)(object)pluginInstance != (Object)null)
{
pluginInstance.NextFile();
UpdateFileName();
Debug.Log((object)"Next file");
}
}
private void WAPreviousFile()
{
((MonoBehaviour)this).Invoke("DelayedPreviousFile", 0.15f);
}
private void DelayedPreviousFile()
{
if ((Object)(object)pluginInstance != (Object)null)
{
pluginInstance.PreviousFile();
UpdateFileName();
Debug.Log((object)"Previous file");
}
}
private void WARefreshVideoFiles()
{
((MonoBehaviour)this).Invoke("DelayedRefreshVideoFiles", 0.15f);
}
private void DelayedRefreshVideoFiles()
{
if ((Object)(object)pluginInstance != (Object)null)
{
pluginInstance.RefreshVideoFiles();
UpdateFileName();
Debug.Log((object)"Video files refreshed");
}
}
private void UpdateFileName()
{
((MonoBehaviour)this).Invoke("DelayedUpdateFileName", 0.16f);
}
private void DelayedUpdateFileName()
{
if ((Object)(object)nameoffile != (Object)null && (Object)(object)pluginInstance != (Object)null)
{
((TMP_Text)nameoffile).text = Plugin.fileName;
}
}
}
[BepInPlugin("doomahreal.ultrakill.theaterplus", "TheaterPlus", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static string fileName;
private AssetBundle uibundle;
private AssetBundle theaterbundle;
private GameObject coolCanvasPrefab;
private GameObject cooltheaterprefab;
public List<string> videoFiles = new List<string>();
private int currentIndex = -1;
private string lastFile = "";
private string videosFolder2;
public GameObject videoPlayerObject;
private float timer = 0f;
private float updateInterval = 0.1f;
private bool isInDesiredScene = false;
private Shader vertexLitShader;
private Shader unlitTransparentAmbientShader;
private Shader unlitShader;
private Shader unlitTransparentShader;
private Shader unlitAdditiveNocullNofogShader;
private void Awake()
{
uibundle = Loader.LoadBundleFromResource("TheaterPlus.theater.bundle");
theaterbundle = Loader.LoadBundleFromResource("TheaterPlus.theaterplus.bundle");
coolCanvasPrefab = uibundle.LoadAsset<GameObject>("myreallycoolcanvas");
cooltheaterprefab = theaterbundle.LoadAsset<GameObject>("Assets/Custom/TheaterPlus/Ultrakill Projector.prefab");
SceneManager.sceneLoaded += OnSceneLoaded;
videosFolder2 = Path.Combine(Application.streamingAssetsPath, "Videos");
string path = Path.Combine(Application.streamingAssetsPath, "Videos");
if (Directory.Exists(path))
{
string[] files = Directory.GetFiles(path);
foreach (string item in files)
{
videoFiles.Add(item);
}
}
if (videoFiles.Count > 0)
{
currentIndex = 0;
}
}
private void Update()
{
timer += Time.deltaTime;
if (timer < updateInterval || !isInDesiredScene)
{
return;
}
timer = 0f;
string currentFile = GetCurrentFile();
if (currentFile == lastFile)
{
return;
}
lastFile = currentFile;
if ((Object)(object)videoPlayerObject == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"VideoPlayer object not found in the scene.");
return;
}
SetVideoFilePath component = videoPlayerObject.GetComponent<SetVideoFilePath>();
if ((Object)(object)component == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"SetVideoFilePath component not found on the VideoPlayer object.");
return;
}
fileName = Path.GetFileName(currentFile);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Current File: " + fileName));
component.videoName = fileName;
}
public string GetCurrentFile()
{
return (currentIndex >= 0 && currentIndex < videoFiles.Count) ? videoFiles[currentIndex] : null;
}
public void NextFile()
{
currentIndex = ((videoFiles.Count > 0) ? ((currentIndex + 1) % videoFiles.Count) : (-1));
}
public void PreviousFile()
{
currentIndex = ((videoFiles.Count > 0) ? ((currentIndex - 1 + videoFiles.Count) % videoFiles.Count) : (-1));
}
public void RefreshVideoFiles()
{
videoFiles.Clear();
string path = Path.Combine(Application.streamingAssetsPath, "Videos");
if (Directory.Exists(path))
{
string[] files = Directory.GetFiles(path);
foreach (string item in files)
{
videoFiles.Add(item);
}
}
if (videoFiles.Count > 0)
{
currentIndex = 0;
}
else
{
currentIndex = -1;
}
}
public void OpenVideosFolder()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
RuntimePlatform platform = Application.platform;
RuntimePlatform val = platform;
if ((int)val <= 2)
{
if ((int)val <= 1)
{
Process.Start("open", videosFolder2);
return;
}
if ((int)val == 2)
{
goto IL_002d;
}
}
else
{
if ((int)val == 7)
{
goto IL_002d;
}
if ((int)val == 13 || (int)val == 16)
{
Process.Start("xdg-open", videosFolder2);
return;
}
}
Debug.LogWarning((object)"BROTHER WHAT IS YOUR OS?????");
return;
IL_002d:
Process.Start("explorer.exe", videosFolder2.Replace("/", "\\"));
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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_014b: Unknown result type (might be due to invalid IL or missing references)
if (((Scene)(ref scene)).name == "e92f893de47503a4f959f7d5bca84261")
{
isInDesiredScene = true;
((MonoBehaviour)this).StartCoroutine(FindVideoPlayerObject());
GameObject val = GameObject.Find("__Room_Theater/Ultrakill Projector/PuzzleScreen/Canvas/Background/");
if ((Object)(object)val != (Object)null)
{
GameObject val2 = Object.Instantiate<GameObject>(coolCanvasPrefab, val.transform);
val2.transform.localPosition = new Vector3(0f, 18.8f, 0f);
val2.transform.localScale = new Vector3(65f, 65f, 65f);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)"Parent object not found in the scene.");
}
}
else if (((Scene)(ref scene)).name == "7b3cb6a0a342eb54dafe5552d4820eeb")
{
isInDesiredScene = true;
GameObject val3 = GameObject.Find("Lake");
if (!((Object)(object)val3 != (Object)null))
{
return;
}
GameObject val4 = Object.Instantiate<GameObject>(cooltheaterprefab);
val4.transform.parent = val3.transform;
val4.transform.localPosition = new Vector3(107.5f, -2.97f, 372.2f);
val4.transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
SandboxTheater sandboxTheater = val4.AddComponent<SandboxTheater>();
Transform val5 = val4.transform.Find("Theater Video Stuff");
Transform val6 = ((val5 != null) ? val5.Find("VideoPlayer (Development History)") : null);
videoPlayerObject = ((val6 != null) ? ((Component)val6).gameObject : null);
((MonoBehaviour)this).StartCoroutine(LoadShadersAndSetChildShader(val4));
MeshRenderer[] componentsInChildren = val4.GetComponentsInChildren<MeshRenderer>();
List<GameObject> list = new List<GameObject>();
MeshRenderer[] array = componentsInChildren;
foreach (MeshRenderer val7 in array)
{
GameObject gameObject = ((Component)val7).gameObject;
if (((Object)gameObject).name != "PuzzleScreen" && ((Object)gameObject).name != "ActivationZone")
{
list.Add(gameObject);
}
}
GameObject[] targets = list.ToArray();
OutdoorsChecker val8 = val4.AddComponent<OutdoorsChecker>();
val8.targets = targets;
val8.nonSolid = false;
}
else
{
DestroyInstances();
}
}
private void DestroyInstances()
{
GameObject val = GameObject.Find("Ultrakill Projector(Clone)");
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
}
private IEnumerator LoadShadersAndSetChildShader(GameObject parentObject)
{
yield return ((MonoBehaviour)this).StartCoroutine(LoadShaders());
GameObject projector = ((Component)parentObject.transform.Find("ProjectorRunning")).gameObject;
GameObject theaterreal = ((Component)parentObject.transform.Find("Theater Video Stuff")).gameObject;
SetChildShader(parentObject, "Large film real.002", vertexLitShader);
SetChildShader(projector, "Plane", unlitTransparentAmbientShader);
SetChildShader(projector, "Plane (1)", unlitTransparentAmbientShader);
SetChildShader(projector, "projector 1.002 (1)", unlitTransparentShader);
SetChildShader(theaterreal, "Quad", unlitAdditiveNocullNofogShader);
SetChildShader(theaterreal, "Quad(Clone)", vertexLitShader);
SetChildShader(parentObject, "Large film real.001", vertexLitShader);
SetChildShader(parentObject, "film Real.001", vertexLitShader);
SetChildShader(parentObject, "projector 1.001", vertexLitShader);
SetChildShader(parentObject, "PuzzleScreen", unlitShader);
}
private void SetChildShader(GameObject parentObject, string childName, Shader shader)
{
Transform val = parentObject.transform.Find(childName);
if (!((Object)(object)val != (Object)null))
{
return;
}
MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null)
{
Material[] materials = ((Renderer)component).materials;
foreach (Material val2 in materials)
{
val2.shader = shader;
}
}
}
private IEnumerator LoadShaders()
{
AsyncOperationHandle<Shader> vertexLitHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-vertexlit.shader");
AsyncOperationHandle<Shader> unlitTransparentAmbientHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Transparent/ULTRAKILL-unlit-transparent-ambient.shader");
AsyncOperationHandle<Shader> unlitHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-unlit.shader");
AsyncOperationHandle<Shader> unlitTransparentHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Transparent/ULTRAKILL-unlit-transparent.shader");
AsyncOperationHandle<Shader> unlitAdditiveNocullNofogHandle = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Transparent/ULTRAKILL-unlit-additive-nocull-nofog.shader");
yield return (object)new WaitUntil((Func<bool>)(() => vertexLitHandle.IsDone && unlitTransparentAmbientHandle.IsDone && unlitHandle.IsDone && unlitTransparentHandle.IsDone && unlitAdditiveNocullNofogHandle.IsDone));
if ((int)vertexLitHandle.Status != 1)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load ULTRAKILL-vertexlit.shader: " + vertexLitHandle.OperationException));
}
if ((int)unlitTransparentAmbientHandle.Status != 1)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load ULTRAKILL-unlit-transparent-ambient.shader: " + unlitTransparentAmbientHandle.OperationException));
}
if ((int)unlitHandle.Status != 1)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load ULTRAKILL-unlit.shader: " + unlitHandle.OperationException));
}
if ((int)unlitTransparentHandle.Status != 1)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load ULTRAKILL-unlit-transparent.shader: " + unlitTransparentHandle.OperationException));
}
if ((int)unlitAdditiveNocullNofogHandle.Status != 1)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load ULTRAKILL-unlit-additive-nocull-nofog.shader: " + unlitAdditiveNocullNofogHandle.OperationException));
}
if ((int)vertexLitHandle.Status == 1)
{
vertexLitShader = vertexLitHandle.Result;
}
if ((int)unlitTransparentAmbientHandle.Status == 1)
{
unlitTransparentAmbientShader = unlitTransparentAmbientHandle.Result;
}
if ((int)unlitHandle.Status == 1)
{
unlitShader = unlitHandle.Result;
}
if ((int)unlitTransparentHandle.Status == 1)
{
unlitTransparentShader = unlitTransparentHandle.Result;
}
if ((int)unlitAdditiveNocullNofogHandle.Status == 1)
{
unlitAdditiveNocullNofogShader = unlitAdditiveNocullNofogHandle.Result;
}
Addressables.Release<Shader>(vertexLitHandle);
Addressables.Release<Shader>(unlitTransparentAmbientHandle);
Addressables.Release<Shader>(unlitHandle);
Addressables.Release<Shader>(unlitTransparentHandle);
Addressables.Release<Shader>(unlitAdditiveNocullNofogHandle);
}
private IEnumerator FindVideoPlayerObject()
{
while ((Object)(object)videoPlayerObject == (Object)null)
{
GameObject roomTheater = GameObject.Find("__Room_Theater");
yield return null;
if ((Object)(object)roomTheater != (Object)null)
{
Transform theaterVideoStuff = roomTheater.transform.Find("Theater Video Stuff");
yield return null;
if ((Object)(object)theaterVideoStuff != (Object)null)
{
Transform videoPlayerTransform = theaterVideoStuff.Find("VideoPlayer (Development History)");
yield return null;
if ((Object)(object)videoPlayerTransform != (Object)null)
{
videoPlayerObject = ((Component)videoPlayerTransform).gameObject;
}
}
}
if ((Object)(object)videoPlayerObject == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"VideoPlayer object not found in the scene hierarchy. Trying again...");
yield return (object)new WaitForSeconds(1f);
}
}
}
private void OnDestroy()
{
AssetBundle obj = uibundle;
if (obj != null)
{
obj.Unload(false);
}
AssetBundle obj2 = theaterbundle;
if (obj2 != null)
{
obj2.Unload(false);
}
}
}
public class SandboxTheater : MonoBehaviour
{
private Transform theaterVideoStuff;
private Transform dayActivator;
private Transform nightDarkerActivator;
private float timer = 0f;
private float checkInterval = 0.1f;
private bool lastState = false;
private void Start()
{
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
theaterVideoStuff = ((Component)this).transform.Find("Theater Video Stuff");
if ((Object)(object)theaterVideoStuff == (Object)null)
{
Debug.LogError((object)"Theater Video Stuff GameObject not found.");
return;
}
GameObject val = GameObject.Find("Activators");
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"Activators GameObject not found in the scene.");
return;
}
dayActivator = val.transform.Find("Day Activator");
if ((Object)(object)dayActivator == (Object)null)
{
Debug.LogError((object)"Day Activator GameObject not found under Activators.");
return;
}
nightDarkerActivator = val.transform.Find("Night Darker Activator");
if ((Object)(object)nightDarkerActivator == (Object)null)
{
Debug.LogError((object)"Night Darker Activator GameObject not found under Activators.");
return;
}
Transform val2 = theaterVideoStuff.Find("VideoAudioSource");
if ((Object)(object)val2 == (Object)null)
{
Debug.LogError((object)"VideoAudioSource GameObject not found under Theater Video Stuff.");
return;
}
Follow component = ((Component)val2).GetComponent<Follow>();
if ((Object)(object)component == (Object)null)
{
Debug.LogError((object)"Follow component not found on VideoAudioSource GameObject.");
return;
}
((Bounds)(ref component.area)).center = new Vector3(108.1855f, -1.5f, 311.4661f);
Transform val3 = theaterVideoStuff.Find("Quad");
if ((Object)(object)val3 == (Object)null)
{
Debug.LogWarning((object)"Quad GameObject not found under Theater Video Stuff.");
return;
}
val3.position = new Vector3(val3.position.x, 17.03f, val3.position.z);
((Component)theaterVideoStuff).gameObject.SetActive(false);
Transform val4 = Object.Instantiate<Transform>(theaterVideoStuff.Find("Quad"), theaterVideoStuff);
val4.localScale *= 1.1f;
val4.localPosition += new Vector3(0.1f, 0f, 0f);
((Component)val4).gameObject.SetActive(false);
}
private void Update()
{
timer += Time.deltaTime;
if (!(timer >= checkInterval))
{
return;
}
timer = 0f;
if (((Component)theaterVideoStuff).gameObject.activeSelf != lastState)
{
lastState = ((Component)theaterVideoStuff).gameObject.activeSelf;
if (lastState)
{
ActivateNightDarkerActivatorOnce();
}
else
{
ActivateDayActivatorOnce();
}
}
}
private void ActivateDayActivatorOnce()
{
if ((Object)(object)dayActivator != (Object)null)
{
((Component)dayActivator).gameObject.SetActive(true);
((Component)theaterVideoStuff.Find("Quad(Clone)")).gameObject.SetActive(false);
}
else
{
Debug.LogError((object)"Day Activator not assigned.");
}
}
private void ActivateNightDarkerActivatorOnce()
{
if ((Object)(object)nightDarkerActivator != (Object)null)
{
((Component)nightDarkerActivator).gameObject.SetActive(true);
((Component)theaterVideoStuff.Find("Quad(Clone)")).gameObject.SetActive(true);
}
else
{
Debug.LogError((object)"Night Darker Activator not assigned.");
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TheaterPlus";
public const string PLUGIN_NAME = "TheaterPlus";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}