Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetSplinePoint.c
Go to the documentation of this file.
1 class SCR_AIGetSplinePoint: AITaskScripted
2 {
3  static const string PORT_ENTITY = "EntityWithSplineIn";
4  static const string PORT_POSITION = "PositionOut";
5 
6  protected static ref TStringArray s_aVarsIn = {
7  PORT_ENTITY
8  };
9  override TStringArray GetVariablesIn()
10  {
11  return s_aVarsIn;
12  }
13 
14  protected static ref TStringArray s_aVarsOut = {
15  PORT_POSITION
16  };
17  override TStringArray GetVariablesOut()
18  {
19  return s_aVarsOut;
20  }
21 
22  private int m_iLastIndex;
23  private ref array <vector> m_aOffsetPath;
24  private vector m_vOrigin;
25  private bool m_bShouldFail;
26 
27 
28  protected override void OnInit(AIAgent owner)
29  {
30  IEntity ent;
31  if(!GetVariableIn(PORT_ENTITY,ent))
32  ent = owner.GetControlledEntity();
33 
34  m_aOffsetPath = new array <vector>;
35 
36  if (ent.GetChildren())
37  {
38  IEntity entPoly = ent.GetChildren();
39  PolylineShapeEntity polyline = PolylineShapeEntity.Cast(entPoly);
40 
41  while (!polyline && entPoly)
42  {
43  entPoly = entPoly.GetSibling();
44  polyline = PolylineShapeEntity.Cast(entPoly);
45  };
46  if (!polyline)
47  {
48  m_bShouldFail = true;
49  return;
50  }
51 
52  m_vOrigin = polyline.GetOrigin();
53 
54  polyline.GetPointsPositions(m_aOffsetPath);
55  }
56  }
57 
58  protected override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
59  {
60  if (m_bShouldFail)
61  return ENodeResult.FAIL;
62 
63  m_iLastIndex = (m_iLastIndex + 1) % m_aOffsetPath.Count();
64  vector positionOut = m_aOffsetPath[m_iLastIndex] + m_vOrigin;
65 
66  SetVariableOut(PORT_POSITION,positionOut);
67 
68  return ENodeResult.SUCCESS;
69  }
70 
71  protected override bool VisibleInPalette()
72  {
73  return true;
74  }
75 
76  protected override string GetOnHoverDescription()
77  {
78  return "BT node for returning position on spline that is hierarchical child of provided entity. Each tick next point on spline is taken.";
79  }
80 
81 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
m_iLastIndex
int m_iLastIndex
Definition: SCR_KeybindActionDisplayComponent.c:110
SCR_AIGetSplinePoint
Definition: SCR_AIGetSplinePoint.c:1