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

◆ AccessorySwap()

static bool Terraria.UI.ItemSlot.AccessorySwap ( Player player,
Item item,
ref Item result )
inlinestaticprivate

Definition at line 4121 of file ItemSlot.cs.

4122 {
4123 accSlotToSwapTo = -1;
4125 Item[] accessories = AccessorySlotLoader.ModSlotPlayer(player).exAccessorySlot;
4126 for (int j = 3; j < 10; j++)
4127 {
4128 if (player.IsItemSlotUnlockedAndUsable(j) && player.armor[j].type == 0 && ItemLoader.CanEquipAccessory(item, j, modded: false))
4129 {
4130 accSlotToSwapTo = j - 3;
4131 break;
4132 }
4133 }
4134 if (accSlotToSwapTo < 0)
4135 {
4136 for (int i = 0; i < accessories.Length / 2; i++)
4137 {
4138 if (accLoader.ModdedIsItemSlotUnlockedAndUsable(i, player) && accessories[i].type == 0 && accLoader.CanAcceptItem(i, item, -10) && ItemLoader.CanEquipAccessory(item, i, modded: true))
4139 {
4140 accSlotToSwapTo = i + 20;
4141 break;
4142 }
4143 }
4144 }
4145 accLoader.ModifyDefaultSwapSlot(item, ref accSlotToSwapTo);
4146 for (int l = 0; l < player.armor.Length; l++)
4147 {
4148 if (item.IsTheSameAs(player.armor[l]) && ItemLoader.CanEquipAccessory(item, l, modded: false))
4149 {
4150 accSlotToSwapTo = l - 3;
4151 }
4152 if (l < 10 && ((item.wingSlot > 0 && player.armor[l].wingSlot > 0) || !ItemLoader.CanAccessoryBeEquippedWith(player.armor[l], item)) && ItemLoader.CanEquipAccessory(item, l, modded: false))
4153 {
4154 accSlotToSwapTo = l - 3;
4155 }
4156 }
4157 for (int k = 0; k < accessories.Length; k++)
4158 {
4159 if (item.IsTheSameAs(accessories[k]) && accLoader.CanAcceptItem(k, item, (k < accessories.Length / 2) ? (-10) : (-11)) && ItemLoader.CanEquipAccessory(item, k, modded: true))
4160 {
4161 accSlotToSwapTo = k + 20;
4162 }
4163 if (k < accLoader.list.Count && ((item.wingSlot > 0 && accessories[k].wingSlot > 0) || !ItemLoader.CanAccessoryBeEquippedWith(accessories[k], item)) && accLoader.CanAcceptItem(k, item, (k < accessories.Length / 2) ? (-10) : (-11)) && ItemLoader.CanEquipAccessory(item, k, modded: true))
4164 {
4165 accSlotToSwapTo = k + 20;
4166 }
4167 }
4168 if (accSlotToSwapTo == -1 && !ItemLoader.CanEquipAccessory(item, 0, modded: false))
4169 {
4170 return false;
4171 }
4173 if (accSlotToSwapTo >= 20)
4174 {
4175 int num3 = accSlotToSwapTo - 20;
4176 if (isEquipLocked(accessories[num3].type))
4177 {
4178 result = item;
4179 return false;
4180 }
4181 result = accessories[num3].Clone();
4182 accessories[num3] = item.Clone();
4183 }
4184 else
4185 {
4186 int num4 = 3 + accSlotToSwapTo;
4187 if (isEquipLocked(player.armor[num4].type))
4188 {
4189 result = item;
4190 return false;
4191 }
4192 result = player.armor[num4].Clone();
4193 player.armor[num4] = item.Clone();
4194 }
4195 return true;
4196 }
static ModAccessorySlotPlayer ModSlotPlayer(Player player)
This serves as a central place to store equipment slots and their corresponding textures....
static bool CanAccessoryBeEquippedWith(Item equippedItem, Item incomingItem)
static bool CanEquipAccessory(Item item, int slot, bool modded)
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26
static bool isEquipLocked(int type)
Definition ItemSlot.cs:358
static int accSlotToSwapTo
Definition ItemSlot.cs:165

References Terraria.UI.ItemSlot.accSlotToSwapTo, Terraria.Player.armor, Terraria.ModLoader.ItemLoader.CanAccessoryBeEquippedWith(), Terraria.ModLoader.ItemLoader.CanEquipAccessory(), Terraria.Item.Clone(), Terraria.UI.ItemSlot.isEquipLocked(), Terraria.Player.IsItemSlotUnlockedAndUsable(), Terraria.Item.IsTheSameAs(), Terraria.ModLoader.AccessorySlotLoader.ModSlotPlayer(), Terraria.Item.type, and Terraria.Item.wingSlot.

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

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