Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ResourceContainerStorageQueue.c
Go to the documentation of this file.
2 class SCR_ResourceContainerStorageQueue<Class ResourceActorType> : Managed
3 {
4  protected int m_iOffsetPosition;
5  protected int m_iContainerCount;
6  private array<SCR_ResourceContainer> m_aContainers;
7 
8  //------------------------------------------------------------------------------------------------
9  int GetContainerCount()
10  {
11  return m_iContainerCount;
12  }
13 
14  //------------------------------------------------------------------------------------------------
15  int GetOffsetPosition()
16  {
17  return m_iOffsetPosition;
18  }
19 
20  //------------------------------------------------------------------------------------------------
21  protected int GetUpperOffsetPosition()
22  {
23  return m_iOffsetPosition + m_iContainerCount;
24  }
25 
26  //------------------------------------------------------------------------------------------------
27  protected SCR_ResourceContainer GetContainerRelativeAt(int index)
28  {
29  return m_aContainers[m_iOffsetPosition + index];
30  }
31 
32  //------------------------------------------------------------------------------------------------
33  protected SCR_ResourceContainer GetContainerAt(int index)
34  {
35  if (m_aContainers.IsIndexValid(index))
36  return m_aContainers[index];
37 
38  return null;
39  }
40 
41  //------------------------------------------------------------------------------------------------
42  bool IsEmpty()
43  {
44  return m_iContainerCount == 0;
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  bool ShouldContainerChangeCauseUpdate()
49  {
50  return false;
51  }
52 
53  //------------------------------------------------------------------------------------------------
57  int RegisterContainer(notnull SCR_ResourceContainer container, notnull ResourceActorType actor)
58  {
59  return InsertContainerAt(container, ComputePosition(container, actor));
60  }
61 
62  //------------------------------------------------------------------------------------------------
64  void UnregisterFirstContainer()
65  {
66  if (!m_iContainerCount)
67  return;
68 
69  m_aContainers.RemoveOrdered(m_iOffsetPosition);
70  m_iContainerCount--;
71  }
72 
73  //------------------------------------------------------------------------------------------------
75  void UnregisterContainerAt(int position)
76  {
77  if (!m_iContainerCount)
78  return;
79 
80  m_aContainers.RemoveOrdered(m_iOffsetPosition + position);
81  m_iContainerCount--;
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  int ComputePosition(SCR_ResourceContainer container, ResourceActorType actor)
86  {
87  return 0;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  protected int InsertContainerAt(SCR_ResourceContainer container, int index)
92  {
93  if (index == SCR_ResourceContainerQueue.INVALID_CONTAINER_INDEX)
94  return SCR_ResourceContainerQueue.INVALID_CONTAINER_INDEX;
95 
96  int position = m_iOffsetPosition + index;
97 
98  m_aContainers.InsertAt(container, position);
99  m_iContainerCount++;
100 
101  return position;
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  int InsertContainerAtEx(SCR_ResourceContainer container, int index)
106  {
107  if (index == SCR_ResourceContainerQueue.INVALID_CONTAINER_INDEX)
108  return SCR_ResourceContainerQueue.INVALID_CONTAINER_INDEX;
109 
110  int position = m_iOffsetPosition + index;
111 
112  m_aContainers.InsertAt(container, position);
113 
114  return position;
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  void SetOffsetPosition(int offset)
119  {
120  m_iOffsetPosition = offset;
121  }
122 
123  //------------------------------------------------------------------------------------------------
124  void IncrementOffset(int increment)
125  {
126  m_iOffsetPosition += increment;
127  }
128 
129  //------------------------------------------------------------------------------------------------
130  void DecrementOffset(int decrement)
131  {
132  m_iOffsetPosition -= decrement;
133  }
134 
135  //------------------------------------------------------------------------------------------------
136  void Initialize(array<SCR_ResourceContainer> containers)
137  {
138  Reset();
139  m_aContainers = containers;
140  }
141 
142  //------------------------------------------------------------------------------------------------
143  void Reset(int offsetPosition = 0)
144  {
145  m_iOffsetPosition = offsetPosition;
146  m_iContainerCount = 0;
147  }
148 
149  //------------------------------------------------------------------------------------------------
150  void DebugPrint()
151  {
152  string content = string.Format("Storage Container Queue of [ %1 ] has: %2 containers", ToString(), m_iContainerCount);
153 
154  for (int i = 0; i < m_iContainerCount; i++)
155  {
156  content += string.Format("\n\tContainer %1", GetContainerRelativeAt(i).m_sDebugName);
157  }
158 
159  content += "\n";
160 
161  Print(string.ToString(content, false, false, false));
162  }
163 
164  //------------------------------------------------------------------------------------------------
165  void SCR_ResourceContainerStorage()
166  {
167  m_iOffsetPosition = 0;
168  }
169 };
Initialize
void Initialize()
Definition: SCR_CampaignMilitaryBaseComponent.c:181
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_ResourceContainer
Definition: SCR_ResourceContainer.c:34
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
Reset
void Reset()
Sets variables to default values when freed to be reused by another object on demand.
Definition: SCR_BuildingDestructionManagerComponent.c:34
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468