Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BranchedJunctionPowerPole.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Power", description: "This is the power pole entity.", color: "0 255 0 255", visible: false, dynamicBox: true)]
3 {
4 }
5 
7 {
8  [Attribute("3")]
9  protected int m_iBranchSize;
10 
11  //------------------------------------------------------------------------------------------------
12  //Only for when sameLine == false
13  protected int GetClosestBranch(vector point)
14  {
15  int slotsCount = m_aJunctionSlots.Count();
16  int repetitionCount = Math.Floor(slotsCount / m_iBranchSize);
17  int selectedBranch = 0;
18 
19  float closestDistance = float.MAX;
20 
21  float currentDistance;
22  for (int i = slotsCount - 1; i >= 0; i--)
23  {
24  currentDistance += vector.DistanceSq(CoordToParent(m_aJunctionSlots[i].m_vSlotA), point);
25  if (i % m_iBranchSize == 0)
26  {
27  if (currentDistance < closestDistance)
28  {
29  closestDistance = currentDistance;
30  selectedBranch = Math.Floor(i / m_iBranchSize);
31  }
32 
33  currentDistance = 0;
34  }
35  }
36  /*for (int i = 1; i <= repetitionCount; i++)
37  {
38  float currentDistance;
39  for (int j = 0; j < m_iBranchSize; j++)
40  {
41  currentDistance += vector.DistanceSq(m_aJunctionSlots[i * m_iBranchSize - j].m_vSlotA, point);
42  }
43 
44  currentDistance /= m_iBranchSize;
45  if (currentDistance < closestDistance)
46  selectedBranch = i;
47  }*/
48 
49  return selectedBranch;
50  }
51 
52  //------------------------------------------------------------------------------------------------
53  override vector TryGetSlot(int index, vector otherSlot, bool sameLine)
54  {
55  if (sameLine)
56  return super.TryGetSlot(index, otherSlot, sameLine);
57 
58  index += GetClosestBranch(otherSlot) * m_iBranchSize;
59 
60  if (index >= m_aJunctionSlots.Count())
61  {
62  return m_aJunctionSlots[index % m_aJunctionSlots.Count()].m_vSlotA;
63  return vector.Zero;
64  }
65 
66  SCR_PowerPoleSlot dualSlot = SCR_PowerPoleSlot.Cast(m_aJunctionSlots[index]);
67  if (dualSlot)
68  {
69  if (vector.Distance(otherSlot, CoordToParent(dualSlot.m_vSlotA)) > vector.Distance(otherSlot, CoordToParent(dualSlot.m_vSlotB)))
70  return CoordToParent(dualSlot.m_vSlotB);
71  else
72  return CoordToParent(dualSlot.m_vSlotA);
73  }
74 
75  SCR_PowerPoleSlotSingle singleSlot = SCR_PowerPoleSlotSingle.Cast(m_aJunctionSlots[index]);
76  if (singleSlot)
77  return CoordToParent(singleSlot.m_vSlotA);
78 
79  return vector.Zero;
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  // constructor
86  void SCR_BranchedJunctionPowerPole(IEntitySource src, IEntity parent)
87  {
88  }
89 }
SCR_BranchedJunctionPowerPoleClass
Definition: SCR_BranchedJunctionPowerPole.c:2
Attribute
SCR_BranchedJunctionPowerPoleClass SCR_JunctionPowerPoleClass Attribute("3")
Definition: SCR_BranchedJunctionPowerPole.c:8
SCR_JunctionPowerPoleClass
Definition: SCR_JunctionPowerPole.c:2
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_BranchedJunctionPowerPole
void SCR_BranchedJunctionPowerPole(IEntitySource src, IEntity parent)
Definition: SCR_BranchedJunctionPowerPole.c:86
TryGetSlot
override vector TryGetSlot(int index, vector otherSlot, bool sameLine)
Definition: SCR_BranchedJunctionPowerPole.c:53
SCR_PowerPoleSlot
Definition: SCR_PowerPoleSlot.c:2
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_JunctionPowerPole
void SCR_JunctionPowerPole(IEntitySource src, IEntity parent)
Definition: SCR_JunctionPowerPole.c:87
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180