Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkAIAddWaypoint.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "SlotWaypoint that spawns waypoint - Use GetLayerBase")];
5 ref SCR_ScenarioFrameworkGet m_Getter;
6
7 [Attribute(desc: "True checked, this waypoint will be added on a first position. Otherwise it will append it at the end of the waypoint queue.")];
8 bool m_bAddOnTopOfQueue;
9
10 [Attribute(desc: "True checked, previous waypoints should be cleared.")];
11 bool m_bClearPreviousWaypoints;
12
13 AIWaypoint m_Waypoint;
14
15 //------------------------------------------------------------------------------------------------
16 override void OnActivate()
17 {
18 if (!m_Getter)
19 return;
20
21 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
22 if (!entityWrapper)
23 {
24 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
25 return;
26 }
27
28 IEntity entity = entityWrapper.GetValue();
29 if (!entity)
30 {
31 Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
32 return;
33 }
34
35 m_Waypoint = AIWaypoint.Cast(entity);
36 if (!m_Waypoint)
37 {
39 if (!layer)
40 {
41 Print(string.Format("ScenarioFramework Action: Entity is not Layer Base for Action %1.", this), LogLevel.ERROR);
42 return;
43 }
44
45 IEntity spawnedEntity = layer.GetSpawnedEntity();
46 if (!spawnedEntity)
47 {
48 layer.GetOnAllChildrenSpawned().Insert(OnWaypointSpawned);
49 return;
50 }
51
52 m_Waypoint = AIWaypoint.Cast(spawnedEntity);
53 if (!m_Waypoint)
54 {
55 Print(string.Format("ScenarioFramework Action: Waypoint not found for Action %1.", this), LogLevel.ERROR);
56 return;
57 }
58 }
59
60 if (m_bClearPreviousWaypoints)
61 ClearCurrentWaypoints();
62
63 if (m_bAddOnTopOfQueue)
64 m_AIGroup.AddWaypointAt(m_Waypoint, 0);
65 else
66 m_AIGroup.AddWaypoint(m_Waypoint);
67 }
68
69 //------------------------------------------------------------------------------------------------
70 void ClearCurrentWaypoints()
71 {
72 array<AIWaypoint> currentWaypoints = {};
73 m_AIGroup.GetWaypoints(currentWaypoints);
74 foreach (AIWaypoint waypoint : currentWaypoints)
75 {
76 m_AIGroup.RemoveWaypointFromGroup(waypoint);
77 }
78 }
79
80 //------------------------------------------------------------------------------------------------
81 void OnWaypointSpawned(SCR_ScenarioFrameworkLayerBase layer)
82 {
83 layer.GetOnAllChildrenSpawned().Remove(OnWaypointSpawned);
84
85 IEntity spawnedEntity = layer.GetSpawnedEntity();
86 if (!spawnedEntity)
87 return;
88
89 m_Waypoint = AIWaypoint.Cast(spawnedEntity);
90 if (!m_Waypoint)
91 {
92 Print(string.Format("ScenarioFramework Action: Waypoint not found for Action %1.", this), LogLevel.ERROR);
93 return;
94 }
95
96 if (m_bClearPreviousWaypoints)
97 ClearCurrentWaypoints();
98
99 if (m_bAddOnTopOfQueue)
100 m_AIGroup.AddWaypointAt(m_Waypoint, 0);
101 else
102 m_AIGroup.AddWaypoint(m_Waypoint);
103 }
104}
LayerPresets layer
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
override void OnActivate()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external Managed FindComponent(typename typeName)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute