Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditorLinkComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor", description: "")]
3{
4 [Attribute(desc: "If true it will allow variant randomization of editable entities. The 'Update editable entity' tool will automatically set this value if any of the direct children have variants.")]
5 bool m_bRandomizeVariants;
6
7 [Attribute()]
8 ref array<ref SCR_EditorLinkEntry> m_aEntries;
9}
10
13
17class SCR_EditorLinkComponent : ScriptComponent
18{
19 protected static bool s_bIgnoreSpawning;
20
21 protected ref array<IEntity> m_aLinkedChildren;
22
24
35
39 static bool IsSpawningIgnored()
40 {
41 return s_bIgnoreSpawning;
42 }
43
50 static void IgnoreSpawning(bool ignore)
51 {
52 s_bIgnoreSpawning = ignore;
53 }
54
60 static bool IsSpawned(SCR_EditableEntityComponent entity)
61 {
62 SCR_EditorLinkComponent linkComponent = SCR_EditorLinkComponent.Cast(entity.GetOwner().FindComponent(SCR_EditorLinkComponent));
63 return linkComponent && linkComponent.IsSpawned();
64 }
65
69 bool IsSpawned()
70 {
71 return m_aLinkedChildren != null;
72 }
73
74 override void EOnInit(IEntity owner)
75 {
77 {
79 if (editable)
80 editable.SetEntityFlag(EEditableEntityFlag.SPAWN_UNFINISHED, true);
81 s_bIgnoreSpawning = false;
82 return;
83 }
84
86 }
87
88 override void OnPostInit(IEntity owner)
89 {
90 if ((Replication.IsClient() && !Replication.Loadtime()) || SCR_Global.IsEditMode(owner))
91 return;
92
94 if (!parent)
95 return;
96
97 SetEventMask(owner, EntityEvent.INIT);
98 }
99
101 {
102 if ((Replication.IsClient() && !Replication.Loadtime()) || SCR_Global.IsEditMode(GetOwner()))
103 return;
104
106 if (!prefabData)
107 return;
108
109 ArmaReforgerScripted game = GetGame();
110 BaseWorld world = GetOwner().GetWorld();
111
112 EntitySpawnParams spawnParams = new EntitySpawnParams();
113 spawnParams.TransformMode = ETransformMode.LOCAL;
114 spawnParams.Parent = GetOwner();
115
117 foreach (SCR_EditorLinkEntry entry : prefabData.m_aEntries)
118 {
119 entry.SetSpawnParams(spawnParams);
120 const IEntity entity = game.SpawnEntityPrefabEx(entry.m_Prefab, prefabData.m_bRandomizeVariants, world, spawnParams);
121 if (!entity)
122 Print(string.Format("Unable to spawn linked entity @\"%1\"!", entry.m_Prefab.GetPath()), LogLevel.WARNING);
123
124 m_aLinkedChildren.Insert(entity);
125 }
126
128 m_OnLinkedEntitiesSpawned.Invoke(this);
129 }
130
131 array<IEntity> GetLinkedChildren()
132 {
133 return m_aLinkedChildren;
134 }
135
136 bool HasChild(IEntity entity)
137 {
139 return false;
140
141 return m_aLinkedChildren.Contains(entity);
142 }
143}
144
146class SCR_EditorLinkEntry
147{
148 [Attribute(uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et")]
149 ResourceName m_Prefab;
150
151 [Attribute(params: "inf inf purpose=coords space=entity anglesVar=m_vAngles")]
152 vector m_vPosition;
153
154 [Attribute(params: "inf inf purpose=angles space=entity coordsVar=m_vPosition")]
155 vector m_vAngles;
156
157 [Attribute(defvalue: "1")]
158 float m_fScale;
159
160 void SetSpawnParams(out EntitySpawnParams spawnParams)
161 {
162 Math3D.AnglesToMatrix(Vector(m_vAngles[1], m_vAngles[0], m_vAngles[2]), spawnParams.Transform);
163 spawnParams.Scale = m_fScale;
164 spawnParams.Transform[3] = m_vPosition;
165 }
166
167 void SCR_EditorLinkEntry(ResourceName prefab, vector position, vector angles, float scale)
168 {
169 if (!prefab.IsEmpty())
170 {
171 m_Prefab = prefab;
172 m_vPosition = position;
173 m_vAngles = angles;
174 m_fScale = scale;
175 }
176 }
177}
vector scale
ref DSGameConfig game
Definition DSConfig.c:81
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void SpawnComposition()
Spawn the composition belonging to this layout.
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
SCR_CharacterSoundComponentClass GetComponentData()
vector position
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
Main replication API.
Definition Replication.c:14
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
void SetEntityFlag(EEditableEntityFlag flag, bool toSet)
static bool IsEditMode()
Definition Functions.c:1566
void EntitySpawnParams()
Definition gameLib.c:130
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
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
SCR_EditorLinkComponentClass s_bIgnoreSpawning
EEditableEntityFlag
Unique flags of the entity.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
proto native vector Vector(float x, float y, float z)
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134