Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TreePartHierarchyV2.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
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};
ref DSGameConfig game
Definition DSConfig.c:81
ArmaReforgerScripted GetGame()
Definition game.c:1398
RplMode
Mode of replication.
Definition RplMode.c:9
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
proto external vector GetOrigin()
proto external int AddChild(notnull IEntity child, TNodeId pivot, EAddChildFlags flags=EAddChildFlags.AUTO_TRANSFORM)
Add Entity to hierarchy. Pivot is pivot index, or -1 for center of parent.
proto external bool SetTransform(vector mat[4])
proto external void GetTransform(out vector mat[])
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
SCR_FieldOfViewSettings Attribute
EAddChildFlags