using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Burglary Box")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Burglary Box")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3ac34078-449b-4e47-99c6-c584ce3ea7cf")] [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("burglarybox", "Burglary Box", "0.3.3")] public sealed class BurglaryBoxPlugin : BaseUnityPlugin { internal static ConfigEntry SpawnMenuToggleKeyString; internal static KeyCode SpawnMenuToggleKey { get { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) try { return (KeyCode)Enum.Parse(typeof(KeyCode), SpawnMenuToggleKeyString.Value, ignoreCase: true); } catch { return (KeyCode)282; } } } private void Awake() { SpawnMenuToggleKeyString = ((BaseUnityPlugin)this).Config.Bind("Spawn Menu", "ToggleKey", "F1", "Change to open/close the spawn menu."); ((BaseUnityPlugin)this).Config.Save(); if (File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { File.WriteAllLines(((BaseUnityPlugin)this).Config.ConfigFilePath, from l in File.ReadAllLines(((BaseUnityPlugin)this).Config.ConfigFilePath) where !l.TrimStart(Array.Empty()).StartsWith("# Setting type:") && !l.TrimStart(Array.Empty()).StartsWith("# Default value:") && !l.TrimStart(Array.Empty()).StartsWith("# Acceptable values:") select l); } } private void OnGUI() { SpawnMenuController.OnGUI(); } } internal static class Spawner_Check { private const float CheckIntervalSeconds = 0.35f; private static float _nextCheckTime; private static GameObject _cachedPlayerPuppet; private static int _lastPlayerPuppetId; private static bool _pendingPlayerPuppetChanged; internal static bool CanOpenSpawner() { return (Object)(object)GetPlayerPuppet() != (Object)null; } internal static bool ConsumePlayerPuppetChanged() { UpdatePlayerPuppetState(); if (!_pendingPlayerPuppetChanged) { return false; } _pendingPlayerPuppetChanged = false; return true; } internal static GameObject GetPlayerPuppet() { UpdatePlayerPuppetState(); return _cachedPlayerPuppet; } private static void UpdatePlayerPuppetState() { if ((Object)(object)_cachedPlayerPuppet != (Object)null || Time.realtimeSinceStartup < _nextCheckTime) { return; } _nextCheckTime = Time.realtimeSinceStartup + 0.35f; GameObject val = FindPlayerPuppet(); if ((Object)(object)val == (Object)null) { if (_lastPlayerPuppetId != 0) { _lastPlayerPuppetId = 0; _pendingPlayerPuppetChanged = true; } _cachedPlayerPuppet = null; return; } int instanceID = ((Object)val).GetInstanceID(); _cachedPlayerPuppet = val; if (_lastPlayerPuppetId != instanceID) { _lastPlayerPuppetId = instanceID; _pendingPlayerPuppetChanged = true; } } private static GameObject FindPlayerPuppet() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("PlayerPuppet(Clone)"); if ((Object)(object)val != (Object)null) { return val; } Transform[] array = Resources.FindObjectsOfTypeAll(); foreach (Transform val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null)) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid() && string.Equals(((Object)val2).name, "PlayerPuppet(Clone)", StringComparison.Ordinal)) { return ((Component)val2).gameObject; } } } return null; } } internal static class SpawnMenuController { internal enum SpawnCategory { All, Resources, Items, Gear, Wearables } internal sealed class SpawnItemEntry { public ItemData Item; public string Name; public string DisplayName; public SpawnCategory Category; } private const float AutoRefreshSeconds = 5f; private const bool HostOnly = true; private const int MaxInventoryBatchAmount = 25; private const int MaxWorldSpawnBatchAmount = 50; private const float WorldDropDistance = 1.35f; internal static readonly List AllEntries = new List(); internal static readonly List VisibleEntries = new List(); private static bool _open; private static string _search = string.Empty; private static string _selectedItemName; private static float _nextAutoRefresh; private static int _amount = 1; private static SpawnCategory _category = SpawnCategory.All; private static AllItems _cachedAllItems; private static bool _needsRebuild = true; private static Component _uiLockedController; private static bool _uiLockApplied; private static bool _previousPlayerUiOpen; private static Type _controllerReflectionType; private static FieldInfo _playerIsUiOpenField; private static MethodInfo _refreshMouseStateMethod; private static MethodInfo _showCursorMethod; internal static bool IsOpen => _open; internal static int Amount => _amount; internal static string Search => _search ?? string.Empty; internal static SpawnCategory Category => _category; internal static string SelectedItemName => _selectedItemName; internal static void Toggle() { SetOpen(!_open); } internal static void SetOpen(bool value) { if ((!value || Spawner_Check.CanOpenSpawner()) && _open != value) { _open = value; if (_open) { _nextAutoRefresh = 0f; _needsRebuild = true; SetPlayerMenuLock(locked: true); SpawnMenuGameUI.Show(); RefreshItemsForUi(rebuildCache: true); } else { SpawnMenuGameUI.Hide(); SetPlayerMenuLock(locked: false); } } } internal static void OnGUI() { if (Spawner_Check.ConsumePlayerPuppetChanged()) { if (_open) { SetOpen(value: false); } else { SpawnMenuGameUI.Hide(); ClearPossibleStartupCameraLock(); } } HandleToggleEvent(); if (!_open) { ReleaseSpawnerPlayerLockIfNeeded(); return; } if (!Spawner_Check.CanOpenSpawner()) { SetOpen(value: false); return; } KeepCursorAndCameraReleased(); UpdateAutoRefresh(); SpawnMenuGameUI.Tick(); } internal static void ForceCloseAndRelease() { _open = false; SpawnMenuGameUI.Hide(); ReleaseSpawnerPlayerLockIfNeeded(); } internal static void SetSearch(string value) { value = value ?? string.Empty; if (!string.Equals(_search, value, StringComparison.Ordinal)) { _search = value; _needsRebuild = true; RefreshItemsForUi(rebuildCache: false); } } internal static void SetAmount(int value) { _amount = ClampSpawnAmount(value); SpawnMenuGameUI.RefreshStaticState(); } internal static void SetCategory(SpawnCategory category) { if (_category != category) { _category = category; _needsRebuild = true; RefreshItemsForUi(rebuildCache: false); } } internal static void SelectItem(string itemName) { _selectedItemName = itemName; SpawnMenuGameUI.RefreshSelection(); } internal static void AddSelectedItemToInventory() { AddItemToInventory(GetSelectedEntry()); } internal static void DropSelectedItemInWorld() { DropItemInWorld(GetSelectedEntry()); } private static void HandleToggleEvent() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current != null && (int)current.type == 4 && current.keyCode == BurglaryBoxPlugin.SpawnMenuToggleKey) { Toggle(); current.Use(); } } private static void UpdateAutoRefresh() { float realtimeSinceStartup = Time.realtimeSinceStartup; if (_nextAutoRefresh <= 0f || realtimeSinceStartup >= _nextAutoRefresh) { _needsRebuild = true; _nextAutoRefresh = realtimeSinceStartup + 5f; RefreshItemsForUi(rebuildCache: true); } } private static void RefreshItemsForUi(bool rebuildCache) { if (rebuildCache) { _needsRebuild = true; } EnsureItemCache(); ApplyFilterIfNeeded(); SpawnMenuGameUI.RebuildItems(); } private static SpawnItemEntry GetSelectedEntry() { if (string.IsNullOrEmpty(_selectedItemName)) { return null; } for (int i = 0; i < AllEntries.Count; i++) { if (string.Equals(AllEntries[i].Name, _selectedItemName, StringComparison.Ordinal)) { return AllEntries[i]; } } return null; } private static void AddItemToInventory(SpawnItemEntry entry) { if (!CanSpawnNow(out var _, out var inventory, out var _) || entry == null || (Object)(object)entry.Item == (Object)null || string.IsNullOrEmpty(entry.Name)) { return; } int num = ClampSpawnAmount(_amount); for (int i = 0; i < num; i++) { if (!((InventoryBase)inventory).TryAddItem(entry.Name, 1)) { break; } } } private static void DropItemInWorld(SpawnItemEntry entry) { //IL_0079: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00a2: 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_00ac: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if (!CanSpawnNow(out var player, out var inventory, out var _) || entry == null || (Object)(object)entry.Item == (Object)null || string.IsNullOrEmpty(entry.Name)) { return; } AllItems boundItems = ((InventoryBase)inventory).BoundItems; if ((Object)(object)boundItems == (Object)null) { return; } int num = Mathf.Min(ClampSpawnAmount(_amount), 50); Vector3 val = ((Component)player).transform.position + ((Component)player).transform.forward * 1.35f + Vector3.up * 0.35f; Vector3 val2 = default(Vector3); for (int i = 0; i < num; i++) { try { float num2 = (float)(i % 16) * (float)Math.PI * 2f / 16f; float num3 = 0.12f + 0.11f * (float)(i / 16); ((Vector3)(ref val2))..ctor(Mathf.Cos(num2) * num3, 0f, Mathf.Sin(num2) * num3); boundItems.SpawnItemInstance(entry.Name, val + val2); } catch { break; } } } private static bool CanSpawnNow(out PlayerNetworking player, out PlayerInventory inventory, out string reason) { player = null; inventory = null; reason = null; NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { reason = "Load into a lobby/game first."; return false; } player = ServerManager.GetLocalPlayer(); if ((Object)(object)player == (Object)null) { reason = "No local player found yet."; return false; } inventory = player.Inventory; if ((Object)(object)inventory == (Object)null) { reason = "Local player inventory is missing."; return false; } if (!singleton.IsServer) { reason = "Host only."; return false; } if (!((NetworkBehaviour)inventory).IsServer) { reason = "Inventory is not server-owned on this machine."; return false; } return true; } internal static string GetHostSteamName() { try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return "OFFLINE"; } PlayerNetworking val = ((!singleton.IsServer) ? ServerManager.GetPlayer(0uL) : ServerManager.GetLocalPlayer()); if ((Object)(object)val == (Object)null) { return "UNKNOWN"; } SteamPlayer componentInChildren = ((Component)val).GetComponentInChildren(); string text = default(string); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.TryGetName(ref text) && !string.IsNullOrWhiteSpace(text)) { return text; } return string.IsNullOrWhiteSpace(((Object)val).name) ? "HOST" : ((Object)val).name; } catch { return "UNKNOWN"; } } private static void EnsureItemCache() { PlayerInventory val = null; AllItems val2 = null; try { if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening) { PlayerNetworking localPlayer = ServerManager.GetLocalPlayer(); val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.Inventory : null); val2 = (((Object)(object)val != (Object)null) ? ((InventoryBase)val).BoundItems : null); } } catch { val2 = null; } if (!_needsRebuild && (Object)(object)val2 == (Object)(object)_cachedAllItems) { return; } _cachedAllItems = val2; AllEntries.Clear(); if ((Object)(object)val2 != (Object)null && val2.items != null) { for (int i = 0; i < val2.items.Length; i++) { ItemData val3 = val2.items[i]; if (!((Object)(object)val3 == (Object)null)) { string text = SafeItemName(val3); if (!string.IsNullOrEmpty(text)) { AllEntries.Add(new SpawnItemEntry { Item = val3, Name = text, DisplayName = SafeDisplayName(val3, text), Category = ClassifyItem(val3, text) }); } } } AllEntries.Sort((SpawnItemEntry a, SpawnItemEntry b) => string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase)); } _needsRebuild = true; } private static void ApplyFilterIfNeeded() { if (!_needsRebuild) { return; } _needsRebuild = false; VisibleEntries.Clear(); string text = (_search ?? string.Empty).Trim(); for (int i = 0; i < AllEntries.Count; i++) { SpawnItemEntry spawnItemEntry = AllEntries[i]; if ((_category == SpawnCategory.All || spawnItemEntry.Category == _category) && (string.IsNullOrEmpty(text) || ContainsIgnoreCase(spawnItemEntry.Name, text) || ContainsIgnoreCase(spawnItemEntry.DisplayName, text))) { VisibleEntries.Add(spawnItemEntry); } } bool flag = false; if (!string.IsNullOrEmpty(_selectedItemName)) { for (int j = 0; j < VisibleEntries.Count; j++) { if (string.Equals(VisibleEntries[j].Name, _selectedItemName, StringComparison.Ordinal)) { flag = true; break; } } } if (!flag) { _selectedItemName = ((VisibleEntries.Count > 0) ? VisibleEntries[0].Name : null); } } private static SpawnCategory ClassifyItem(ItemData item, string name) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 int num = default(int); if (ResourceStorage.TryGetItemEntry(name, ref num)) { return SpawnCategory.Resources; } if ((int)item.equipmentType == 1) { return SpawnCategory.Gear; } if ((int)item.equipmentType == 2) { return SpawnCategory.Wearables; } return SpawnCategory.Items; } private static string SafeItemName(ItemData item) { try { return ((CraftableItemBase)item).Name; } catch { return ((Object)(object)item != (Object)null) ? ((Object)item).name : string.Empty; } } private static string SafeDisplayName(ItemData item, string fallback) { try { string localizedName = ((CraftableItemBase)item).LocalizedName; if (!string.IsNullOrEmpty(localizedName)) { return localizedName; } } catch { } return NicifyName(fallback); } private static string NicifyName(string value) { if (string.IsNullOrEmpty(value)) { return "Unnamed Item"; } return value.Replace('_', ' ').Replace('-', ' ').Trim(); } private static bool ContainsIgnoreCase(string source, string search) { return !string.IsNullOrEmpty(source) && source.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0; } private static int ClampSpawnAmount(int value) { return Mathf.Clamp(value, 1, 25); } private static void KeepCursorAndCameraReleased() { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; if (!_uiLockApplied) { SetPlayerMenuLock(locked: true); } else if ((Object)(object)_uiLockedController != (Object)null) { SetPlayerUiOpen(_uiLockedController, value: true); InvokeRefreshMouseState(_uiLockedController); InvokeShowCursor(_uiLockedController, show: true); } } private static void ReleaseSpawnerPlayerLockIfNeeded() { if (_uiLockApplied) { SetPlayerMenuLock(locked: false); } } private static void ClearPossibleStartupCameraLock() { Component localControllerComponent = GetLocalControllerComponent(); _uiLockedController = null; _uiLockApplied = false; _previousPlayerUiOpen = false; if (!((Object)(object)localControllerComponent == (Object)null)) { SetPlayerUiOpen(localControllerComponent, value: false); InvokeRefreshMouseState(localControllerComponent); InvokeShowCursor(localControllerComponent, show: false); Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } private static void SetPlayerMenuLock(bool locked) { Component localControllerComponent = GetLocalControllerComponent(); if (locked) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; if (!((Object)(object)localControllerComponent == (Object)null)) { CacheControllerReflection(localControllerComponent); if (!_uiLockApplied || (Object)(object)_uiLockedController != (Object)(object)localControllerComponent) { _uiLockedController = localControllerComponent; _previousPlayerUiOpen = GetPlayerUiOpen(localControllerComponent); _uiLockApplied = true; } SetPlayerUiOpen(localControllerComponent, value: true); InvokeRefreshMouseState(localControllerComponent); InvokeShowCursor(localControllerComponent, show: true); } return; } Component val = (((Object)(object)_uiLockedController != (Object)null) ? _uiLockedController : localControllerComponent); bool flag = !_previousPlayerUiOpen; if ((Object)(object)val != (Object)null && _uiLockApplied) { CacheControllerReflection(val); SetPlayerUiOpen(val, _previousPlayerUiOpen); InvokeRefreshMouseState(val); if (flag) { InvokeShowCursor(val, show: false); } } _uiLockedController = null; _uiLockApplied = false; _previousPlayerUiOpen = false; if ((Object)(object)val == (Object)null || flag) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } private static Component GetLocalControllerComponent() { try { if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return null; } PlayerNetworking localPlayer = ServerManager.GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { return null; } Component component = ((Component)localPlayer).GetComponent("PlayerController"); if ((Object)(object)component != (Object)null) { return component; } MonoBehaviour[] componentsInChildren = ((Component)localPlayer).GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "PlayerController") { return (Component)(object)val; } } } catch { } return null; } private static void CacheControllerReflection(Component controller) { if (!((Object)(object)controller == (Object)null)) { Type type = ((object)controller).GetType(); if (!(_controllerReflectionType == type)) { _controllerReflectionType = type; _playerIsUiOpenField = type.GetField("isUiOpen", BindingFlags.Instance | BindingFlags.NonPublic); _refreshMouseStateMethod = type.GetMethod("RefreshMouseState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _showCursorMethod = type.GetMethod("ShowCursor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null); } } } private static bool GetPlayerUiOpen(Component controller) { try { CacheControllerReflection(controller); return _playerIsUiOpenField != null && (bool)_playerIsUiOpenField.GetValue(controller); } catch { return false; } } private static void SetPlayerUiOpen(Component controller, bool value) { try { CacheControllerReflection(controller); if (_playerIsUiOpenField != null) { _playerIsUiOpenField.SetValue(controller, value); } } catch { } } private static void InvokeRefreshMouseState(Component controller) { try { CacheControllerReflection(controller); if (_refreshMouseStateMethod != null) { _refreshMouseStateMethod.Invoke(controller, null); } } catch { } } private static void InvokeShowCursor(Component controller, bool show) { try { CacheControllerReflection(controller); if (_showCursorMethod != null) { _showCursorMethod.Invoke(controller, new object[1] { show }); } else { Cursor.visible = show; Cursor.lockState = (CursorLockMode)(!show); } } catch { Cursor.visible = show; Cursor.lockState = (CursorLockMode)(!show); } } } internal static class SpawnMenuGameUI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__36_0; public static UnityAction <>9__37_0; public static UnityAction <>9__37_1; public static UnityAction <>9__42_0; internal void b__36_0() { if ((Object)(object)_searchInput != (Object)null) { _searchInput.text = string.Empty; } SpawnMenuController.SetSearch(string.Empty); } internal void b__37_0(string value) { if (int.TryParse(value, out var result)) { SpawnMenuController.SetAmount(result); } } internal void b__37_1(string value) { if (!int.TryParse(value, out var result) || result < 1) { result = 1; } SpawnMenuController.SetAmount(result); if ((Object)(object)_amountInput != (Object)null) { _amountInput.SetTextWithoutNotify(SpawnMenuController.Amount.ToString()); } } internal void b__42_0() { SpawnMenuController.SetOpen(value: false); } } private const float WindowWidth = 760f; private const float WindowHeight = 590f; private const float ItemButtonWidth = 146f; private const float ItemButtonHeight = 44f; private static readonly List