Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ResourceGeneratorContainerStorageQueueExtended.c
Go to the documentation of this file.
3 {
4  //------------------------------------------------------------------------------------------------
5  override bool ShouldContainerChangeCauseUpdate()
6  {
7  return true;
8  }
9 
10  //------------------------------------------------------------------------------------------------
11  override int ComputePosition(SCR_ResourceContainer container, SCR_ResourceGenerator actor)
12  {
13  int containerComparePosition;
14  float containerCompareResource;
15  float containerCompareMaxResource;
16  float containerCompareNorm;
17  SCR_ResourceContainer containerCompare;
18  int position = m_iOffsetPosition;
19  int maxPosition = GetUpperOffsetPosition();
20  float containerResource = container.GetResourceValue();
21  float containerMaxResource = container.GetMaxResourceValue();
22 
24  if (containerResource == containerMaxResource)
25  return maxPosition - m_iOffsetPosition;
26 
27  float containerNorm = vector.DistanceSq(actor.GetOwnerOrigin(), container.GetOwnerOrigin());
28 
29  while (position < maxPosition)
30  {
31  containerComparePosition = position + ((maxPosition - position) >> 1);
32  containerCompare = GetContainerAt(containerComparePosition);
33 
34  if (!containerCompare)
35  {
36  maxPosition = containerComparePosition;
37  continue;
38  }
39 
40  containerCompareResource = containerCompare.GetResourceValue();
41  containerCompareMaxResource = containerCompare.GetMaxResourceValue();
42  containerCompareNorm = vector.DistanceSq(actor.GetOwnerOrigin(), containerCompare.GetOwnerOrigin());
43 
44  if (containerNorm > containerCompareNorm)
45  position = containerComparePosition + 1;
46 
47  else if (containerNorm < containerCompareNorm)
48  maxPosition = containerComparePosition;
49 
50  else if (containerResource > containerCompareResource)
51  position = containerComparePosition + 1;
52 
53  else if (containerResource < containerCompareResource)
54  maxPosition = containerComparePosition;
55 
56  else if (containerMaxResource > containerCompareMaxResource)
57  position = containerComparePosition + 1;
58 
59  else if (containerMaxResource < containerCompareMaxResource)
60  maxPosition = containerComparePosition;
61 
62  else
63  break;
64  }
65 
66  return position - m_iOffsetPosition;
67  }
68 };
SCR_ResourceGeneratorContainerStorageQueueExtended
Definition: SCR_ResourceGeneratorContainerStorageQueueExtended.c:2
SCR_ResourceGeneratorContainerStorageQueue
Definition: SCR_ResourceGeneratorContainerStorageQueue.c:2
SCR_ResourceContainer
Definition: SCR_ResourceContainer.c:34
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCR_ResourceGenerator
Definition: SCR_ResourceGenerator.c:79
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