Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TaskExecutor.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 static SCR_TaskExecutor FromLocalPlayer()
5 {
6 return FromPlayerID(SCR_PlayerController.GetLocalPlayerId());
7 }
8
9 //------------------------------------------------------------------------------------------------
10 static SCR_TaskExecutor FromPlayerID(int playerID)
11 {
13 executor.SetPlayerID(playerID);
14
15 return executor;
16 }
17
18 //------------------------------------------------------------------------------------------------
19 static SCR_TaskExecutor FromEntity(IEntity ent)
20 {
21 if (!ent)
22 return null;
23
25 executor.SetEntity(ent);
26
27 return executor;
28 }
29
30 //------------------------------------------------------------------------------------------------
31 static SCR_TaskExecutor FromGroup(int groupID)
32 {
34 executor.SetGroupID(groupID);
35
36 return executor;
37 }
38
39 //------------------------------------------------------------------------------------------------
40 static SCR_TaskExecutor FindMatchingTaskExecutor(notnull array<ref SCR_TaskExecutor> container, out notnull SCR_TaskExecutor template, bool recursive = false)
41 {
42 SCR_GroupsManagerComponent groupsManagerComponent = SCR_GroupsManagerComponent.GetInstance();
43 if (recursive && !groupsManagerComponent)
44 return null;
45
46 SCR_AIGroup group;
47 SCR_TaskExecutor match;
48 foreach (SCR_TaskExecutor e : container)
49 {
50 if (!e)
51 continue;
52
53 if (e.IsClonedBy(template))
54 return e;
55
56 if (recursive && SCR_TaskExecutorGroup.Cast(e))
57 {
58 group = groupsManagerComponent.FindGroup(e.GetGroupID());
59 if (!group)
60 continue;
61
62 array<int> groupMemberIDs = group.GetPlayerIDs();
63 if (!groupMemberIDs || groupMemberIDs.IsEmpty())
64 continue;
65
66 array<ref SCR_TaskExecutor> groupMemberExecutors = {};
67 SCR_TaskExecutor groupMemberExecutor;
68 foreach (int groupMemberID : groupMemberIDs)
69 {
70 groupMemberExecutor = SCR_TaskExecutor.FromPlayerID(groupMemberID);
71 if (groupMemberExecutor)
72 groupMemberExecutors.Insert(groupMemberExecutor);
73 }
74
75 match = SCR_TaskExecutor.FindMatchingTaskExecutor(groupMemberExecutors, template);
76 if (match)
77 return match;
78 }
79 }
80
81 return null;
82 }
83
84 //------------------------------------------------------------------------------------------------
85 bool IsClonedBy(SCR_TaskExecutor executor)
86 {
87 if (Type() != executor.Type())
88 return false;
89
90 return true;
91 }
92
93 //------------------------------------------------------------------------------------------------
95 {
96 return FactionKey.Empty;
97 }
98
99 //------------------------------------------------------------------------------------------------
100 int GetGroupID()
101 {
102 return -1;
103 }
104}
int GetGroupID()
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
FactionKey GetFactionKey()
int Type
array< int > GetPlayerIDs()
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.