Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGetSplinePoint.c
Go to the documentation of this file.
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 };
10 {
11 return s_aVarsIn;
12 }
13
14 protected static ref TStringArray s_aVarsOut = {
15 PORT_POSITION
16 };
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 static override bool VisibleInPalette()
72 {
73 return true;
74 }
75
76 protected static 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};
proto external vector GetOrigin()
proto external IEntity GetChildren()
proto external IEntity GetSibling()
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
override void OnInit(AIAgent owner)
override TStringArray GetVariablesIn()
static override string GetOnHoverDescription()
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
static ref TStringArray s_aVarsOut
override TStringArray GetVariablesOut()
static override bool VisibleInPalette()
static ref TStringArray s_aVarsIn
ENodeResult
Definition ENodeResult.c:13
array< string > TStringArray
Definition Types.c:385