-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shop.cs
86 lines (68 loc) · 2.1 KB
/
Shop.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Terraria.Audio;
using Terraria.ID;
namespace MerchantsPlus.Merchants;
internal abstract class Shop
{
public List<string> Shops;
public List<string> Quests;
protected Chest Inv;
protected int NextSlot = 0;
/// <summary>
/// Sets up a new shop for a particular merchant.
/// </summary>
/// <param name="merchant">Is the NPC a merchant by default?</param>
public Shop(bool merchant, params string[] shops)
{
Shops = new List<string>();
if (merchant) Shops.Add("Vanilla");
List<string> otherShops = new List<string>();
for (int i = 0; i < shops.Length; i++)
otherShops.Add(shops[i]);
Shops.AddRange(otherShops);
Quests = new List<string>();
}
/// <summary>
/// Initalizes the merchants particular shop.
/// </summary>
/// <param name="shop">The current shop we are in.</param>
/// <param name="nextSlot">The nextSlot of the item to sell.</param>
public virtual void OpenShop(string shop)
{
PrepareShop();
}
private void PrepareShop()
{
SoundEngine.PlaySound(SoundID.MenuTick);
Main.playerInventory = true;
Main.npcChatText = "";
//Main.SetNPCShopIndex(20);
Inv = Main.instance.shop[Main.npcShop];
//Inv.SetupShop(0);
NextSlot = 0;
Quests.Clear();
}
protected void AddItem(int itemID)
{
Inv.item[NextSlot++].SetDefaults(itemID);
}
protected void AddItem(int itemID, int price)
{
Inv.item[NextSlot].SetDefaults(itemID);
Inv.item[NextSlot++].shopCustomPrice = price;
}
protected void ReplaceItem(int itemID)
{
Inv.item[NextSlot].SetDefaults(itemID);
}
protected void ReplaceItem(int itemID, int price)
{
Inv.item[NextSlot].SetDefaults(itemID);
Inv.item[NextSlot].shopCustomPrice = price;
}
protected void ReplacePrice(int price)
{
Inv.item[NextSlot].shopCustomPrice = price;
}
public override string ToString() =>
GetType().Name.Replace("Shop", "").AddSpaceBeforeEachCapital();
}