Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_JunctionPowerPole.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(desc: "Slots for connecting with other power poles in a junction", category: "Power Cable Slots")]
9  protected ref array<ref SCR_PowerPoleSlotBase> m_aJunctionSlots;
10 
11  //------------------------------------------------------------------------------------------------
12  override void DrawDebugShapes()
13  {
14  super.DrawDebugShapes();
15 
16  if (!m_bDrawDebugShapes)
17  return;
18 
19  foreach (SCR_PowerPoleSlotBase slot : m_aJunctionSlots)
20  {
21  slot.DrawDebugShapes(m_aDebugShapes, this);
22  }
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  override vector GetSlot(int index, bool sameLine)
27  {
28  if (sameLine)
29  return super.GetSlot(index, sameLine);
30  else
31  return m_aJunctionSlots[index].m_vSlotA;
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override int GetSlotsCount(bool sameLine = true)
36  {
37  if (sameLine)
38  return m_aSlots.Count();
39  else
40  return m_aJunctionSlots.Count();
41  }
42 
43  //------------------------------------------------------------------------------------------------
44  override vector TryGetSlot(int index, vector otherSlot, bool sameLine)
45  {
46  if (sameLine)
47  return super.TryGetSlot(index, otherSlot, sameLine);
48 
49  int junctionCount = m_aJunctionSlots.Count();
50  if (index >= junctionCount)
51  index = index % junctionCount;
52 
53  SCR_PowerPoleSlot dualSlot = SCR_PowerPoleSlot.Cast(m_aJunctionSlots[index]);
54  if (dualSlot)
55  {
56  vector avgSideA;
57  vector avgSideB;
58  SCR_PowerPoleSlot powerPoleJunction;
59  for (int i; i < junctionCount; i++)
60  {
61  avgSideA += m_aJunctionSlots[i].m_vSlotA;
62  powerPoleJunction = SCR_PowerPoleSlot.Cast(m_aJunctionSlots[i]);
63  if (powerPoleJunction)
64  avgSideB += powerPoleJunction.m_vSlotB;
65  }
66 
67  avgSideA /= (float)junctionCount;
68  avgSideB /= (float)junctionCount;
69 
70  if (avgSideB == vector.Zero || vector.Distance(otherSlot, CoordToParent(avgSideA)) <= vector.Distance(otherSlot, CoordToParent(avgSideB)))
71  return CoordToParent(dualSlot.m_vSlotA);
72  else
73  return CoordToParent(dualSlot.m_vSlotB);
74  }
75 
76  SCR_PowerPoleSlotSingle singleSlot = SCR_PowerPoleSlotSingle.Cast(m_aJunctionSlots[index]);
77  if (singleSlot)
78  return CoordToParent(singleSlot.m_vSlotA);
79 
80  return vector.Zero;
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  // constructor
87  void SCR_JunctionPowerPole(IEntitySource src, IEntity parent)
88  {
89  }
90 }
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
GetSlotsCount
override int GetSlotsCount(bool sameLine=true)
Definition: SCR_JunctionPowerPole.c:35
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
SCR_JunctionPowerPoleClass SCR_PowerPoleClass Attribute(desc:"Slots for connecting with other power poles in a junction", category:"Power Cable Slots")
Definition: SCR_JunctionPowerPole.c:8
TryGetSlot
override vector TryGetSlot(int index, vector otherSlot, bool sameLine)
Definition: SCR_JunctionPowerPole.c:44
SCR_PowerPoleSlot
Definition: SCR_PowerPoleSlot.c:2
m_aSlots
protected ref array< SCR_WeaponRackSlotEntity > m_aSlots
Definition: SCR_ArsenalDisplayComponent.c:13
DrawDebugShapes
protected void DrawDebugShapes()
Definition: SCR_PowerPole.c:74
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
m_aDebugShapes
protected ref array< ref Shape > m_aDebugShapes
Definition: SCR_PowerlineGeneratorEntity.c:64
SCR_PowerPoleClass
Definition: SCR_PowerPole.c:2
SCR_JunctionPowerPole
void SCR_JunctionPowerPole(IEntitySource src, IEntity parent)
Definition: SCR_JunctionPowerPole.c:87
SCR_PowerPole
void SCR_PowerPole(IEntitySource src, IEntity parent)
Definition: SCR_PowerPole.c:87
GetSlot
override vector GetSlot(int index, bool sameLine)
Definition: SCR_JunctionPowerPole.c:26
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180