using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Extensions;
using HarmonyLib;
using Mirror;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ElevatorMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ElevatorMod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eafa11bc-f60d-47c5-b45f-3cb9e5bb4fee")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.elevatormod", "Elevator Mod", "1.4.2")]
public class ElevatorMod : BaseUnityPlugin
{
internal static ManualLogSource Log;
public static ConfigEntry<bool> ModEnabled;
public static ConfigEntry<bool> ShowStatusDisplay;
public static int LocalPlayerCurrentFloor;
private void Awake()
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the elevator mod.");
ShowStatusDisplay = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowStatusDisplay", true, "Show the READY/BUSY status display on screen.");
if (ShowStatusDisplay.Value)
{
GameObject val = new GameObject("ElevatorStatusDisplay");
val.AddComponent<ElevatorStatusDisplay>();
Object.DontDestroyOnLoad((Object)(object)val);
}
Harmony val2 = new Harmony("com.yourname.elevatormod");
val2.PatchAll();
Log.LogInfo((object)"ElevatorMod 1.4.2 loaded!");
}
}
public class ElevatorStatusDisplay : MonoBehaviour
{
private const float DISPLAY_DISTANCE = 15f;
private GUIStyle _boxStyle;
private GUIStyle _textStyle;
private bool _stylesInitialized = false;
private void InitStyles()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
if (!_stylesInitialized)
{
_boxStyle = new GUIStyle(GUI.skin.box);
_boxStyle.fontSize = 18;
_boxStyle.fontStyle = (FontStyle)1;
_boxStyle.alignment = (TextAnchor)4;
_textStyle = new GUIStyle(GUI.skin.label);
_textStyle.fontSize = 18;
_textStyle.fontStyle = (FontStyle)1;
_textStyle.alignment = (TextAnchor)4;
_stylesInitialized = true;
}
}
private void OnGUI()
{
//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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
if (!ElevatorMod.ModEnabled.Value || !ElevatorMod.ShowStatusDisplay.Value || !NetworkClient.active)
{
return;
}
ElevatorManager instance = NetworkSingleton<ElevatorManager>.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
NetworkIdentity localPlayer = NetworkClient.localPlayer;
if (!((Object)(object)localPlayer == (Object)null))
{
float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)instance).transform.position);
if (!(num > 15f))
{
bool isTeleporting = instance.isTeleporting;
InitStyles();
float num2 = 240f;
float num3 = 50f;
float num4 = (float)Screen.width / 2f - num2 / 2f;
float num5 = 20f;
Rect val = default(Rect);
((Rect)(ref val))..ctor(num4, num5, num2, num3);
Color backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = (isTeleporting ? new Color(0.8f, 0.1f, 0.1f, 0.85f) : new Color(0.1f, 0.7f, 0.1f, 0.85f));
GUI.Box(val, "", _boxStyle);
GUI.backgroundColor = backgroundColor;
_textStyle.normal.textColor = Color.white;
GUI.Label(val, isTeleporting ? "ELEVATOR — BUSY" : "ELEVATOR — READY", _textStyle);
}
}
}
}
[HarmonyPatch(typeof(ElevatorManager), "CheckPlayersInside")]
public class ElevatorCheckPatch
{
private static bool Prefix(ElevatorManager __instance, ref bool __result)
{
//IL_0064: 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_0074: Unknown result type (might be due to invalid IL or missing references)
if (!ElevatorMod.ModEnabled.Value)
{
return true;
}
Collider value = Traverse.Create((object)__instance).Field("checkCollider").GetValue<Collider>();
if ((Object)(object)value == (Object)null)
{
return true;
}
bool flag = false;
foreach (PlayerReferences player in MonoSingleton<LocalManager>.Instance.players)
{
Bounds bounds = value.bounds;
if (((Bounds)(ref bounds)).Contains(player.transform.position))
{
flag = true;
break;
}
}
__result = flag;
ElevatorMod.Log.LogDebug((object)$"ElevatorMod: CheckPlayersInside -> {__result}");
return false;
}
}
[HarmonyPatch(typeof(ElevatorManager), "ServerTeleportPlayersOutside")]
public class ElevatorTeleportPatch
{
private static bool Prefix(ElevatorManager __instance)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_00ba: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
if (!ElevatorMod.ModEnabled.Value)
{
return true;
}
Collider value = Traverse.Create((object)__instance).Field("checkCollider").GetValue<Collider>();
if ((Object)(object)value == (Object)null)
{
return true;
}
int num = 0;
int num2 = 0;
Vector3 val2 = default(Vector3);
foreach (PlayerReferences player in MonoSingleton<LocalManager>.Instance.players)
{
if (!((Item)player.carry).GetIsBeingHeld())
{
Bounds bounds = value.bounds;
if (((Bounds)(ref bounds)).Contains(player.transform.position))
{
Vector2 val = Random.insideUnitCircle * 3f;
((Vector3)(ref val2))..ctor(val.x, 0f, val.y);
Vector3 position = NetworkSingleton<ElevatorManager>.Instance.playerSpawnPosition.position;
player.controller.ServerTeleport(position + val2);
player.controller.ServerRotate(new Vector2(180f, 0f));
num++;
}
else
{
num2++;
}
}
}
ElevatorMod.Log.LogDebug((object)$"ElevatorMod: {num} player(s) travelled, {num2} player(s) stayed on their floor.");
return false;
}
}
[HarmonyPatch(typeof(ElevatorManager), "UserCode_RpcSetActiveFloorOnly__Int32")]
public class ElevatorFloorChangePatch
{
private static bool Prefix(ElevatorManager __instance, int index)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
if (!ElevatorMod.ModEnabled.Value)
{
return true;
}
Collider value = Traverse.Create((object)__instance).Field("checkCollider").GetValue<Collider>();
NetworkIdentity localPlayer = NetworkClient.localPlayer;
if ((Object)(object)value == (Object)null || (Object)(object)localPlayer == (Object)null)
{
return true;
}
bool flag = false;
Bounds bounds;
foreach (PlayerReferences player in MonoSingleton<LocalManager>.Instance.players)
{
bounds = value.bounds;
if (((Bounds)(ref bounds)).Contains(player.transform.position))
{
flag = true;
break;
}
}
if (!flag)
{
ElevatorMod.Log.LogDebug((object)$"ElevatorMod: No players in elevator — letting floor change to {index} run for everyone");
ElevatorMod.LocalPlayerCurrentFloor = index;
return true;
}
bounds = value.bounds;
if (((Bounds)(ref bounds)).Contains(((Component)localPlayer).transform.position))
{
ElevatorMod.Log.LogDebug((object)$"ElevatorMod: Local player IN elevator — applying floor change to {index}");
ElevatorMod.LocalPlayerCurrentFloor = index;
return true;
}
ElevatorMod.Log.LogDebug((object)$"ElevatorMod: Local player NOT in elevator — blocking floor change to {index}, re-enabling all floors");
List<CasinoFloor> value2 = Traverse.Create((object)__instance).Field("allFloors").GetValue<List<CasinoFloor>>();
if (value2 != null)
{
foreach (CasinoFloor item in value2)
{
((Component)item).gameObject.SetActive(true);
item.SetSfxTrigger(item.floorIndex == ElevatorMod.LocalPlayerCurrentFloor);
}
}
return false;
}
}