public GuardianShopItem AddNewItem(int ItemID, int Price = -1, string Name = "", int FixedSellStack = 1) { //Main.NewText("Tried to add ID zero item to shop.", 200, 128, 0); GuardianShopItem item = new GuardianShopItem(); item.SetItemForSale(ItemID, Price, Name, FixedSellStack); if (ItemID > 0) { Items.Add(item); } return(item); }
public static void SaveShops(Terraria.ModLoader.IO.TagCompound tag) { tag.Add("Shop_Count", Shops.Count); for (int s = 0; s < Shops.Count; s++) { string ShopTag = "Shop_s" + s + ">"; GuardianShop shop = Shops[s]; tag.Add(ShopTag + "OwnerID", shop.OwnerID); tag.Add(ShopTag + "OwnerModID", shop.OwnerModID); tag.Add(ShopTag + "ItemCount", shop.Items.Count); for (int i = 0; i < shop.Items.Count; i++) { string ItemTag = ShopTag + "i" + i + ">"; GuardianShopItem item = shop.Items[i]; bool HasItem = item.ItemID != 0; tag.Add(ItemTag + "hasitem", HasItem); if (HasItem) { Item dummyItem = new Item(); dummyItem.SetDefaults(item.ItemID, true); bool IsModItem = dummyItem.modItem != null; tag.Add(ItemTag + "ismoditem", IsModItem); if (IsModItem) { tag.Add(ItemTag + "itemname", dummyItem.modItem.Name); tag.Add(ItemTag + "itemmodname", dummyItem.modItem.mod.Name); } else { tag.Add(ItemTag + "itemid", item.ItemID); } tag.Add(ItemTag + "saletime", item.SaleTime); tag.Add(ItemTag + "timedsaletime", item.TimedSaleTime); tag.Add(ItemTag + "stack", item.Stack); } } } }