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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+517976fc8d3caccfe59b52dca6ede28a88ebc572")]
[assembly: AssemblyProduct("TruckDoorMod")]
[assembly: AssemblyTitle("TruckDoorMod")]
[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;
}
}
}
public static class TransformExtensions
{
public static Transform FindRecursive(this Transform t, string name)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
if ((Object)(object)t == (Object)null)
{
return null;
}
foreach (Transform item in t)
{
Transform val = item;
if (((Object)val).name.Equals(name, StringComparison.OrdinalIgnoreCase))
{
return val;
}
Transform val2 = val.FindRecursive(name);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
public static string GetHierarchyPath(this Transform t)
{
if ((Object)(object)t == (Object)null)
{
return "<null>";
}
StringBuilder stringBuilder = new StringBuilder();
while ((Object)(object)t != (Object)null)
{
stringBuilder.Insert(0, "/" + ((Object)t).name);
t = t.parent;
}
return stringBuilder.ToString();
}
}
namespace Empress.TruckDoorController
{
[BepInPlugin("empress.repo.truckdoorcontroller", "Empress Truck Door Controller", "1.6.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <AutoBindDoorAfterSceneLoad>d__28 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private DoorRuntime <rt>5__1;
private int <i>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AutoBindDoorAfterSceneLoad>d__28(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<rt>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<rt>5__1 = HostGO.GetComponent<DoorRuntime>();
if ((Object)(object)<rt>5__1 != (Object)null && <rt>5__1.EnsureBound())
{
LogS.LogDebug((object)"[Empress] Door auto-bound after scene load - all clients ready for events!");
break;
}
<i>5__2 = 0;
goto IL_0116;
case 2:
{
<>1__state = -1;
if ((Object)(object)<rt>5__1 != (Object)null && <rt>5__1.EnsureBound())
{
LogS.LogDebug((object)$"[Empress] Door auto-bound after scene load (retry {<i>5__2 + 1}) - all clients ready for events!");
return false;
}
<i>5__2++;
goto IL_0116;
}
IL_0116:
if (<i>5__2 < 5)
{
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 2;
return true;
}
LogS.LogDebug((object)"[Empress] Failed to auto-bind door after scene load. Manual button press may be required.");
break;
}
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 <TryLoadDoorAudio>d__31 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private string <dir>5__1;
private string <path>5__2;
private string <url>5__3;
private UnityWebRequest <req>5__4;
private bool <failed>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TryLoadDoorAudio>d__31(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<dir>5__1 = null;
<path>5__2 = null;
<url>5__3 = null;
<req>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
<>1__state = -1;
if ((Object)(object)DoorClip != (Object)null)
{
result = false;
break;
}
<dir>5__1 = GetPluginDir();
<path>5__2 = Path.Combine(<dir>5__1, DoorClipFileName);
if (!File.Exists(<path>5__2))
{
LogS.LogDebug((object)("[Empress] door.ogg not found next to DLL: " + <path>5__2));
result = false;
break;
}
<url>5__3 = new Uri(<path>5__2).AbsoluteUri;
<req>5__4 = UnityWebRequestMultimedia.GetAudioClip(<url>5__3, (AudioType)14);
<>1__state = -3;
LogS.LogDebug((object)("[Empress] Loading door audio: " + <path>5__2));
<>2__current = <req>5__4.SendWebRequest();
<>1__state = 1;
result = true;
break;
case 1:
<>1__state = -3;
<failed>5__5 = <req>5__4.isNetworkError || <req>5__4.isHttpError;
if (<failed>5__5)
{
LogS.LogDebug((object)("[Empress] door.ogg load failed: " + <req>5__4.error));
result = false;
<>m__Finally1();
break;
}
DoorClip = DownloadHandlerAudioClip.GetContent(<req>5__4);
if ((Object)(object)DoorClip != (Object)null)
{
LogS.LogDebug((object)"[Empress] door.ogg loaded.");
}
<>m__Finally1();
<req>5__4 = null;
result = false;
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<req>5__4 != null)
{
((IDisposable)<req>5__4).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string PluginGuid = "empress.repo.truckdoorcontroller";
public const string PluginName = "Empress Truck Door Controller";
public const string PluginVersion = "1.6.0";
internal static ManualLogSource LogS;
internal static GameObject HostGO;
internal static ConfigEntry<string> CfgRootHint;
internal static ConfigEntry<string> CfgParentName;
internal static ConfigEntry<string> CfgDoorName;
internal static ConfigEntry<bool> CfgUseLocal;
internal static ConfigEntry<float> CfgClosedY;
internal static ConfigEntry<float> CfgOpenY;
internal static ConfigEntry<float> CfgCloseDuration;
internal static ConfigEntry<float> CfgOpenDuration;
internal static ConfigEntry<float> CfgAutoOpenDelay;
internal static ConfigEntry<bool> CfgShowPrompt;
internal static ConfigEntry<float> CfgButtonCooldown;
internal static ConfigEntry<KeyboardShortcut> CfgToggleKey;
internal static AudioClip DoorClip;
internal static AudioClip BeepClip;
internal static string DoorClipFileName = "door.ogg";
internal const string ButtonBundleName = "buttonfab";
internal const string ButtonPrefabName = "button";
internal static GameObject ButtonGO;
private Harmony _harmony;
private const string AsciiBanner = "\r\n/* ██████╗ ███╗ ███╗███╗ ██╗██╗ */\r\n/* ██╔═══██╗████╗ ████║████╗ ██║██║ */\r\n/* ██║ ██║██╔████╔██║██╔██╗ ██║██║ */\r\n/* ██║ ██║██║╚██╔╝██║██║╚██╗██║██║ */\r\n/* ╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║ */\r\n/* ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ */\r\n/* */\r\n/* ███████╗███╗ ███╗██████╗ ██████╗ ███████╗███████╗███████╗ */\r\n/* ██╔════╝████╗ ████║██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ */\r\n/* █████╗ ██╔████╔██║██████╔╝██████╔╝█████╗ ███████╗███████╗ */\r\n/* ██╔══╝ ██║╚██╔╝██║██╔═══╝ ██╔══██╗██╔══╝ ╚════██║╚════██║ */\r\n/* ███████╗██║ ╚═╝ ██║██║ ██║ ██║███████╗███████║███████║ */\r\n/* ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ */\r\n";
private void Awake()
{
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Expected O, but got Unknown
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Expected O, but got Unknown
LogS = ((BaseUnityPlugin)this).Logger;
LogS.LogInfo((object)"\r\n/* ██████╗ ███╗ ███╗███╗ ██╗██╗ */\r\n/* ██╔═══██╗████╗ ████║████╗ ██║██║ */\r\n/* ██║ ██║██╔████╔██║██╔██╗ ██║██║ */\r\n/* ██║ ██║██║╚██╔╝██║██║╚██╗██║██║ */\r\n/* ╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║ */\r\n/* ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ */\r\n/* */\r\n/* ███████╗███╗ ███╗██████╗ ██████╗ ███████╗███████╗███████╗ */\r\n/* ██╔════╝████╗ ████║██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ */\r\n/* █████╗ ██╔████╔██║██████╔╝██████╔╝█████╗ ███████╗███████╗ */\r\n/* ██╔══╝ ██║╚██╔╝██║██╔═══╝ ██╔══██╗██╔══╝ ╚════██║╚════██║ */\r\n/* ███████╗██║ ╚═╝ ██║██║ ██║ ██║███████╗███████║███████║ */\r\n/* ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ */\r\n");
LogS.LogDebug((object)"[Empress] Awake() — Truck Door Controller v1.6.0");
CfgRootHint = ((BaseUnityPlugin)this).Config.Bind<string>("DoorFind", "RootHint", "Truck Run", "Optional top-level GameObject name that contains the door (speeds up search). Leave blank if unsure.");
CfgParentName = ((BaseUnityPlugin)this).Config.Bind<string>("DoorFind", "ParentName", "Door", "Parent object that holds the truck door.");
CfgDoorName = ((BaseUnityPlugin)this).Config.Bind<string>("DoorFind", "DoorName", "Truck Door", "Exact GameObject name for the truck door.");
CfgUseLocal = ((BaseUnityPlugin)this).Config.Bind<bool>("Motion", "UseLocal", false, "Animate in local space (true) or world space (false).");
CfgClosedY = ((BaseUnityPlugin)this).Config.Bind<float>("Motion", "ClosedY", 1f, "Y coordinate when door is closed.");
CfgOpenY = ((BaseUnityPlugin)this).Config.Bind<float>("Motion", "OpenY", 3.148f, "Y coordinate when door is open. The door will ALWAYS open to this value.");
CfgCloseDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Motion", "CloseDuration", 0.8f, "Seconds to roll the door down.");
CfgOpenDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Motion", "OpenDuration", 0.8f, "Seconds to roll the door up.");
CfgAutoOpenDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Motion", "AutoOpenDelay", 15f, "After a close, auto-open after this many seconds if untouched.");
CfgShowPrompt = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowPrompt", true, "Show interact prompt when near the button.");
CfgButtonCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "ButtonCooldown", 1.5f, "Seconds to wait between button presses.");
CfgToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "ToggleKey", new KeyboardShortcut((KeyCode)101, Array.Empty<KeyCode>()), "Key (or key combo) to toggle the truck door. Example: F, K, LeftControl + K. Set to None to use the game's Interact key instead.");
_harmony = new Harmony("empress.repo.truckdoorcontroller");
_harmony.PatchAll(typeof(Plugin));
HostGO = new GameObject("Empress_TruckDoorController_Host");
Object.DontDestroyOnLoad((Object)(object)HostGO);
((Object)HostGO).hideFlags = (HideFlags)52;
HostGO.AddComponent<DoorRuntime>();
HostGO.AddComponent<ButtonActivator>();
SceneManager.sceneLoaded += OnSceneLoaded;
LogS.LogDebug((object)"[Empress] Host created — will auto-bind door on scene load.");
BeepClip = MakeBeepClip(220f, 0.18f, 0.3f);
}
private void OnDestroy()
{
try
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
catch
{
}
}
private void OnSceneLoaded(Scene s, LoadSceneMode m)
{
try
{
ButtonGO = null;
DoorRuntime component = HostGO.GetComponent<DoorRuntime>();
if ((Object)(object)component != (Object)null)
{
component.ResetBinding();
}
TrySpawnButton();
DoorRuntime component2 = HostGO.GetComponent<DoorRuntime>();
if (component2 != null)
{
((MonoBehaviour)component2).StartCoroutine(TryLoadDoorAudio());
}
DoorEventHandler.Initialize();
if ((Object)(object)component != (Object)null)
{
((MonoBehaviour)component).StartCoroutine(AutoBindDoorAfterSceneLoad());
}
}
catch (Exception arg)
{
LogS.LogError((object)$"[Empress] sceneLoaded hook failed: {arg}");
}
}
[IteratorStateMachine(typeof(<AutoBindDoorAfterSceneLoad>d__28))]
private static IEnumerator AutoBindDoorAfterSceneLoad()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AutoBindDoorAfterSceneLoad>d__28(0);
}
internal static void EnsureRelayAttached(Transform doorTf, float openY, float closedY)
{
try
{
if ((Object)(object)doorTf == (Object)null)
{
LogS.LogDebug((object)"[Empress] EnsureRelayAttached: doorTf null");
return;
}
if ((Object)(object)HostGO == (Object)null)
{
LogS.LogError((object)"[Empress] HostGO missing; cannot attach relay.");
return;
}
DoorEventHandler doorEventHandler = HostGO.GetComponent<DoorEventHandler>();
if ((Object)(object)doorEventHandler == (Object)null)
{
doorEventHandler = HostGO.AddComponent<DoorEventHandler>();
}
doorEventHandler.BindDoor(doorTf, openY, closedY);
LogS.LogDebug((object)"[Empress] Event handler attached to HostGO.");
}
catch (Exception arg)
{
LogS.LogError((object)$"[Empress] EnsureRelayAttached failed: {arg}");
}
}
internal static string GetPluginDir()
{
try
{
return Path.GetDirectoryName(typeof(Plugin).Assembly.Location);
}
catch
{
return Paths.PluginPath;
}
}
[IteratorStateMachine(typeof(<TryLoadDoorAudio>d__31))]
private static IEnumerator TryLoadDoorAudio()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TryLoadDoorAudio>d__31(0);
}
private static void TrySpawnButton()
{
//IL_00ea: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)ButtonGO != (Object)null)
{
return;
}
string pluginDir = GetPluginDir();
string text = Path.Combine(pluginDir, "buttonfab");
if (!File.Exists(text))
{
LogS.LogDebug((object)("[Empress] Button bundle not found: " + text));
return;
}
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
LogS.LogDebug((object)"[Empress] Failed to load button AssetBundle.");
return;
}
GameObject val2 = val.LoadAsset<GameObject>("button");
if ((Object)(object)val2 == (Object)null)
{
LogS.LogDebug((object)"[Empress] Prefab 'button' not found in bundle.");
val.Unload(false);
return;
}
ButtonGO = Object.Instantiate<GameObject>(val2);
((Object)ButtonGO).name = "Empress_DoorButton";
ButtonGO.transform.position = new Vector3(-2.322f, 1.876f, -12.973f);
ButtonGO.transform.rotation = Quaternion.identity;
((Object)ButtonGO).hideFlags = (HideFlags)52;
Collider component = ButtonGO.GetComponent<Collider>();
if ((Object)(object)component == (Object)null)
{
BoxCollider val3 = ButtonGO.AddComponent<BoxCollider>();
((Collider)val3).isTrigger = true;
val3.center = Vector3.zero;
val3.size = new Vector3(0.3f, 0.3f, 0.3f);
}
if ((Object)(object)HostGO.GetComponent<ButtonActivator>() == (Object)null)
{
HostGO.AddComponent<ButtonActivator>();
}
val.Unload(false);
LogS.LogDebug((object)"[Empress] Spawned door button prefab at (-2.322, 1.876, -12.973).");
}
catch (Exception arg)
{
LogS.LogError((object)$"[Empress] Button spawn failed: {arg}");
}
}
private static AudioClip MakeBeepClip(float freq, float seconds, float volume)
{
try
{
int num = ((AudioSettings.outputSampleRate > 0) ? AudioSettings.outputSampleRate : 48000);
int num2 = Mathf.Max(1, Mathf.RoundToInt(seconds * (float)num));
float[] array = new float[num2];
float num3 = MathF.PI * 2f;
for (int i = 0; i < num2; i++)
{
array[i] = Mathf.Sin(num3 * freq * ((float)i / (float)num)) * Mathf.Clamp01(volume);
}
AudioClip val = AudioClip.Create("Empress_Beep", num2, 1, num, false);
val.SetData(array, 0);
return val;
}
catch
{
return null;
}
}
internal static bool IsTogglePressed()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
try
{
KeyboardShortcut value = CfgToggleKey.Value;
if ((int)((KeyboardShortcut)(ref value)).MainKey > 0)
{
if (((KeyboardShortcut)(ref value)).IsDown())
{
return true;
}
return false;
}
}
catch
{
}
return SemiFunc.InputDown((InputKey)2);
}
internal static string ToggleKeyDisplay()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
try
{
KeyboardShortcut value = CfgToggleKey.Value;
if ((int)((KeyboardShortcut)(ref value)).MainKey > 0)
{
return ((object)(KeyboardShortcut)(ref value)).ToString();
}
}
catch
{
}
return "Interact";
}
}
public class DoorRuntime : MonoBehaviour
{
[CompilerGenerated]
private sealed class <AutoOpenAfterDelay_Master>d__8 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DoorRuntime <>4__this;
private float <delay>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AutoOpenAfterDelay_Master>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<delay>5__1 = Mathf.Max(0.01f, Plugin.CfgAutoOpenDelay.Value);
<>2__current = (object)new WaitForSeconds(<delay>5__1);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (DoorEventHandler.IsDoorClosed)
{
DoorEventHandler.RequestOpen();
}
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 Transform _doorTf;
private float _openY;
private float _closedY;
public Transform DoorTransform => _doorTf;
public void ResetBinding()
{
_doorTf = null;
_openY = Plugin.CfgOpenY.Value;
_closedY = Plugin.CfgClosedY.Value;
}
public bool EnsureBound()
{
if ((Object)(object)_doorTf != (Object)null && ((Component)_doorTf).gameObject.activeInHierarchy)
{
return true;
}
Transform val = FindDoorTransform(Plugin.CfgRootHint.Value, Plugin.CfgParentName.Value, Plugin.CfgDoorName.Value);
if ((Object)(object)val == (Object)null)
{
Plugin.LogS.LogDebug((object)"[Empress] Door not found on demand. Check DoorFind names.");
return false;
}
_doorTf = val;
EnsureSolidCollider(_doorTf);
Plugin.EnsureRelayAttached(_doorTf, _openY, _closedY);
Plugin.LogS.LogDebug((object)$"[Empress] Bound door on demand. openY={_openY:F3} closedY={_closedY:F3} UseLocal={Plugin.CfgUseLocal.Value}");
return true;
}
public void NotifyClosed()
{
if (PhotonNetwork.IsMasterClient)
{
((MonoBehaviour)this).StartCoroutine(AutoOpenAfterDelay_Master());
}
}
[IteratorStateMachine(typeof(<AutoOpenAfterDelay_Master>d__8))]
private IEnumerator AutoOpenAfterDelay_Master()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AutoOpenAfterDelay_Master>d__8(0)
{
<>4__this = this
};
}
private Transform FindDoorTransform(string rootHint, string parentName, string doorName)
{
Transform val = null;
if (!string.IsNullOrWhiteSpace(rootHint))
{
GameObject val2 = GameObject.Find(rootHint);
if ((Object)(object)val2 != (Object)null)
{
val = val2.transform;
}
}
if ((Object)(object)val == (Object)null)
{
Transform[] array = Object.FindObjectsOfType<Transform>(true);
Transform[] array2 = array;
foreach (Transform val3 in array2)
{
if (((Object)val3).name.Equals(doorName, StringComparison.OrdinalIgnoreCase))
{
return val3;
}
}
Transform[] array3 = array;
foreach (Transform val4 in array3)
{
if (((Object)val4).name.Equals("TruckDoor", StringComparison.OrdinalIgnoreCase) || ((Object)val4).name.Equals("Truck_Door", StringComparison.OrdinalIgnoreCase))
{
return val4;
}
}
return null;
}
Transform val5 = val.FindRecursive(parentName);
if ((Object)(object)val5 != (Object)null)
{
Transform val6 = val5.Find(doorName);
if ((Object)(object)val6 != (Object)null)
{
return val6;
}
}
Transform val7 = val.FindRecursive(doorName);
if ((Object)(object)val7 != (Object)null)
{
return val7;
}
return null;
}
private void EnsureSolidCollider(Transform target)
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: 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)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)target == (Object)null)
{
return;
}
MeshRenderer[] componentsInChildren = ((Component)target).GetComponentsInChildren<MeshRenderer>(true);
if (componentsInChildren == null || componentsInChildren.Length == 0)
{
BoxCollider val = ((Component)target).gameObject.GetComponent<BoxCollider>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)target).gameObject.AddComponent<BoxCollider>();
}
((Collider)val).isTrigger = false;
val.center = Vector3.zero;
val.size = new Vector3(1f, 1f, 0.1f);
return;
}
Bounds bounds = ((Renderer)componentsInChildren[0]).bounds;
Vector3 center = ((Bounds)(ref bounds)).center;
bounds = ((Renderer)componentsInChildren[0]).bounds;
Bounds val2 = default(Bounds);
((Bounds)(ref val2))..ctor(center, ((Bounds)(ref bounds)).size);
for (int i = 1; i < componentsInChildren.Length; i++)
{
((Bounds)(ref val2)).Encapsulate(((Renderer)componentsInChildren[i]).bounds);
}
Vector3 center2 = target.InverseTransformPoint(((Bounds)(ref val2)).center);
Vector3 size = ((Bounds)(ref val2)).size;
Vector3 size2 = default(Vector3);
((Vector3)(ref size2))..ctor(Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(size.x, 0f, 0f)), Vector3.right)) + Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(0f, size.y, 0f)), Vector3.right)) + Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(0f, 0f, size.z)), Vector3.right)), Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(size.x, 0f, 0f)), Vector3.up)) + Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(0f, size.y, 0f)), Vector3.up)) + Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(0f, 0f, size.z)), Vector3.up)), Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(size.x, 0f, 0f)), Vector3.forward)) + Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(0f, size.y, 0f)), Vector3.forward)) + Mathf.Abs(Vector3.Dot(target.InverseTransformVector(new Vector3(0f, 0f, size.z)), Vector3.forward)));
BoxCollider val3 = ((Component)target).gameObject.GetComponent<BoxCollider>();
if ((Object)(object)val3 == (Object)null)
{
val3 = ((Component)target).gameObject.AddComponent<BoxCollider>();
}
((Collider)val3).isTrigger = false;
val3.center = center2;
val3.size = size2;
}
catch
{
}
}
}
[DisallowMultipleComponent]
public class ButtonActivator : MonoBehaviour
{
public float interactRange = 2f;
public string promptCloseBase = "to <b>close</b> truck door";
public string promptOpenBase = "to <b>open</b> truck door";
private DoorRuntime _rt;
private float _nextUseTime = 0f;
private float Cooldown => Mathf.Max(0f, Plugin.CfgButtonCooldown.Value);
private void Awake()
{
_rt = ((Component)this).GetComponent<DoorRuntime>();
if ((Object)(object)_rt == (Object)null)
{
_rt = ((Component)this).gameObject.AddComponent<DoorRuntime>();
}
}
private void Update()
{
//IL_0030: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GameDirector.instance == (Object)null)
{
return;
}
PlayerController instance = PlayerController.instance;
Vector3 position;
if ((Object)(object)instance != (Object)null)
{
position = ((Component)instance).transform.position;
}
else
{
if (!((Object)(object)Camera.main != (Object)null))
{
return;
}
position = ((Component)Camera.main).transform.position;
}
Transform val = (((Object)(object)Plugin.ButtonGO != (Object)null) ? Plugin.ButtonGO.transform : null);
if ((Object)(object)val == (Object)null || Vector3.Distance(position, val.position) > interactRange)
{
return;
}
string text = "<color=yellow>" + Plugin.ToggleKeyDisplay() + "</color>";
string text2 = "Press " + text + " " + promptCloseBase;
string text3 = "Press " + text + " " + promptOpenBase;
if (Plugin.CfgShowPrompt.Value)
{
AssetManager instance2 = AssetManager.instance;
Color val2 = (((Object)(object)instance2 != (Object)null) ? instance2.colorYellow : Color.yellow);
if (Time.time < _nextUseTime)
{
float num = Mathf.Max(0f, _nextUseTime - Time.time);
string text4 = $" <color=grey>(cooldown {num:0.0}s)</color>";
if (DoorEventHandler.IsDoorClosed)
{
SemiFunc.UIFocusText(text3 + text4, Color.white, val2, 3f);
}
else
{
SemiFunc.UIFocusText(text2 + text4, Color.white, val2, 3f);
}
}
else if (DoorEventHandler.IsDoorClosed)
{
SemiFunc.UIFocusText(text3, Color.white, val2, 3f);
}
else
{
SemiFunc.UIFocusText(text2, Color.white, val2, 3f);
}
}
if (!(Time.time < _nextUseTime) && Plugin.IsTogglePressed() && _rt.EnsureBound())
{
_nextUseTime = Time.time + Cooldown;
if (DoorEventHandler.IsDoorClosed)
{
DoorEventHandler.RequestOpen();
}
else
{
DoorEventHandler.RequestClose(force: true);
}
}
}
}
[DisallowMultipleComponent]
public class DoorEventHandler : MonoBehaviour, IOnEventCallback
{
[CompilerGenerated]
private sealed class <ButtonFXAndMove>d__20 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public bool close;
public DoorEventHandler <>4__this;
private Vector3 <p>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ButtonFXAndMove>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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_00b0: 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)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.FlashButtonAndBeep());
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
try
{
if ((Object)(object)Plugin.DoorClip != (Object)null)
{
<p>5__1 = (((Object)(object)Plugin.ButtonGO != (Object)null) ? Plugin.ButtonGO.transform.position : (((Object)(object)<>4__this._doorTf != (Object)null) ? <>4__this._doorTf.position : Vector3.zero));
AudioSource.PlayClipAtPoint(Plugin.DoorClip, <p>5__1, 1f);
}
}
catch
{
}
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
if (close)
{
<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.CloseRoutine());
<>1__state = 3;
return true;
}
<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.OpenRoutine());
<>1__state = 4;
return true;
case 3:
<>1__state = -1;
Plugin.HostGO.GetComponent<DoorRuntime>()?.NotifyClosed();
break;
case 4:
<>1__state = -1;
break;
}
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 <CloseRoutine>d__22 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DoorEventHandler <>4__this;
private DoorRuntime <rt>5__1;
private Transform <door>5__2;
private bool <local>5__3;
private float <dur>5__4;
private float <from>5__5;
private float <to>5__6;
private float <t>5__7;
private float <a>5__8;
private float <ny>5__9;
private Vector3 <lp>5__10;
private Vector3 <wp>5__11;
private Vector3 <lp>5__12;
private Vector3 <wp>5__13;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CloseRoutine>d__22(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<rt>5__1 = null;
<door>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<rt>5__1 = Plugin.HostGO.GetComponent<DoorRuntime>();
if ((Object)(object)<rt>5__1 == (Object)null || (Object)(object)<rt>5__1.DoorTransform == (Object)null)
{
return false;
}
<door>5__2 = <rt>5__1.DoorTransform;
IsDoorClosed = true;
<local>5__3 = Plugin.CfgUseLocal.Value;
<dur>5__4 = Mathf.Max(0.05f, Plugin.CfgCloseDuration.Value);
<from>5__5 = (<local>5__3 ? <door>5__2.localPosition.y : <door>5__2.position.y);
<to>5__6 = Plugin.CfgClosedY.Value;
<t>5__7 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<t>5__7 < <dur>5__4)
{
<t>5__7 += Time.deltaTime;
<a>5__8 = Mathf.Clamp01(<t>5__7 / <dur>5__4);
<ny>5__9 = Mathf.Lerp(<from>5__5, <to>5__6, <a>5__8);
if (<local>5__3)
{
<lp>5__10 = <door>5__2.localPosition;
<lp>5__10.y = <ny>5__9;
<door>5__2.localPosition = <lp>5__10;
}
else
{
<wp>5__11 = <door>5__2.position;
<wp>5__11.y = <ny>5__9;
<door>5__2.position = <wp>5__11;
}
<>2__current = null;
<>1__state = 1;
return true;
}
if (<local>5__3)
{
<lp>5__12 = <door>5__2.localPosition;
<lp>5__12.y = <to>5__6;
<door>5__2.localPosition = <lp>5__12;
}
else
{
<wp>5__13 = <door>5__2.position;
<wp>5__13.y = <to>5__6;
<door>5__2.position = <wp>5__13;
}
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 <EnsureBoundThenRun>d__19 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public bool close;
public DoorEventHandler <>4__this;
private float <timeout>5__1;
private float <t>5__2;
private DoorRuntime <rt>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnsureBoundThenRun>d__19(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<rt>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<timeout>5__1 = 2f;
<t>5__2 = 0f;
break;
case 1:
<>1__state = -1;
return false;
case 2:
<>1__state = -1;
<rt>5__3 = null;
break;
}
if (<t>5__2 < <timeout>5__1)
{
<rt>5__3 = (((Object)(object)Plugin.HostGO != (Object)null) ? Plugin.HostGO.GetComponent<DoorRuntime>() : null);
if ((Object)(object)<rt>5__3 != (Object)null && <rt>5__3.EnsureBound())
{
<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ButtonFXAndMove(close));
<>1__state = 1;
return true;
}
<t>5__2 += Time.deltaTime;
<>2__current = null;
<>1__state = 2;
return true;
}
Plugin.LogS.LogDebug((object)"[Empress] Door event received but door could not be bound in time.");
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 <FlashButtonAndBeep>d__21 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DoorEventHandler <>4__this;
private List<Renderer> <renderers>5__1;
private List<Color> <originals>5__2;
private List<Renderer>.Enumerator <>s__3;
private Renderer <r>5__4;
private Material <m>5__5;
private Color <c>5__6;
private int <i>5__7;
private Renderer <r>5__8;
private Material <m>5__9;
private Vector3 <p>5__10;
private int <i>5__11;
private Renderer <r>5__12;
private Material <m>5__13;
private Color <orig>5__14;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FlashButtonAndBeep>d__21(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<renderers>5__1 = null;
<originals>5__2 = null;
<>s__3 = default(List<Renderer>.Enumerator);
<r>5__4 = null;
<m>5__5 = null;
<r>5__8 = null;
<m>5__9 = null;
<r>5__12 = null;
<m>5__13 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Expected O, but got Unknown
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<renderers>5__1 = new List<Renderer>();
<originals>5__2 = new List<Color>();
if ((Object)(object)Plugin.ButtonGO != (Object)null)
{
Plugin.ButtonGO.GetComponentsInChildren<Renderer>(true, <renderers>5__1);
<>s__3 = <renderers>5__1.GetEnumerator();
try
{
while (<>s__3.MoveNext())
{
<r>5__4 = <>s__3.Current;
<m>5__5 = (((Object)(object)<r>5__4 != (Object)null) ? <r>5__4.material : null);
if ((Object)(object)<m>5__5 == (Object)null)
{
<originals>5__2.Add(Color.white);
continue;
}
<c>5__6 = Color.white;
if (<m>5__5.HasProperty("_BaseColor"))
{
<c>5__6 = <m>5__5.GetColor("_BaseColor");
}
else if (<m>5__5.HasProperty("_Color"))
{
<c>5__6 = <m>5__5.GetColor("_Color");
}
<originals>5__2.Add(<c>5__6);
<m>5__5 = null;
<r>5__4 = null;
}
}
finally
{
((IDisposable)<>s__3).Dispose();
}
<>s__3 = default(List<Renderer>.Enumerator);
}
<i>5__7 = 0;
while (<i>5__7 < <renderers>5__1.Count)
{
<r>5__8 = <renderers>5__1[<i>5__7];
if (!((Object)(object)<r>5__8 == (Object)null))
{
<m>5__9 = <r>5__8.material;
if (!((Object)(object)<m>5__9 == (Object)null))
{
if (<m>5__9.HasProperty("_BaseColor"))
{
<m>5__9.SetColor("_BaseColor", Color.green);
}
if (<m>5__9.HasProperty("_Color"))
{
<m>5__9.SetColor("_Color", Color.green);
}
<r>5__8 = null;
<m>5__9 = null;
}
}
<i>5__7++;
}
if ((Object)(object)Plugin.BeepClip != (Object)null)
{
try
{
<p>5__10 = (((Object)(object)Plugin.ButtonGO != (Object)null) ? Plugin.ButtonGO.transform.position : Vector3.zero);
AudioSource.PlayClipAtPoint(Plugin.BeepClip, <p>5__10, 0.9f);
}
catch
{
}
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<i>5__11 = 0;
while (<i>5__11 < <renderers>5__1.Count)
{
<r>5__12 = <renderers>5__1[<i>5__11];
if (!((Object)(object)<r>5__12 == (Object)null))
{
<m>5__13 = <r>5__12.material;
if (!((Object)(object)<m>5__13 == (Object)null))
{
<orig>5__14 = ((<i>5__11 < <originals>5__2.Count) ? <originals>5__2[<i>5__11] : Color.white);
if (<m>5__13.HasProperty("_BaseColor"))
{
<m>5__13.SetColor("_BaseColor", <orig>5__14);
}
if (<m>5__13.HasProperty("_Color"))
{
<m>5__13.SetColor("_Color", <orig>5__14);
}
<r>5__12 = null;
<m>5__13 = null;
}
}
<i>5__11++;
}
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 <OpenRoutine>d__23 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DoorEventHandler <>4__this;
private DoorRuntime <rt>5__1;
private Transform <door>5__2;
private bool <local>5__3;
private float <dur>5__4;
private float <from>5__5;
private float <to>5__6;
private float <t>5__7;
private float <a>5__8;
private float <ny>5__9;
private Vector3 <lp>5__10;
private Vector3 <wp>5__11;
private Vector3 <lp>5__12;
private Vector3 <wp>5__13;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OpenRoutine>d__23(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<rt>5__1 = null;
<door>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<rt>5__1 = Plugin.HostGO.GetComponent<DoorRuntime>();
if ((Object)(object)<rt>5__1 == (Object)null || (Object)(object)<rt>5__1.DoorTransform == (Object)null)
{
return false;
}
<door>5__2 = <rt>5__1.DoorTransform;
IsDoorClosed = false;
<local>5__3 = Plugin.CfgUseLocal.Value;
<dur>5__4 = Mathf.Max(0.05f, Plugin.CfgOpenDuration.Value);
<from>5__5 = (<local>5__3 ? <door>5__2.localPosition.y : <door>5__2.position.y);
<to>5__6 = Plugin.CfgOpenY.Value;
<t>5__7 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<t>5__7 < <dur>5__4)
{
<t>5__7 += Time.deltaTime;
<a>5__8 = Mathf.Clamp01(<t>5__7 / <dur>5__4);
<ny>5__9 = Mathf.Lerp(<from>5__5, <to>5__6, <a>5__8);
if (<local>5__3)
{
<lp>5__10 = <door>5__2.localPosition;
<lp>5__10.y = <ny>5__9;
<door>5__2.localPosition = <lp>5__10;
}
else
{
<wp>5__11 = <door>5__2.position;
<wp>5__11.y = <ny>5__9;
<door>5__2.position = <wp>5__11;
}
<>2__current = null;
<>1__state = 1;
return true;
}
if (<local>5__3)
{
<lp>5__12 = <door>5__2.localPosition;
<lp>5__12.y = <to>5__6;
<door>5__2.localPosition = <lp>5__12;
}
else
{
<wp>5__13 = <door>5__2.position;
<wp>5__13.y = <to>5__6;
<door>5__2.position = <wp>5__13;
}
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 static DoorEventHandler _inst;
private Transform _doorTf;
private float _openY;
private float _closedY;
private const byte DOOR_CLOSE_EVENT = 1;
private const byte DOOR_OPEN_EVENT = 2;
public static bool IsDoorClosed { get; private set; }
public static void Initialize()
{
if ((Object)(object)_inst != (Object)null)
{
PhotonNetwork.RemoveCallbackTarget((object)_inst);
PhotonNetwork.AddCallbackTarget((object)_inst);
Plugin.LogS.LogDebug((object)"[Empress] Event handler re-hooked to Photon after scene load.");
}
}
private void Awake()
{
_inst = this;
PhotonNetwork.AddCallbackTarget((object)this);
Plugin.LogS.LogDebug((object)"[Empress] Event handler ready.");
}
private void OnDestroy()
{
if ((Object)(object)_inst == (Object)(object)this)
{
PhotonNetwork.RemoveCallbackTarget((object)this);
_inst = null;
}
}
public void BindDoor(Transform doorTf, float openY, float closedY)
{
_doorTf = doorTf;
_openY = openY;
_closedY = closedY;
}
public static void RequestClose(bool force = false)
{
//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_0043: Expected O, but got Unknown
//IL_0045: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_005d: Expected O, but got Unknown
if ((Object)(object)_inst == (Object)null)
{
Plugin.LogS.LogDebug((object)"[Empress] DoorEventHandler not initialized.");
}
else if (PhotonNetwork.InRoom)
{
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"force", (object)force);
Hashtable val2 = val;
PhotonNetwork.RaiseEvent((byte)1, (object)val2, new RaiseEventOptions
{
Receivers = (ReceiverGroup)1
}, SendOptions.SendReliable);
}
else
{
_inst.HandleCloseEvent(force);
}
}
public static void RequestOpen()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
if ((Object)(object)_inst == (Object)null)
{
Plugin.LogS.LogDebug((object)"[Empress] DoorEventHandler not initialized.");
}
else if (PhotonNetwork.InRoom)
{
PhotonNetwork.RaiseEvent((byte)2, (object)null, new RaiseEventOptions
{
Receivers = (ReceiverGroup)1
}, SendOptions.SendReliable);
}
else
{
_inst.HandleOpenEvent();
}
}
public void OnEvent(EventData photonEvent)
{
try
{
switch (photonEvent.Code)
{
case 1:
{
bool force = false;
object customData = photonEvent.CustomData;
Hashtable val = (Hashtable)((customData is Hashtable) ? customData : null);
if (val != null && ((Dictionary<object, object>)(object)val).ContainsKey((object)"force"))
{
force = (bool)val[(object)"force"];
}
HandleCloseEvent(force);
break;
}
case 2:
HandleOpenEvent();
break;
}
}
catch (Exception arg)
{
Plugin.LogS.LogError((object)$"[Empress] Error handling door event: {arg}");
}
}
private void HandleCloseEvent(bool force = false)
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(EnsureBoundThenRun(close: true));
}
private void HandleOpenEvent()
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(EnsureBoundThenRun(close: false));
}
[IteratorStateMachine(typeof(<EnsureBoundThenRun>d__19))]
private IEnumerator EnsureBoundThenRun(bool close)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EnsureBoundThenRun>d__19(0)
{
<>4__this = this,
close = close
};
}
[IteratorStateMachine(typeof(<ButtonFXAndMove>d__20))]
private IEnumerator ButtonFXAndMove(bool close)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ButtonFXAndMove>d__20(0)
{
<>4__this = this,
close = close
};
}
[IteratorStateMachine(typeof(<FlashButtonAndBeep>d__21))]
private IEnumerator FlashButtonAndBeep()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FlashButtonAndBeep>d__21(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<CloseRoutine>d__22))]
private IEnumerator CloseRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CloseRoutine>d__22(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<OpenRoutine>d__23))]
private IEnumerator OpenRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OpenRoutine>d__23(0)
{
<>4__this = this
};
}
}
}