Merge pull request #820 from nolt/feature-bots

(cherry picked from commit b10de0645a869485fbb5771a739abd06b5708c2d)
This commit is contained in:
sven-n
2026-07-16 22:01:57 +02:00
committed by Acentech Dev
parent 8baf329654
commit d04cbecae3
58 changed files with 14856 additions and 62 deletions

View File

@@ -137,6 +137,37 @@ public static class ItemExtensions
return item.Definition?.Group == ShieldItemGroup;
}
/// <summary>
/// Determines whether equipping an item of this definition into the given hand slot would conflict
/// with what the other hand already holds: a two-handed item needs the other hand free (ammunition
/// aside), and nothing but ammunition fits next to an already equipped two-handed item.
/// </summary>
/// <param name="itemDefinition">The definition of the item which would be equipped.</param>
/// <param name="inventory">The inventory to check the other hand in.</param>
/// <param name="toSlot">The hand slot the item would be equipped into.</param>
/// <returns><c>true</c> if the other hand blocks this item; otherwise, <c>false</c>.</returns>
public static bool ConflictsWithEquippedHands(this ItemDefinition itemDefinition, IStorage inventory, byte toSlot)
{
if (itemDefinition.ItemSlot is null)
{
return false;
}
static bool IsOneHandedOrShield(ItemDefinition definition) =>
(definition.ItemSlot!.ItemSlots.Contains(InventoryConstants.RightHandSlot) && definition.ItemSlot.ItemSlots.Contains(InventoryConstants.LeftHandSlot))
|| definition.Group == ShieldItemGroup;
var rightHandItemDefinition = inventory.GetItem(InventoryConstants.RightHandSlot)?.Definition;
return (toSlot == InventoryConstants.LeftHandSlot
&& itemDefinition.Width >= 2
&& rightHandItemDefinition is not null
&& !rightHandItemDefinition.IsAmmunition)
|| (toSlot == InventoryConstants.RightHandSlot
&& IsOneHandedOrShield(itemDefinition)
&& inventory.GetItem(InventoryConstants.LeftHandSlot)?.Definition?.Width >= 2);
}
/// <summary>
/// Determines whether this item is a jewelry (pendant or ring) item.
/// </summary>