Ejemplo n.º 1
0
        void CloseBank(BasePlayer player, StorageContainer view)
        {
            if (!onlinePlayers.ContainsKey(player))
            {
                return;
            }
            if (onlinePlayers [player].View == null)
            {
                return;
            }

            if (!banks.ContainsKey(player.userID))
            {
                return;
            }

            BankProfile profile = banks [player.userID];

            InvalidateBank(player, profile, view);

            profile.items.Clear();
            foreach (Item item in view.inventory.itemList)
            {
                profile.Add(item);
            }

            SaveProfile(player.userID, profile);

            foreach (Item item in view.inventory.itemList.ToArray())
            {
                if (item.position != -1)
                {
                    item.RemoveFromContainer();
                    item.Remove(0f);
                }
            }

            profile.open = false;

            if (containers.ContainsKey(view.inventory))
            {
                containers.Remove(view.inventory);
            }

            player.inventory.loot.containers = new List <ItemContainer> ();
            view.inventory = new ItemContainer();

            if (player.inventory.loot.IsLooting())
            {
                player.SendConsoleCommand("inventory.endloot", null);
            }


            onlinePlayers [player].View   = null;
            onlinePlayers [player].Target = null;

            view.Kill(BaseNetworkable.DestroyMode.None);
            //view.KillMessage();
            if (onlinePlayers.Values.Count(p => p.View != null) <= 0)
            {
                //Unsubscribe(nameof(CanNetworkTo));
                Unsubscribe(nameof(OnEntityTakeDamage));
            }
        }