21 {
23 if (targetEntity && item)
24 {
25 GameInventory inv = targetEntity.GetInventory();
26 if (!inv)
27 return InventorySlots.INVALID;
28
29 int slotsCount = item.GetInventory().GetSlotIdCount();
30 array<string> selections = new array<string>();
31 targetEntity.GetActionComponentNameList(target.GetComponentIndex(), selections);
32
33 foreach (string selection : selections)
34 {
35 int slotId = -1;
36 if (!targetEntity.TranslateSlotFromSelection(selection, slotId))
37 slotId = InventorySlots.GetSlotIdFromString(selection);
38
39 if (slotId == -1)
40 continue;
41
42 for (int i=0; i < slotsCount; ++i)
43 {
44 int itemSlotId = item.GetInventory().GetSlotId(i);
45 if (slotId == itemSlotId)
46 {
48 if (currentAttachment)
49 {
51 return itemSlotId;
52 }
53 else
54 {
56 return itemSlotId;
57 }
58 }
59 }
60 }
61 }
62
63 return InventorySlots.INVALID;
64 }
class GP5GasMask extends MaskBase ItemBase
proto native bool CanAddAttachment(notnull EntityAI e)
Check if attachment can be added to any slot.
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)