Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TreePartHierarchyV2.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 class SCR_TreePartHierarchyV2 : Managed
4 {
5  [Attribute("-1", UIWidgets.ResourceNamePicker, "Pick a prefab for this tree part", "et")]
6  ResourceName m_Prefab;
7  [Attribute("", UIWidgets.Object, "")]
8  ref array<ref SCR_TreePartHierarchyV2> m_aChildren;
9 
10 #ifdef ENABLE_DESTRUCTION
11  void SpawnAllChildren(IEntity parent, array<SCR_TreePartV2> treeParts = null)
12  {
13  if (!parent)
14  return;
15 
16  int count = m_aChildren.Count();
17  for (int i = 0; i < count; i++)
18  {
19  if (!m_aChildren[i])
20  return;
21  if (m_aChildren[i].m_Prefab.GetPath() == "-1")
22  return;
23 
24  Resource resource = Resource.Load(m_aChildren[i].m_Prefab);
25  if (!resource.IsValid())
26  return;
27 
28  vector mat[4];
29  parent.GetTransform(mat);
30 
31  ArmaReforgerScripted game = GetGame();
32  if (!game)
33  continue;
34 
35  IEntity ent = game.SpawnEntityPrefab(resource);
36 
37  if (RplSession.Mode() == RplMode.Client)
38  parent.AddChild(ent, -1, EAddChildFlags.AUTO_TRANSFORM);
39  else parent.AddChild(ent, -1, EAddChildFlags.NONE);
40  ent.SetTransform(mat);
41 
42  if (treeParts)
43  {
44  SCR_TreePartV2 treePart = SCR_TreePartV2.Cast(ent);
45  if (treePart)
46  {
47  treePart.m_vLockedOrigin = parent.GetOrigin();
48  treeParts.Insert(treePart);
49  }
50  }
51 
52  m_aChildren[i].SpawnAllChildren(ent, treeParts);
53  }
54  }
55 
57  {
58  foreach (SCR_TreePartHierarchyV2 hierarchy : m_aChildren)
59  {
60  hierarchy = null;
61  }
62  m_aChildren = null;
63  }
64 #endif
65 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_TreePartV2
Definition: SCR_TreePartV2.c:8
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_aChildren
protected ref array< SCR_ScenarioFrameworkLayerBase > m_aChildren
Definition: SCR_ScenarioFrameworkLayerBase.c:57
SCR_TreePartHierarchyV2
Definition: SCR_TreePartHierarchyV2.c:3
m_Prefab
ResourceName m_Prefab
Definition: ForestGeneratorObjects.c:48
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468