Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkActionAssignTask.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Which task to work with - Use GetTask")]
5 ref SCR_ScenarioFrameworkGetTask m_TaskGetter;
6
7 [Attribute(desc: "Getter for player, or array of players, to assign task.")];
8 ref SCR_ScenarioFrameworkGet m_PlayerGetter;
9
10 [Attribute(defvalue: "1", desc: "Assign Task")]
11 bool m_bAssignTask;
12
13 [Attribute(defvalue: "1", desc: "Force Assign")]
14 bool m_bForceAssign;
15
16 //------------------------------------------------------------------------------------------------
17 override void OnActivate(IEntity object)
18 {
19 //First get task
20 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_TaskGetter.Get());
21 if (!entityWrapper)
22 {
23 PrintFormat("ScenarioFramework Action: Issue with Task Getter detected for Action %1.", this, level:LogLevel.ERROR);
24 return;
25 }
26
27 SCR_ScenarioFrameworkTask task = SCR_ScenarioFrameworkTask.Cast(entityWrapper.GetValue());
28 if (!task)
29 {
30 if (object)
31 PrintFormat("ScenarioFramework Action: Task not found for Action %1 attached on %2.", this, object.GetName(), level:LogLevel.ERROR);
32 else
33 PrintFormat("ScenarioFramework Action: Task not found for Action %1.", this, level:LogLevel.ERROR);
34
35 return;
36 }
37
38 //Get player, or array of players to assign task
39 entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_PlayerGetter.Get());
40 if (!entityWrapper)
41 {
42 SCR_ScenarioFrameworkParam<array<IEntity>> entityArrayWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_PlayerGetter.Get());
43 if (!entityArrayWrapper)
44 {
45 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
46 return;
47 }
48
49 array<IEntity> entities = {};
50 entities = entityArrayWrapper.GetValue();
51
52 if (entities.IsEmpty())
53 {
54 Print(string.Format("ScenarioFramework Action: Array Getter for %1 has no elements to work with.", this), LogLevel.ERROR);
55 return;
56 }
57
58 foreach (IEntity entity : entities)
59 {
60 ProcessPlayer(entity, task);
61 }
62
63 return;
64 }
65
66 IEntity entity = entityWrapper.GetValue();
67 if (!entity)
68 {
69 Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
70 return;
71 }
72
73 ProcessPlayer(entity, task);
74 }
75
76 //------------------------------------------------------------------------------------------------
77 void ProcessPlayer(notnull IEntity playerEnt, notnull SCR_ScenarioFrameworkTask task)
78 {
79 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
80 if (!taskSystem)
81 return;
82
83 SCR_TaskExecutor executor = SCR_TaskExecutor.FromEntity(playerEnt);
84 if (!executor)
85 return;
86
87 if (m_bAssignTask)
88 taskSystem.AssignTask(task, executor, m_bForceAssign);
89 else
90 taskSystem.UnassignTask(task, executor);
91 }
92}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
override void OnActivate()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
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
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute