Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ItemVault v1.1.0
ItemVault.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace ItemVault; internal class VaultEntry { public int id; public PickupIndex pickup; public int count; public PickupIndex[] options; public bool IsChoice => options != null; } internal class QueueSlot { public PickupIndex pickup; public int count; } internal class PlayerVault { public NetworkUser owner; public readonly List<VaultEntry> entries = new List<VaultEntry>(); private int nextId = 1; public readonly List<QueueSlot> queue = new List<QueueSlot>(); public bool queueKnown; public bool loop; public readonly Dictionary<int, int> positions = new Dictionary<int, int>(); public readonly Dictionary<int, int> progress = new Dictionary<int, int>(); public bool dirty = true; public string status = ""; private readonly List<QueueSlot> giveQueue = new List<QueueSlot>(); public int pendingGive; private readonly List<PickupIndex> dropQueue = new List<PickupIndex>(); public bool HasPendingGive => giveQueue.Count > 0; public int PendingDrop => dropQueue.Count; public Inventory Inventory { get { if ((Object)(object)owner == (Object)null || (Object)(object)owner.master == (Object)null) { return null; } return owner.master.inventory; } } public void EnqueueGive(PickupIndex index) { //IL_0052: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) QueueSlot queueSlot = ((giveQueue.Count > 0) ? giveQueue[giveQueue.Count - 1] : null); if (queueSlot != null && queueSlot.pickup == index) { queueSlot.count++; } else { QueueSlot queueSlot2 = new QueueSlot(); queueSlot2.pickup = index; queueSlot2.count = 1; giveQueue.Add(queueSlot2); } pendingGive++; dirty = true; } public void GiveTick(int budget) { //IL_002c: 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_0041: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = Inventory; if ((Object)(object)inventory == (Object)null) { return; } while (budget > 0 && giveQueue.Count > 0) { QueueSlot queueSlot = giveQueue[0]; int num = Math.Min(budget, queueSlot.count); PickupDef pickupDef = PickupCatalog.GetPickupDef(queueSlot.pickup); if (pickupDef != null && (int)pickupDef.itemIndex != -1) { inventory.GiveItemPermanent(pickupDef.itemIndex, num); } queueSlot.count -= num; if (queueSlot.count <= 0) { giveQueue.RemoveAt(0); } budget -= num; pendingGive -= num; } dirty = true; } public void EnqueueDrop(PickupIndex index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) dropQueue.Add(index); dirty = true; } public List<PickupIndex> TakeDrops(int budget) { int num = Math.Min(budget, dropQueue.Count); List<PickupIndex> range = dropQueue.GetRange(0, num); dropQueue.RemoveRange(0, num); if (num > 0) { dirty = true; } return range; } public VaultEntry Add(PickupIndex index) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) dirty = true; foreach (VaultEntry entry in entries) { if (!entry.IsChoice && entry.pickup == index) { entry.count++; return entry; } } VaultEntry vaultEntry = new VaultEntry(); vaultEntry.id = nextId++; vaultEntry.pickup = index; vaultEntry.count = 1; entries.Add(vaultEntry); return vaultEntry; } public void AddChoice(PickupIndex source, PickupIndex[] options) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) dirty = true; int num = ItemVaultPlugin.PickupKey(source); foreach (VaultEntry entry in entries) { if (entry.IsChoice && ItemVaultPlugin.PickupKey(entry.pickup) == num) { entry.count++; return; } } VaultEntry vaultEntry = new VaultEntry(); vaultEntry.id = nextId++; vaultEntry.pickup = source; vaultEntry.count = 1; vaultEntry.options = options; entries.Add(vaultEntry); } public void AddUnit(VaultEntry like) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (like.IsChoice) { AddChoice(like.pickup, like.options); } else { Add(like.pickup); } } public int ApplyQueue() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) int num = 0; VaultEntry[] array = entries.ToArray(); foreach (VaultEntry vaultEntry in array) { if (!vaultEntry.IsChoice) { continue; } List<PickupIndex> options = new List<PickupIndex>(vaultEntry.options); while (vaultEntry.count > 0) { PickupIndex val = NextFromQueue(options); if (val == PickupIndex.none) { break; } RemoveOne(vaultEntry); GiveDirect(val); num++; } } return num; } public VaultEntry Find(int id) { return entries.Find((VaultEntry e) => e.id == id); } public string TakeMany(VaultEntry entry, int amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 PickupDef pickupDef = PickupCatalog.GetPickupDef(entry.pickup); if (pickupDef == null || (int)pickupDef.itemIndex == -1 || amount <= 1) { return Take(entry); } int num = Math.Min(amount, entry.count); for (int i = 0; i < num; i++) { string text = Take(entry); if (!text.StartsWith("Взято")) { return text; } } return "Взято: " + ItemVaultPlugin.DisplayName(pickupDef) + " x" + num; } public void RemoveOne(VaultEntry entry) { entry.count--; if (entry.count <= 0) { entries.Remove(entry); } dirty = true; } public string Take(VaultEntry entry) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_0036: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = Inventory; if ((Object)(object)inventory == (Object)null) { return "Персонаж не найден."; } PickupDef pickupDef = PickupCatalog.GetPickupDef(entry.pickup); if (pickupDef == null) { return ""; } if ((int)pickupDef.itemIndex != -1) { EnqueueGive(entry.pickup); RemoveOne(entry); return "Взято: " + ItemVaultPlugin.DisplayName(pickupDef); } if ((int)pickupDef.equipmentIndex != -1) { EquipmentIndex currentEquipmentIndex = inventory.currentEquipmentIndex; inventory.SetEquipmentIndex(pickupDef.equipmentIndex); RemoveOne(entry); if ((int)currentEquipmentIndex != -1) { Add(PickupCatalog.FindPickupIndex(currentEquipmentIndex)); } return "Снаряжение: " + ItemVaultPlugin.DisplayName(pickupDef); } return ""; } public string TakeAllItems() { //IL_0023: 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_0038: Invalid comparison between Unknown and I4 int num = 0; VaultEntry[] array = entries.ToArray(); foreach (VaultEntry vaultEntry in array) { if (vaultEntry.IsChoice) { continue; } PickupDef pickupDef = PickupCatalog.GetPickupDef(vaultEntry.pickup); if (pickupDef == null || (int)pickupDef.itemIndex == -1) { continue; } while (vaultEntry.count > 0) { string text = Take(vaultEntry); if (!text.StartsWith("Взято")) { return text; } num++; } } return "Взято предметов: " + num; } public void GiveDirect(PickupIndex index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Take(Add(index)); } public List<int> SlotsForKey(int key) { List<int> list = new List<int>(); for (int i = 0; i < queue.Count; i++) { if (ItemVaultPlugin.SlotKey(queue[i]) == key) { list.Add(i); } } return list; } public PickupIndex NextFromQueue(List<PickupIndex> options) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_011a: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(options[0]); if (pickupDef == null) { return PickupIndex.none; } int key = ItemVaultPlugin.SortKey(pickupDef); List<int> list = SlotsForKey(key); int count = list.Count; if (count == 0) { return PickupIndex.none; } int num = ItemVaultPlugin.GetOrZero(positions, key) % count; int num2 = (loop ? num : 0); for (int i = 0; i < count; i++) { int num3 = (num2 + i) % count; QueueSlot queueSlot = queue[list[num3]]; if (!options.Contains(queueSlot.pickup)) { continue; } if (loop) { int num4 = ((num3 == num) ? ItemVaultPlugin.GetOrZero(progress, key) : 0); num4++; if (num4 >= queueSlot.count) { num4 = 0; num3 = (num3 + 1) % count; } positions[key] = num3; progress[key] = num4; } else { queueSlot.count--; if (queueSlot.count <= 0) { queue.RemoveAt(list[num3]); } } dirty = true; return queueSlot.pickup; } return PickupIndex.none; } } internal class VaultSyncMessage : MessageBase { public string status = ""; public int playerNumber; public int playerCount; public int pendingGive; public int pendingDrop; public bool adminMode; public List<VaultEntry> entries = new List<VaultEntry>(); public List<VaultEntry> shared = new List<VaultEntry>(); public bool queueKnown; public List<QueueSlot> queue = new List<QueueSlot>(); public Dictionary<int, int> positions = new Dictionary<int, int>(); public Dictionary<int, int> progress = new Dictionary<int, int>(); private static void WriteEntries(NetworkWriter writer, List<VaultEntry> list) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) writer.Write(list.Count); foreach (VaultEntry item in list) { writer.Write(item.id); writer.Write(item.pickup.value); writer.Write(item.count); writer.Write((item.options != null) ? item.options.Length : (-1)); if (item.options != null) { PickupIndex[] options = item.options; for (int i = 0; i < options.Length; i++) { PickupIndex val = options[i]; writer.Write(val.value); } } } } private static List<VaultEntry> ReadEntries(NetworkReader reader) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) int num = reader.ReadInt32(); List<VaultEntry> list = new List<VaultEntry>(num); for (int i = 0; i < num; i++) { VaultEntry vaultEntry = new VaultEntry(); vaultEntry.id = reader.ReadInt32(); vaultEntry.pickup = new PickupIndex(reader.ReadInt32()); vaultEntry.count = reader.ReadInt32(); int num2 = reader.ReadInt32(); if (num2 >= 0) { vaultEntry.options = (PickupIndex[])(object)new PickupIndex[num2]; for (int j = 0; j < num2; j++) { ref PickupIndex reference = ref vaultEntry.options[j]; reference = new PickupIndex(reader.ReadInt32()); } } list.Add(vaultEntry); } return list; } public override void Serialize(NetworkWriter writer) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) writer.Write(status ?? ""); writer.Write(playerNumber); writer.Write(playerCount); writer.Write(adminMode); writer.Write(pendingGive); writer.Write(pendingDrop); WriteEntries(writer, entries); WriteEntries(writer, shared); writer.Write(queueKnown); writer.Write(queue.Count); foreach (QueueSlot item in queue) { writer.Write(item.pickup.value); writer.Write(item.count); } writer.Write(positions.Count); foreach (KeyValuePair<int, int> position in positions) { writer.Write(position.Key); writer.Write(position.Value); writer.Write(ItemVaultPlugin.GetOrZero(progress, position.Key)); } } public override void Deserialize(NetworkReader reader) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) status = reader.ReadString(); playerNumber = reader.ReadInt32(); playerCount = reader.ReadInt32(); adminMode = reader.ReadBoolean(); pendingGive = reader.ReadInt32(); pendingDrop = reader.ReadInt32(); entries = ReadEntries(reader); shared = ReadEntries(reader); queueKnown = reader.ReadBoolean(); int num = reader.ReadInt32(); queue = new List<QueueSlot>(num); for (int i = 0; i < num; i++) { QueueSlot queueSlot = new QueueSlot(); queueSlot.pickup = new PickupIndex(reader.ReadInt32()); queueSlot.count = reader.ReadInt32(); queue.Add(queueSlot); } num = reader.ReadInt32(); for (int j = 0; j < num; j++) { int key = reader.ReadInt32(); positions[key] = reader.ReadInt32(); progress[key] = reader.ReadInt32(); } } } internal class VaultActionMessage : MessageBase { public const byte Take = 1; public const byte TakeAll = 2; public const byte Choose = 3; public const byte CollectMap = 4; public const byte Spawn = 5; public const byte ToShared = 6; public const byte FromShared = 7; public const byte ApplyQueue = 8; public const byte Drop = 9; public const byte Delete = 10; public byte action; public int entryId; public int pickup; public int amount = 1; public override void Serialize(NetworkWriter writer) { writer.Write(action); writer.Write(entryId); writer.Write(pickup); writer.Write(amount); } public override void Deserialize(NetworkReader reader) { action = reader.ReadByte(); entryId = reader.ReadInt32(); pickup = reader.ReadInt32(); amount = reader.ReadInt32(); } } internal class QueueSyncMessage : MessageBase { public bool loop; public List<QueueSlot> queue = new List<QueueSlot>(); public override void Serialize(NetworkWriter writer) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) writer.Write(loop); writer.Write(queue.Count); foreach (QueueSlot item in queue) { writer.Write(item.pickup.value); writer.Write(item.count); } } public override void Deserialize(NetworkReader reader) { //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) loop = reader.ReadBoolean(); int num = reader.ReadInt32(); queue = new List<QueueSlot>(num); for (int i = 0; i < num; i++) { QueueSlot queueSlot = new QueueSlot(); queueSlot.pickup = new PickupIndex(reader.ReadInt32()); queueSlot.count = reader.ReadInt32(); queue.Add(queueSlot); } } } [BepInPlugin("com.proigryfedorov.itemvault", "ItemVault", "1.1.0")] public class ItemVaultPlugin : BaseUnityPlugin { public const string PluginGuid = "com.proigryfedorov.itemvault"; public const string PluginName = "ItemVault"; public const string PluginVersion = "1.1.0"; private const short MsgVaultSync = 18774; private const short MsgVaultAction = 18775; private const short MsgQueueSync = 18776; internal static ItemVaultPlugin Instance; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> CollectEquipment; internal static ConfigEntry<bool> CollectLunar; internal static ConfigEntry<bool> CollectVoid; internal static ConfigEntry<bool> CollectCommand; internal static ConfigEntry<float> CollectInterval; internal static ConfigEntry<int> CollectPerTick; internal static ConfigEntry<float> GiveInterval; internal static ConfigEntry<int> GivePerTick; internal static ConfigEntry<string> CommandQueueConfig; internal static ConfigEntry<bool> CommandQueueLoop; internal static ConfigEntry<bool> AdminMode; private readonly Dictionary<NetworkUser, PlayerVault> vaults = new Dictionary<NetworkUser, PlayerVault>(); private PlayerVault shared = new PlayerVault(); private float lastExitBlockedMessage = -100f; private readonly Dictionary<int, int> nextRecipient = new Dictionary<int, int>(); internal readonly List<VaultEntry> clientEntries = new List<VaultEntry>(); internal readonly List<VaultEntry> clientShared = new List<VaultEntry>(); internal readonly Dictionary<int, int> clientPositions = new Dictionary<int, int>(); internal readonly Dictionary<int, int> clientProgress = new Dictionary<int, int>(); internal string clientStatus = ""; internal int clientPlayerNumber; internal int clientPlayerCount; internal bool clientAdminMode; internal int clientPendingGive; internal int clientPendingDrop; internal readonly List<QueueSlot> queue = new List<QueueSlot>(); internal int version; private static readonly Dictionary<PickupIndex, Sprite> iconCache = new Dictionary<PickupIndex, Sprite>(); private static List<PickupIndex> catalog; private static readonly MethodInfo getOptionsFromPickupState = AccessTools.Method(typeof(PickupPickerController), "GetOptionsFromPickupState", new Type[1] { typeof(UniquePickup) }, (Type[])null); internal static readonly FieldInfo submenuObjectField = AccessTools.Field(typeof(PauseScreenController), "submenuObject"); private static readonly FieldInfo pickerOptionsField = AccessTools.Field(typeof(PickupPickerController), "options"); private static readonly FieldInfo pickerSourceField = AccessTools.Field(typeof(PickupPickerController), "pickupThatGeneratedOptions"); private readonly List<GameObject> pending = new List<GameObject>(); private readonly HashSet<GameObject> pendingSet = new HashSet<GameObject>(); private float nextCollectTime; private float nextGiveTime; private readonly Dictionary<PickupIndex, int> ignoreDrops = new Dictionary<PickupIndex, int>(); internal bool AdminActive { get { if (!NetworkServer.active) { return clientAdminMode; } return AdminMode.Value; } } private static NetworkClient Client { get { NetworkClient val = (((Object)(object)NetworkManager.singleton != (Object)null) ? NetworkManager.singleton.client : null); if (val == null || !val.isConnected) { return null; } return val; } } private void Awake() { //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown Instance = this; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Автоматически собирать выпавшие предметы в хранилище (действует настройка хоста)."); CollectEquipment = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CollectEquipment", true, "Собирать снаряжение (оранжевые предметы)."); CollectLunar = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CollectLunar", true, "Собирать лунные предметы."); CollectVoid = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CollectVoid", true, "Собирать предметы Пустоты."); CollectCommand = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CollectCommand", true, "С Артефактом Команды класть выбор предмета в хранилище вместо куба."); CollectInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Performance", "CollectInterval", 0.5f, "Пауза между порциями сбора (секунды)."); CollectPerTick = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "CollectPerTick", 5, "Сколько предметов собирать за одну порцию."); GiveInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Performance", "GiveInterval", 0.5f, "Пауза между порциями выдачи взятых предметов игроку (секунды)."); GivePerTick = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "GivePerTick", 5, "Сколько взятых предметов выдавать игроку за одну порцию."); CommandQueueConfig = ((BaseUnityPlugin)this).Config.Bind<string>("CommandQueue", "Queue", "", "Очередь предметов для Артефакта Команды (внутренние имена через запятую, Имя*N — стак)."); CommandQueueLoop = ((BaseUnityPlugin)this).Config.Bind<bool>("CommandQueue", "Loop", false, "Зациклить очередь: после последнего стака начинать сначала."); AdminMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Admin", "AdminMode", false, "Админ-режим для тестов (только хост): спавн любых предметов, телепорт заблокирован. Сам выключается в конце забега."); Run.onRunStartGlobal += OnRunStart; Run.onRunDestroyGlobal += OnRunDestroy; Stage.onStageStartGlobal += OnStageStart; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LoadQueue)); Harmony val = new Harmony("com.proigryfedorov.itemvault"); val.Patch((MethodBase)AccessTools.Method(typeof(GenericPickupController), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ItemVaultPlugin), "PickupStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(PickupDropletController), "CreateCommandCube", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemVaultPlugin), "CommandCubePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(PauseScreenController), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ItemVaultPlugin), "PauseAwakePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(SceneExitController), "Begin", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemVaultPlugin), "SceneExitBeginPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ItemVault 1.1.0 loaded"); } private void OnRunStart(Run run) { ResetState(); RegisterHandlers(); } private void OnRunDestroy(Run run) { ResetState(); if (AdminMode.Value) { AdminMode.Value = false; } } internal void EnableAdminMode() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (NetworkServer.active && !AdminMode.Value) { AdminMode.Value = true; shared.dirty = true; SimpleChatMessage val = new SimpleChatMessage(); val.baseToken = "<color=#ff6060>ItemVault: хост включил админ-режим. Переход на следующую локацию заблокирован до конца забега.</color>"; Chat.SendBroadcastChat((ChatMessageBase)(object)val); } } private void ResetState() { vaults.Clear(); shared = new PlayerVault(); clientShared.Clear(); nextRecipient.Clear(); ignoreDrops.Clear(); pending.Clear(); pendingSet.Clear(); clientEntries.Clear(); clientPositions.Clear(); clientProgress.Clear(); clientStatus = ""; version++; } private void OnStageStart(Stage stage) { ignoreDrops.Clear(); RegisterHandlers(); SendQueue(); } private void RegisterHandlers() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if (NetworkServer.active) { NetworkServer.RegisterHandler((short)18775, new NetworkMessageDelegate(OnServerAction)); NetworkServer.RegisterHandler((short)18776, new NetworkMessageDelegate(OnServerQueueSync)); } NetworkClient val = (((Object)(object)NetworkManager.singleton != (Object)null) ? NetworkManager.singleton.client : null); if (val != null) { val.RegisterHandler((short)18774, new NetworkMessageDelegate(OnClientSync)); } } internal void SendAction(byte action, int entryId, PickupIndex pickup) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) SendAction(action, entryId, pickup, 1); } internal static int ClickAmount() { bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); bool flag2 = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); if (flag && flag2) { return 1000; } if (flag2) { return 100; } if (flag) { return 10; } return 1; } internal void SendAction(byte action, int entryId, PickupIndex pickup, int amount) { NetworkClient client = Client; if (client == null) { clientStatus = "Нет соединения с хостом."; version++; return; } VaultActionMessage vaultActionMessage = new VaultActionMessage(); vaultActionMessage.action = action; vaultActionMessage.entryId = entryId; vaultActionMessage.pickup = pickup.value; vaultActionMessage.amount = amount; client.Send((short)18775, (MessageBase)(object)vaultActionMessage); } internal void SendQueue() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) NetworkClient client = Client; if (client == null || (Object)(object)Run.instance == (Object)null) { return; } QueueSyncMessage queueSyncMessage = new QueueSyncMessage(); queueSyncMessage.loop = CommandQueueLoop.Value; foreach (QueueSlot item in queue) { QueueSlot queueSlot = new QueueSlot(); queueSlot.pickup = item.pickup; queueSlot.count = item.count; queueSyncMessage.queue.Add(queueSlot); } client.Send((short)18776, (MessageBase)(object)queueSyncMessage); } private void OnClientSync(NetworkMessage netMsg) { VaultSyncMessage vaultSyncMessage = netMsg.ReadMessage<VaultSyncMessage>(); clientEntries.Clear(); clientEntries.AddRange(vaultSyncMessage.entries); clientShared.Clear(); clientShared.AddRange(vaultSyncMessage.shared); clientPositions.Clear(); clientProgress.Clear(); foreach (KeyValuePair<int, int> position in vaultSyncMessage.positions) { clientPositions[position.Key] = position.Value; } foreach (KeyValuePair<int, int> item in vaultSyncMessage.progress) { clientProgress[item.Key] = item.Value; } if (!string.IsNullOrEmpty(vaultSyncMessage.status)) { clientStatus = vaultSyncMessage.status; } clientPlayerNumber = vaultSyncMessage.playerNumber; clientPlayerCount = vaultSyncMessage.playerCount; clientAdminMode = vaultSyncMessage.adminMode; clientPendingGive = vaultSyncMessage.pendingGive; clientPendingDrop = vaultSyncMessage.pendingDrop; if (vaultSyncMessage.queueKnown && !SameQueue(vaultSyncMessage.queue)) { queue.Clear(); queue.AddRange(vaultSyncMessage.queue); SaveQueue(); } version++; } private bool SameQueue(List<QueueSlot> other) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (other.Count != queue.Count) { return false; } for (int i = 0; i < other.Count; i++) { if (other[i].pickup != queue[i].pickup || other[i].count != queue[i].count) { return false; } } return true; } private PlayerVault VaultFromConnection(NetworkConnection conn) { foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList) { if ((Object)(object)readOnlyInstances != (Object)null && ((NetworkBehaviour)readOnlyInstances).connectionToClient == conn) { return GetVault(readOnlyInstances); } } return null; } private PlayerVault GetVault(NetworkUser user) { if (!vaults.TryGetValue(user, out var value)) { value = new PlayerVault(); value.owner = user; vaults[user] = value; } return value; } private void OnServerQueueSync(NetworkMessage netMsg) { QueueSyncMessage queueSyncMessage = netMsg.ReadMessage<QueueSyncMessage>(); PlayerVault playerVault = VaultFromConnection(netMsg.conn); if (playerVault != null) { playerVault.queue.Clear(); playerVault.queue.AddRange(queueSyncMessage.queue); playerVault.loop = queueSyncMessage.loop; playerVault.queueKnown = true; playerVault.dirty = true; } } private void OnServerAction(NetworkMessage netMsg) { //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) VaultActionMessage vaultActionMessage = netMsg.ReadMessage<VaultActionMessage>(); PlayerVault playerVault = VaultFromConnection(netMsg.conn); if (playerVault == null || (Object)(object)Run.instance == (Object)null) { return; } int num = Mathf.Clamp(vaultActionMessage.amount, 1, 1000); switch (vaultActionMessage.action) { case 1: { VaultEntry vaultEntry = playerVault.Find(vaultActionMessage.entryId); if (vaultEntry != null && !vaultEntry.IsChoice) { playerVault.status = playerVault.TakeMany(vaultEntry, num); } break; } case 2: playerVault.status = playerVault.TakeAllItems(); break; case 3: { VaultEntry vaultEntry = playerVault.Find(vaultActionMessage.entryId); PickupIndex val = default(PickupIndex); ((PickupIndex)(ref val))..ctor(vaultActionMessage.pickup); if (vaultEntry != null && vaultEntry.IsChoice && Array.IndexOf(vaultEntry.options, val) >= 0) { int num2 = Math.Min(num, vaultEntry.count); for (int j = 0; j < num2; j++) { playerVault.RemoveOne(vaultEntry); playerVault.Add(val); } PickupDef pickupDef = PickupCatalog.GetPickupDef(val); playerVault.status = ((pickupDef != null) ? ("Выбрано: " + DisplayName(pickupDef) + " x" + num2) : ""); } break; } case 4: { int num3 = CollectAllOnMap(); playerVault.status = "Найдено на карте: " + num3 + ". Собираю по " + CollectPerTick.Value + " каждые " + CollectInterval.Value + " с."; break; } case 5: playerVault.status = AdminSpawn(playerVault, new PickupIndex(vaultActionMessage.pickup), num); break; case 6: { VaultEntry vaultEntry = playerVault.Find(vaultActionMessage.entryId); if (vaultEntry != null) { int num2 = Math.Min(num, vaultEntry.count); for (int m = 0; m < num2; m++) { shared.AddUnit(vaultEntry); playerVault.RemoveOne(vaultEntry); } playerVault.status = "Отправлено в общий инвентарь: " + num2; } break; } case 7: { VaultEntry vaultEntry = shared.Find(vaultActionMessage.entryId); if (vaultEntry != null) { int num2 = Math.Min(num, vaultEntry.count); for (int i = 0; i < num2; i++) { playerVault.AddUnit(vaultEntry); shared.RemoveOne(vaultEntry); } playerVault.status = "Забрано из общего инвентаря: " + num2; } break; } case 9: { VaultEntry vaultEntry = playerVault.Find(vaultActionMessage.entryId); if (vaultEntry != null) { int num2 = Math.Min(num, vaultEntry.count); for (int l = 0; l < num2; l++) { playerVault.EnqueueDrop(vaultEntry.pickup); playerVault.RemoveOne(vaultEntry); } playerVault.status = "Выбрасывается на землю: " + num2; } break; } case 10: { VaultEntry vaultEntry = playerVault.Find(vaultActionMessage.entryId); if (vaultEntry != null) { int num2 = Math.Min(num, vaultEntry.count); for (int k = 0; k < num2; k++) { playerVault.RemoveOne(vaultEntry); } playerVault.status = "Удалено: " + num2; } break; } case 8: if (!playerVault.queueKnown || playerVault.queue.Count == 0) { playerVault.status = "Очередь Команды пуста."; } else { playerVault.status = "Выдано по очереди: " + playerVault.ApplyQueue(); } break; } playerVault.dirty = true; } private void SendSync(PlayerVault vault, int number, int count) { NetworkUser owner = vault.owner; if (!((Object)(object)owner == (Object)null) && ((NetworkBehaviour)owner).connectionToClient != null) { VaultSyncMessage vaultSyncMessage = new VaultSyncMessage(); vaultSyncMessage.status = vault.status; vaultSyncMessage.playerNumber = number; vaultSyncMessage.playerCount = count; vaultSyncMessage.adminMode = AdminMode.Value; vaultSyncMessage.pendingGive = vault.pendingGive; vaultSyncMessage.pendingDrop = vault.PendingDrop; vaultSyncMessage.entries = vault.entries; vaultSyncMessage.shared = shared.entries; vaultSyncMessage.queueKnown = vault.queueKnown; vaultSyncMessage.queue = vault.queue; vaultSyncMessage.positions = vault.positions; vaultSyncMessage.progress = vault.progress; ((NetworkBehaviour)owner).connectionToClient.Send((short)18774, (MessageBase)(object)vaultSyncMessage); vault.status = ""; vault.dirty = false; } } private static List<NetworkUser> PlayerTable() { List<NetworkUser> list = new List<NetworkUser>(); foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList) { if ((Object)(object)readOnlyInstances != (Object)null && (Object)(object)readOnlyInstances.master != (Object)null) { list.Add(readOnlyInstances); } } return list; } private PlayerVault NextRecipient(int key) { List<NetworkUser> list = PlayerTable(); if (list.Count == 0) { return null; } int num = GetOrZero(nextRecipient, key) % list.Count; NetworkUser user = list[num]; nextRecipient[key] = (num + 1) % list.Count; return GetVault(user); } private void Enqueue(GameObject go) { if ((Object)(object)go != (Object)null && pendingSet.Add(go)) { pending.Add(go); } } private void Update() { if (!NetworkServer.active || (Object)(object)Run.instance == (Object)null) { pending.Clear(); pendingSet.Clear(); return; } if (pending.Count > 0 && Time.unscaledTime >= nextCollectTime) { nextCollectTime = Time.unscaledTime + Mathf.Max(0.05f, CollectInterval.Value); int num = 0; int num2 = Mathf.Max(1, CollectPerTick.Value); while (pending.Count > 0 && num < num2) { GameObject val = pending[0]; pending.RemoveAt(0); pendingSet.Remove(val); if (!((Object)(object)val == (Object)null) && TryCollect(val)) { num++; } } } if (Time.unscaledTime >= nextGiveTime) { nextGiveTime = Time.unscaledTime + Mathf.Max(0.05f, GiveInterval.Value); int budget = Mathf.Max(1, GivePerTick.Value); foreach (PlayerVault value in vaults.Values) { if (value.HasPendingGive) { value.GiveTick(budget); } if (value.PendingDrop > 0) { DropTick(value, budget); } } } List<NetworkUser> list = PlayerTable(); for (int i = 0; i < list.Count; i++) { PlayerVault vault = GetVault(list[i]); if (vault.dirty || shared.dirty) { SendSync(vault, i + 1, list.Count); } } shared.dirty = false; } private void DropTick(PlayerVault vault, int budget) { //IL_0060: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = (((Object)(object)vault.owner != (Object)null && (Object)(object)vault.owner.master != (Object)null) ? vault.owner.master.GetBody() : null); if ((Object)(object)val == (Object)null) { return; } Vector3 val2 = (((Object)(object)val.inputBank != (Object)null) ? val.inputBank.aimDirection : ((Component)val).transform.forward); val2.y = 0f; val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : Vector3.forward); foreach (PickupIndex item in vault.TakeDrops(budget)) { ignoreDrops[item] = GetOrZero(ignoreDrops, item) + 1; Vector3 val3 = Quaternion.Euler(0f, Random.Range(-35f, 35f), 0f) * val2 * 8f + Vector3.up * 15f; PickupDropletController.CreatePickupDroplet(item, val.corePosition + Vector3.up * 1.5f, val3); } } private bool ConsumeIgnoredDrop(PickupIndex index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) int orZero = GetOrZero(ignoreDrops, index); if (orZero <= 0) { return false; } if (orZero == 1) { ignoreDrops.Remove(index); } else { ignoreDrops[index] = orZero - 1; } return true; } private static bool SceneExitBeginPrefix() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown if (!NetworkServer.active || (Object)(object)Instance == (Object)null || !AdminMode.Value) { return true; } if (Time.unscaledTime - Instance.lastExitBlockedMessage > 3f) { Instance.lastExitBlockedMessage = Time.unscaledTime; SimpleChatMessage val = new SimpleChatMessage(); val.baseToken = "<color=#ff6060>ItemVault: админ-режим — переход на следующую локацию заблокирован.</color>"; Chat.SendBroadcastChat((ChatMessageBase)(object)val); } return false; } private bool TryCollect(GameObject go) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) GenericPickupController component = go.GetComponent<GenericPickupController>(); if ((Object)(object)component != (Object)null) { UniquePickup pickup = component.pickup; if (!((UniquePickup)(ref pickup)).isValid || ((UniquePickup)(ref pickup)).isTempItem || pickup.isRental) { return false; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (pickupDef == null || !ShouldCollect(pickupDef)) { return false; } PlayerVault playerVault = NextRecipient(SortKey(pickupDef)); if (playerVault == null) { return false; } playerVault.Add(pickup.pickupIndex); NetworkServer.Destroy(go); return true; } PickupPickerController component2 = go.GetComponent<PickupPickerController>(); if ((Object)(object)component2 != (Object)null) { UniquePickup? val = (UniquePickup?)pickerSourceField.GetValue(component2); Option[] opts = (Option[])pickerOptionsField.GetValue(component2); if (!val.HasValue || !HandleCommandChoice(val.Value, opts)) { return false; } NetworkServer.Destroy(go); return true; } return false; } internal int CollectAllOnMap() { int count = pending.Count; GenericPickupController[] array = Object.FindObjectsOfType<GenericPickupController>(); foreach (GenericPickupController val in array) { Enqueue(((Component)val).gameObject); } PickupPickerController[] array2 = Object.FindObjectsOfType<PickupPickerController>(); foreach (PickupPickerController val2 in array2) { if (pickerSourceField.GetValue(val2) != null) { Enqueue(((Component)val2).gameObject); } } return pending.Count - count; } private string AdminSpawn(PlayerVault vault, PickupIndex index, int amount) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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) if (!AdminMode.Value) { return "Админ-режим выключен у хоста."; } PickupDef pickupDef = PickupCatalog.GetPickupDef(index); if (amount > 1 && pickupDef != null) { for (int i = 0; i < amount; i++) { vault.Add(index); } return "Добавлено в хранилище: " + DisplayName(pickupDef) + " x" + amount; } CharacterBody val = (((Object)(object)vault.owner != (Object)null && (Object)(object)vault.owner.master != (Object)null) ? vault.owner.master.GetBody() : null); if (pickupDef == null || (Object)(object)val == (Object)null) { return "Нельзя заспавнить: нет персонажа."; } Vector3 val2 = (((Object)(object)val.inputBank != (Object)null) ? val.inputBank.aimDirection : ((Component)val).transform.forward); val2.y = 0f; PickupDropletController.CreatePickupDroplet(index, val.corePosition + Vector3.up * 1.5f, ((Vector3)(ref val2)).normalized * 8f + Vector3.up * 15f); return "Заспавнено: " + DisplayName(pickupDef); } private static void PickupStartPostfix(GenericPickupController __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && !((Object)(object)Instance == (Object)null) && !((Object)(object)Run.instance == (Object)null) && !Instance.ConsumeIgnoredDrop(__instance.pickup.pickupIndex) && Enabled.Value) { Instance.Enqueue(((Component)__instance).gameObject); } } private static bool CommandCubePrefix(CreatePickupInfo ___createPickupInfo) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0067: 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) if (!NetworkServer.active || (Object)(object)Instance == (Object)null || (Object)(object)Run.instance == (Object)null) { return true; } UniquePickup pickup = ((CreatePickupInfo)(ref ___createPickupInfo)).pickup; if (Instance.ConsumeIgnoredDrop(pickup.pickupIndex) || !Enabled.Value || !CollectCommand.Value) { return true; } Option[] opts = (Option[])getOptionsFromPickupState.Invoke(null, new object[1] { pickup }); return !Instance.HandleCommandChoice(pickup, opts); } private bool HandleCommandChoice(UniquePickup pickup, Option[] opts) { //IL_001f: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (!((UniquePickup)(ref pickup)).isValid || ((UniquePickup)(ref pickup)).isTempItem || pickup.isRental) { return false; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (pickupDef == null || !ShouldCollect(pickupDef)) { return false; } if (opts == null || opts.Length == 0) { return false; } List<PickupIndex> list = new List<PickupIndex>(); for (int i = 0; i < opts.Length; i++) { Option val = opts[i]; if (val.available && val.pickup.pickupIndex != PickupIndex.none) { list.Add(val.pickup.pickupIndex); } } if (list.Count == 0) { return false; } PlayerVault playerVault = NextRecipient(SortKey(pickupDef)); if (playerVault == null) { return false; } PickupIndex val2 = playerVault.NextFromQueue(list); if (val2 != PickupIndex.none) { playerVault.GiveDirect(val2); } else { playerVault.AddChoice(pickup.pickupIndex, list.ToArray()); } return true; } private static bool ShouldCollect(PickupDef def) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 if (def.coinValue != 0) { return false; } if (def.isLunar && !CollectLunar.Value) { return false; } if ((int)def.itemIndex != -1) { ItemTier itemTier = def.itemTier; if ((int)itemTier == 6 || (int)itemTier == 7 || (int)itemTier == 8 || (int)itemTier == 9) { return CollectVoid.Value; } return true; } if ((int)def.equipmentIndex != -1) { return CollectEquipment.Value; } return false; } internal static int SlotKey(QueueSlot slot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return PickupKey(slot.pickup); } internal static int PickupKey(PickupIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(index); if (pickupDef == null) { return 50; } return SortKey(pickupDef); } internal List<int> SlotsForKey(int key) { List<int> list = new List<int>(); for (int i = 0; i < queue.Count; i++) { if (SlotKey(queue[i]) == key) { list.Add(i); } } return list; } internal static int GetOrZero<TKey>(Dictionary<TKey, int> dict, TKey key) { if (!dict.TryGetValue(key, out var value)) { return 0; } return value; } internal void QueueAdd(PickupIndex index, int amount) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0045: Unknown result type (might be due to invalid IL or missing references) QueueSlot queueSlot = queue.Find((QueueSlot s) => s.pickup == index); if (queueSlot != null) { queueSlot.count += amount; } else { queueSlot = new QueueSlot(); queueSlot.pickup = index; queueSlot.count = amount; queue.Add(queueSlot); } QueueChanged(); } internal void QueueRemove(int i, int amount) { QueueSlot queueSlot = queue[i]; queueSlot.count -= amount; if (queueSlot.count <= 0) { queue.RemoveAt(i); } QueueChanged(); } internal void QueueClear() { queue.Clear(); QueueChanged(); } internal void QueueChanged() { SaveQueue(); SendQueue(); version++; } private void SaveQueue() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); foreach (QueueSlot item in queue) { PickupDef pickupDef = PickupCatalog.GetPickupDef(item.pickup); if (pickupDef != null) { list.Add((item.count > 1) ? (pickupDef.internalName + "*" + item.count) : pickupDef.internalName); } } CommandQueueConfig.Value = string.Join(",", list.ToArray()); } private void LoadQueue() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) queue.Clear(); string[] array = CommandQueueConfig.Value.Split(','); foreach (string text in array) { string text2 = text.Trim(); int result = 1; int num = text2.IndexOf('*'); if (num >= 0) { if (!int.TryParse(text2.Substring(num + 1), out result) || result < 1) { result = 1; } text2 = text2.Substring(0, num); } if (text2.Length == 0) { continue; } PickupIndex index = PickupCatalog.FindPickupIndex(text2); if (!(index == PickupIndex.none)) { QueueSlot queueSlot = queue.Find((QueueSlot s) => s.pickup == index); if (queueSlot != null) { queueSlot.count += result; continue; } queueSlot = new QueueSlot(); queueSlot.pickup = index; queueSlot.count = result; queue.Add(queueSlot); } } version++; } internal static List<PickupIndex> GetCatalog() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (catalog != null) { return catalog; } List<PickupDef> list = new List<PickupDef>(); foreach (PickupDef allPickup in PickupCatalog.allPickups) { if ((int)allPickup.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(allPickup.itemIndex); if ((Object)(object)itemDef != (Object)null && itemDef.inDroppableTier && !itemDef.hidden) { list.Add(allPickup); } } else if ((int)allPickup.equipmentIndex != -1) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(allPickup.equipmentIndex); if ((Object)(object)equipmentDef != (Object)null && equipmentDef.canDrop) { list.Add(allPickup); } } } list.Sort(delegate(PickupDef a, PickupDef b) { int num = SortKey(a); int num2 = SortKey(b); return (num != num2) ? num.CompareTo(num2) : string.Compare(DisplayName(a), DisplayName(b), StringComparison.CurrentCulture); }); catalog = new List<PickupIndex>(); foreach (PickupDef item in list) { catalog.Add(item.pickupIndex); } return catalog; } internal static string SectionName(int sortKey) { return sortKey switch { 0 => "Обычные", 1 => "Необычные", 2 => "Легендарные", 3 => "Босс", 4 => "Лунные", 5 => "Пустота: обычные", 6 => "Пустота: необычные", 7 => "Пустота: легендарные", 8 => "Пустота: босс", 100 => "Активные предметы", 101 => "Лунные активные предметы", _ => "Прочие", }; } internal static int SortKey(PickupDef def) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown if ((int)def.equipmentIndex != -1) { if (!def.isLunar) { return 100; } return 101; } ItemTier itemTier = def.itemTier; return (int)itemTier switch { 0 => 0, 1 => 1, 2 => 2, 4 => 3, 3 => 4, 6 => 5, 7 => 6, 8 => 7, 9 => 8, _ => 50, }; } internal static string DisplayName(PickupDef def) { return Language.GetString(def.nameToken); } internal static string DescriptionToken(PickupDef def) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((int)def.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(def.itemIndex); if ((Object)(object)itemDef != (Object)null) { return itemDef.descriptionToken; } } if ((int)def.equipmentIndex != -1) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(def.equipmentIndex); if ((Object)(object)equipmentDef != (Object)null) { return equipmentDef.descriptionToken; } } return def.pickupToken; } internal static Sprite GetIcon(PickupIndex index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0052: Invalid comparison between Unknown and I4 //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_0055: 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) if (iconCache.TryGetValue(index, out var value) && (Object)(object)value != (Object)null) { return value; } PickupDef pickupDef = PickupCatalog.GetPickupDef(index); if (pickupDef == null) { return null; } value = pickupDef.iconSprite; if ((Object)(object)value == (Object)null) { value = LoadSprite(pickupDef.iconSpriteReference); } if ((Object)(object)value == (Object)null && (int)pickupDef.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if ((Object)(object)itemDef != (Object)null) { value = (((Object)(object)itemDef.pickupIconSprite != (Object)null) ? itemDef.pickupIconSprite : LoadSprite(itemDef.pickupIconSpriteReference)); } } if ((Object)(object)value == (Object)null && (int)pickupDef.equipmentIndex != -1) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); if ((Object)(object)equipmentDef != (Object)null) { value = (((Object)(object)equipmentDef.pickupIconSprite != (Object)null) ? equipmentDef.pickupIconSprite : LoadSprite(equipmentDef.pickupIconSpriteReference)); } } iconCache[index] = value; return value; } private static Sprite LoadSprite(AssetReferenceT<Sprite> reference) { //IL_0013: 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 (reference == null || !((AssetReference)reference).RuntimeKeyIsValid()) { return null; } try { return Addressables.LoadAssetAsync<Sprite>(((AssetReference)reference).RuntimeKey).WaitForCompletion(); } catch (Exception ex) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Иконка не загрузилась: " + ex.Message)); } return null; } } private static void PauseAwakePostfix(PauseScreenController __instance) { try { AddPauseButton(__instance); } catch (Exception ex) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogError((object)("Не удалось добавить кнопку в меню паузы: " + ex)); } } } internal static GameObject CloneMenuButton(GameObject template, Transform parent, string label, UnityAction onClick) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(template, parent); LanguageTextMeshController[] componentsInChildren = val.GetComponentsInChildren<LanguageTextMeshController>(true); foreach (LanguageTextMeshController val2 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val2); } TextMeshProUGUI[] componentsInChildren2 = val.GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val3 in componentsInChildren2) { ((TMP_Text)val3).text = label; } Button component = val.GetComponent<Button>(); if ((Object)(object)component != (Object)null) { component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(onClick); } val.SetActive(true); return val; } private static void AddPauseButton(PauseScreenController pause) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown GameObject exitGameButton = pause.exitGameButton; if (!((Object)(object)exitGameButton == (Object)null)) { GameObject val = CloneMenuButton(exitGameButton, exitGameButton.transform.parent, "Хранилище", (UnityAction)delegate { VaultPanel.Open(pause); }); ((Object)val).name = "ItemVaultButton"; val.transform.SetSiblingIndex(exitGameButton.transform.GetSiblingIndex()); } } } internal class RightClickHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public UnityAction onRightClick; public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)eventData.button == 1 && onRightClick != null) { onRightClick.Invoke(); } } } internal class VaultPanel : MonoBehaviour { private enum Mode { Vault, Choose, Queue, Admin, Shared, Settings } private enum ClickMode { Take, Drop, Delete } private const string AmountHint = "Shift ×10, Ctrl ×100, Shift+Ctrl ×1000"; private const float ButtonHeight = 48f; private PauseScreenController pause; private GameObject buttonTemplate; private TMP_FontAsset font; private TextMeshProUGUI title; private TextMeshProUGUI info; private RectTransform grid; private RectTransform cells; private TextMeshProUGUI catalogLabel; private GameObject catalogScroll; private RectTransform catalogGrid; private GameObject takeAllButton; private GameObject collectMapButton; private GameObject sharedButton; private GameObject applyButton; private GameObject settingsButton; private GameObject clickModeButton; private ClickMode clickMode; private GameObject queueButton; private GameObject adminButton; private GameObject loopButton; private GameObject clearButton; private Mode mode; private int choosingId; private int builtVersion = -1; private bool catalogBuilt; public static void Open(PauseScreenController pause) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_005c: 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) GameObject val = (GameObject)ItemVaultPlugin.submenuObjectField.GetValue(pause); if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } GameObject val2 = new GameObject("ItemVaultPanel", new Type[1] { typeof(RectTransform) }); RectTransform val3 = (RectTransform)val2.transform; ((Transform)val3).SetParent((Transform)(object)pause.rootPanel, false); Stretch(val3, Vector2.zero, Vector2.one); VaultPanel vaultPanel = val2.AddComponent<VaultPanel>(); vaultPanel.pause = pause; vaultPanel.buttonTemplate = pause.exitGameButton; TextMeshProUGUI componentInChildren = pause.exitGameButton.GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)componentInChildren != (Object)null) { vaultPanel.font = ((TMP_Text)componentInChildren).font; } vaultPanel.Build(); ItemVaultPlugin.submenuObjectField.SetValue(pause, val2); ((Component)pause.pausePanel).gameObject.SetActive(false); ((Component)pause.gameMenuPanel).gameObject.SetActive(true); ((Component)pause.mainPanel).gameObject.SetActive(false); } private void Build() { //IL_0030: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00fb: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Expected O, but got Unknown //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Expected O, but got Unknown //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Expected O, but got Unknown //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Expected O, but got Unknown Image val = ((Component)this).gameObject.AddComponent<Image>(); ((Graphic)val).color = new Color(0f, 0f, 0f, 0.6f); RectTransform val2 = NewRect("Box", ((Component)this).transform); Stretch(val2, new Vector2(0.12f, 0.08f), new Vector2(0.88f, 0.92f)); Image val3 = ((Component)val2).gameObject.AddComponent<Image>(); ((Graphic)val3).color = new Color(0.09f, 0.1f, 0.12f, 0.96f); Outline val4 = ((Component)val2).gameObject.AddComponent<Outline>(); ((Shadow)val4).effectColor = new Color(0.55f, 0.6f, 0.65f, 0.6f); ((Shadow)val4).effectDistance = new Vector2(2f, -2f); VerticalLayoutGroup val5 = ((Component)val2).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val5).padding = new RectOffset(24, 24, 18, 18); ((HorizontalOrVerticalLayoutGroup)val5).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false; title = NewText("Title", (Transform)(object)val2, 40f, (TextAlignmentOptions)514); SetHeight(((Component)title).gameObject, 50f); info = NewText("Info", (Transform)(object)val2, 22f, (TextAlignmentOptions)514); ((Graphic)info).color = new Color(0.8f, 0.82f, 0.85f); SetHeight(((Component)info).gameObject, 30f); grid = NewScrollGrid("Scroll", (Transform)(object)val2, 1f, sections: true); catalogLabel = NewText("CatalogLabel", (Transform)(object)val2, 22f, (TextAlignmentOptions)513); ((Graphic)catalogLabel).color = new Color(0.8f, 0.82f, 0.85f); SetHeight(((Component)catalogLabel).gameObject, 30f); catalogGrid = NewScrollGrid("CatalogScroll", (Transform)(object)val2, 2f, sections: true); catalogScroll = ((Component)((Transform)catalogGrid).parent).gameObject; RectTransform val6 = NewRect("Buttons", (Transform)(object)val2); SetHeight(((Component)val6).gameObject, 48f); HorizontalLayoutGroup val7 = ((Component)val6).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)val7).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandHeight = true; ItemVaultPlugin plugin = ItemVaultPlugin.Instance; takeAllButton = AddButton((Transform)(object)val6, "Взять все", (UnityAction)delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(2, 0, PickupIndex.none); }); collectMapButton = AddButton((Transform)(object)val6, "Собрать с карты", (UnityAction)delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(4, 0, PickupIndex.none); }); sharedButton = AddButton((Transform)(object)val6, "Общий инвентарь", (UnityAction)delegate { SetMode(Mode.Shared); }); applyButton = AddButton((Transform)(object)val6, "Применить очередь", (UnityAction)delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(8, 0, PickupIndex.none); }); queueButton = AddButton((Transform)(object)val6, "Очередь Команды", (UnityAction)delegate { SetMode(Mode.Queue); }); settingsButton = AddButton((Transform)(object)val6, "Настройки", (UnityAction)delegate { SetMode(Mode.Settings); }); adminButton = AddButton((Transform)(object)val6, "Админ", (UnityAction)delegate { SetMode(Mode.Admin); }); clickModeButton = AddButton((Transform)(object)val6, "", (UnityAction)delegate { clickMode = ((clickMode == ClickMode.Take) ? ClickMode.Drop : ((clickMode == ClickMode.Drop) ? ClickMode.Delete : ClickMode.Take)); UpdateLabels(); builtVersion = -1; }); loopButton = AddButton((Transform)(object)val6, "", (UnityAction)delegate { ItemVaultPlugin.CommandQueueLoop.Value = !ItemVaultPlugin.CommandQueueLoop.Value; UpdateLabels(); plugin.QueueChanged(); }); clearButton = AddButton((Transform)(object)val6, "Очистить очередь", (UnityAction)delegate { plugin.QueueClear(); }); AddButton((Transform)(object)val6, "Назад", (UnityAction)delegate { if (mode != Mode.Vault) { SetMode(Mode.Vault); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } }); UpdateLabels(); SetMode(Mode.Vault); } private GameObject AddButton(Transform row, string label, UnityAction onClick) { GameObject val = ItemVaultPlugin.CloneMenuButton(buttonTemplate, row, label, onClick); LayoutElement val2 = val.GetComponent<LayoutElement>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<LayoutElement>(); } val2.minHeight = 48f; val2.preferredHeight = 48f; val2.flexibleHeight = 0f; val2.minWidth = 0f; val2.preferredWidth = 0f; val2.flexibleWidth = 1f; TextMeshProUGUI[] componentsInChildren = val.GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val3 in componentsInChildren) { ((TMP_Text)val3).enableAutoSizing = true; ((TMP_Text)val3).fontSizeMin = 12f; ((TMP_Text)val3).fontSizeMax = 20f; ((TMP_Text)val3).enableWordWrapping = false; } return val; } private void UpdateLabels() { SetButtonText(loopButton, ItemVaultPlugin.CommandQueueLoop.Value ? "Цикл: вкл" : "Цикл: выкл"); string label = ((clickMode == ClickMode.Drop) ? "ЛКМ: выбросить" : ((clickMode == ClickMode.Delete) ? "<color=#ff5050>ЛКМ: удалить</color>" : "ЛКМ: взять")); SetButtonText(clickModeButton, label); } private static void SetButtonText(GameObject button, string label) { TextMeshProUGUI[] componentsInChildren = button.GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val in componentsInChildren) { ((TMP_Text)val).text = label; } } private void SetMode(Mode newMode) { mode = newMode; ItemVaultPlugin.Instance.clientStatus = ""; bool flag = mode == Mode.Vault; takeAllButton.SetActive(flag); collectMapButton.SetActive(flag); sharedButton.SetActive(flag); applyButton.SetActive(flag); settingsButton.SetActive(flag); queueButton.SetActive(flag); clickModeButton.SetActive(flag); adminButton.SetActive(flag && ItemVaultPlugin.Instance.AdminActive); loopButton.SetActive(mode == Mode.Queue); clearButton.SetActive(mode == Mode.Queue); bool flag2 = mode == Mode.Queue || mode == Mode.Admin; ((Component)catalogLabel).gameObject.SetActive(flag2); catalogScroll.SetActive(flag2); ((TMP_Text)catalogLabel).text = ((mode == Mode.Admin) ? "Админ: нажмите на предмет, чтобы заспавнить его рядом с собой" : "Все предметы — нажмите, чтобы добавить в очередь (Shift ×10, Ctrl ×100, Shift+Ctrl ×1000)"); if (flag2 && !catalogBuilt) { BuildCatalog(); } builtVersion = -1; } private void Update() { if (builtVersion != ItemVaultPlugin.Instance.version) { Rebuild(); } } private VaultEntry FindClientEntry(int id) { return ItemVaultPlugin.Instance.clientEntries.Find((VaultEntry e) => e.id == id); } private void Rebuild() { ItemVaultPlugin instance = ItemVaultPlugin.Instance; builtVersion = instance.version; if (mode == Mode.Choose && FindClientEntry(choosingId) == null) { SetMode(Mode.Vault); } for (int num = ((Transform)grid).childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)((Transform)grid).GetChild(num)).gameObject); } if (mode != Mode.Queue && mode != Mode.Settings) { cells = NewRect("Section", (Transform)(object)grid); AddGrid(cells); } if (mode == Mode.Choose) { RebuildChoose(instance); } else if (mode == Mode.Shared) { RebuildShared(instance); } else if (mode == Mode.Settings) { RebuildSettings(); } else if (mode == Mode.Queue) { RebuildQueue(instance); } else { RebuildVault(instance); } } private void RebuildVault(ItemVaultPlugin plugin) { //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown int num = 0; foreach (VaultEntry clientEntry in plugin.clientEntries) { num += clientEntry.count; } ((TMP_Text)title).text = ((mode == Mode.Admin) ? "Админ-режим" : "Хранилище предметов"); string text = ((plugin.clientPlayerCount > 1) ? ("Вы игрок " + plugin.clientPlayerNumber + " из " + plugin.clientPlayerCount + " · ") : ""); ((TMP_Text)info).text = (string.IsNullOrEmpty(plugin.clientStatus) ? (text + "Всего: " + num + ((plugin.clientPendingGive > 0) ? (" · Выдаётся: " + plugin.clientPendingGive) : "") + ((plugin.clientPendingDrop > 0) ? (" · Выбрасывается: " + plugin.clientPendingDrop) : "") + " · ЛКМ — " + ClickModeVerb() + ", ПКМ — в общий · Shift ×10, Ctrl ×100, Shift+Ctrl ×1000") : plugin.clientStatus); foreach (VaultEntry clientEntry2 in plugin.clientEntries) { UnityAction val = null; UnityAction val2 = null; UnityAction val3 = null; UnityAction val4 = null; VaultEntry entry = clientEntry2; UnityAction onRightClick = (UnityAction)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(6, entry.id, PickupIndex.none, ItemVaultPlugin.ClickAmount()); }; UnityAction onClick; if (clickMode == ClickMode.Drop) { if (val == null) { val = (UnityAction)delegate { //IL_0018: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(9, entry.id, PickupIndex.none, ItemVaultPlugin.ClickAmount()); }; } onClick = val; } else if (clickMode == ClickMode.Delete) { if (val2 == null) { val2 = (UnityAction)delegate { //IL_0018: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(10, entry.id, PickupIndex.none, ItemVaultPlugin.ClickAmount()); }; } onClick = val2; } else if (entry.IsChoice) { if (val3 == null) { val3 = (UnityAction)delegate { choosingId = entry.id; SetMode(Mode.Choose); }; } onClick = val3; } else { if (val4 == null) { val4 = (UnityAction)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(1, entry.id, PickupIndex.none, ItemVaultPlugin.ClickAmount()); }; } onClick = val4; } AddCell(cells, entry.pickup, entry.count, entry.IsChoice, onClick, null, onRightClick); } } private string ClickModeVerb() { return clickMode switch { ClickMode.Drop => "выбросить на землю", ClickMode.Delete => "УДАЛИТЬ", _ => "взять", }; } private void RebuildShared(ItemVaultPlugin plugin) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown int num = 0; foreach (VaultEntry item in plugin.clientShared) { num += item.count; } ((TMP_Text)title).text = "Общий инвентарь"; ((TMP_Text)info).text = (string.IsNullOrEmpty(plugin.clientStatus) ? ("Всего: " + num + " · Нажмите, чтобы забрать себе · Shift ×10, Ctrl ×100, Shift+Ctrl ×1000") : plugin.clientStatus); foreach (VaultEntry item2 in plugin.clientShared) { VaultEntry entry = item2; AddCell(cells, entry.pickup, entry.count, entry.IsChoice, (UnityAction)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(7, entry.id, PickupIndex.none, ItemVaultPlugin.ClickAmount()); }); } } private void RebuildSettings() { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown ((TMP_Text)title).text = "Настройки ItemVault"; ((TMP_Text)info).text = (NetworkServer.active ? "Вы хост: сбор, раздача и админ-режим работают по вашим настройкам." : "В онлайне сбор и админ-режим работают по настройкам хоста."); AddToggle("Автосбор предметов", ItemVaultPlugin.Enabled); AddToggle("Собирать активные предметы", ItemVaultPlugin.CollectEquipment); AddToggle("Собирать лунные предметы", ItemVaultPlugin.CollectLunar); AddToggle("Собирать предметы Пустоты", ItemVaultPlugin.CollectVoid); AddToggle("Артефакт Команды: класть выбор в хранилище", ItemVaultPlugin.CollectCommand); AddCycle("Предметов за порцию сбора", ItemVaultPlugin.CollectPerTick, new int[7] { 1, 2, 3, 5, 10, 20, 50 }); AddCycle("Пауза между порциями (с)", ItemVaultPlugin.CollectInterval, new float[5] { 0.1f, 0.25f, 0.5f, 1f, 2f }); AddCycle("Выдача игроку: предметов за порцию", ItemVaultPlugin.GivePerTick, new int[8] { 1, 2, 3, 5, 10, 20, 50, 100 }); AddCycle("Выдача игроку: пауза между порциями (с)", ItemVaultPlugin.GiveInterval, new float[5] { 0.1f, 0.25f, 0.5f, 1f, 2f }); bool adminActive = ItemVaultPlugin.Instance.AdminActive; AddSettingButton("Админ-режим (спавн предметов): " + (adminActive ? "ВКЛ" : "ВЫКЛ"), new UnityAction(OnAdminClicked)); AddSettingButton("Блок перехода на следующую локацию: " + (adminActive ? "ВКЛ (пока включён админ-режим)" : "ВЫКЛ"), (UnityAction)delegate { ShowDialog("Блок перехода", "Блок перехода включается вместе с админ-режимом и выключается только вместе с ним — в конце забега.", "Понятно", null, null); }); } private void OnAdminClicked() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown if (!NetworkServer.active) { ShowDialog("Вы не хост", "Вы не хост и не можете включить админ-режим. Включить его может только хост игры.", "Понятно", null, null); return; } if (ItemVaultPlugin.AdminMode.Value) { ShowDialog("Админ-режим уже включён", "Выключить админ-режим нельзя до конца забега. Он выключится сам, когда забег закончится.", "Понятно", null, null); return; } ShowDialog("Включить админ-режим?", "Что будет:\n• Появится кнопка «Админ» — спавн любых предметов. Ей смогут пользоваться все игроки.\n• Телепорт перестанет переносить на следующую локацию — забег останется на этой карте.\n• Все игроки увидят в чате, что админ-режим включён.\n• Выключить его нельзя до конца забега. Он выключится сам, когда забег закончится.\n\nРежим нужен для тестов мода, а не для обычной игры.", "Да, включить", (UnityAction)delegate { ItemVaultPlugin.Instance.EnableAdminMode(); builtVersion = -1; }, "Нет"); } private void ShowDialog(string header, string body, string yesLabel, UnityAction onYes, string noLabel) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_005c: 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_008b: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_0124: 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_014d: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown UnityAction val = null; GameObject overlay = new GameObject("ItemVaultDialog", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)overlay.transform; ((Transform)val2).SetParent(((Component)this).transform, false); Stretch(val2, Vector2.zero, Vector2.one); ((Graphic)overlay.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.75f); RectTransform val3 = NewRect("Box", (Transform)(object)val2); Stretch(val3, new Vector2(0.3f, 0.3f), new Vector2(0.7f, 0.7f)); ((Graphic)((Component)val3).gameObject.AddComponent<Image>()).color = new Color(0.12f, 0.13f, 0.16f, 0.98f); Outline val4 = ((Component)val3).gameObject.AddComponent<Outline>(); ((Shadow)val4).effectColor = new Color(0.9f, 0.4f, 0.35f, 0.8f); ((Shadow)val4).effectDistance = new Vector2(2f, -2f); VerticalLayoutGroup val5 = ((Component)val3).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val5).padding = new RectOffset(28, 28, 20, 20); ((HorizontalOrVerticalLayoutGroup)val5).spacing = 12f; ((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false; TextMeshProUGUI val6 = NewText("Header", (Transform)(object)val3, 32f, (TextAlignmentOptions)514); ((TMP_Text)val6).text = header; SetHeight(((Component)val6).gameObject, 44f); TextMeshProUGUI val7 = NewText("Body", (Transform)(object)val3, 21f, (TextAlignmentOptions)257); ((TMP_Text)val7).text = body; ((Graphic)val7).color = new Color(0.85f, 0.87f, 0.9f); ((Component)val7).gameObject.AddComponent<LayoutElement>().flexibleHeight = 1f; RectTransform val8 = NewRect("Buttons", (Transform)(object)val3); SetHeight(((Component)val8).gameObject, 48f); HorizontalLayoutGroup val9 = ((Component)val8).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val9).spacing = 12f; ((HorizontalOrVerticalLayoutGroup)val9).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val9).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val9).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val9).childForceExpandHeight = true; AddButton((Transform)(object)val8, yesLabel, (UnityAction)delegate { Object.Destroy((Object)(object)overlay); if (onYes != null) { onYes.Invoke(); } }); if (noLabel == null) { return; } if (val == null) { val = (UnityAction)delegate { Object.Destroy((Object)(object)overlay); }; } AddButton((Transform)(object)val8, noLabel, val); } private void AddSettingButton(string label, UnityAction onClick) { GameObject val = AddButton((Transform)(object)grid, label, onClick); TextMeshProUGUI[] componentsInChildren = val.GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val2 in componentsInChildren) { ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; } } private void AddToggle(string label, ConfigEntry<bool> entry) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown AddSettingButton(label + ": " + (entry.Value ? "ВКЛ" : "ВЫКЛ"), (UnityAction)delegate { entry.Value = !entry.Value; builtVersion = -1; }); } private void AddCycle(string label, ConfigEntry<int> entry, int[] values) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown AddSettingButton(label + ": " + entry.Value, (UnityAction)delegate { int num = Array.IndexOf(values, entry.Value); entry.Value = values[(num + 1) % values.Length]; builtVersion = -1; }); } private void AddCycle(string label, ConfigEntry<float> entry, float[] values) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown AddSettingButton(label + ": " + entry.Value, (UnityAction)delegate { int num = Array.IndexOf(values, entry.Value); entry.Value = values[(num + 1) % values.Length]; builtVersion = -1; }); } private void RebuildChoose(ItemVaultPlugin plugin) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown VaultEntry choice = FindClientEntry(choosingId); ((TMP_Text)title).text = "Артефакт Команды: выберите предмет (осталось " + choice.count + ")"; ((TMP_Text)info).text = (string.IsNullOrEmpty(plugin.clientStatus) ? "Выбранный предмет попадёт в хранилище · Shift ×10, Ctrl ×100, Shift+Ctrl ×1000" : plugin.clientStatus); PickupIndex[] options = choice.options; foreach (PickupIndex val in options) { PickupIndex picked = val; AddCell(cells, val, 0, isChoice: false, (UnityAction)delegate { //IL_001d: Unknown result type (might be due to invalid IL or missing references) plugin.SendAction(3, choice.id, picked, ItemVaultPlugin.ClickAmount()); }); } } private void RebuildQueue(ItemVaultPlugin plugin) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_024e: Expected O, but got Unknown bool value = ItemVaultPlugin.CommandQueueLoop.Value; ((TMP_Text)title).text = "Очередь Артефакта Команды"; ((TMP_Text)info).text = ((plugin.queue.Count == 0) ? "Очередь пуста. Добавьте предметы снизу." : (value ? "Цикл: стаки по кругу. ЛКМ — добавить, ПКМ — убрать. Shift ×10, Ctrl ×100, Shift+Ctrl ×1000" : "Стаки выдаются один раз. ЛКМ — добавить, ПКМ — убрать. Shift ×10, Ctrl ×100, Shift+Ctrl ×1000")); List<int> list = new List<int>(); foreach (QueueSlot item2 in plugin.queue) { int item = ItemVaultPlugin.SlotKey(item2); if (!list.Contains(item)) { list.Add(item); } } foreach (int item3 in list) { List<int> list2 = plugin.SlotsForKey(item3); int count = list2.Count; PickupDef pickupDef = PickupCatalog.GetPickupDef(plugin.queue[list2[0]].pickup); RectTransform parent = AddSection(grid, "Очередь: " + ItemVaultPlugin.SectionName(item3), pickupDef?.baseColor ?? Color.white); int num = ItemVaultPlugin.GetOrZero(plugin.clientPositions, item3) % count; for (int i = 0; i < count; i++) { int index = list2[i]; QueueSlot queueSlot = plugin.queue[index]; string corner = (i + 1).ToString(); if (value && i == num) { corner = ">" + (i + 1) + " " + ItemVaultPlugin.GetOrZero(plugin.clientProgress, item3) + "/" + queueSlot.count; } PickupIndex pickup = queueSlot.pickup; AddCell(parent, pickup, queueSlot.count, isChoice: false, (UnityAction)delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) plugin.QueueAdd(pickup, ItemVaultPlugin.ClickAmount()); }, corner, (UnityAction)delegate { plugin.QueueRemove(index, ItemVaultPlugin.ClickAmount()); }); } } } private RectTransform AddSection(RectTransform list, string headerText, Color color) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = NewText("Header", (Transform)(object)list, 22f, (TextAlignmentOptions)1025); ((TMP_Text)val).text = headerText; ((Graphic)val).color = color; ((TMP_Text)val).fontStyle = (FontStyles)1; ((TMP_Text)val).margin = new Vector4(12f, 0f, 0f, 0f); SetHeight(((Component)val).gameObject, 32f); RectTransform val2 = NewRect("Section", (Transform)(object)list); AddGrid(val2); return val2; } private void BuildCatalog() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0090: Expected O, but got Unknown catalogBuilt = true; int num = int.MinValue; RectTransform val = null; foreach (PickupIndex item in ItemVaultPlugin.GetCatalog()) { PickupDef pickupDef = PickupCatalog.GetPickupDef(item); if (pickupDef == null) { continue; } int num2 = ItemVaultPlugin.SortKey(pickupDef); if ((Object)(object)val == (Object)null || num2 != num) { num = num2; val = AddSection(catalogGrid, ItemVaultPlugin.SectionName(num2), pickupDef.baseColor); } PickupIndex picked = item; AddCell(val, item, 0, isChoice: false, (UnityAction)delegate { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (mode == Mode.Admin) { ItemVaultPlugin.Instance.SendAction(5, 0, picked, ItemVaultPlugin.ClickAmount()); } else { ItemVaultPlugin.Instance.QueueAdd(picked, ItemVaultPlugin.ClickAmount()); } }); } } private void AddCell(RectTransform parent, PickupIndex index, int count, bool isChoice, UnityAction onClick) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) AddCell(parent, index, count, isChoice, onClick, null); } private void AddCell(RectTransform parent, PickupIndex index, int count, bool isChoice, UnityAction onClick, string corner) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) AddCell(parent, index, count, isChoice, onClick, corner, null); } private void AddCell(RectTransform parent, PickupIndex index, int count, bool isChoice, UnityAction onClick, string corner, UnityAction onRightClick) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown