using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Reptile; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 OsakaTheater { public enum LowerTheLightsMode { Enabled, Disabled, Automatic } public sealed class SyncVideoTheaterConfig { public ConfigEntry LowerTheLights { get; } public ConfigEntry MuteRoadCarsInTheater { get; } public SyncVideoTheaterConfig(ConfigFile config) { LowerTheLights = config.Bind("Theater", "Lower the Lights!", LowerTheLightsMode.Automatic, "Adjust the ambient lighting inside the theater. Enabled darkens the theater, Disabled never darkens the theater, and Automatic only darkens the theater when you're in a SyncVideo lobby."); MuteRoadCarsInTheater = config.Bind("Theater", "Mute the Cars!", true, "Mute all the cars while inside the theater."); } } [BepInPlugin("OsakaTheater.SyncVideoTheater", "Sync Video Theater", "1.5.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__9 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; private string 5__1; private string 5__2; private AssetBundleCreateRequest 5__3; private AssetBundle 5__4; private AssetBundleRequest 5__5; private Object[] <>s__6; private int <>s__7; private Object 5__8; private string 5__9; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; <>s__6 = null; 5__8 = null; 5__9 = null; <>1__state = -2; } private bool MoveNext() { //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = Path.GetDirectoryName(((BaseUnityPlugin)<>4__this).Info.Location); 5__2 = Path.Combine(5__1, "theater"); Log.LogInfo((object)("Looking for AssetBundle at: " + 5__2)); if (!File.Exists(5__2)) { Log.LogError((object)("Bundle not found: " + 5__2)); return false; } 5__3 = AssetBundle.LoadFromFileAsync(5__2); <>2__current = 5__3; <>1__state = 1; return true; case 1: <>1__state = -1; 5__4 = 5__3.assetBundle; if ((Object)(object)5__4 == (Object)null) { Log.LogError((object)"Failed to load AssetBundle."); return false; } 5__5 = 5__4.LoadAllAssetsAsync(); <>2__current = 5__5; <>1__state = 2; return true; case 2: <>1__state = -1; <>s__6 = 5__5.allAssets; for (<>s__7 = 0; <>s__7 < <>s__6.Length; <>s__7++) { 5__8 = <>s__6[<>s__7]; Log.LogInfo((object)("Bundle asset: " + 5__8.name)); if (!((Object)(object)theaterPrefab != (Object)null)) { 5__9 = 5__8.name.ToLowerInvariant(); if (5__9.Contains("theater") || 5__9.Contains("theatre")) { theaterPrefab = (GameObject)5__8; } 5__9 = null; 5__8 = null; } } <>s__6 = null; if ((Object)(object)theaterPrefab == (Object)null && 5__5.allAssets.Length != 0) { theaterPrefab = (GameObject)5__5.allAssets[0]; Log.LogInfo((object)("Loaded first GameObject as fallback: " + ((Object)theaterPrefab).name)); } if ((Object)(object)theaterPrefab == (Object)null) { Log.LogError((object)"Failed to load theater prefab."); } else { Log.LogInfo((object)("Theater prefab loaded: " + ((Object)theaterPrefab).name)); } 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(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; private Player

5__1; private Vector3 5__2; private Vector3 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() {

5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; if (!((Object)(object)WorldHandler.instance == (Object)null)) {

5__1 = WorldHandler.instance.GetCurrentPlayer(); if (!((Object)(object)

5__1 == (Object)null)) { 5__2 = ((Component)

5__1).transform.position; 5__3 = ((Component)

5__1).transform.eulerAngles; Log.LogWarning((object)$"[PlayerPos] Position: {5__2} | Rotation: {5__3}");

5__1 = null; } } break; } <>2__current = (object)new WaitForSeconds(0.5f); <>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(); } } public static GameObject theaterPrefab; public static ManualLogSource Log; public static Plugin Instance; public static bool debug; public static SyncVideoTheaterConfig ConfigSettings; public static ConfigFile TheaterConfigFile; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; string text = Path.Combine(Paths.ConfigPath, "transrights.SyncVideoTheater.cfg"); TheaterConfigFile = new ConfigFile(text, true); ConfigSettings = new SyncVideoTheaterConfig(TheaterConfigFile); Harmony val = new Harmony("OsakaTheater.SyncVideoTheater"); val.PatchAll(); ((MonoBehaviour)this).StartCoroutine(LoadBundleAsync()); ScenePatch.TrySubscribeToSyncVideoLobbyEvent(); if (debug) { ((MonoBehaviour)this).StartCoroutine(LogPlayerPositionLoop()); } } private void Update() { ScenePatch.Tick(); } [IteratorStateMachine(typeof(d__8))] private IEnumerator LogPlayerPositionLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__9))] private IEnumerator LoadBundleAsync() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { <>4__this = this }; } } [HarmonyPatch(typeof(ASceneSetupInstruction), "SetSceneActive")] public class ScenePatch { [CompilerGenerated] private sealed class <>c__DisplayClass26_0 { public int maxFrames; public Transform tvRoot; internal bool b__0() { maxFrames--; return (Object)(object)tvRoot == (Object)null || tvRoot.childCount > 0 || maxFrames <= 0; } } [CompilerGenerated] private sealed class d__26 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Transform tvRoot; private <>c__DisplayClass26_0 <>8__1; private int 5__2; private Transform 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass26_0(); <>8__1.tvRoot = tvRoot; <>8__1.maxFrames = 60; <>2__current = (object)new WaitUntil((Func)delegate { <>8__1.maxFrames--; return (Object)(object)<>8__1.tvRoot == (Object)null || <>8__1.tvRoot.childCount > 0 || <>8__1.maxFrames <= 0; }); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)<>8__1.tvRoot == (Object)null) { return false; } if (<>8__1.tvRoot.childCount == 0) { Plugin.Log.LogWarning((object)"No SyncVideo child appeared under TV."); return false; } 5__2 = 0; while (5__2 < <>8__1.tvRoot.childCount) { 5__3 = <>8__1.tvRoot.GetChild(5__2); 5__3.localScale = new Vector3(2f, 2f, 2f); Plugin.Log.LogInfo((object)$"Scaled SyncVideo child: {((Object)5__3).name} to {5__3.localScale}"); 5__3 = null; 5__2++; } 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(); } } private const string TargetSceneName = "osaka"; private const string TargetObjectName = "StageChunks/OsakaStart/NotVisibleFromBridge/CombinedMeshes_osaka_OsakaFronts01_-1429972"; private const string SpawnedName = "Theater_Instance"; private const string AmbientTriggerName = "SyncVideoTheater_AmbientTrigger"; private static GameObject spawnedTheater; private static GameObject ambientTriggerObject; private static bool lastAutomaticLobbyState; private static LowerTheLightsMode lastLowerLightsMode = (LowerTheLightsMode)(-1); private static float ambientTriggerDestroyTimer; private const float AmbientTriggerDestroyTimerSec = 2f; private static bool syncVideoLookupAttempted; private static PropertyInfo syncVideoLobbyManagerProperty; private static PropertyInfo syncVideoInLobbyProperty; private static object cachedSyncVideoLobbyManager; public static void Tick() { if (!(ambientTriggerDestroyTimer <= 0f)) { ambientTriggerDestroyTimer -= Time.unscaledDeltaTime; if (!(ambientTriggerDestroyTimer > 0f)) { ambientTriggerDestroyTimer = 0f; DestroyAmbientTrigger(); } } } private static void Postfix(string sceneToSetActive) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (sceneToSetActive != "osaka") { return; } if ((Object)(object)Plugin.theaterPrefab == (Object)null) { Plugin.Log.LogError((object)"Theater prefab is null."); return; } if ((Object)(object)GameObject.Find("Theater_Instance") != (Object)null) { Plugin.Log.LogInfo((object)"Theater already spawned. Skipping."); return; } GameObject val = GameObject.Find("StageChunks/OsakaStart/NotVisibleFromBridge/CombinedMeshes_osaka_OsakaFronts01_-1429972"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"Could not find target object: StageChunks/OsakaStart/NotVisibleFromBridge/CombinedMeshes_osaka_OsakaFronts01_-1429972"); return; } Plugin.Log.LogInfo((object)("Found target object: " + GetHierarchyPath(val.transform))); GameObject val2 = GameObject.Find("OS_CinemaFront"); if ((Object)(object)val2 != (Object)null) { Plugin.Log.LogInfo((object)"Disabling OS_CinemaFront..."); val2.SetActive(false); } else { Plugin.Log.LogWarning((object)"OS_CinemaFront not found."); } Bounds combinedBounds = GetCombinedBounds(val); Quaternion rotation = val.transform.rotation; Plugin.Log.LogInfo((object)$"Target bounds center {((Bounds)(ref combinedBounds)).center}, size {((Bounds)(ref combinedBounds)).size}, minY {((Bounds)(ref combinedBounds)).min.y}"); ApplyTextureToSceneBillboard(); RemoveTargetObject(val); GameObject val3 = SpawnReplacement(combinedBounds, rotation); } private static void RemoveTargetObject(GameObject targetObject) { Plugin.Log.LogInfo((object)("Removing target object: " + GetHierarchyPath(targetObject.transform))); targetObject.SetActive(false); Object.Destroy((Object)(object)targetObject); Plugin.Log.LogInfo((object)"Target object removed."); } private static GameObject SpawnReplacement(Bounds targetBounds, Quaternion targetRotation) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)"Spawning theater replacement..."); GameObject val = Object.Instantiate(Plugin.theaterPrefab); ((Object)val).name = "Theater_Instance"; val.transform.rotation = targetRotation; MeshRenderer[] componentsInChildren = val.GetComponentsInChildren(true); foreach (MeshRenderer val2 in componentsInChildren) { ((Renderer)val2).enabled = true; } spawnedTheater = val; ApplyLowerTheLightsForCurrentState(); SpawnSyncVideoTvMarker(val.transform); Plugin.Log.LogInfo((object)$"Spawned theater at {val.transform.position}"); return val; } public static void TrySubscribeToSyncVideoLobbyEvent() { try { Type type = Type.GetType("SyncVideo.SyncVideoPlugin, SyncVideo"); if (type == null) { Plugin.Log.LogInfo((object)"[SyncVideoTheater] SyncVideo not present; lobby lighting disabled."); return; } EventInfo @event = type.GetEvent("LobbyStateChanged", BindingFlags.Static | BindingFlags.Public); if (@event == null) { Plugin.Log.LogWarning((object)"[SyncVideoTheater] LobbyStateChanged event not found on SyncVideoPlugin."); return; } Action handler = OnSyncVideoLobbyStateChanged; @event.AddEventHandler(null, handler); Plugin.Log.LogInfo((object)"[SyncVideoTheater] Subscribed to SyncVideo.LobbyStateChanged."); } catch (Exception ex) { Plugin.Log.LogError((object)("[SyncVideoTheater] Failed to subscribe to SyncVideo lobby event: " + ex.Message)); } } public static void OnSyncVideoLobbyStateChanged(bool inLobby) { if ((Object)(object)spawnedTheater == (Object)null) { return; } SyncVideoTheaterConfig configSettings = Plugin.ConfigSettings; if (configSettings != null && configSettings.LowerTheLights.Value == LowerTheLightsMode.Automatic && inLobby != lastAutomaticLobbyState) { lastAutomaticLobbyState = inLobby; if (inLobby) { ambientTriggerDestroyTimer = 0f; EnsureAmbientTrigger(); } else { ambientTriggerDestroyTimer = 2f; } } } private static void ApplyLowerTheLightsForCurrentState() { if (Plugin.ConfigSettings == null) { return; } switch (lastLowerLightsMode = Plugin.ConfigSettings.LowerTheLights.Value) { case LowerTheLightsMode.Enabled: ambientTriggerDestroyTimer = 0f; EnsureAmbientTrigger(); return; case LowerTheLightsMode.Disabled: ambientTriggerDestroyTimer = 0f; DestroyAmbientTrigger(); return; } lastAutomaticLobbyState = IsInSyncVideoLobby(); if (lastAutomaticLobbyState) { ambientTriggerDestroyTimer = 0f; EnsureAmbientTrigger(); } else { ambientTriggerDestroyTimer = 0f; DestroyAmbientTrigger(); } } private static void EnsureAmbientTrigger() { ambientTriggerDestroyTimer = 0f; if (!((Object)(object)ambientTriggerObject != (Object)null)) { SpawnAmbientTrigger(spawnedTheater); } } private static void DestroyAmbientTrigger() { if ((Object)(object)ambientTriggerObject == (Object)null) { GameObject val = GameObject.Find("SyncVideoTheater_AmbientTrigger"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } else { Object.Destroy((Object)(object)ambientTriggerObject); ambientTriggerObject = null; Plugin.Log.LogInfo((object)"Destroyed SyncVideo Theater ambient trigger."); } } private static bool IsInSyncVideoLobby() { try { if (!TryGetSyncVideoLobbyManager(out var lobbyManager)) { return false; } if (syncVideoInLobbyProperty == null || cachedSyncVideoLobbyManager != lobbyManager) { cachedSyncVideoLobbyManager = lobbyManager; syncVideoInLobbyProperty = lobbyManager.GetType().GetProperty("InLobby", BindingFlags.Instance | BindingFlags.Public); } if (syncVideoInLobbyProperty == null) { return false; } object value = syncVideoInLobbyProperty.GetValue(lobbyManager, null); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch (Exception ex) { if (Plugin.debug) { Plugin.Log.LogWarning((object)("Failed to read SyncVideo lobby state: " + ex.Message)); } return false; } } private static bool TryGetSyncVideoLobbyManager(out object lobbyManager) { lobbyManager = null; if (!syncVideoLookupAttempted) { syncVideoLookupAttempted = true; Type type = Type.GetType("SyncVideo.SyncVideoPlugin, SyncVideo"); if (type != null) { syncVideoLobbyManagerProperty = type.GetProperty("LobbyManager", BindingFlags.Static | BindingFlags.Public); } } if (syncVideoLobbyManagerProperty == null) { return false; } lobbyManager = syncVideoLobbyManagerProperty.GetValue(null, null); return lobbyManager != null; } private static void SpawnSyncVideoTvMarker(Transform theaterRoot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TV"); val.transform.SetParent(theaterRoot, false); val.transform.localPosition = new Vector3(115.0057f, -5.59f, -82.3467f); val.transform.localRotation = Quaternion.Euler(0f, 306.1724f, 0f); val.transform.localScale = new Vector3(20f, 20f, 1f); if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } Plugin.Log.LogInfo((object)$"Spawned SyncVideo TV marker at {val.transform.position}"); ((MonoBehaviour)Plugin.Instance).StartCoroutine(ScaleSyncVideoScreenAfterSpawn(val.transform)); } [IteratorStateMachine(typeof(d__26))] private static IEnumerator ScaleSyncVideoScreenAfterSpawn(Transform tvRoot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0) { tvRoot = tvRoot }; } private static Bounds GetCombinedBounds(GameObject root) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { return new Bounds(root.transform.position, Vector3.zero); } Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } return bounds; } private static string GetHierarchyPath(Transform current) { StringBuilder stringBuilder = new StringBuilder(((Object)current).name); while ((Object)(object)current.parent != (Object)null) { current = current.parent; stringBuilder.Insert(0, '/'); stringBuilder.Insert(0, ((Object)current).name); } return stringBuilder.ToString(); } private static void ApplyTextureToSceneBillboard() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) string text = "StageChunks/OsakaStart/NotVisibleFromBridge/Buildings_OsakaStart/North/Buildings/BillboardSquare03"; GameObject val = GameObject.Find(text); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)("Scene billboard not found: " + text)); return; } Renderer val2 = val.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = val.GetComponentInChildren(true); } if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogError((object)"Renderer not found on scene billboard."); return; } string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); string text2 = Path.Combine(directoryName, "NewBillboardAtlas.png"); if (!File.Exists(text2)) { Plugin.Log.LogError((object)("Texture not found: " + text2)); return; } byte[] array = File.ReadAllBytes(text2); Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val3, array)) { Plugin.Log.LogError((object)"Failed to load NewBillboardAtlas.png."); return; } ((Object)val3).name = "NewBillboardAtlas"; ((Texture)val3).wrapMode = (TextureWrapMode)0; ((Texture)val3).filterMode = (FilterMode)1; val3.Apply(false, false); Shader val4 = Shader.Find("Unlit/Texture"); if ((Object)(object)val4 == (Object)null) { Plugin.Log.LogError((object)"Could not find Unlit/Texture shader."); return; } Material val5 = new Material(val4); ((Object)val5).name = "NewBillboardAtlas_Opaque_Unlit"; val5.mainTexture = (Texture)(object)val3; if (val5.HasProperty("_MainTex")) { val5.SetTexture("_MainTex", (Texture)(object)val3); val5.SetTextureScale("_MainTex", Vector2.one); val5.SetTextureOffset("_MainTex", Vector2.zero); } if (val5.HasProperty("_Color")) { val5.SetColor("_Color", Color.white); } if (val5.HasProperty("_SrcBlend")) { val5.SetFloat("_SrcBlend", 1f); } if (val5.HasProperty("_DstBlend")) { val5.SetFloat("_DstBlend", 0f); } if (val5.HasProperty("_ZWrite")) { val5.SetFloat("_ZWrite", 1f); } val5.renderQueue = 2000; val5.DisableKeyword("_ALPHABLEND_ON"); val5.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val5.DisableKeyword("_ALPHATEST_ON"); val5.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); val5.DisableKeyword("_EMISSION"); val5.DisableKeyword("_DETAIL_MULX2"); val5.DisableKeyword("_DETAIL_SCALED"); val2.SetPropertyBlock((MaterialPropertyBlock)null); Material[] array2 = (Material[])(object)new Material[val2.sharedMaterials.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = val5; } val2.sharedMaterials = array2; val2.materials = array2; val2.SetPropertyBlock((MaterialPropertyBlock)null); Plugin.Log.LogInfo((object)("Forced opaque unlit New Billboard Atlas material on: " + GetHierarchyPath(((Component)val2).transform))); } private static void SpawnAmbientTrigger(GameObject theater) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); ((Color)(ref val))..ctor(0.02f, 0.02f, 0.02f, 0.75f); Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(125.62f, 8.27f, -73.94f), new Vector3(109.94f, 7.58f, -95.58f), new Vector3(125.62f, -8.77f, -73.94f), new Vector3(109.65f, -8.86f, -95.17f), new Vector3(96.32f, 8.53f, -51.23f), new Vector3(79.63f, 8.53f, -73.32f), new Vector3(94.86f, -7.73f, -51.64f), new Vector3(78.16f, -8.85f, -72.33f) }; Bounds val2 = default(Bounds); ((Bounds)(ref val2))..ctor(array[0], Vector3.zero); for (int i = 1; i < array.Length; i++) { ((Bounds)(ref val2)).Encapsulate(array[i]); } if ((Object)(object)ambientTriggerObject != (Object)null) { return; } GameObject val3 = (ambientTriggerObject = new GameObject("SyncVideoTheater_AmbientTrigger")); val3.transform.position = new Vector3(107.2773f, -0.165f, -74.805f); val3.transform.rotation = Quaternion.Euler(0f, 36.5862f, 0f); BoxCollider val4 = val3.AddComponent(); ((Collider)val4).isTrigger = true; val4.center = Vector3.zero; val4.size = ((Bounds)(ref val2)).size; if (Plugin.debug) { GameObject val5 = new GameObject("AmbientTrigger_Visual"); val5.transform.SetParent(val3.transform, false); val5.transform.localPosition = val4.center; val5.transform.localRotation = Quaternion.identity; val5.transform.localScale = val4.size; MeshFilter val6 = val5.AddComponent(); MeshRenderer val7 = val5.AddComponent(); val6.sharedMesh = CreateDebugCubeMesh(); Shader val8 = Shader.Find("Unlit/Color"); if ((Object)(object)val8 == (Object)null) { val8 = Shader.Find("Sprites/Default"); } Material val9 = new Material(val8); ((Object)val9).name = "AmbientTrigger_Debug_Black_Transparent"; val9.color = new Color(0f, 0f, 0f, 0.35f); if (val9.HasProperty("_Color")) { val9.SetColor("_Color", new Color(0f, 0f, 0f, 0.35f)); } if (val9.HasProperty("_SrcBlend")) { val9.SetInt("_SrcBlend", 5); } if (val9.HasProperty("_DstBlend")) { val9.SetInt("_DstBlend", 10); } if (val9.HasProperty("_ZWrite")) { val9.SetInt("_ZWrite", 0); } val9.DisableKeyword("_ALPHATEST_ON"); val9.EnableKeyword("_ALPHABLEND_ON"); val9.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val9.renderQueue = 3000; ((Renderer)val7).sharedMaterial = val9; } AmbientTrigger val10 = val3.AddComponent(); val10.AmbientEnvLight = val; val10.AmbientEnvShadow = val; val10.transitionDuration = 2f; val10.revertTransitionDuration = 2f; SyncVideoTheaterConfig configSettings = Plugin.ConfigSettings; if (configSettings != null && (configSettings.MuteRoadCarsInTheater?.Value).GetValueOrDefault()) { val3.AddComponent(); } PersistentAmbientTriggerDriver persistentAmbientTriggerDriver = val3.AddComponent(); persistentAmbientTriggerDriver.Trigger = val10; persistentAmbientTriggerDriver.Collider = val4; Plugin.Log.LogInfo((object)"Spawned SyncVideo Theater ambient trigger."); } private static Bounds ComputeInteriorBounds(GameObject theater) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = theater.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "OuterAreas") { Bounds combinedBounds = GetCombinedBounds(((Component)val).gameObject); Plugin.Log.LogInfo((object)$"AmbientTrigger bounds from OuterAreas: center {((Bounds)(ref combinedBounds)).center}, size {((Bounds)(ref combinedBounds)).size}"); return combinedBounds; } } Renderer[] componentsInChildren2 = theater.GetComponentsInChildren(true); bool flag = false; Bounds result = default(Bounds); Renderer[] array = componentsInChildren2; foreach (Renderer val2 in array) { if (!((Object)((Component)val2).gameObject).name.StartsWith("CombinedMeshes_")) { if (!flag) { result = val2.bounds; flag = true; } else { ((Bounds)(ref result)).Encapsulate(val2.bounds); } } } if (!flag) { result = GetCombinedBounds(theater); } Plugin.Log.LogWarning((object)$"OuterAreas not found, using fallback bounds: center {((Bounds)(ref result)).center}, size {((Bounds)(ref result)).size}"); return result; } private static Mesh CreateDebugCubeMesh() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); ((Object)val).name = "AmbientTrigger_DebugCubeMesh"; Vector3[] vertices = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f) }; int[] triangles = new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 0, 4, 7, 0, 7, 3, 1, 2, 6, 1, 6, 5 }; val.vertices = vertices; val.triangles = triangles; val.RecalculateNormals(); val.RecalculateBounds(); return val; } } public class RoadCarsAmbientMute : MonoBehaviour { private readonly Dictionary savedMuteStates = new Dictionary(); private int playerInsideCount; private float tickTimer; private const float TickInterval = 0.25f; private void OnTriggerEnter(Collider other) { if (IsLocalPlayer(other)) { playerInsideCount++; MuteRoadCars(); } } private void OnTriggerExit(Collider other) { if (IsLocalPlayer(other)) { playerInsideCount = Mathf.Max(0, playerInsideCount - 1); if (playerInsideCount == 0) { RestoreRoadCars(); } } } private void Update() { if (playerInsideCount > 0) { tickTimer += Time.unscaledDeltaTime; if (!(tickTimer < 0.25f)) { tickTimer = 0f; MuteRoadCars(); } } } private void OnDisable() { RestoreRoadCars(); } private void OnDestroy() { RestoreRoadCars(); } private static bool IsLocalPlayer(Collider other) { try { Player componentInParent = ((Component)other).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return false; } WorldHandler instance = WorldHandler.instance; Player val = ((instance != null) ? instance.GetCurrentPlayer() : null); return (Object)(object)val == (Object)null || (Object)(object)componentInParent == (Object)(object)val; } catch { return false; } } private void MuteRoadCars() { MuteRoadCarRoot("roadCars1"); MuteRoadCarRoot("roadCars2"); } private void MuteRoadCarRoot(string rootName) { GameObject val = GameObject.Find(rootName); if ((Object)(object)val == (Object)null) { return; } AudioSource[] componentsInChildren = val.GetComponentsInChildren(true); AudioSource[] array = componentsInChildren; foreach (AudioSource val2 in array) { if (!((Object)(object)val2 == (Object)null)) { if (!savedMuteStates.ContainsKey(val2)) { savedMuteStates[val2] = val2.mute; } val2.mute = true; } } } private void RestoreRoadCars() { foreach (KeyValuePair savedMuteState in savedMuteStates) { if ((Object)(object)savedMuteState.Key != (Object)null) { savedMuteState.Key.mute = savedMuteState.Value; } } savedMuteStates.Clear(); playerInsideCount = 0; tickTimer = 0f; } } public class PersistentAmbientTriggerDriver : MonoBehaviour { public AmbientTrigger Trigger; public BoxCollider Collider; private AmbientManager ambientManager; private FieldInfo curAmbientTriggerField; private float checkTimer; private bool wasInside; private const float CheckInterval = 0.1f; private void Start() { ambientManager = Object.FindObjectOfType(); curAmbientTriggerField = typeof(AmbientManager).GetField("curAmbientTrigger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } private void Update() { if ((Object)(object)Trigger == (Object)null || (Object)(object)Collider == (Object)null) { return; } checkTimer -= Time.unscaledDeltaTime; if (checkTimer > 0f) { return; } checkTimer = 0.1f; if ((Object)(object)ambientManager == (Object)null) { ambientManager = Object.FindObjectOfType(); } if ((Object)(object)ambientManager == (Object)null) { return; } bool flag = IsCurrentPlayerInsideCollider(); AmbientTrigger currentAmbientTrigger = GetCurrentAmbientTrigger(); if (flag) { if ((Object)(object)currentAmbientTrigger != (Object)(object)Trigger) { ambientManager.InAmbientTrigger(Trigger); } wasInside = true; } else { if ((Object)(object)currentAmbientTrigger == (Object)(object)Trigger) { ambientManager.OutAmbientTrigger(Trigger); } wasInside = false; } } private AmbientTrigger GetCurrentAmbientTrigger() { if ((Object)(object)ambientManager == (Object)null || curAmbientTriggerField == null) { return null; } object? value = curAmbientTriggerField.GetValue(ambientManager); return (AmbientTrigger)((value is AmbientTrigger) ? value : null); } private bool IsCurrentPlayerInsideCollider() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) if ((Object)(object)WorldHandler.instance == (Object)null) { return false; } Player currentPlayer = WorldHandler.instance.GetCurrentPlayer(); if ((Object)(object)currentPlayer == (Object)null) { return false; } Vector3 val = ((Component)Collider).transform.InverseTransformPoint(((Component)currentPlayer).transform.position) - Collider.center; Vector3 val2 = Collider.size * 0.5f; return Mathf.Abs(val.x) <= val2.x && Mathf.Abs(val.y) <= val2.y && Mathf.Abs(val.z) <= val2.z; } } } namespace SyncVideo { internal static class PluginInfo { public const string PLUGIN_GUID = "transrights.SyncVideoTheater"; public const string PLUGIN_NAME = "Versum Video Venue"; public const string PLUGIN_VERSION = "1.2.0"; } }