Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EntityCatalogEntry.c
Go to the documentation of this file.
1 
4 [BaseContainerProps(), BaseContainerCustomDoubleCheckIntResourceNameTitleField("m_bEnabled", "m_sEntityPrefab", 1, "%1", "DISABLED - %1")]
6 {
7  [Attribute(desc: "Prefab of entity", UIWidgets.ResourcePickerThumbnail, params: "et")]
8  protected ResourceName m_sEntityPrefab;
9 
10  [Attribute("1", desc: "Allows to disable the Entity data. It will be removed from the array on init if it is disabled and can never be obtained. Used for specific gamemodes and modding.")]
11  protected bool m_bEnabled;
12 
13  [Attribute(desc: "List of specific Data for the entity. Each element should be an unique class (Unless all but one are disabled). This list is static and should not be changed in runtime.")]
14  protected ref array<ref SCR_BaseEntityCatalogData> m_aEntityDataList;
15 
16  //~ Index within catalog. Set by Catalog
17  protected int m_iCatalogIndex = -1;
18 
19  //~ UI Info that is obtained from the Prefab data.
20  protected ref SCR_UIInfo m_EditableEntityUiInfo;
21 
22  //~ Reference to parent catalog this entry is part of
23  protected SCR_EntityCatalog m_CatalogParent;
24 
25  //======================================== GETTERS AND SETTERS ========================================\\
26  //--------------------------------- Is Enabled ---------------------------------\\
27 
31  bool IsEnabled()
32  {
33  return m_bEnabled;
34  }
35 
36  //--------------------------------- Get Index ---------------------------------\\
37 
41  int GetCatalogIndex()
42  {
43  return m_iCatalogIndex;
44  }
45 
46  //--------------------------------- Get Prefab ---------------------------------\\
47 
51  ResourceName GetPrefab()
52  {
53  return m_sEntityPrefab;
54  }
55 
56  //--------------------------------- Get Catalog Parent ---------------------------------\\
57 
61  SCR_EntityCatalog GetCatalogParent()
62  {
63  return m_CatalogParent;
64  }
65 
66  //======================================== UI INFO ========================================\\
67  //--------------------------------- Get UI Info ---------------------------------\\
68 
74  SCR_UIInfo GetEntityUiInfo()
75  {
76  return m_EditableEntityUiInfo;
77  }
78 
79  //--------------------------------- Get Name ---------------------------------\\
80 
85  LocalizedString GetEntityName()
86  {
87  if (!GetEntityUiInfo())
88  return string.Empty;
89 
90  return GetEntityUiInfo().GetName();
91  }
92 
93  //======================================== LABELS ========================================\\
94  //--------------------------------- Get all Labels ---------------------------------\\
95 
101  int GetEditableEntityLabels(notnull out array<EEditableEntityLabel> editableEntityLables)
102  {
103  editableEntityLables.Clear();
104 
105  SCR_EditableEntityUIInfo editableUiInfo = SCR_EditableEntityUIInfo.Cast(GetEntityUiInfo());
106  if (!editableUiInfo)
107  return 0;
108 
109  return editableUiInfo.GetEntityLabels(editableEntityLables);
110  }
111 
112  //--------------------------------- Has Label ---------------------------------\\
113 
119  bool HasEditableEntityLabel(EEditableEntityLabel editableEntityLabel)
120  {
121  SCR_EditableEntityUIInfo editableUiInfo = SCR_EditableEntityUIInfo.Cast(GetEntityUiInfo());
122  if (!editableUiInfo)
123  return false;
124 
125  return editableUiInfo.HasEntityLabel(editableEntityLabel);
126  }
127 
128  //--------------------------------- Has Any label ---------------------------------\\
129 
135  bool HasAnyEditableEntityLabels(notnull array<EEditableEntityLabel> editableEntityLables)
136  {
137  SCR_EditableEntityUIInfo editableUiInfo = SCR_EditableEntityUIInfo.Cast(GetEntityUiInfo());
138  if (!editableUiInfo)
139  return false;
140 
141  foreach (EEditableEntityLabel label: editableEntityLables)
142  {
143  if (editableUiInfo.HasEntityLabel(label))
144  return true;
145  }
146 
147  return false;
148  }
149 
150  //--------------------------------- Has all labels ---------------------------------\\
151 
157  bool HasAllEditableEntityLabels(notnull array<EEditableEntityLabel> editableEntityLables)
158  {
159  SCR_EditableEntityUIInfo editableUiInfo = SCR_EditableEntityUIInfo.Cast(GetEntityUiInfo());
160  if (!editableUiInfo)
161  return false;
162 
163  foreach (EEditableEntityLabel label: editableEntityLables)
164  {
165  if (!editableUiInfo.HasEntityLabel(label))
166  return false;
167  }
168 
169  return true;
170  }
171 
172  //======================================== DATA LISTS ========================================\\
173  //--------------------------------- Get Entity Data from type ---------------------------------\\
174 
180  SCR_BaseEntityCatalogData GetEntityDataOfType(typename dataType)
181  {
182  foreach (SCR_BaseEntityCatalogData entityData: m_aEntityDataList)
183  {
184  //~ Check if correct type and not disabled
185  if (entityData.IsEnabled() && entityData.Type() == dataType)
186  return entityData;
187  }
188 
189  return null;
190  }
191 
192  //--------------------------------- Get Entity Data list ---------------------------------\\
193 
199  int GetEntityDataList(notnull out array<SCR_BaseEntityCatalogData> entityDataList)
200  {
201  //~ Clear Given list
202  entityDataList.Clear();
203 
204  //~ Copy list
205  foreach (SCR_BaseEntityCatalogData entityData: m_aEntityDataList)
206  {
207  //~ Ignore if disabled
208  if (entityData.IsEnabled())
209  entityDataList.Insert(entityData);
210  }
211 
212  return entityDataList.Count();
213  }
214 
215  //--------------------------------- Has Entity Data from type ---------------------------------\\
216 
222  bool HasEntityDataOfType(typename dataType)
223  {
224  foreach (SCR_BaseEntityCatalogData entityData: m_aEntityDataList)
225  {
226  //~ Check if correct type and not disabled
227  if (entityData.IsEnabled() && entityData.Type() == dataType)
228  return true;
229  }
230 
231  return false;
232  }
233 
240  bool HasAllEntityDataOfTypes(array<typename> dataTypes)
241  {
242  //~ Check for each data type if type exist. Return false if it does not
243  foreach (typename dataType: dataTypes)
244  {
245  if (!HasEntityDataOfType(dataType))
246  return false;
247  }
248 
249  return true;
250  }
251 
258  bool HasAnyEntityDataOfTypes(array<typename> dataTypes)
259  {
260  //~ Check for each data type if type exist. Return true if it has any in the given list
261  foreach (typename dataType: dataTypes)
262  {
263  if (HasEntityDataOfType(dataType))
264  return true;
265  }
266 
267  return false;
268  }
269 
270  //======================================== INIT ========================================\\
271  //--------------------------------- Class Specific Init ---------------------------------\\
272 
278  void InitEntry(SCR_EntityCatalog catalog, int catalogIndex)
279  {
280  //~ Set idexes for easy getting the entry from the catalog
281  if (GetCatalogIndex() == -1)
282  m_iCatalogIndex = catalogIndex;
283 
284  //~ Set Catalog Reference
285  m_CatalogParent = catalog;
286 
287  //~ Class Specific Init
288  ClassSpecificInit();
289 
290  //~ Init the data found in the list (Do last)
291  array<SCR_BaseEntityCatalogData> entityDataList = {};
292  GetEntityDataList(entityDataList);
293  foreach (SCR_BaseEntityCatalogData data: entityDataList)
294  {
295  data.InitData(this);
296  }
297  }
298 
299  //--------------------------------- Class Specific Init ---------------------------------\\
300  //~ This is a class specific init. Override and call any specific init functionality that should only be executed in the specific class
301  //~ Gets UIInfo from editable entity in base class
302  protected void ClassSpecificInit()
303  {
304  //~ Already has Init called
305  if (m_EditableEntityUiInfo != null)
306  return;
307 
308  //~ Load Prefab
309  Resource entityPrefab = Resource.Load(GetPrefab());
310  if (!entityPrefab)
311  return;
312 
313  //~ Get entity source
314  IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(entityPrefab);
315  if (!entitySource)
316  return;
317 
318  //~ Get EditableEntity component
319  IEntityComponentSource editableEntitySource = SCR_EditableEntityComponentClass.GetEditableEntitySource(entitySource);
320  if (!editableEntitySource)
321  return;
322 
323  //~ Save UI Info found on Editable Enity
324  m_EditableEntityUiInfo = SCR_EditableEntityComponentClass.GetInfo(editableEntitySource);
325  }
326 };
BaseContainerCustomDoubleCheckIntResourceNameTitleField
Attribute for setting a custom format if the given checkVar is equal to checkVarEqual....
Definition: Attributes.c:591
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
SCR_BaseEntityCatalogData
Definition: SCR_BaseEntityCatalogData.c:5
SCR_EditableEntityUIInfo
Definition: SCR_EditableEntityUIInfo.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
SCR_EntityCatalog
Definition: SCR_EntityCatalog.c:181
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_EditableEntityComponentClass
Definition: SCR_EditableEntityComponentClass.c:2
LocalizedString
Definition: LocalizedString.c:21
SCR_EntityCatalogEntry
Definition: SCR_EntityCatalogEntry.c:5
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