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

◆ ArmorSwap()

static Item Terraria.UI.ItemSlot.ArmorSwap ( Item item,
out bool success )
inlinestaticprivate

Definition at line 3117 of file ItemSlot.cs.

3118 {
3119 success = false;
3120 if (item.stack < 1)
3121 {
3122 return item;
3123 }
3124 if (item.headSlot == -1 && item.bodySlot == -1 && item.legSlot == -1 && !item.accessory)
3125 {
3126 return item;
3127 }
3128 Player player = Main.player[Main.myPlayer];
3129 int num = ((item.vanity && !item.accessory) ? 10 : 0);
3130 item.favorited = false;
3131 Item result = item;
3132 if (item.headSlot != -1)
3133 {
3134 result = player.armor[num].Clone();
3135 player.armor[num] = item.Clone();
3136 }
3137 else if (item.bodySlot != -1)
3138 {
3139 result = player.armor[num + 1].Clone();
3140 player.armor[num + 1] = item.Clone();
3141 }
3142 else if (item.legSlot != -1)
3143 {
3144 result = player.armor[num + 2].Clone();
3145 player.armor[num + 2] = item.Clone();
3146 }
3147 else if (item.accessory && !AccessorySwap(player, item, ref result))
3148 {
3149 return result;
3150 }
3152 Recipe.FindRecipes();
3153 success = true;
3154 return result;
3155 }
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 bool AccessorySwap(Player player, Item item, ref Item result)
Definition ItemSlot.cs:4121

References Terraria.Item.accessory, Terraria.UI.ItemSlot.AccessorySwap(), Terraria.Player.armor, Terraria.Item.bodySlot, Terraria.Item.Clone(), Terraria.Recipe.FindRecipes(), Terraria.Item.headSlot, Terraria.Item.legSlot, Terraria.Main.myPlayer, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), and Terraria.Item.stack.

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

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