Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ContainerBudgetManager.c
Go to the documentation of this file.
1 
5 class SCR_ContainerBudgetManager<Class CONTAINER_TYPE, Class ITEM_TYPE>
6 {
7  protected CONTAINER_TYPE m_Container;
8  protected int m_iBudgetSize;
9  protected int m_iPivot;
10 
11  //------------------------------------------------------------------------------------------------
15  CONTAINER_TYPE GetContainer()
16  {
17  return m_Container;
18  }
19 
20  //------------------------------------------------------------------------------------------------
26  void SetContainer(CONTAINER_TYPE container)
27  {
28  m_Container = container;
29  }
30 
31  //------------------------------------------------------------------------------------------------
38  array<ITEM_TYPE> ProcessNextBatch()
39  {
40  if (!m_Container)
41  return null;
42 
43  ITEM_TYPE item;
44  int containerCount = m_Container.Count();
45  array<ITEM_TYPE> batch = {};
46 
47  batch.Reserve(m_iBudgetSize);
48 
49  if (containerCount == 0)
50  return batch;
51 
52  for (int i = 0; (i < m_iBudgetSize && batch.Count() < m_iBudgetSize); ++i)
53  {
54  if (m_iPivot >= containerCount)
55  m_iPivot = 0;
56 
57  item = m_Container[m_iPivot++];
58 
59  batch.Insert(item);
60  }
61 
62  return batch;
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  void SCR_ContainerBudgetManager(CONTAINER_TYPE container, int budgetSize)
67  {
68  m_Container = container;
69  m_iBudgetSize = budgetSize;
70  }
71 }
GetContainer
SCR_ResourceContainer GetContainer(EResourceType resourceType)
Definition: SCR_ResourceComponent.c:463