Example #1
0
        public override void UpdateInventory(Player player)
        {
            if (!active)
            {
                return;
            }

            for (int i = 0; i < Main.item.Length; i++)
            {
                ref Item it = ref Main.item[i];

                var item1 = it;
                if (it == null || it.IsAir || Vector2.Distance(it.Center, player.Center) > maxRange || player.Inventory().OfType <BaseBag>().All(bag => !bag.Handler.HasSpace(item1)))
                {
                    if (it != null && PSItem.BlackHoleData.ContainsKey(i))
                    {
                        PSItem.BlackHoleData.Remove(i);
                    }
                    continue;
                }

                if (!PSItem.BlackHoleData.ContainsKey(i))
                {
                    PSItem.BlackHoleData.Add(i, (1, 0));
                }

                if (PSItem.BlackHoleData[i].scale <= 0f)
                {
                    if (!ItemLoader.OnPickup(it, player))
                    {
                        it = new Item();
                    }
                    else if (ItemID.Sets.NebulaPickup[it.type])
                    {
                        int buffType = it.buffType;
                        it = new Item();

                        if (Main.netMode == 1)
                        {
                            NetMessage.SendData(MessageID.NebulaLevelupRequest, -1, -1, null, player.whoAmI, buffType, player.Center.X, player.Center.Y);
                        }
                        else
                        {
                            player.NebulaLevelup(buffType);
                        }
                    }
                    else if (it.type == 58 || it.type == 1734 || it.type == 1867)
                    {
                        player.statLife += 20;
                        if (Main.myPlayer == player.whoAmI)
                        {
                            player.HealEffect(20);
                        }
                        if (player.statLife > player.statLifeMax2)
                        {
                            player.statLife = player.statLifeMax2;
                        }

                        it = new Item();
                    }
                    else if (it.type == 184 || it.type == 1735 || it.type == 1868)
                    {
                        player.statMana += 100;
                        if (Main.myPlayer == player.whoAmI)
                        {
                            player.ManaEffect(100);
                        }
                        if (player.statMana > player.statManaMax2)
                        {
                            player.statMana = player.statManaMax2;
                        }

                        it = new Item();
                    }
                    else
                    {
                        foreach (BaseBag bag in player.inventory.OfType <BaseBag>().OrderBy(bag => !bag.GetType().IsSubclassOf(typeof(BaseNormalBag))))
                        {
                            if (bag.Handler.HasSpace(it))
                            {
                                Item temp = it.Clone();

                                bag.Handler.InsertItem(ref it);

                                Hooking.BagItemText(bag.item, temp, temp.stack - it.stack, false, false);

                                if (it.IsAir || !it.active)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        NetMessage.SendData(MessageID.SyncItem, -1, -1, null, i);
                    }
                }
            }