Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EquipItemAction.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
4{
5 [Attribute("-1", desc: "If this value is different thatn -1 then script will ignore slot that is normally used fot this\ntype of an item and it will try to use the slot with provided id.\nFirst slot number is 0 while last is 9", params: "-1 9 1")]
7
8 protected bool m_bShowBindingInfo;
9
10 protected const LocalizedString REASON_NO_SPACE = "#AR-SupportStation_Resupply_ActionInvalid_NoInventorySpace";
11 protected const LocalizedString TEXT_SLOT_ID = "#AR-ControlsHint_BindToQuickslot";
12 protected const string FORMAT = "%1 (%2)";
13
14 //------------------------------------------------------------------------------------------------
15 override bool CanBePerformedScript(IEntity user)
16 {
17 if (!super.CanBePerformedScript(user))
18 return false;
19
20 SCR_InventoryStorageManagerComponent pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(user.FindComponent(SCR_InventoryStorageManagerComponent));
22 return false;
23
24 if (!pInventoryManager.CanInsertItem(GetOwner()))
25 {
26 m_bShowBindingInfo = false;
28 return false;
29 }
30
32 return true;
33
34 SCR_CharacterInventoryStorageComponent characterStorage = pInventoryManager.GetCharacterStorage();
35 if (!characterStorage)
36 return false;
37
38 IEntity boundItem = characterStorage.GetItemFromQuickSlot(m_iEquipmentSlotIdOverride);
39 if (boundItem && boundItem.GetPrefabData().GetPrefabName() == GetOwner().GetPrefabData().GetPrefabName())
40 m_bShowBindingInfo = false;
41 else
42 m_bShowBindingInfo = true;
43
44 return true;
45 }
46
47 //------------------------------------------------------------------------------------------------
48 override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
49 {
50 SCR_InvEquipAnyItemCB inventoryCallBack = new SCR_InvEquipAnyItemCB();
51 inventoryCallBack.m_pItem = pOwnerEntity;
52 inventoryCallBack.m_pStorageToPickUp = manager.GetCharacterStorage();
53 inventoryCallBack.m_iSlotToFocus = m_iEquipmentSlotIdOverride;
54 inventoryCallBack.m_bShouldEquip = true;
55
56 manager.InsertItem(pOwnerEntity, cb: inventoryCallBack);
57 }
58
59 //------------------------------------------------------------------------------------------------
60 override bool GetActionNameScript(out string outName)
61 {
63 return false;
64
65 UIInfo info = GetUIInfo();
66 if (!info)
67 return false;
68
69 outName = info.GetName();
71 return true;
72
73 outName = string.Format(FORMAT, outName, WidgetManager.Translate(TEXT_SLOT_ID, m_iEquipmentSlotIdOverride + 1));
74 return true;
75 }
76}
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_InventoryStorageManagerComponent pInventoryManager
SCR_VehicleDamageManagerComponentClass GetPrefabData()
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
modded version for to be used with the inventory 2.0
const LocalizedString TEXT_SLOT_ID
override bool CanBePerformedScript(IEntity user)
void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
override bool GetActionNameScript(out string outName)
const LocalizedString REASON_NO_SPACE
modded version for to be used with the inventory 2.0
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
SCR_FieldOfViewSettings Attribute