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

◆ SellOrTrash()

static void Terraria.UI.ItemSlot.SellOrTrash ( Item[] inv,
int context,
int slot )
inlinestatic

Definition at line 1025 of file ItemSlot.cs.

1026 {
1027 Player player = Main.player[Main.myPlayer];
1028 if (inv[slot].type <= 0)
1029 {
1030 return;
1031 }
1032 if (Main.npcShop > 0 && !inv[slot].favorited)
1033 {
1034 Chest chest = Main.instance.shop[Main.npcShop];
1035 if ((inv[slot].type < 71 || inv[slot].type > 74) && PlayerLoader.CanSellItem(player, player.TalkNPC, chest.item, inv[slot]))
1036 {
1037 if (player.SellItem(inv[slot]))
1038 {
1039 AnnounceTransfer(new ItemTransferInfo(inv[slot], context, 15));
1040 int soldItemIndex = chest.AddItemToShop(inv[slot]);
1041 inv[slot].TurnToAir();
1043 Recipe.FindRecipes();
1044 PlayerLoader.PostSellItem(player, player.TalkNPC, chest.item, chest.item[soldItemIndex]);
1045 }
1046 else if (inv[slot].value == 0)
1047 {
1048 AnnounceTransfer(new ItemTransferInfo(inv[slot], context, 15));
1049 int soldItemIndex2 = chest.AddItemToShop(inv[slot]);
1050 inv[slot].TurnToAir();
1052 Recipe.FindRecipes();
1053 PlayerLoader.PostSellItem(player, player.TalkNPC, chest.item, chest.item[soldItemIndex2]);
1054 }
1055 }
1056 }
1057 else if (!inv[slot].favorited)
1058 {
1060 player.trashItem = inv[slot].Clone();
1061 AnnounceTransfer(new ItemTransferInfo(player.trashItem, context, 6));
1062 inv[slot].TurnToAir();
1063 if (context == 3 && Main.netMode == 1)
1064 {
1065 NetMessage.SendData(32, -1, -1, null, player.chest, slot);
1066 }
1067 Recipe.FindRecipes();
1068 }
1069 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
static void PostSellItem(Player player, NPC npc, Item[] shopInventory, Item item)
static bool CanSellItem(Player player, NPC npc, Item[] shopInventory, Item item)
This is where all ModPlayer hooks are gathered and called.
static void AnnounceTransfer(ItemTransferInfo info)
Definition ItemSlot.cs:270

References Terraria.Chest.AddItemToShop(), Terraria.UI.ItemSlot.AnnounceTransfer(), Terraria.ModLoader.PlayerLoader.CanSellItem(), Terraria.Player.chest, Terraria.Recipe.FindRecipes(), Terraria.Main.instance, Terraria.Chest.item, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Main.npcShop, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.ModLoader.PlayerLoader.PostSellItem(), Terraria.Player.SellItem(), Terraria.NetMessage.SendData(), Terraria.Player.TalkNPC, and Terraria.Player.trashItem.

Referenced by Terraria.UI.ItemSlot.LeftClick_SellOrTrash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: