Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AttachementAction.c
Go to the documentation of this file.
8
9class SCR_AttachementAction : SCR_InventoryAction
10{
11 #ifndef DISABLE_INVENTORY
12 [Attribute("0", UIWidgets.ComboBox, "", "", ParamEnumArray.FromEnum(EWeaponAttachmentActionType) )]
13 protected EWeaponAttachmentActionType m_WeaponAttachmentActionType;
14
15 protected SCR_InventoryStorageManagerComponent m_InventoryManager;
18
19 //------------------------------------------------------------------------------------------------
20 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
21 {
23 }
24
25 //------------------------------------------------------------------------------------------------
26 override bool CanBeShownScript(IEntity user)
27 {
28 if(!m_InventoryItemComp || !m_InventoryItemComp.GetParentSlot())
29 return false;
30
32 if(!character)
33 return false;
34
35 CharacterControllerComponent controller = character.GetCharacterController();
36 if(!controller)
37 return false;
38
39 if(!controller.GetInspect())
40 return false;
41
42 BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
43 if(!weaponManager)
44 return false;
45
47 m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast(character.FindComponent(SCR_InventoryStorageManagerComponent));
49 return false;
50
51 BaseWeaponComponent weaponComp = controller.GetWeaponManagerComponent().GetCurrentWeapon();
52 if(!weaponComp || weaponComp.GetOwner() != m_InventoryItemComp.GetParentSlot().GetOwner())
53 return false;
54
56
57 return (m_Attachment != null);
58 }
59
60 //------------------------------------------------------------------------------------------------
61 override bool CanBePerformedScript(IEntity user)
62 {
64 return false;
65 BaseInventoryStorageComponent storage = m_InventoryManager.FindStorageForItem(m_Attachment);
66 if (!storage)
67 return false;
68 return m_InventoryManager.CanMoveItemToStorage(m_Attachment, storage);
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
73 {
74 BaseInventoryStorageComponent storage = m_InventoryManager.FindStorageForItem(m_Attachment, EStoragePurpose.PURPOSE_EQUIPMENT_ATTACHMENT);
75
76 if (!storage)
77 storage = m_InventoryManager.FindStorageForItem(m_Attachment);
78
79 manager.TryMoveItemToStorage(m_Attachment, storage);
80 manager.PlayItemSound(pOwnerEntity, "SOUND_UNEQUIP");
81 }
82
83 //------------------------------------------------------------------------------------------------
84 override bool GetActionNameScript(out string outName)
85 {
87 return false;
88 UIInfo actionInfo = GetUIInfo();
89 UIInfo itemInfo = m_InventoryItemComp.GetUIInfo();
90 if (actionInfo && itemInfo)
91 {
92 outName = string.Format("%1%2", actionInfo.GetName(), itemInfo.GetName());
93 return true;
94 }
95 else
96 {
97 return false;
98 }
99 }
100 #endif
101}
override void Init()
SCR_InventoryStorageManagerComponent m_InventoryManager
IEntity m_Attachment
InventoryItemComponent m_InventoryItemComp
EWeaponAttachmentActionType
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
proto external Managed FindComponent(typename typeName)
modded version for to be used with the inventory 2.0
override bool CanBePerformedScript(IEntity user)
override bool GetActionNameScript(out string outName)
override bool CanBeShownScript(IEntity user)
void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
static IEntity GetLocalControlledEntity()
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
SCR_FieldOfViewSettings Attribute
EStoragePurpose