Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InventoryAction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  #ifndef DISABLE_INVENTORY
7  protected const string SREASON_TOO_BIG = "#AR-Inventory_InfoTooBig";
8  protected const string SREASON_TOO_HEAVY = "#AR-Inventory_InfoTooHeavy";
9 
10  //------------------------------------------------------------------------------------------------
11  protected string GetReason( SCR_InventoryStorageManagerComponent pInventoryManager )
12  {
13  if( !pInventoryManager )
14  return "";
15  EInventoryRetCode ERetCode = pInventoryManager.GetReturnCode();
16  string sReason = "";
17 
18  //ERetCode &= EInventoryRetCode.RETCODE_ITEM_TOO_BIG;
19 
20  if ( ( ERetCode & EInventoryRetCode.RETCODE_ITEM_TOO_BIG ) == EInventoryRetCode.RETCODE_ITEM_TOO_BIG )
21  sReason += " " + SREASON_TOO_BIG;
22 
23  if ( ( ERetCode & EInventoryRetCode.RETCODE_ITEM_TOO_HEAVY ) == EInventoryRetCode.RETCODE_ITEM_TOO_HEAVY )
24  sReason += " " + SREASON_TOO_HEAVY;
25  return sReason;
26  }
27 
28 
29  //------------------------------------------------------------------------------------------------
30  override bool CanBeShownScript(IEntity user)
31  {
32  if (m_Item == null || m_Item.GetParentSlot() != null || m_Item.IsLocked())
33  return false;
34 
35  IEntity itemEntity = m_Item.GetOwner();
36  BaseMagazineComponent baseMagComponent = BaseMagazineComponent.Cast(itemEntity.FindComponent(BaseMagazineComponent));
37  if (baseMagComponent)
38  {
39  if (baseMagComponent.IsUsed())
40  return false;
41 
42  // This is a temporary fix for issue #18454,
43  // we should lock items during reload instead
44  IEntity itemParent = itemEntity.GetParent();
45  if (ChimeraCharacter.Cast(itemParent))
46  return false;
47  }
48 
49  return true;
50  }
51  //------------------------------------------------------------------------------------------------
52  override bool CanBePerformedScript(IEntity user)
53  {
54  if (!user)
55  return false;
56  Managed genericInventoryManager = user.FindComponent( SCR_InventoryStorageManagerComponent );
57  if (!genericInventoryManager)
58  return false;
59  RplComponent genericRpl = RplComponent.Cast(user.FindComponent( RplComponent ));
60  if (!genericRpl)
61  return false;
62 
63  return genericRpl.IsOwner();
64  }
65  //---------------------------------------------------------
66  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
67  {
68  if (!CanBePerformedScript(pUserEntity))
69  return;
70  SCR_InventoryStorageManagerComponent genericInventoryManager = SCR_InventoryStorageManagerComponent.Cast(pUserEntity.FindComponent( SCR_InventoryStorageManagerComponent ));
71  if ( !genericInventoryManager )
72  return;
73  PerformActionInternal( genericInventoryManager, pOwnerEntity, pUserEntity);
74 
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  override bool GetActionNameScript(out string outName)
79  {
80  return false;
81  }
82 
83  override bool HasLocalEffectOnlyScript()
84  {
85  return true;
86  }
87 
88  protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
89  {
90 
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
95  {
96  m_Item = InventoryItemComponent.Cast( pOwnerEntity .FindComponent( InventoryItemComponent ));
97  }
98  //------------------------------------------------------------------------------------------------
99  #else
100  override bool GetActionNameScript(out string outName)
101  {
102  outName = "#AR-Inventory_Disabled";
103  return true;
104  }
105  #endif
106 
107 };
pInventoryManager
protected SCR_InventoryStorageManagerComponent pInventoryManager
Definition: SCR_UniversalInventoryStorageComponent.c:25
SCR_InventoryAction
modded version for to be used with the inventory 2.0
Definition: SCR_InventoryAction.c:3
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
ScriptedUserAction
Definition: ScriptedUserAction.c:12
InventoryItemComponent
Definition: InventoryItemComponent.c:12