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

◆ FillAmmo()

Item Terraria.Player.FillAmmo ( int plr,
Item newItem,
GetItemSettings settings )
inline

Definition at line 38082 of file Player.cs.

38083 {
38084 for (int i = 54; i < 58; i++)
38085 {
38086 if (inventory[i].type > 0 && inventory[i].stack < inventory[i].maxStack && newItem.IsTheSameAs(inventory[i]) && ItemLoader.TryStackItems(inventory[i], newItem, out var numTransfered))
38087 {
38088 SoundEngine.PlaySound(7, (int)position.X, (int)position.Y);
38089 if (!settings.NoText)
38090 {
38091 PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, numTransfered);
38092 }
38093 DoCoins(i);
38094 if (plr == Main.myPlayer)
38095 {
38096 Recipe.FindRecipes();
38097 }
38098 settings.HandlePostAction(inventory[i]);
38099 if (newItem.stack <= 0)
38100 {
38101 return new Item();
38102 }
38103 }
38104 }
38105 if (newItem.CanFillEmptyAmmoSlot())
38106 {
38107 for (int j = 54; j < 58; j++)
38108 {
38109 if (inventory[j].type == 0)
38110 {
38111 newItem.shimmered = false;
38112 inventory[j] = newItem;
38113 if (!settings.NoText)
38114 {
38115 PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, newItem.stack);
38116 }
38117 DoCoins(j);
38118 SoundEngine.PlaySound(7, (int)position.X, (int)position.Y);
38119 if (plr == Main.myPlayer)
38120 {
38121 Recipe.FindRecipes();
38122 }
38123 settings.HandlePostAction(inventory[j]);
38124 return new Item();
38125 }
38126 }
38127 }
38128 return newItem;
38129 }
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 ...
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
static bool TryStackItems(Item destination, Item source, out int numTransferred, bool infiniteSource=false)
Stacks source onto destination if CanStack permits the transfer.
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26
void DoCoins(int i)
Definition Player.cs:38062
Item[] inventory
The player's normal inventory. Indexes 0-9 hold the hotbar items, 10-49 the rest of the main inventor...
Definition Player.cs:1767

References Terraria.Player.DoCoins(), Terraria.Recipe.FindRecipes(), Terraria.Player.inventory, Terraria.Main.myPlayer, Terraria.PopupText.NewText(), Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, and Terraria.ModLoader.ItemLoader.TryStackItems().

Referenced by Terraria.Player.GetItem().

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