Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditorLinkComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "")]
2 class SCR_EditorLinkComponentClass : ScriptComponentClass
3 {
4  [Attribute()]
5  ref array<ref SCR_EditorLinkEntry> m_aEntries;
6 }
7 
14 class SCR_EditorLinkComponent : ScriptComponent
15 {
16  protected static bool s_bIgnoreSpawning;
17 
18  protected bool m_bIsSpawned;
19  protected ref ScriptInvoker m_OnLinkedEntitiesSpawned;
20 
25  {
27  m_OnLinkedEntitiesSpawned = new ScriptInvoker();
28 
30  }
31 
36  {
37  return s_bIgnoreSpawning;
38  }
39 
46  static void IgnoreSpawning(bool ignore)
47  {
48  s_bIgnoreSpawning = ignore;
49  }
50 
56  static bool IsSpawned(SCR_EditableEntityComponent entity)
57  {
58  SCR_EditorLinkComponent linkComponent = SCR_EditorLinkComponent.Cast(entity.GetOwner().FindComponent(SCR_EditorLinkComponent));
59  return linkComponent && linkComponent.IsSpawned();
60  }
61 
65  bool IsSpawned()
66  {
67  return m_bIsSpawned;
68  }
69 
70  override void EOnInit(IEntity owner)
71  {
73  {
75  if (editable)
76  editable.SetEntityFlag(EEditableEntityFlag.SPAWN_UNFINISHED, true);
77  s_bIgnoreSpawning = false;
78  return;
79  }
80 
82  }
83 
84  override void OnPostInit(IEntity owner)
85  {
86  if ((Replication.IsClient() && !Replication.Loadtime()) || SCR_Global.IsEditMode(owner))
87  return;
88 
89  SCR_EditableEntityComponent parent = SCR_EditableEntityComponent.GetEditableEntity(owner);
90  if (!parent)
91  return;
92 
93  SetEventMask(owner, EntityEvent.INIT);
94  }
95 
97  {
98  if ((Replication.IsClient() && !Replication.Loadtime()) || SCR_Global.IsEditMode(GetOwner()))
99  return;
100 
101  SCR_EditorLinkComponentClass prefabData = SCR_EditorLinkComponentClass.Cast(GetComponentData(GetOwner()));
102  if (!prefabData)
103  return;
104 
105  Game game = GetGame();
106  BaseWorld world = GetOwner().GetWorld();
107 
108  EntitySpawnParams spawnParams = new EntitySpawnParams();
109  spawnParams.TransformMode = ETransformMode.LOCAL;
110  spawnParams.Parent = GetOwner();
111 
112  foreach (SCR_EditorLinkEntry entry : prefabData.m_aEntries)
113  {
114  entry.SetSpawnParams(spawnParams);
115  if (!game.SpawnEntityPrefab(Resource.Load(entry.m_Prefab), world, spawnParams))
116  Print(string.Format("Unable to spawn linked entity @\"%1\"!", entry.m_Prefab.GetPath()), LogLevel.WARNING);
117  }
118 
119  m_bIsSpawned = true;
120 
122  m_OnLinkedEntitiesSpawned.Invoke(this);
123  }
124 }
125 
128 {
129  [Attribute(uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et")]
130  ResourceName m_Prefab;
131 
132  [Attribute()]
133  vector m_vPosition;
134 
135  [Attribute()]
136  vector m_vAngles;
137 
138  [Attribute(defvalue: "1")]
139  float m_fScale;
140 
141  void SetSpawnParams(out EntitySpawnParams spawnParams)
142  {
143  Math3D.AnglesToMatrix(Vector(m_vAngles[1], m_vAngles[0], m_vAngles[2]), spawnParams.Transform);
144  spawnParams.Scale = m_fScale;
145  spawnParams.Transform[3] = m_vPosition;
146  }
147 
148  void SCR_EditorLinkEntry(ResourceName prefab, vector position, vector angles, float scale)
149  {
150  if (!prefab.IsEmpty())
151  {
152  m_Prefab = prefab;
154  m_vAngles = angles;
155  m_fScale = scale;
156  }
157  }
158 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
EEditableEntityFlag
EEditableEntityFlag
Unique flags of the entity.
Definition: EEditableEntityFlag.c:5
SCR_BaseContainerCustomTitleResourceName
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
Definition: SCR_CampaignMilitaryBaseComponent.c:2522
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
Attribute
typedef Attribute
Post-process effect of scripted camera.
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_EditorLinkComponent.c:84
SCR_EditorLinkEntry
Definition: SCR_EditorLinkComponent.c:127
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_EditorLinkComponent.c:70
SCR_Global
Definition: Functions.c:6
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
m_vPosition
vector m_vPosition
Definition: SCR_AITalkRequest.c:23
s_bIgnoreSpawning
SCR_EditorLinkComponentClass s_bIgnoreSpawning
m_Prefab
ResourceName m_Prefab
Definition: ForestGeneratorObjects.c:48
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
m_fScale
float m_fScale
Definition: ForestGeneratorObjects.c:65
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
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180