Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGetSmartActionComponent.c
Go to the documentation of this file.
2{
3 static const string WAYPOINT_PORT = "WaypointIn";
4 static const string COMPONENT_PORT = "SmartActionComponent";
5
6 //------------------------------------------------------------------------------------------
7 protected static override bool VisibleInPalette()
8 {
9 return true;
10 }
11
12 //------------------------------------------------------------------------------------------
13 protected static ref TStringArray s_aVarsIn = {
14 WAYPOINT_PORT
15 };
17 {
18 return s_aVarsIn;
19 }
20
21 //------------------------------------------------------------------------------------------
22 protected static ref TStringArray s_aVarsOut = {
23 COMPONENT_PORT
24 };
26 {
27 return s_aVarsOut;
28 }
29
30 //------------------------------------------------------------------------------------------
31 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
32 {
33 AIGroup group = AIGroup.Cast(owner);
34 if (!group)
35 {
36 SCR_AgentMustBeAIGroup(this, owner);
37 return ENodeResult.FAIL;
38 }
39
40 AIWaypoint wp;
41 if(!GetVariableIn(WAYPOINT_PORT,wp))
42 wp = group.GetCurrentWaypoint();
43 if (!wp)
44 return ENodeResult.FAIL;
45
47
48 if (!SAWP)
49 return ENodeResult.FAIL;
50
51 IEntity SAEntity;
52 string SATag;
53
54 SAWP.GetSmartActionEntity(SAEntity, SATag);
55
56 if (!SAEntity || SATag.IsEmpty())
57 return ENodeResult.FAIL;
58
59 if (SAEntity)
60 {
61 array<Managed> outComponents = {};
63 array<string> outTags = {};
64 SAEntity.FindComponents(SCR_AISmartActionComponent, outComponents);
65 // searching in hierarchy of SAEntity for SmartActionComponents
66 IEntity child = SAEntity.GetChildren();
67 while (child)
68 {
69 array<Managed> entityComponents = {};
70 child.FindComponents(SCR_AISmartActionComponent,entityComponents);
71 outComponents.InsertAll(entityComponents);
72 child = child.GetSibling();
73 }
74 // searching SmartActionComponents of smartactions with correct TAG
75 foreach (Managed outComponent : outComponents)
76 {
77 component = SCR_AISmartActionComponent.Cast(outComponent);
78 if (!component)
79 continue;
80 component.GetTags(outTags);
81 if (outTags.Contains(SATag) && component.IsActionAccessible())
82 {
83 SetVariableOut(COMPONENT_PORT, component);
84 return ENodeResult.SUCCESS;
85 }
86 }
87 }
88 return ENodeResult.FAIL;
89 }
90
91 //------------------------------------------------------------------------------------------
92 protected static override string GetOnHoverDescription()
93 {
94 return "Returns SmartActionComponent set on waypoint, fails if waypoint is not set properly (entity or tag is missing).";
95 }
96};
void SCR_AgentMustBeAIGroup(Node node, AIAgent owner)
Definition NodeError.c:14
proto external IEntity GetChildren()
proto external int FindComponents(typename typeName, notnull array< Managed > outComponents)
proto external IEntity GetSibling()
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
ENodeResult
Definition ENodeResult.c:13
array< string > TStringArray
Definition Types.c:385