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<string> 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<string>("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<char>()).StartsWith("# Setting type:") && !l.TrimStart(Array.Empty<char>()).StartsWith("# Default value:") && !l.TrimStart(Array.Empty<char>()).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<Transform>();
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<SpawnItemEntry> AllEntries = new List<SpawnItemEntry>();
internal static readonly List<SpawnItemEntry> VisibleEntries = new List<SpawnItemEntry>();
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<SteamPlayer>();
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<MonoBehaviour>(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<string> <>9__37_0;
public static UnityAction<string> <>9__37_1;
public static UnityAction <>9__42_0;
internal void <BuildSearchRow>b__36_0()
{
if ((Object)(object)_searchInput != (Object)null)
{
_searchInput.text = string.Empty;
}
SpawnMenuController.SetSearch(string.Empty);
}
internal void <BuildAmountRow>b__37_0(string value)
{
if (int.TryParse(value, out var result))
{
SpawnMenuController.SetAmount(result);
}
}
internal void <BuildAmountRow>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 <BuildFooter>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<Button> AmountButtons = new List<Button>();
private static readonly List<Button> CategoryButtons = new List<Button>();
private static readonly List<Button> ItemButtons = new List<Button>();
private static readonly Dictionary<Button, int> AmountByButton = new Dictionary<Button, int>();
private static readonly Dictionary<Button, SpawnMenuController.SpawnCategory> CategoryByButton = new Dictionary<Button, SpawnMenuController.SpawnCategory>();
private static readonly Dictionary<Button, string> ItemNameByButton = new Dictionary<Button, string>();
private static GameObject _rootObject;
private static RectTransform _rootRect;
private static RectTransform _contentRoot;
private static GameObject _buttonTemplateFooter;
private static GameObject _buttonTemplateMain;
private static Transform _itemContent;
private static TMP_InputField _searchInput;
private static TMP_InputField _amountInput;
private static Button _addButton;
private static Button _dropButton;
private static bool _built;
private static bool _pendingRebuild;
private static TMP_FontAsset _fontAsset;
private static Material _fontMaterial;
internal static void Show()
{
EnsureBuilt();
if ((Object)(object)_rootObject != (Object)null)
{
_rootObject.SetActive(true);
}
RefreshStaticState();
RebuildItems();
}
internal static void Hide()
{
if ((Object)(object)_rootObject != (Object)null)
{
_rootObject.SetActive(false);
}
}
internal static void Tick()
{
if (!_built || (Object)(object)_rootObject == (Object)null)
{
EnsureBuilt();
}
else if (_pendingRebuild)
{
_pendingRebuild = false;
RebuildItemsNow();
}
}
internal static void RebuildItems()
{
if (!_built || (Object)(object)_rootObject == (Object)null)
{
_pendingRebuild = true;
}
else
{
RebuildItemsNow();
}
}
internal static void RefreshStaticState()
{
if (!_built)
{
return;
}
for (int i = 0; i < AmountButtons.Count; i++)
{
Button val = AmountButtons[i];
if ((Object)(object)val != (Object)null && AmountByButton.TryGetValue(val, out var value))
{
SetButtonSelected(val, value == SpawnMenuController.Amount);
}
}
for (int j = 0; j < CategoryButtons.Count; j++)
{
Button val2 = CategoryButtons[j];
if ((Object)(object)val2 != (Object)null && CategoryByButton.TryGetValue(val2, out var value2))
{
SetButtonSelected(val2, value2 == SpawnMenuController.Category);
}
}
if ((Object)(object)_searchInput != (Object)null && !string.Equals(_searchInput.text, SpawnMenuController.Search, StringComparison.Ordinal))
{
_searchInput.SetTextWithoutNotify(SpawnMenuController.Search);
}
if ((Object)(object)_amountInput != (Object)null)
{
string text = SpawnMenuController.Amount.ToString();
if (!string.Equals(_amountInput.text, text, StringComparison.Ordinal))
{
_amountInput.SetTextWithoutNotify(text);
}
}
RefreshSelection();
}
internal static void RefreshSelection()
{
if (!_built)
{
return;
}
for (int i = 0; i < ItemButtons.Count; i++)
{
Button val = ItemButtons[i];
if ((Object)(object)val != (Object)null && ItemNameByButton.TryGetValue(val, out var value))
{
SetButtonSelected(val, string.Equals(value, SpawnMenuController.SelectedItemName, StringComparison.Ordinal));
}
}
}
private static void EnsureBuilt()
{
if ((!_built || !((Object)(object)_rootObject != (Object)null)) && Spawner_Check.CanOpenSpawner())
{
ClearCachedUi();
_buttonTemplateFooter = FindSceneObject("Canvas/Settings/BUttons/SGButtonPrimaryUGUI (save) (1)", "SGButtonPrimaryUGUI (save) (1)", "BUttons");
_buttonTemplateMain = FindSceneObject("Canvas/Settings/BUttons/SGButtonPrimaryUGUI (save) (2)", "SGButtonPrimaryUGUI (save) (2)", "BUttons");
GameObject val = FindSettingsBackgroundImage();
if ((Object)(object)val == (Object)null)
{
CreateFallbackRoot();
}
else
{
CreateSettingsBackgroundRoot(val);
}
CacheTextTemplate();
BuildContent();
_built = (Object)(object)_rootObject != (Object)null;
if ((Object)(object)_rootObject != (Object)null)
{
_rootObject.SetActive(false);
}
}
}
private static void CreateSettingsBackgroundRoot(GameObject backgroundTemplate)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_00a0: 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_00d4: 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_0108: 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_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: 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_018f: Unknown result type (might be due to invalid IL or missing references)
Transform val = GetCanvasParent(backgroundTemplate.transform);
if ((Object)(object)val == (Object)null)
{
val = backgroundTemplate.transform.parent;
}
_rootObject = new GameObject("Spawner Menu", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image)
});
_rootObject.transform.SetParent(val, false);
_rootObject.SetActive(true);
_rootRect = _rootObject.GetComponent<RectTransform>();
_rootRect.anchorMin = new Vector2(1f, 0.5f);
_rootRect.anchorMax = new Vector2(1f, 0.5f);
_rootRect.pivot = new Vector2(1f, 0.5f);
_rootRect.anchoredPosition = new Vector2(-70f, 0f);
_rootRect.sizeDelta = new Vector2(760f, 590f);
((Transform)_rootRect).localScale = Vector3.one;
Image component = _rootObject.GetComponent<Image>();
Image component2 = backgroundTemplate.GetComponent<Image>();
if ((Object)(object)component2 != (Object)null)
{
CopyImageVisual(component2, component);
}
else
{
((Graphic)component).color = new Color(0.27f, 0.17f, 0.1f, 0.96f);
}
Color color = ((Graphic)component).color;
color.a = Mathf.Max(color.a, 0.96f);
((Graphic)component).color = color;
((Graphic)component).raycastTarget = false;
}
private static void CreateFallbackRoot()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: 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)
GameObject val = new GameObject("Spawner Canvas", new Type[4]
{
typeof(RectTransform),
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
});
Canvas component = val.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
component.sortingOrder = 9999;
CanvasScaler component2 = val.GetComponent<CanvasScaler>();
component2.uiScaleMode = (ScaleMode)1;
component2.referenceResolution = new Vector2(1920f, 1080f);
_rootObject = new GameObject("Spawner Menu", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image)
});
_rootObject.transform.SetParent(val.transform, false);
_rootRect = _rootObject.GetComponent<RectTransform>();
_rootRect.anchorMin = new Vector2(1f, 0.5f);
_rootRect.anchorMax = new Vector2(1f, 0.5f);
_rootRect.pivot = new Vector2(1f, 0.5f);
_rootRect.anchoredPosition = new Vector2(-70f, 0f);
_rootRect.sizeDelta = new Vector2(760f, 590f);
((Graphic)_rootObject.GetComponent<Image>()).color = new Color(0.27f, 0.17f, 0.1f, 0.96f);
}
private static void BuildContent()
{
//IL_003e: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_rootObject == (Object)null))
{
_contentRoot = CreateRect("Spawner Content", _rootObject.transform);
_contentRoot.anchorMin = new Vector2(0f, 0f);
_contentRoot.anchorMax = new Vector2(1f, 1f);
_contentRoot.offsetMin = new Vector2(52f, 42f);
_contentRoot.offsetMax = new Vector2(-52f, -44f);
BuildButtonSectionPanel();
BuildTitleRow();
BuildSearchRow();
BuildAmountRow();
BuildCategoryRow();
BuildItemScroll();
BuildActionButtons();
BuildFooter();
RefreshStaticState();
}
}
private static void BuildButtonSectionPanel()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect("Button Section", (Transform)(object)_contentRoot);
SetTopLeft(val, 10f, 188f, 636f, 246f);
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0.5f, 0.5f, 0.5f, 0.3f);
((Graphic)val2).raycastTarget = false;
((Transform)val).SetAsFirstSibling();
}
private static void BuildTitleRow()
{
TextMeshProUGUI val = CreateText("Title", (Transform)(object)_contentRoot, "Burglary Box", 24, (TextAlignmentOptions)4097);
RectTransform rectTransform = ((TMP_Text)val).rectTransform;
SetTopLeft(rectTransform, 0f, 14f, 320f, 40f);
TextMeshProUGUI val2 = CreateText("Host", (Transform)(object)_contentRoot, "HOST ONLY", 14, (TextAlignmentOptions)4100);
RectTransform rectTransform2 = ((TMP_Text)val2).rectTransform;
SetTopLeft(rectTransform2, 280f, 10f, 352f, 32f);
}
private static void BuildSearchRow()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_00aa: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: 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_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: 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_01e3: Expected O, but got Unknown
RectTransform val = CreateRect("Search", (Transform)(object)_contentRoot);
SetTopLeft(val, 0f, 52f, 420f, 38f);
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(1f, 1f, 1f, 0.14f);
TMP_InputField val3 = ((Component)val).gameObject.AddComponent<TMP_InputField>();
TextMeshProUGUI val4 = CreateText("Text", (Transform)(object)val, string.Empty, 14, (TextAlignmentOptions)4097);
RectTransform rectTransform = ((TMP_Text)val4).rectTransform;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.offsetMin = new Vector2(12f, 0f);
rectTransform.offsetMax = new Vector2(-12f, 0f);
TextMeshProUGUI val5 = CreateText("Placeholder", (Transform)(object)val, "Search", 14, (TextAlignmentOptions)4097);
((Graphic)val5).color = new Color(1f, 1f, 1f, 0.45f);
RectTransform rectTransform2 = ((TMP_Text)val5).rectTransform;
rectTransform2.anchorMin = Vector2.zero;
rectTransform2.anchorMax = Vector2.one;
rectTransform2.offsetMin = new Vector2(12f, 0f);
rectTransform2.offsetMax = new Vector2(-12f, 0f);
val3.textComponent = (TMP_Text)(object)val4;
val3.placeholder = (Graphic)(object)val5;
((UnityEventBase)val3.onValueChanged).RemoveAllListeners();
((UnityEvent<string>)(object)val3.onValueChanged).AddListener((UnityAction<string>)SpawnMenuController.SetSearch);
_searchInput = val3;
Button val6 = CreateButton("Clear", (Transform)(object)_contentRoot, 432f, 52f, 92f, 38f, "Clear", footerTemplate: false);
ButtonClickedEvent onClick = val6.onClick;
object obj = <>c.<>9__36_0;
if (obj == null)
{
UnityAction val7 = delegate
{
if ((Object)(object)_searchInput != (Object)null)
{
_searchInput.text = string.Empty;
}
SpawnMenuController.SetSearch(string.Empty);
};
<>c.<>9__36_0 = val7;
obj = (object)val7;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
}
private static void BuildAmountRow()
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: 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_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = CreateText("Amount Label", (Transform)(object)_contentRoot, "Amount", 13, (TextAlignmentOptions)4097);
SetTopLeft(((TMP_Text)val).rectTransform, 0f, 100f, 78f, 34f);
RectTransform val2 = CreateRect("Amount Input", (Transform)(object)_contentRoot);
SetTopLeft(val2, 86f, 100f, 92f, 34f);
Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
((Graphic)val3).color = new Color(1f, 1f, 1f, 0.14f);
TMP_InputField val4 = ((Component)val2).gameObject.AddComponent<TMP_InputField>();
val4.contentType = (ContentType)2;
val4.characterLimit = 3;
TextMeshProUGUI val5 = CreateText("Text", (Transform)(object)val2, string.Empty, 13, (TextAlignmentOptions)514);
RectTransform rectTransform = ((TMP_Text)val5).rectTransform;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.offsetMin = new Vector2(8f, 0f);
rectTransform.offsetMax = new Vector2(-8f, 0f);
TextMeshProUGUI val6 = CreateText("Placeholder", (Transform)(object)val2, "1", 13, (TextAlignmentOptions)514);
((Graphic)val6).color = new Color(1f, 1f, 1f, 0.45f);
RectTransform rectTransform2 = ((TMP_Text)val6).rectTransform;
rectTransform2.anchorMin = Vector2.zero;
rectTransform2.anchorMax = Vector2.one;
rectTransform2.offsetMin = new Vector2(8f, 0f);
rectTransform2.offsetMax = new Vector2(-8f, 0f);
val4.textComponent = (TMP_Text)(object)val5;
val4.placeholder = (Graphic)(object)val6;
val4.SetTextWithoutNotify(SpawnMenuController.Amount.ToString());
((UnityEventBase)val4.onValueChanged).RemoveAllListeners();
((UnityEvent<string>)(object)val4.onValueChanged).AddListener((UnityAction<string>)delegate(string value)
{
if (int.TryParse(value, out var result))
{
SpawnMenuController.SetAmount(result);
}
});
((UnityEventBase)val4.onEndEdit).RemoveAllListeners();
((UnityEvent<string>)(object)val4.onEndEdit).AddListener((UnityAction<string>)delegate(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());
}
});
_amountInput = val4;
}
private static void BuildCategoryRow()
{
AddCategoryButton(SpawnMenuController.SpawnCategory.All, "All", 0f);
AddCategoryButton(SpawnMenuController.SpawnCategory.Resources, "Resources", 132f);
AddCategoryButton(SpawnMenuController.SpawnCategory.Items, "Items", 264f);
AddCategoryButton(SpawnMenuController.SpawnCategory.Gear, "Gear", 396f);
AddCategoryButton(SpawnMenuController.SpawnCategory.Wearables, "Wearables", 528f);
}
private static void AddCategoryButton(SpawnMenuController.SpawnCategory category, string label, float x)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
Button val = CreateButton(label, (Transform)(object)_contentRoot, x, 144f, 124f, 38f, label, footerTemplate: false);
((UnityEvent)val.onClick).AddListener((UnityAction)delegate
{
SpawnMenuController.SetCategory(category);
});
CategoryButtons.Add(val);
CategoryByButton[val] = category;
}
private static void BuildItemScroll()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_0085: 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_00e1: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect("Items", (Transform)(object)_contentRoot);
SetTopLeft(val, 0f, 196f, 656f, 224f);
ScrollRect val2 = ((Component)val).gameObject.AddComponent<ScrollRect>();
val2.horizontal = false;
val2.vertical = true;
val2.scrollSensitivity = 24f;
RectTransform val3 = CreateRect("Viewport", (Transform)(object)val);
val3.anchorMin = Vector2.zero;
val3.anchorMax = Vector2.one;
val3.offsetMin = Vector2.zero;
val3.offsetMax = Vector2.zero;
Image val4 = ((Component)val3).gameObject.AddComponent<Image>();
((Graphic)val4).color = new Color(0f, 0f, 0f, 0.01f);
((Component)val3).gameObject.AddComponent<RectMask2D>();
RectTransform val5 = CreateRect("Content", (Transform)(object)val3);
val5.anchorMin = new Vector2(0f, 1f);
val5.anchorMax = new Vector2(1f, 1f);
val5.pivot = new Vector2(0.5f, 1f);
val5.anchoredPosition = Vector2.zero;
val5.sizeDelta = new Vector2(0f, 0f);
GridLayoutGroup val6 = ((Component)val5).gameObject.AddComponent<GridLayoutGroup>();
val6.cellSize = new Vector2(146f, 44f);
val6.spacing = new Vector2(8f, 10f);
((LayoutGroup)val6).childAlignment = (TextAnchor)1;
val6.constraint = (Constraint)1;
val6.constraintCount = 4;
ContentSizeFitter val7 = ((Component)val5).gameObject.AddComponent<ContentSizeFitter>();
val7.verticalFit = (FitMode)2;
val2.viewport = val3;
val2.content = val5;
_itemContent = (Transform)(object)val5;
}
private static void BuildActionButtons()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Expected O, but got Unknown
_addButton = CreateButton("Add", (Transform)(object)_contentRoot, 166f, 456f, 178f, 38f, "Add to Inventory", footerTemplate: false);
((UnityEvent)_addButton.onClick).AddListener(new UnityAction(SpawnMenuController.AddSelectedItemToInventory));
_dropButton = CreateButton("Drop", (Transform)(object)_contentRoot, 350f, 456f, 178f, 38f, "Drop in World", footerTemplate: false);
((UnityEvent)_dropButton.onClick).AddListener(new UnityAction(SpawnMenuController.DropSelectedItemInWorld));
}
private static void BuildFooter()
{
//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_0050: Expected O, but got Unknown
Button val = CreateButton("Close", (Transform)(object)_contentRoot, 0f, 456f, 112f, 38f, "Close", footerTemplate: true);
ButtonClickedEvent onClick = val.onClick;
object obj = <>c.<>9__42_0;
if (obj == null)
{
UnityAction val2 = delegate
{
SpawnMenuController.SetOpen(value: false);
};
<>c.<>9__42_0 = val2;
obj = (object)val2;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
GameObject val3 = CreateButtonVisual("Tag", (Transform)(object)_contentRoot, 544f, 456f, 112f, 38f, "@NoS6X", footerTemplate: true);
Button component = val3.GetComponent<Button>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
}
private static void RebuildItemsNow()
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
if ((Object)(object)_itemContent == (Object)null)
{
return;
}
for (int num = _itemContent.childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)_itemContent.GetChild(num)).gameObject);
}
ItemButtons.Clear();
ItemNameByButton.Clear();
for (int i = 0; i < SpawnMenuController.VisibleEntries.Count; i++)
{
SpawnMenuController.SpawnItemEntry spawnItemEntry = SpawnMenuController.VisibleEntries[i];
Button val = CreateButton(spawnItemEntry.Name, _itemContent, 0f, 0f, 146f, 44f, spawnItemEntry.DisplayName, footerTemplate: false);
string itemName = spawnItemEntry.Name;
((UnityEvent)val.onClick).AddListener((UnityAction)delegate
{
SpawnMenuController.SelectItem(itemName);
});
ItemButtons.Add(val);
ItemNameByButton[val] = itemName;
}
Canvas.ForceUpdateCanvases();
RefreshSelection();
RefreshStaticState();
}
private static Button CreateButton(string name, Transform parent, float x, float y, float width, float height, string text, bool footerTemplate)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateButtonVisual(name, parent, x, y, width, height, text, footerTemplate);
Button val2 = val.GetComponent<Button>();
if ((Object)(object)val2 == (Object)null)
{
val2 = val.AddComponent<Button>();
}
((UnityEventBase)val2.onClick).RemoveAllListeners();
Navigation navigation = ((Selectable)val2).navigation;
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)val2).navigation = navigation;
return val2;
}
private static GameObject CreateButtonVisual(string name, Transform parent, float x, float y, float width, float height, string text, bool footerTemplate)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
GameObject val = (footerTemplate ? _buttonTemplateFooter : _buttonTemplateMain);
GameObject val2;
if ((Object)(object)val != (Object)null)
{
val2 = Object.Instantiate<GameObject>(val, parent, false);
((Object)val2).name = name;
val2.SetActive(true);
DestroyNonUiBehaviours(val2);
}
else
{
val2 = new GameObject(name, new Type[4]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image),
typeof(Button)
});
val2.transform.SetParent(parent, false);
Image component = val2.GetComponent<Image>();
((Graphic)component).color = new Color(0.68f, 0.2f, 0.09f, 1f);
}
RectTransform val3 = val2.GetComponent<RectTransform>();
if ((Object)(object)val3 == (Object)null)
{
val3 = val2.AddComponent<RectTransform>();
}
SetTopLeft(val3, x, y, width, height);
SetButtonText(val2, text);
return val2;
}
private static void SetButtonText(GameObject go, string text)
{
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI[] componentsInChildren = go.GetComponentsInChildren<TextMeshProUGUI>(true);
if (componentsInChildren.Length != 0)
{
for (int i = 0; i < componentsInChildren.Length; i++)
{
((TMP_Text)componentsInChildren[i]).text = ((i == 0) ? text : string.Empty);
((TMP_Text)componentsInChildren[i]).textWrappingMode = (TextWrappingModes)1;
((TMP_Text)componentsInChildren[i]).overflowMode = (TextOverflowModes)1;
((TMP_Text)componentsInChildren[i]).alignment = (TextAlignmentOptions)514;
}
return;
}
Text[] componentsInChildren2 = go.GetComponentsInChildren<Text>(true);
if (componentsInChildren2.Length != 0)
{
for (int j = 0; j < componentsInChildren2.Length; j++)
{
componentsInChildren2[j].text = ((j == 0) ? text : string.Empty);
componentsInChildren2[j].alignment = (TextAnchor)4;
}
}
else
{
TextMeshProUGUI val = CreateText("Text", go.transform, text, 13, (TextAlignmentOptions)514);
RectTransform rectTransform = ((TMP_Text)val).rectTransform;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.offsetMin = new Vector2(6f, 2f);
rectTransform.offsetMax = new Vector2(-6f, -2f);
}
}
private static void SetButtonSelected(Button button, bool selected)
{
//IL_002e: 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)
if (!((Object)(object)button == (Object)null))
{
((Component)button).transform.localScale = (Vector3)(selected ? new Vector3(1.035f, 1.035f, 1f) : Vector3.one);
if (ItemNameByButton.ContainsKey(button))
{
ApplyButtonTemplateVisual(((Component)button).gameObject, selected ? _buttonTemplateFooter : _buttonTemplateMain);
}
}
}
private static void ApplyButtonTemplateVisual(GameObject target, GameObject template)
{
if (!((Object)(object)target == (Object)null) && !((Object)(object)template == (Object)null))
{
Image[] componentsInChildren = target.GetComponentsInChildren<Image>(true);
Image[] componentsInChildren2 = template.GetComponentsInChildren<Image>(true);
int num = Mathf.Min(componentsInChildren.Length, componentsInChildren2.Length);
for (int i = 0; i < num; i++)
{
CopyImageVisual(componentsInChildren2[i], componentsInChildren[i]);
}
}
}
private static void CopyImageVisual(Image source, Image target)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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)
if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null))
{
target.sprite = source.sprite;
target.overrideSprite = source.overrideSprite;
target.type = source.type;
((Graphic)target).color = ((Graphic)source).color;
((Graphic)target).material = ((Graphic)source).material;
target.preserveAspect = source.preserveAspect;
target.fillCenter = source.fillCenter;
target.fillMethod = source.fillMethod;
target.fillAmount = source.fillAmount;
target.fillClockwise = source.fillClockwise;
target.fillOrigin = source.fillOrigin;
((Graphic)target).raycastTarget = ((Graphic)source).raycastTarget;
target.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier;
}
}
private static TextMeshProUGUI CreateText(string name, Transform parent, string value, int size, TextAlignmentOptions alignment)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_005c: 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)
GameObject val = new GameObject(name, new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(TextMeshProUGUI)
});
val.transform.SetParent(parent, false);
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = value;
((TMP_Text)component).fontSize = size;
((TMP_Text)component).alignment = alignment;
((Graphic)component).color = Color.white;
((TMP_Text)component).textWrappingMode = (TextWrappingModes)0;
if ((Object)(object)_fontAsset != (Object)null)
{
((TMP_Text)component).font = _fontAsset;
}
if ((Object)(object)_fontMaterial != (Object)null)
{
((TMP_Text)component).fontSharedMaterial = _fontMaterial;
}
return component;
}
private static RectTransform CreateRect(string name, Transform parent)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
return val.GetComponent<RectTransform>();
}
private static void SetTopLeft(RectTransform rect, float x, float y, float width, float height)
{
//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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)
rect.anchorMin = new Vector2(0f, 1f);
rect.anchorMax = new Vector2(0f, 1f);
rect.pivot = new Vector2(0f, 1f);
rect.anchoredPosition = new Vector2(x, 0f - y);
rect.sizeDelta = new Vector2(width, height);
}
private static void CacheTextTemplate()
{
TextMeshProUGUI val = null;
if ((Object)(object)_buttonTemplateMain != (Object)null)
{
val = _buttonTemplateMain.GetComponentInChildren<TextMeshProUGUI>(true);
}
if ((Object)(object)val == (Object)null && (Object)(object)_buttonTemplateFooter != (Object)null)
{
val = _buttonTemplateFooter.GetComponentInChildren<TextMeshProUGUI>(true);
}
if ((Object)(object)val == (Object)null && (Object)(object)_rootObject != (Object)null)
{
val = _rootObject.GetComponentInChildren<TextMeshProUGUI>(true);
}
if ((Object)(object)val != (Object)null)
{
_fontAsset = ((TMP_Text)val).font;
_fontMaterial = ((TMP_Text)val).fontSharedMaterial;
}
}
private static Transform GetCanvasParent(Transform source)
{
if ((Object)(object)source == (Object)null)
{
return null;
}
Canvas componentInParent = ((Component)source).GetComponentInParent<Canvas>(true);
if ((Object)(object)componentInParent != (Object)null)
{
return ((Component)componentInParent).transform;
}
Transform val = source;
while ((Object)(object)val != (Object)null)
{
if (string.Equals(((Object)val).name, "Canvas in front", StringComparison.Ordinal))
{
return val;
}
val = val.parent;
}
return null;
}
private static void DestroyChildren(Transform root)
{
if (!((Object)(object)root == (Object)null))
{
for (int num = root.childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)root.GetChild(num)).gameObject);
}
}
}
private static void ClearCachedUi()
{
AmountButtons.Clear();
CategoryButtons.Clear();
ItemButtons.Clear();
AmountByButton.Clear();
CategoryByButton.Clear();
ItemNameByButton.Clear();
_rootObject = null;
_rootRect = null;
_contentRoot = null;
_itemContent = null;
_searchInput = null;
_amountInput = null;
_addButton = null;
_dropButton = null;
_fontAsset = null;
_fontMaterial = null;
_pendingRebuild = false;
}
private static GameObject FindSettingsBackgroundImage()
{
GameObject val = FindSceneObject("PlayerPuppet(Clone)/Canvas in front/Menu/Settings", "Settings", "Menu");
if ((Object)(object)val != (Object)null)
{
List<GameObject> list = new List<GameObject>();
for (int i = 0; i < val.transform.childCount; i++)
{
Transform child = val.transform.GetChild(i);
if (!((Object)(object)child == (Object)null) && !((Object)(object)((Component)child).GetComponent<Image>() == (Object)null) && string.Equals(((Object)child).name, "Image", StringComparison.Ordinal))
{
list.Add(((Component)child).gameObject);
}
}
if (list.Count >= 2)
{
return list[1];
}
if (list.Count == 1)
{
return list[0];
}
}
GameObject val2 = GameObject.Find("PlayerPuppet(Clone)/Canvas in front/Menu/Settings/Image");
if ((Object)(object)val2 != (Object)null)
{
Transform parent = val2.transform.parent;
if ((Object)(object)parent != (Object)null)
{
int num = 0;
for (int j = 0; j < parent.childCount; j++)
{
Transform child2 = parent.GetChild(j);
if (!((Object)(object)child2 == (Object)null) && !((Object)(object)((Component)child2).GetComponent<Image>() == (Object)null) && string.Equals(((Object)child2).name, "Image", StringComparison.Ordinal))
{
if (num == 1)
{
return ((Component)child2).gameObject;
}
num++;
}
}
}
return val2;
}
return FindSceneObject("PlayerPuppet(Clone)/Canvas in front/Menu/Settings/Image", "Image", "Settings");
}
private static GameObject FindSceneObject(string path, string objectName, string parentName)
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: 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)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find(path);
if ((Object)(object)val != (Object)null)
{
return val;
}
Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
Scene scene;
if (!string.IsNullOrEmpty(path))
{
foreach (Transform val2 in array)
{
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null))
{
scene = ((Component)val2).gameObject.scene;
if (((Scene)(ref scene)).IsValid() && PathEndsWith(val2, path))
{
return ((Component)val2).gameObject;
}
}
}
}
foreach (Transform val3 in array)
{
if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)null))
{
scene = ((Component)val3).gameObject.scene;
if (((Scene)(ref scene)).IsValid() && string.Equals(((Object)val3).name, objectName, StringComparison.Ordinal) && (string.IsNullOrEmpty(parentName) || HasParentNamed(val3, parentName)))
{
return ((Component)val3).gameObject;
}
}
}
return null;
}
private static bool PathEndsWith(Transform transform, string path)
{
if ((Object)(object)transform == (Object)null || string.IsNullOrEmpty(path))
{
return false;
}
string[] array = path.Split(new char[1] { '/' });
int num = array.Length - 1;
Transform val = transform;
while (num >= 0 && (Object)(object)val != (Object)null)
{
if (!string.Equals(((Object)val).name, array[num], StringComparison.Ordinal))
{
return false;
}
num--;
val = val.parent;
}
return num < 0;
}
private static bool HasParentNamed(Transform transform, string parentName)
{
Transform parent = transform.parent;
while ((Object)(object)parent != (Object)null)
{
if (string.Equals(((Object)parent).name, parentName, StringComparison.Ordinal))
{
return true;
}
parent = parent.parent;
}
return false;
}
private static void DestroyNonUiBehaviours(GameObject root)
{
MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren<MonoBehaviour>(true);
foreach (MonoBehaviour val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null) && !(val is UIBehaviour))
{
Object.Destroy((Object)(object)val);
}
}
}
}