Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AttachementAction.c
Go to the documentation of this file.
2 {
5  UGL,
7 }
8 
9 class SCR_AttachementAction : SCR_InventoryAction
10 {
11  #ifndef DISABLE_INVENTORY
12  [Attribute("0", UIWidgets.ComboBox, "", "", ParamEnumArray.FromEnum(EWeaponAttachmentActionType) )]
13  EWeaponAttachmentActionType m_WeaponAttachmentActionType;
14 
15  SCR_InventoryStorageManagerComponent m_InventoryManager;
16  IEntity attachment;
18 
19  //------------------------------------------------------------------------------------------------
20  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
21  {
22  m_InventoryItemComp = InventoryItemComponent.Cast(pOwnerEntity.FindComponent(InventoryItemComponent));
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  override bool CanBeShownScript(IEntity user)
27  {
28  if(!m_InventoryItemComp || !m_InventoryItemComp.GetParentSlot())
29  return false;
30 
31  ChimeraCharacter character = ChimeraCharacter.Cast(SCR_PlayerController.GetLocalControlledEntity());
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 
55  attachment = m_InventoryItemComp.GetOwner();
56 
57  return (attachment != null);
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  override bool CanBePerformedScript(IEntity user)
62  {
63  BaseInventoryStorageComponent storage = m_InventoryManager.FindStorageForItem(attachment);
64  if (!storage)
65  return false;
66  return m_InventoryManager.CanMoveItemToStorage(attachment, storage);
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
71  {
72  BaseInventoryStorageComponent storage = m_InventoryManager.FindStorageForItem(attachment);
73  manager.TryMoveItemToStorage(attachment, storage);
74  manager.PlayItemSound(pOwnerEntity, "SOUND_UNEQUIP");
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  override bool GetActionNameScript(out string outName)
79  {
81  return false;
82  UIInfo actionInfo = GetUIInfo();
83  UIInfo itemInfo = m_InventoryItemComp.GetUIInfo();
84  if (actionInfo && itemInfo)
85  {
86  outName = string.Format("%1%2", actionInfo.GetName(), itemInfo.GetName());
87  return true;
88  }
89  else
90  {
91  return false;
92  }
93  }
94  #endif
95 }
SCR_InventoryAction
modded version for to be used with the inventory 2.0
Definition: SCR_InventoryAction.c:3
SCR_PlayerController
Definition: SCR_PlayerController.c:31
EWeaponAttachmentActionType
EWeaponAttachmentActionType
Definition: SCR_AttachementAction.c:1
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
GetActionNameScript
override bool GetActionNameScript(out string outName)
Definition: SCR_AttachementAction.c:78
Muzzle
Muzzle
Definition: SCR_AttachementAction.c:6
Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition: SCR_AttachementAction.c:20
CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition: SCR_AttachementAction.c:61
m_InventoryManager
SCR_InventoryStorageManagerComponent m_InventoryManager
Definition: SCR_AttachementAction.c:15
GetUIInfo
SCR_UIInfo GetUIInfo()
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:27
UGL
UGL
Definition: SCR_AttachementAction.c:4
PerformActionInternal
override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
Definition: SCR_AttachementAction.c:70
BaseWeaponComponent
Definition: BaseWeaponComponent.c:12
attachment
IEntity attachment
Definition: SCR_AttachementAction.c:16
InventoryItemComponent
Definition: InventoryItemComponent.c:12
Magazine
Magazine
Definition: SCR_AttachementAction.c:3
Attribute
enum EWeaponAttachmentActionType Attribute("0", UIWidgets.ComboBox, "", "", ParamEnumArray.FromEnum(EWeaponAttachmentActionType))] EWeaponAttachmentActionType m_WeaponAttachmentActionType
CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition: SCR_AttachementAction.c:26
m_InventoryItemComp
InventoryItemComponent m_InventoryItemComp
Definition: SCR_AttachementAction.c:17
ScopeDetach
ScopeDetach
Definition: SCR_AttachementAction.c:2