예제 #1
0
        private void ItemDropped(GetDataHandlers.ItemDropEventArgs args)
        {
            //Debug.Print("Dropped Item!");

            var itemIdName = EnglishLanguage.GetItemNameById(args.Type);

            if (_itemName?.Equals(itemIdName, StringComparison.OrdinalIgnoreCase) ?? true)
            {
                var index = Main.maxItems;
                for (var i = 0; i < Main.maxItems; ++i)
                {
                    if (!Main.item[i].active && Main.itemLockoutTime[i] == 0)
                    {
                        index = i;
                        break;
                    }
                }
                if (index == Main.maxItems)
                {
                    var minTimeDiff = 0;
                    for (var i = 0; i < Main.maxItems; ++i)
                    {
                        var timeDiff = Main.item[i].spawnTime - Main.itemLockoutTime[i];
                        if (timeDiff > minTimeDiff)
                        {
                            minTimeDiff = timeDiff;
                            index       = i;
                        }
                    }
                }
                _blacklistedIndexes.Add(index);
            }
        }
예제 #2
0
        private void ItemGathered(GetDataHandlers.ItemDropEventArgs args)
        {
            //Debug.Print("Gathered Item!");

            //only continue if an entire Item(stack) is being removed. ( We have to account for multiple item stacks combining into a single stack. )
            if (args.Stacks != 0)
            {
                return;
            }

            var index = args.ID;
            var item  = Main.item[index];

            if (_itemName?.Equals(item.Name, StringComparison.OrdinalIgnoreCase) ?? true)
            {
                if (_blacklistedIndexes.Contains(index))
                {
                    _blacklistedIndexes.Remove(index);
                }
                else
                {
                    itemsRequired = Math.Max(0, itemsRequired - item.stack);

                    if (HasTallyChangedAction)
                    {
                        var member = partyMembers.FirstOrDefault(pm => pm.Player == args.Player);
                        if (member != null)
                        {
                            TryEnqueueTallyChange(member, item.stack);
                        }
                    }
                }
            }
        }
예제 #3
0
        private void OnItemDrop(object sender, GetDataHandlers.ItemDropEventArgs args)
        {
            var player = args.Player;

            if (args.Handled)
            {
                return;
            }

            if (args.ID == Main.maxItems)
            {
                var itemIdName = EnglishLanguage.GetItemNameById(args.Type);
                if (_itemName?.Equals(itemIdName, StringComparison.OrdinalIgnoreCase) ?? true)
                {
                    var index = Main.maxItems;
                    for (var i = 0; i < Main.maxItems; ++i)
                    {
                        if (!Main.item[i].active && Main.itemLockoutTime[i] == 0)
                        {
                            index = i;
                            break;
                        }
                    }
                    if (index == Main.maxItems)
                    {
                        var minTimeDiff = 0;
                        for (var i = 0; i < Main.maxItems; ++i)
                        {
                            var timeDiff = Main.item[i].spawnTime - Main.itemLockoutTime[i];
                            if (timeDiff > minTimeDiff)
                            {
                                minTimeDiff = timeDiff;
                                index       = i;
                            }
                        }
                    }
                    _blacklistedIndexes.Add(index);
                }
            }
            else if (partyMembers.Any(p => p.IsValidMember && p.Player.Index == player.Index))
            {
                var index = args.ID;
                var item  = Main.item[index];
                if (_itemName?.Equals(item.Name, StringComparison.OrdinalIgnoreCase) ?? true)
                {
                    if (_blacklistedIndexes.Contains(index))
                    {
                        _blacklistedIndexes.Remove(index);
                    }
                    else
                    {
                        var difference = item.stack - args.Stacks;
                        _amount = Math.Max(0, _amount - difference);
                    }
                }
            }
        }
        private void OnDroppedEvent(object sender, GetDataHandlers.ItemDropEventArgs arg)
        {
            TSPlayer player = arg.Player;

            // Check if user has info and he/she in died state
            if (lastPlaceOfDeathData.GetUserSavedMoney(player.UUID) && player.TPlayer.DeadOrGhost)
            {
                // Check if the Coin Dropped after death
                if (arg.Type <= ItemID.PlatinumCoin && arg.Type >= ItemID.CopperCoin)
                {
                    Item coin = ItemManager.GetTerrariaItemByID(arg.Type);
                    coin.stack = arg.Stacks;
                    player.SendMessage("Dropped your Coin!", Color.OrangeRed);
                }
            }
        }
예제 #5
0
        private void OnItemDrop(object sender, GetDataHandlers.ItemDropEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }

            if (args.ID == Main.maxItems)
            {
                ItemDropped(args);
            }
            else if (partyMembers.Any(p => p.IsValidMember && p.Player.Index == args.Player.Index))
            {
                ItemGathered(args);
            }
        }
예제 #6
0
        private void OnItemDrop(object sender, GetDataHandlers.ItemDropEventArgs args)
        {
            var player = args.Player;

            if (args.Handled || args.ID != Main.maxItems || partyMembers.All(p => p.Player.Index != player.Index))
            {
                return;
            }

            var itemIdName = EnglishLanguage.GetItemNameById(args.Type);

            if (_itemName?.Equals(itemIdName, StringComparison.OrdinalIgnoreCase) ?? true)
            {
                _amount -= args.Stacks;
                if (_amount < 0)
                {
                    player.GiveItem(args.Type, "", 20, 42, -_amount, args.Prefix);
                    _amount = 0;
                }
                args.Handled = true;
            }
        }