v0.13.0.11
This commit is contained in:
@@ -123,7 +123,16 @@ namespace Barotrauma
|
||||
|
||||
public override bool CanBePut(Item item, int i)
|
||||
{
|
||||
return base.CanBePut(item, i) && item.AllowedSlots.Contains(SlotTypes[i]);
|
||||
return
|
||||
base.CanBePut(item, i) && item.AllowedSlots.Any(s => s.HasFlag(SlotTypes[i])) &&
|
||||
(SlotTypes[i] == InvSlotType.Any || slots[i].ItemCount < 1);
|
||||
}
|
||||
|
||||
public override bool CanBePut(ItemPrefab itemPrefab, int i)
|
||||
{
|
||||
return
|
||||
base.CanBePut(itemPrefab, i) &&
|
||||
(SlotTypes[i] == InvSlotType.Any || slots[i].ItemCount < 1);
|
||||
}
|
||||
|
||||
public bool CanBeAutoMovedToCorrectSlots(Item item)
|
||||
@@ -141,6 +150,44 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void RemoveItem(Item item)
|
||||
{
|
||||
RemoveItem(item, tryEquipFromSameStack: false);
|
||||
}
|
||||
|
||||
public void RemoveItem(Item item, bool tryEquipFromSameStack)
|
||||
{
|
||||
if (!Contains(item)) { return; }
|
||||
|
||||
bool wasEquipped = character.HasEquippedItem(item);
|
||||
var indices = FindIndices(item);
|
||||
|
||||
base.RemoveItem(item);
|
||||
#if CLIENT
|
||||
CreateSlots();
|
||||
#endif
|
||||
//if the item was equipped and there are more items in the same stack, equip one of those items
|
||||
if (tryEquipFromSameStack && wasEquipped)
|
||||
{
|
||||
int limbSlot = indices.Find(j => SlotTypes[j] != InvSlotType.Any);
|
||||
foreach (int i in indices)
|
||||
{
|
||||
var itemInSameSlot = GetItemAt(i);
|
||||
if (itemInSameSlot != null)
|
||||
{
|
||||
if (TryPutItem(itemInSameSlot, limbSlot, allowSwapping: false, allowCombine: false, character))
|
||||
{
|
||||
#if CLIENT
|
||||
visualSlots[i].ShowBorderHighlight(GUI.Style.Green, 0.1f, 0.412f);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// If there is no room in the generic inventory (InvSlotType.Any), check if the item can be auto-equipped into its respective limbslot
|
||||
/// </summary>
|
||||
@@ -156,6 +203,19 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (allowedSlots != null && !allowedSlots.Contains(InvSlotType.Any))
|
||||
{
|
||||
int slot = FindLimbSlot(allowedSlots.First());
|
||||
if (slot > -1 && slots[slot].Items.Any(it => it != item) && slots[slot].First().AllowDroppingOnSwapWith(item))
|
||||
{
|
||||
foreach (Item existingItem in slots[slot].Items.ToList())
|
||||
{
|
||||
existingItem.Drop(user);
|
||||
if (existingItem.ParentInventory != null) { existingItem.ParentInventory.RemoveItem(existingItem); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TryPutItem(item, user, allowedSlots, createNetworkEvent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user