コード例 #1
0
        public void CheckExpired()
        {
            var currentTime = MasterThread.CurrentDate.ToFileTimeUtc();

            _cashItems.GetExpiredItems(currentTime, expiredItems =>
            {
                var dict = new Dictionary <byte, List <short> >();
                expiredItems.ForEach(x =>
                {
                    InventoryPacket.SendCashItemExpired(Character, x.ItemId);
                    var inventory = Constants.getInventory(x.ItemId);
                    var baseItem  = GetItemByCashID(x.CashId, inventory);

                    if (baseItem != null)
                    {
                        if (dict.TryGetValue(inventory, out var curList))
                        {
                            curList.Add(baseItem.InventorySlot);
                        }
                        else
                        {
                            dict[inventory] = new List <short> {
                                baseItem.InventorySlot
                            };
                        }
                    }
                    RemoveLockerItem(x, baseItem, true);
                });

                dict.ForEach(x => InventoryPacket.MultiDelete(Character, x.Key, x.Value.ToArray()));
            });

            GetExpiredItems(currentTime, expiredItems =>
            {
                var dict    = new Dictionary <byte, List <short> >();
                var itemIds = new List <int>();
                expiredItems.ForEach(x =>
                {
                    var inventory = Constants.getInventory(x.ItemID);
                    if (x.CashId != 0)
                    {
                        var baseItem = GetItemByCashID(x.CashId, inventory);
                        if (dict.TryGetValue(inventory, out var curList))
                        {
                            curList.Add(baseItem.InventorySlot);
                        }
                        else
                        {
                            dict[inventory] = new List <short> {
                                baseItem.InventorySlot
                            };
                        }
                        TryRemoveCashItem(x);
                    }
                    SetItem(inventory, x.InventorySlot, null);
                    itemIds.Add(x.ItemID);
                });

                InventoryPacket.SendItemsExpired(Character, itemIds);
                dict.ForEach(x => InventoryPacket.MultiDelete(Character, x.Key, x.Value.ToArray()));
            });
        }