Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DestructiblePrefabFinderTool.c
Go to the documentation of this file.
1#ifdef WORKBENCH
2[WorkbenchToolAttribute("Destructible Prefab Finder Tool", "Scans selected folder for prefabs containing MPD components or destructible entities", "", awesomeFontCode: 0xF468)]
3class SCR_DestructiblePrefabFinderTool : WorldEditorTool
4{
5 [Attribute("1", UIWidgets.CheckBox, "Find prefabs containing SCR_DestructionMultiPhaseComponent in given folder", category: "Folder Scan Filters")]
6 protected bool m_bFindMultiPhaseDestructionComponents;
7
8 [Attribute("1", UIWidgets.CheckBox, "Find prefabs containing SCR_DestructibleEntity in given folder", category: "Folder Scan Filters")]
9 protected bool m_bFindDestructibleEntities;
10
11 [Attribute("1", UIWidgets.CheckBox, "Find prefabs containing SCR_DestructibleEntity as well as SCR_DestructionMultiPhaseComponent", category: "Folder Scan Filters")]
12 protected bool m_bFindDestructibleEntitiesWithMPD;
13
14 [Attribute("0", UIWidgets.CheckBox, "Include disabled MPD Components", category: "Folder Scan Filters")]
15 protected bool m_bIncludeDisabledMPDComponents;
16
17 [Attribute("1", UIWidgets.CheckBox, "Check if MPD Components have at least one hit zone attached to them", category: "Folder Scan Filters")]
18 protected bool m_bCheckMPDForHitzone;
19
20 [Attribute("1", UIWidgets.CheckBox, "Check if MPD Prefabs have RplComponent attached to them", category: "Folder Scan Filters")]
21 protected bool m_bCheckMPDForRplComponent;
22
23 [Attribute("1", UIWidgets.CheckBox, "Check if MPD Components have default values", category: "Folder Scan Filters")]
24 protected bool m_bCheckMPDForDefaultValues;
25
26 protected ref array<ResourceName> m_aSelection = {};
27 protected ref array<ResourceName> m_aPrefabs = {};
28
29 protected ref array<ResourceName> m_aMPDComponents = {};
30 protected ref array<ResourceName> m_aMPDComponentsNoHitZone = {};
31 protected ref array<ResourceName> m_aMPDComponentsMissingRpl = {};
32 protected ref array<ResourceName> m_aMPDComponentsDefaultValues = {};
33
34 protected ref array<ResourceName> m_aDestructibleEntities = {};
35 protected ref array<ResourceName> m_aDestructibleEntitiesWithMPD = {};
36
37 //------------------------------------------------------------------------------------------------
38 protected void CheckForMPDComponent(ResourceName resourceName, Resource resource)
39 {
40 IEntityComponentSource componentSource = SCR_BaseContainerTools.FindComponentSource(resource, SCR_DestructionMultiPhaseComponent);
41
42 if (!componentSource)
43 return;
44
45 bool enabled;
46 if (m_bIncludeDisabledMPDComponents || (componentSource.Get("Enabled", enabled) && enabled))
47 {
48 m_aMPDComponents.Insert(resourceName);
49
50 if (m_bCheckMPDForRplComponent)
51 {
52 IEntityComponentSource rplSource = SCR_BaseContainerTools.FindComponentSource(resource, RplComponent);
53 if (!rplSource)
54 m_aMPDComponentsMissingRpl.Insert(resourceName);
55 }
56
57 if (m_bCheckMPDForHitzone)
58 {
59 BaseContainerList hitZoneArray = componentSource.GetObjectArray("Additional hit zones");
60 if (!hitZoneArray || hitZoneArray.Count() < 1)
61 m_aMPDComponentsNoHitZone.Insert(resourceName);
62 }
63
64 if (m_bCheckMPDForDefaultValues)
65 {
66 array<string> modifiedVarNames = SCR_BaseContainerTools.GetPrefabSetValueNames(componentSource);
67 if (modifiedVarNames.IsEmpty())
68 m_aMPDComponentsDefaultValues.Insert(resourceName);
69 }
70 }
71 }
72
73 //------------------------------------------------------------------------------------------------
74 protected void CheckForDestructibleEntity(ResourceName resourceName, Resource resource)
75 {
76 typename className = SCR_BaseContainerTools.GetContainerClassName(resource).ToType();
77 if (className != SCR_DestructibleEntity)
78 return;
79
80 m_aDestructibleEntities.Insert(resourceName);
81
82 if (m_bFindDestructibleEntitiesWithMPD)
83 {
84 IEntityComponentSource componentSource = SCR_BaseContainerTools.FindComponentSource(resource, SCR_DestructionMultiPhaseComponent);
85
86 if (componentSource)
87 {
88 bool enabled;
89 if (m_bIncludeDisabledMPDComponents || (componentSource.Get("Enabled", enabled) && enabled))
90 m_aDestructibleEntitiesWithMPD.Insert(resourceName);
91 }
92 }
93 }
94
95 //------------------------------------------------------------------------------------------------
96 [ButtonAttribute("Scan Folders")]
97 protected void FolderScan()
98 {
99 m_aSelection.Clear();
100 m_aPrefabs.Clear();
101 m_aMPDComponents.Clear();
102 m_aMPDComponentsMissingRpl.Clear();
103 m_aMPDComponentsNoHitZone.Clear();
104 m_aMPDComponentsDefaultValues.Clear();
105 m_aDestructibleEntities.Clear();
106 m_aDestructibleEntitiesWithMPD.Clear();
107
108 Debug.BeginTimeMeasure();
109
110 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
111 worldEditor.GetResourceBrowserSelection(m_aSelection.Insert, true);
112
113 foreach (string resourceName : m_aSelection)
114 {
115 if (resourceName.EndsWith(".et"))
116 m_aPrefabs.Insert(resourceName);
117 }
118
119 Resource resource;
120 foreach (string resourceName : m_aPrefabs)
121 {
122 resource = Resource.Load(resourceName);
123
124 if (m_bFindMultiPhaseDestructionComponents)
125 CheckForMPDComponent(resourceName, resource);
126
127 if (m_bFindDestructibleEntities)
128 CheckForDestructibleEntity(resourceName, resource);
129 }
130
131 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
132
133 if (m_bFindMultiPhaseDestructionComponents)
134 {
135 if (m_bIncludeDisabledMPDComponents)
136 Print("Number of *.et files containing SCR_DestructionMultiPhaseComponent: " + m_aMPDComponents.Count(), LogLevel.NORMAL);
137 else
138 Print("Number of *.et files containing enabled SCR_DestructionMultiPhaseComponent: " + m_aMPDComponents.Count(), LogLevel.NORMAL);
139 }
140
141 if (m_bFindDestructibleEntities)
142 Print("Number of *.et files containing SCR_DestructibleEntity: " + m_aDestructibleEntities.Count(), LogLevel.NORMAL);
143
144 if (m_bFindDestructibleEntitiesWithMPD)
145 {
146 if (m_bIncludeDisabledMPDComponents)
147 Print("Number of *.et files containing SCR_DestructibleEntity and SCR_DestructionMultiPhaseComponent: " + m_aDestructibleEntitiesWithMPD.Count(), LogLevel.NORMAL);
148 else
149 Print("Number of *.et files containing SCR_DestructibleEntity and enabled SCR_DestructionMultiPhaseComponent: " + m_aDestructibleEntitiesWithMPD.Count(), LogLevel.NORMAL);
150 }
151
152 Debug.EndTimeMeasure("Folder scan done");
153 }
154
155 //------------------------------------------------------------------------------------------------
156 [ButtonAttribute("Print MPDs")]
157 protected void PrintMPDComponents()
158 {
159 Debug.BeginTimeMeasure();
160
161 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
162
163 foreach (ResourceName resourceName : m_aMPDComponents)
164 {
165 Print(resourceName.GetPath(), LogLevel.NORMAL);
166 }
167
168 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
169
170 if (m_bIncludeDisabledMPDComponents)
171 Debug.EndTimeMeasure("Found " + m_aMPDComponents.Count() + " MPD Components");
172 else
173 Debug.EndTimeMeasure("Found " + m_aMPDComponents.Count() + " enabled MPD Components");
174 }
175
176 //------------------------------------------------------------------------------------------------
177 [ButtonAttribute("Print Destr. Entities")]
178 protected void PrintDestructibleEntities()
179 {
180 Debug.BeginTimeMeasure();
181
182 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
183
184 foreach (ResourceName resourceName : m_aDestructibleEntities)
185 {
186 Print(resourceName.GetPath(), LogLevel.NORMAL);
187 }
188
189 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
190
191 Debug.EndTimeMeasure("Found " + m_aDestructibleEntities.Count() + " Destructible Entities");
192 }
193
194 //------------------------------------------------------------------------------------------------
195 [ButtonAttribute("Print Destr. Entities w/ MPD")]
196 protected void PrintDestructibleEntitiesWithMPD()
197 {
198 Debug.BeginTimeMeasure();
199
200 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
201
202 foreach (ResourceName resourceName : m_aDestructibleEntitiesWithMPD)
203 {
204 Print(resourceName.GetPath(), LogLevel.NORMAL);
205 }
206
207 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
208
209 if (m_bIncludeDisabledMPDComponents)
210 Debug.EndTimeMeasure("Found " + m_aDestructibleEntitiesWithMPD.Count() + " Destructible Entities with MPD Components");
211 else
212 Debug.EndTimeMeasure("Found " + m_aDestructibleEntitiesWithMPD.Count() + " Destructible Entities with enabled MPD Components");
213 }
214
215 //------------------------------------------------------------------------------------------------
216 [ButtonAttribute("Print MPDs missing Rpl")]
217 protected void PrintMPDComponentsMissingRpl()
218 {
219 Debug.BeginTimeMeasure();
220
221 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
222
223 foreach (ResourceName resourceName : m_aMPDComponentsMissingRpl)
224 {
225 Print(resourceName.GetPath(), LogLevel.NORMAL);
226 }
227
228 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
229
230 if (m_bIncludeDisabledMPDComponents)
231 Debug.EndTimeMeasure("Found " + m_aMPDComponentsMissingRpl.Count() + " MPD Components without RplComponent");
232 else
233 Debug.EndTimeMeasure("Found " + m_aMPDComponentsMissingRpl.Count() + " enabled MPD Components without RplComponent");
234 }
235
236 //------------------------------------------------------------------------------------------------
237 [ButtonAttribute("Print MPDs missing HitZone")]
238 protected void PrintMPDComponentsMissingHitZone()
239 {
240 Debug.BeginTimeMeasure();
241
242 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
243
244 foreach (ResourceName resourceName : m_aMPDComponentsNoHitZone)
245 {
246 Print(resourceName.GetPath(), LogLevel.NORMAL);
247 }
248
249 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
250
251 if (m_bIncludeDisabledMPDComponents)
252 Debug.EndTimeMeasure("Found " + m_aMPDComponentsNoHitZone.Count() + " MPD Components without any HitZone");
253 else
254 Debug.EndTimeMeasure("Found " + m_aMPDComponentsNoHitZone.Count() + " enabled MPD Components without any HitZone");
255 }
256
257 //------------------------------------------------------------------------------------------------
258 [ButtonAttribute("Print MPDs with Defaults")]
259 protected void PrintMPDComponentsWithDefaults()
260 {
261 Debug.BeginTimeMeasure();
262
263 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
264
265 foreach (ResourceName resourceName : m_aMPDComponentsDefaultValues)
266 {
267 Print(resourceName.GetPath(), LogLevel.NORMAL);
268 }
269
270 Print("------------------------------------------------------------------------", LogLevel.NORMAL);
271
272 if (m_bIncludeDisabledMPDComponents)
273 Debug.EndTimeMeasure("Found " + m_aMPDComponentsDefaultValues.Count() + " MPD Components with default values");
274 else
275 Debug.EndTimeMeasure("Found " + m_aMPDComponentsDefaultValues.Count() + " enabled MPD Components with default values");
276 }
277}
278#endif // WORKBENCH
ResourceName resourceName
Definition SCR_AIGroup.c:66
void SCR_DestructibleEntity(IEntitySource src, IEntity parent)
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
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_FieldOfViewSettings Attribute
void Debug()
Definition Types.c:327