TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ AddItemToShop()

int Terraria.Chest.AddItemToShop ( Item newItem)
inline

Adds an item to the first empty slot in this shop.

Parameters
newItemThe item to add.
Returns
0 if the item could not be added to the shop, or the index in F:Terraria.Chest.item if the item was successfully added.

Definition at line 1043 of file Chest.cs.

1044 {
1045 int num = Main.shopSellbackHelper.Remove(newItem);
1046 if (num >= newItem.stack)
1047 {
1048 return 0;
1049 }
1050 for (int i = 0; i < 38; i++)
1051 {
1052 if (item[i] == null || item[i].type == 0)
1053 {
1054 item[i] = newItem.Clone();
1055 item[i].favorited = false;
1056 item[i].buyOnce = true;
1057 item[i].stack -= num;
1058 _ = item[i].value;
1059 return i;
1060 }
1061 }
1062 return 0;
1063 }
Item[] item
The items this chest contains. F:Terraria.Chest.maxItems elements long.
Definition Chest.cs:93
int value
The number of copper coins this item is worth (aka, cost to buy from a merchant). Setting it to 10462...
Definition Item.cs:655
int stack
The current stack of the item. F:Terraria.Item.maxStack indicates the max possible stack.
Definition Item.cs:396
bool favorited
If true, then the given item is favorited. Favorited items cannot be dropped, automatically moved in...
Definition Item.cs:354
bool buyOnce
Definition Item.cs:628

References Terraria.Item.buyOnce, Terraria.Item.favorited, Terraria.Chest.item, Terraria.Main.shopSellbackHelper, Terraria.Item.stack, and Terraria.Item.value.

Referenced by Terraria.UI.ItemSlot.LeftClick(), and Terraria.UI.ItemSlot.SellOrTrash().

+ Here is the caller graph for this function: