Example #1
0
 public override void ModifyTooltips(Item item, List <TooltipLine> tooltips)
 {
     if (BagsOfHoldingMod.tooltipDisplay)
     {
         tooltips.Add(new TooltipLine(this.mod, "tagID", "<" + GenericHoldingBag.ItemToTag(item) + ">"));
     }
 }
Example #2
0
        public override bool ItemSpace(Item item, Player player)
        {
            string    itmTag = GenericHoldingBag.ItemToTag(item);
            BagPlayer bpl    = player.GetModPlayer <BagPlayer>();

            if (bpl.checkAccessories)
            {
                for (int i = 3; i < 8 + player.extraAccessorySlots; i++)
                {
                    if (player.armor[i] != null && player.armor[i].type != 0 && player.armor[i].modItem != null && player.armor[i].modItem is GenericHoldingBag)
                    {
                        if (((GenericHoldingBag)(player.armor[i].modItem)).canPickupItem(itmTag))
                        {
                            return(true);
                        }
                    }
                }
            }
            if (bpl.checkVanity)
            {
                for (int i = 13; i < 18 + player.extraAccessorySlots; i++)
                {
                    if (player.armor[i] != null && player.armor[i].type != 0 && player.armor[i].modItem != null && player.armor[i].modItem is GenericHoldingBag)
                    {
                        if (((GenericHoldingBag)(player.armor[i].modItem)).canPickupItem(itmTag))
                        {
                            return(true);
                        }
                    }
                }
            }
            if (bpl.checkInventory)
            {
                for (int i = 49; i >= 10; i--)
                {
                    if (player.inventory[i] != null && player.inventory[i].type != 0 && player.inventory[i].modItem != null && player.inventory[i].modItem is GenericHoldingBag)
                    {
                        if (((GenericHoldingBag)(player.inventory[i].modItem)).canPickupItem(itmTag))
                        {
                            return(true);
                        }
                    }
                }
            }
            if (bpl.checkHotbar)
            {
                for (int i = 0; i < 10; i++)
                {
                    if (player.inventory[i] != null && player.inventory[i].type != 0 && player.inventory[i].modItem != null && player.inventory[i].modItem is GenericHoldingBag)
                    {
                        if (((GenericHoldingBag)(player.inventory[i].modItem)).canPickupItem(itmTag))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Example #3
0
        public void addItemIfPossible(Item item, GenericHoldingBag bag)
        {
            if (!bag.canPickupItem(GenericHoldingBag.ItemToTag(item)))
            {
                //ErrorLogger.Log("Could not get in the bag: <" + GenericHoldingBag.ItemToTag(item) + "> order:" + bag.order.Contains(GenericHoldingBag.ItemToTag(item)) + "; preventPickup:" + bag.preventPickup.Contains(GenericHoldingBag.ItemToTag(item)));
                return;
            }

            Item cln = new Item();

            cln.SetDefaults(item.type);
            long total = bag.addItem(item);

            if (total > 0)
            {
                cln.position = new Microsoft.Xna.Framework.Vector2(item.position.X, item.position.Y + 30);
                cln.stack    = (int)total;
                ItemText.NewText(cln, (int)total);
            }
        }
        public override ModItem Clone()
        {
            GenericHoldingBag cln = (GenericHoldingBag)this.MemberwiseClone();

            cln.items = null;
            cln.SetDefaults();
            cln.order         = this.order;
            cln.preventPickup = this.preventPickup;
            cln.items         = new TagCompound();
            if (items != null && items.Count > 0)
            {
                for (int i = 0; i < order.Count; i++)
                {
                    if (items.ContainsKey(order[i]))
                    {
                        cln.items[order[i]] = items[order[i]];
                    }
                }
            }
            return(cln);
        }