Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InventoryOpenedStorageArsenalUI.c
Go to the documentation of this file.
2 {
3  //------------------------------------------------------------------------------------------------
4  override protected void GetAllItems(out notnull array<IEntity> pItemsInStorage, BaseInventoryStorageComponent pStorage = null)
5  {
6  if (pStorage)
7  {
8  super.GetAllItems(pItemsInStorage, pStorage);
9 
10  return;
11  }
12 
13  ChimeraWorld chimeraWorld = GetGame().GetWorld();
14  ItemPreviewManagerEntity itemPreviewManagerEntity = chimeraWorld.GetItemPreviewManager();
15 
16  SCR_ArsenalComponent arsenalComponent = SCR_ArsenalComponent.Cast(m_Storage.GetOwner().FindComponent(SCR_ArsenalComponent));
17  array<ResourceName> prefabsToSpawn = new array<ResourceName>();
18 
19  if (!arsenalComponent)
20  return;
21 
22  arsenalComponent.GetAvailablePrefabs(prefabsToSpawn);
23 
24  foreach (ResourceName resourceName: prefabsToSpawn)
25  {
26  pItemsInStorage.Insert(itemPreviewManagerEntity.ResolvePreviewEntityForPrefab(resourceName));
27  }
28 
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  override void RefreshResources()
33  {
34  if (!m_wResourceAvailableText && !m_wResourceAvailableDisplay)
35  return;
36 
38  {
39  m_wResourceAvailableDisplay.SetVisible(false);
40  return;
41  }
42 
43 
44  float availableResources;
45 
46  if (!m_ResourceComponent || !m_ResourceComponent.IsResourceTypeEnabled() || !SCR_ResourceSystemHelper.GetAvailableResources(m_ResourceComponent, availableResources))
47  {
48  m_wResourceAvailableDisplay.SetVisible(false);
49  return;
50  }
51 
52  m_wResourceAvailableText.SetTextFormat("#AR-Supplies_Arsenal_Availability", SCR_ResourceSystemHelper.SuppliesToString(availableResources));
53 
54  m_wResourceAvailableDisplay.SetVisible(true);
55 
56  if (!m_wResourceAvailableDisplay.IsVisible())
57  m_wResourceAvailableDisplay.SetVisible(false);
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  override void Init()
62  {
63  super.Init();
64 
65  m_wWeightDisplay.SetVisible(false);
66  m_wCapacityDisplay.SetVisible(false);
67 
68  m_wWeightText = null;
69  m_wWeightDisplay = null;
70  m_wCapacityDisplay = null;
71  m_wCapacityPercentageText = null;
72 
73  m_wResourceStoredDisplay = Widget.Cast(m_widget.FindAnyWidget("ResourceDisplayStored"));
74  if (m_wResourceStoredDisplay)
75  m_wResourceStoredText = TextWidget.Cast(m_wResourceStoredDisplay.FindAnyWidget("ResourceText"));
76 
77  m_wResourceAvailableDisplay = Widget.Cast(m_widget.FindAnyWidget("ResourceDisplayAvailable"));
78  if (m_wResourceAvailableDisplay)
79  m_wResourceAvailableText = TextWidget.Cast(m_wResourceAvailableDisplay.FindAnyWidget("ResourceText"));
80 
81  if (!m_wResourceStoredDisplay || !m_wResourceAvailableText)
82  return;
83 
84  if (m_Storage && m_Storage.GetOwner())
85  m_ResourceComponent = SCR_ResourceComponent.FindResourceComponent(m_Storage.GetOwner());
86 
88  {
89  m_wResourceAvailableDisplay.SetVisible(false);
90  return;
91  }
92 
94  m_ResourceComponent.TEMP_GetOnInteractorReplicated().Insert(Refresh);
95 
96  RefreshResources();
97  m_wResourceStoredDisplay.SetVisible(false);
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  override protected SCR_InventorySlotUI CreateSlotUI( InventoryItemComponent pComponent, SCR_ItemAttributeCollection pAttributes = null )
102  {
103  if (!pComponent)
104  {
105  return new SCR_InventorySlotUI(null, this, false, -1, pAttributes);
106  }
107  else
108  {
109  SCR_ArsenalInventorySlotUI slotUI = SCR_ArsenalInventorySlotUI(pComponent, this, false, -1, null); //creates the slot
110 
111  slotUI.SetArsenalResourceComponent(m_ResourceComponent);
112  SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Insert(slotUI, GetCurrentNavigationStorage().GetOwner());
113 
114  return slotUI;
115  }
116  }
117 
118  //------------------------------------------------------------------------------------------------
119  override void Refresh()
120  {
121  super.Refresh();
122 
123  RefreshResources();
124  }
125 };
ChimeraWorld
Definition: ChimeraWorld.c:12
m_ResourceConsumer
protected SCR_ResourceConsumer m_ResourceConsumer
Definition: SCR_BaseSupportStationComponent.c:114
SCR_ResourceSystemHelper
Definition: SCR_ResourceSystemHelper.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ArsenalInventorySlotUI
Definition: SCR_ArsenalInventorySlotUI.c:2
SCR_InventoryStorageBaseUI
Definition: SCR_InventoryStorageBaseUI.c:6
SCR_InventoryOpenedStorageArsenalUI
Definition: SCR_InventoryOpenedStorageArsenalUI.c:1
SCR_InventoryOpenedStorageUI
Definition: SCR_InventoryOpenedStorageUI.c:1
EResourceType
EResourceType
Definition: SCR_ResourceContainer.c:1
m_ResourceComponent
protected SCR_ResourceComponent m_ResourceComponent
Definition: SCR_CampaignBuildingProviderComponent.c:51
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
InventoryItemComponent
Definition: InventoryItemComponent.c:12
SCR_ItemAttributeCollection
Definition: SCR_ItemAttributeCollection.c:2
SCR_ArsenalComponent
Definition: SCR_ArsenalComponent.c:9
SCR_InventorySlotUI
Definition: SCR_InventorySlotUI.c:27
m_Storage
BaseInventoryStorageComponent m_Storage
Definition: SCR_TourniquetStorageComponent.c:10
EResourceGeneratorID
EResourceGeneratorID
Definition: SCR_ResourceGenerator.c:1