1 [
EntityEditorProps(
category:
"GameScripted/Power", description:
"This is the power pole entity.", color:
"0 255 0 255", visible:
false, dynamicBox:
true)]
9 protected int m_iBranchSize;
13 protected int GetClosestBranch(vector point)
15 int slotsCount = m_aJunctionSlots.Count();
16 int repetitionCount = Math.Floor(slotsCount / m_iBranchSize);
17 int selectedBranch = 0;
19 float closestDistance =
float.MAX;
21 float currentDistance;
22 for (
int i = slotsCount - 1; i >= 0; i--)
24 currentDistance += vector.DistanceSq(CoordToParent(m_aJunctionSlots[i].m_vSlotA), point);
25 if (i % m_iBranchSize == 0)
27 if (currentDistance < closestDistance)
29 closestDistance = currentDistance;
30 selectedBranch = Math.Floor(i / m_iBranchSize);
49 return selectedBranch;
56 return super.TryGetSlot(
index, otherSlot, sameLine);
58 index += GetClosestBranch(otherSlot) * m_iBranchSize;
60 if (
index >= m_aJunctionSlots.Count())
62 return m_aJunctionSlots[
index % m_aJunctionSlots.Count()].m_vSlotA;
69 if (vector.Distance(otherSlot, CoordToParent(dualSlot.m_vSlotA)) > vector.Distance(otherSlot, CoordToParent(dualSlot.m_vSlotB)))
70 return CoordToParent(dualSlot.m_vSlotB);
72 return CoordToParent(dualSlot.m_vSlotA);
75 SCR_PowerPoleSlotSingle singleSlot = SCR_PowerPoleSlotSingle.Cast(m_aJunctionSlots[
index]);
77 return CoordToParent(singleSlot.m_vSlotA);