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

◆ BuyItem()

bool Terraria.Player.BuyItem ( long price,
int customCurrency = -1 )
inline

Definition at line 33584 of file Player.cs.

33585 {
33586 if (customCurrency != -1)
33587 {
33589 }
33590 bool overFlowing;
33591 long num = Utils.CoinsCount(out overFlowing, inventory, 58, 57, 56, 55, 54);
33592 long num2 = Utils.CoinsCount(out overFlowing, bank.item);
33593 long num3 = Utils.CoinsCount(out overFlowing, bank2.item);
33594 long num4 = Utils.CoinsCount(out overFlowing, bank3.item);
33595 long num5 = Utils.CoinsCount(out overFlowing, bank4.item);
33596 if (Utils.CoinsCombineStacks(out overFlowing, num, num2, num3, num4, num5) < price)
33597 {
33598 return false;
33599 }
33608 list.Add(inventory);
33609 list.Add(bank.item);
33610 list.Add(bank2.item);
33611 list.Add(bank3.item);
33612 list.Add(bank4.item);
33613 for (int i = 0; i < list.Count; i++)
33614 {
33615 dictionary[i] = new List<int>();
33616 }
33617 dictionary[0] = new List<int> { 58, 57, 56, 55, 54 };
33618 for (int j = 0; j < list.Count; j++)
33619 {
33620 for (int k = 0; k < list[j].Length; k++)
33621 {
33622 if (!dictionary[j].Contains(k) && list[j][k].IsACoin)
33623 {
33624 list3.Add(new Point(j, k));
33625 }
33626 }
33627 }
33628 int num6 = 0;
33629 for (int num7 = list[num6].Length - 1; num7 >= 0; num7--)
33630 {
33631 if (!dictionary[num6].Contains(num7) && (list[num6][num7].type == 0 || list[num6][num7].stack == 0))
33632 {
33633 list2.Add(new Point(num6, num7));
33634 }
33635 }
33636 num6 = 1;
33637 for (int num8 = list[num6].Length - 1; num8 >= 0; num8--)
33638 {
33639 if (!dictionary[num6].Contains(num8) && (list[num6][num8].type == 0 || list[num6][num8].stack == 0))
33640 {
33641 list4.Add(new Point(num6, num8));
33642 }
33643 }
33644 num6 = 2;
33645 for (int num9 = list[num6].Length - 1; num9 >= 0; num9--)
33646 {
33647 if (!dictionary[num6].Contains(num9) && (list[num6][num9].type == 0 || list[num6][num9].stack == 0))
33648 {
33649 list5.Add(new Point(num6, num9));
33650 }
33651 }
33652 num6 = 3;
33653 for (int num10 = list[num6].Length - 1; num10 >= 0; num10--)
33654 {
33655 if (!dictionary[num6].Contains(num10) && (list[num6][num10].type == 0 || list[num6][num10].stack == 0))
33656 {
33657 list6.Add(new Point(num6, num10));
33658 }
33659 }
33660 num6 = 4;
33661 for (int num11 = list[num6].Length - 1; num11 >= 0; num11--)
33662 {
33663 if (!dictionary[num6].Contains(num11) && (list[num6][num11].type == 0 || list[num6][num11].stack == 0))
33664 {
33665 list7.Add(new Point(num6, num11));
33666 }
33667 }
33669 {
33670 return false;
33671 }
33672 return true;
33673 }
void Add(TKey key, TValue value)
Item[] item
Definition Chest.cs:41
static bool BuyItem(Player player, long price, int currencyIndex)
Item[] inventory
Definition Player.cs:1257
static bool TryPurchasing(long price, List< Item[]> inv, List< Point > slotCoins, List< Point > slotsEmpty, List< Point > slotEmptyBank, List< Point > slotEmptyBank2, List< Point > slotEmptyBank3, List< Point > slotEmptyBank4)
Definition Player.cs:33675

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), Terraria.GameContent.UI.CustomCurrencyManager.BuyItem(), Terraria.Utils.CoinsCombineStacks(), Terraria.Utils.CoinsCount(), Microsoft.Xna.Framework.Contains, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.dictionary, Terraria.Chest.item, System.list, and System.type.

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