Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkActionsGetters.c
Go to the documentation of this file.
2 {
3 }
4 
6 {
7  T m_Value;
8 
9  //------------------------------------------------------------------------------------------------
12  {
13  return m_Value;
14  }
15 
16  //------------------------------------------------------------------------------------------------
17  // constructor
20  {
21  m_Value = value;
22  }
23 }
24 
27 {
29 
30  //------------------------------------------------------------------------------------------------
32  void SetValue(SCR_ScenarioFrameworkParamBase value)
33  {
34  m_Value = value;
35  }
36 
37  //------------------------------------------------------------------------------------------------
40  {
41  return m_Value;
42  }
43 
44  //------------------------------------------------------------------------------------------------
48  IEntity FindEntityByName(string name)
49  {
50  IEntity entity = GetGame().GetWorld().FindEntityByName(name);
51  if (!entity)
52  return null;
53 
54  return entity;
55  }
56 }
57 
58 //[BaseContainerProps(), SCR_ContainerActionTitle()]
59 class SCR_ScenarioFrameworkGetLastFinishedTaskLayer : SCR_ScenarioFrameworkGet
60 {
61  //------------------------------------------------------------------------------------------------
63  {
64  SCR_GameModeSFManager gameModeManager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
65  if (!gameModeManager)
66  return null;
67 
68  return new SCR_ScenarioFrameworkParam<SCR_ScenarioFrameworkLayerTask>(SCR_ScenarioFrameworkLayerTask.Cast(gameModeManager.GetLastFinishedTaskLayer()));
69  }
70 }
71 
74 {
75  //------------------------------------------------------------------------------------------------
76  override SCR_ScenarioFrameworkParamBase Get()
77  {
78  SCR_GameModeSFManager gameModeManager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
79  if (!gameModeManager)
80  return null;
81 
82  return new SCR_ScenarioFrameworkParam<IEntity>(gameModeManager.GetLastFinishedTask());
83  }
84 }
85 
87 class SCR_ScenarioFrameworkGetEntityByName : SCR_ScenarioFrameworkGet
88 {
89  [Attribute()]
90  string m_sEntityName;
91 
92  //------------------------------------------------------------------------------------------------
94  {
95  return new SCR_ScenarioFrameworkParam<IEntity>(GetGame().GetWorld().FindEntityByName(m_sEntityName));
96  }
97 }
98 
100 class SCR_ScenarioFrameworkGetSpawnedEntity : SCR_ScenarioFrameworkGet
101 {
102  [Attribute()]
103  string m_sLayerName;
104 
105  //------------------------------------------------------------------------------------------------
107  {
108  IEntity entity = FindEntityByName(m_sLayerName);
109  if (!entity)
110  return null;
111 
113  if (!layer)
114  return null;
115 
116  return new SCR_ScenarioFrameworkParam<IEntity>(layer.GetSpawnedEntity());
117  }
118 }
119 
121 class SCR_ScenarioFrameworkGetTask : SCR_ScenarioFrameworkGet
122 {
123  [Attribute()]
124  string m_sLayerTaskName;
125 
126  //------------------------------------------------------------------------------------------------
128  {
129  IEntity entity = FindEntityByName(m_sLayerTaskName);
130  if (!entity)
131  return null;
132 
133  SCR_ScenarioFrameworkLayerTask layer = SCR_ScenarioFrameworkLayerTask.Cast(entity.FindComponent(SCR_ScenarioFrameworkLayerTask));
134  if (!layer)
135  return null;
136 
137  return new SCR_ScenarioFrameworkParam<IEntity>(layer.GetTask());
138  }
139 }
140 
142 class SCR_ScenarioFrameworkGetLayerTask : SCR_ScenarioFrameworkGet
143 {
144  [Attribute()]
145  string m_sLayerTaskName;
146 
147  //------------------------------------------------------------------------------------------------
149  {
150  IEntity entity = FindEntityByName(m_sLayerTaskName);
151  if (!entity)
152  return null;
153 
154  SCR_ScenarioFrameworkLayerTask layer = SCR_ScenarioFrameworkLayerTask.Cast(entity.FindComponent(SCR_ScenarioFrameworkLayerTask));
155  if (!layer)
156  return null;
157 
158  return new SCR_ScenarioFrameworkParam<IEntity>(entity);
159  }
160 }
161 
163 class SCR_ScenarioFrameworkGetLayerBase : SCR_ScenarioFrameworkGet
164 {
165  [Attribute()]
166  string m_sLayerBaseName;
167 
168  //------------------------------------------------------------------------------------------------
170  {
171  IEntity entity = FindEntityByName(m_sLayerBaseName);
172  if (!entity)
173  return null;
174 
176  if (!layer)
177  return null;
178 
179  return new SCR_ScenarioFrameworkParam<IEntity>(entity);
180  }
181 }
182 
184 class SCR_ScenarioFrameworkGetRandomLayerBase : SCR_ScenarioFrameworkGet
185 {
186  [Attribute(defvalue: "", UIWidgets.EditComboBox, desc: "From this list, random layer will be selected")]
187  ref array<string> m_aNameOfLayers;
188 
189  //------------------------------------------------------------------------------------------------
191  {
192  if (m_aNameOfLayers.IsEmpty())
193  return null;
194 
195  Math.Randomize(-1);
196  string selectedLayer = m_aNameOfLayers.GetRandomElement();
197 
198  IEntity entity = FindEntityByName(selectedLayer);
199  if (!entity)
200  return null;
201 
203  if (!layer)
204  return null;
205 
206  return new SCR_ScenarioFrameworkParam<IEntity>(entity);
207  }
208 }
209 
211 class SCR_ScenarioFrameworkGetArea : SCR_ScenarioFrameworkGet
212 {
213  [Attribute()]
214  string m_sAreaName;
215 
216  //------------------------------------------------------------------------------------------------
218  {
219  IEntity entity = FindEntityByName(m_sAreaName);
220  if (!entity)
221  return null;
222 
224  if (!area)
225  return null;
226 
227  return new SCR_ScenarioFrameworkParam<IEntity>(entity);
228  }
229 }
230 
232 class SCR_ScenarioFrameworkGetAreaTrigger : SCR_ScenarioFrameworkGet
233 {
234  [Attribute()]
235  string m_sAreaName;
236 
237  //------------------------------------------------------------------------------------------------
239  {
240  IEntity entity = FindEntityByName(m_sAreaName);
241  if (!entity)
242  return null;
243 
245  if (!area)
246  return null;
247 
248  SCR_CharacterTriggerEntity trigger = SCR_CharacterTriggerEntity.Cast(area.GetTrigger());
249  if (!trigger)
250  return null;
251 
252  return new SCR_ScenarioFrameworkParam<IEntity>(entity);
253  }
254 }
255 
257 class SCR_ScenarioFrameworkGetListEntitiesInTrigger : SCR_ScenarioFrameworkGet
258 {
259  [Attribute()]
260  string m_sTriggerName;
261 
262  ref array<IEntity> m_aEntities = {};
263 
264  //------------------------------------------------------------------------------------------------
266  {
267  GetEntitiesInTrigger(m_aEntities);
268 
269  return new SCR_ScenarioFrameworkParam<array<IEntity>>(m_aEntities);
270  }
271 
272  //------------------------------------------------------------------------------------------------
274  void GetEntitiesInTrigger(out notnull array<IEntity> aEntities)
275  {
276  BaseGameTriggerEntity trigger = BaseGameTriggerEntity.Cast(GetGame().GetWorld().FindEntityByName(m_sTriggerName));
277  if (!trigger)
278  return;
279 
280  trigger.GetEntitiesInside(aEntities);
281  }
282 }
283 
285 class SCR_ScenarioFrameworkGetCountEntitiesInTrigger : SCR_ScenarioFrameworkGetListEntitiesInTrigger
286 {
287  //------------------------------------------------------------------------------------------------
289  {
290  array<IEntity> aEntities = {};
291  GetEntitiesInTrigger(aEntities);
292 
293  return new SCR_ScenarioFrameworkParam<int>(aEntities.Count());
294  }
295 }
296 
299 class SCR_ScenarioFrameworkGetPlayerEntity : SCR_ScenarioFrameworkGet
300 {
301  //------------------------------------------------------------------------------------------------
303  {
304  array<int> playerIDs = {};
305  GetGame().GetPlayerManager().GetPlayers(playerIDs);
306  IEntity entity;
307  foreach (int playerID : playerIDs)
308  {
309  entity = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
310  if (!entity)
311  continue;
312 
313  return new SCR_ScenarioFrameworkParam<IEntity>(entity);
314  }
315 
316  return null;
317  }
318 }
319 
322 class SCR_ScenarioFrameworkGetClosestPlayerEntity : SCR_ScenarioFrameworkGet
323 {
324  [Attribute(desc: "Closest to what - use getter")]
325  ref SCR_ScenarioFrameworkGet m_Getter;
326 
327  //------------------------------------------------------------------------------------------------
329  {
330  if (!m_Getter)
331  {
332  Print("ScenarioFramework: GetClosestPlayerEntity - The object the distance is calculated from is missing!", LogLevel.ERROR);
333  return null;
334  }
335 
336  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
337  if (!entityWrapper)
338  return null;
339 
340  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
341  if (!entityFrom)
342  return null;
343 
344  array<int> playerIDs = {};
345  GetGame().GetPlayerManager().GetPlayers(playerIDs);
346 
347  IEntity closestEntity;
348  IEntity entityToBeChecked;
349  float fDistance = float.MAX;
350  foreach (int playerID : playerIDs)
351  {
352  entityToBeChecked = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
353  if (!entityToBeChecked)
354  continue;
355 
356  float fActualDistance = vector.DistanceSqXZ(entityFrom.GetOrigin(), entityToBeChecked.GetOrigin());
357 
358  if (fActualDistance < fDistance)
359  {
360  closestEntity = entityToBeChecked;
361  fDistance = fActualDistance;
362  }
363  }
364 
365  if (!closestEntity)
366  return null;
367 
368  return new SCR_ScenarioFrameworkParam<IEntity>(closestEntity);
369  }
370 }
371 
373 class SCR_ScenarioFrameworkGetArrayOfPlayers : SCR_ScenarioFrameworkGet
374 {
375  ref array<IEntity> m_aEntities = {};
376 
377  //------------------------------------------------------------------------------------------------
379  {
380  m_aEntities.Clear();
381  GetPlayerEntities(m_aEntities);
382 
383  return new SCR_ScenarioFrameworkParam<array<IEntity>>(m_aEntities);
384  }
385 
386  //------------------------------------------------------------------------------------------------
388  void GetPlayerEntities(out notnull array<IEntity> aEntities)
389  {
390  array<int> playerIDs = {};
391  GetGame().GetPlayerManager().GetPlayers(playerIDs);
392 
393  IEntity playerEntity;
394  foreach (int playerID : playerIDs)
395  {
396  playerEntity = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
397  if (!playerEntity)
398  continue;
399 
400  aEntities.Insert(playerEntity);
401  }
402  }
403 }
SCR_ScenarioFrameworkParamBase
Definition: SCR_ScenarioFrameworkActionsGetters.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
FindEntityByName
IEntity FindEntityByName(string name)
Definition: SCR_ScenarioFrameworkActionsGetters.c:40
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
BaseContainerProps
SCR_ScenarioFrameworkGetLastFinishedTaskEnity SCR_ScenarioFrameworkGet BaseContainerProps()
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ContainerActionTitle
SCR_ContainerActionTitle BaseContainerCustomTitle SCR_ContainerActionTitle()] class SCR_ScenarioFrameworkActionBase
Definition: SCR_ScenarioFrameworkActions.c:43
SCR_ScenarioFrameworkArea
Definition: SCR_ScenarioFrameworkArea.c:24
GetValue
T GetValue()
Definition: SCR_ScenarioFrameworkActionsGetters.c:11
SCR_CharacterTriggerEntity
Definition: SCR_CharacterTriggerEntity.c:17
SCR_ScenarioFrameworkLayerBase
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkLayerBase.c:875
SCR_ScenarioFrameworkParam
void SCR_ScenarioFrameworkParam(T value)
Definition: SCR_ScenarioFrameworkActionsGetters.c:19
m_Value
class SCR_ScenarioFrameworkParamBase m_Value
Definition: SCR_ScenarioFrameworkActionsGetters.c:20
SCR_ScenarioFrameworkGet
Definition: SCR_ScenarioFrameworkActionsGetters.c:26
SCR_ScenarioFrameworkGetLastFinishedTaskEnity
Definition: SCR_ScenarioFrameworkActionsGetters.c:73
Get
class SCR_ScenarioFrameworkGet Get()
Definition: SCR_ScenarioFrameworkActionsGetters.c:62