public override bool OnPickup(Item item, Player player) { if (pickup != null && BagPickup.NotStorage(item)) { if (canStack) { for (int a = 0; a < pickup.contained.Count; a++) { if (pickup.contained[a].type == item.type && pickup.contained[a].prefix == item.prefix && BagPickup.EndlessStack(pickup, item.type, a)) { Main.PlaySound(SoundID.Grab); pickup.contained[a].stack += item.stack; ItemText.NewText(item, item.stack); item.SetDefaults(ItemID.None); canStack = false; break; } } BagPickup.SetList(new Item(), player.GetModPlayer <CastledPlayer>(), pickup); return(false); } if (!canStack && pickup.contained.Count < pickup.limit) { Main.PlaySound(SoundID.Grab); pickup.contained.Add(item.Clone()); ItemText.NewText(item, item.stack); BagPickup.SetList(new Item(), player.GetModPlayer <CastledPlayer>(), pickup); return(false); } } return(base.OnPickup(item, player)); }
public static PackageData Load(TagCompound tag) { int limit = tag.GetInt("SLimit"); bool pickup = tag.GetBool("SPickup"); BagPickup bagInit = new BagPickup(limit, pickup) { contained = tag.Get <List <Item> >("SStorage") }; return(new PackageData(tag.Get <Vector2>("coord"), tag.GetInt("type"), bagInit)); }
public override bool ItemSpace(Item item, Player player) { if (pickup != null && BagPickup.NotStorage(item)) { for (int a = 0; a < pickup.contained.Count; a++) { if (pickup.contained[a].type == item.type && pickup.contained[a].prefix == item.prefix && BagPickup.EndlessStack(pickup, item.type, a)) { canStack = true; break; } } if (!canStack) { return(pickup.contained.Count < pickup.limit); } else { return(true); } } return(base.ItemSpace(item, player)); }
public PackageData(Vector2 coord, int type, BagPickup storage1) { coordinates = coord; itemType = type; storage = storage1; }