15 {
16 if (!super.ActionCondition(player, target, item))
17 return false;
18
20 if (!targetEntity || targetEntity && !targetEntity.GetInventory())
21 return false;
22
23 if (!targetEntity.GetInventory().HasAttachmentSlot(Battery9V.SLOT_ID))
24 return false;
25
26 EntityAI attachment = targetEntity.GetInventory().FindAttachment(Battery9V.SLOT_ID);
27 if (!attachment)
28 return false;
29
31 if (codeLock)
32 {
33 if (!codeLock.GetHierarchyRoot())
34 return false;
35
36 if (codeLock.
IsLocked() || codeLock.IsLockedInSlot())
37 return false;
38
39 array<string> selections = new array<string>;
40 if (codeLock)
41 codeLock.GetActionComponentNameList(target.GetComponentIndex(), selections);
42
43 bool isFactingBackSide;
44 foreach (string selectionName : selections)
45 {
47 {
48 isFactingBackSide = true;
49 break;
50 }
51 }
52
53 if (!isFactingBackSide)
54 return false;
55 }
56
57 if (player.GetInventory().CanAddEntityIntoHands(attachment))
58 {
59 if (attachment.CanDetachAttachment(targetEntity) && targetEntity.CanReleaseAttachment(attachment))
60 {
61 m_Text =
"#detach_battery " + attachment.GetDisplayName();
62 return true;
63 }
64 }
65
66 return false;
67 }
const string SELECTION_BACK