Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MultiPhaseDestructionSoundlessPrefabSearchPlugin.c
Go to the documentation of this file.
1#ifdef WORKBENCH
3 name: "MultiPhase Destruction Soundless Prefab Search",
4 description: "Search Prefabs using multiphase destruction where Material Sound Type is set to NONE",
5 wbModules: { "ResourceManager" },
6 category: SCR_PluginCategory.RESOURCEMANAGER_PREFABS,
7 awesomeFontCode: 0xF7CE)]
8class SCR_MultiPhaseDestructionSoundlessPrefabSearchPlugin : WorkbenchPlugin
9{
10 [Attribute(desc: "Ignore SCR_DestructibleEntity entities that have destruction disabled", category: "Options")]
11 protected bool m_bIgnoreDestructibleEntitiesWithDisabledDestruction;
12
13 [Attribute(desc: "Ignore components that are disabled", category: "Options")]
14 protected bool m_bIgnoreDisabledComponents;
15
16 [Attribute(desc: "Include Prefabs having at least one Small Debris with Material Sound Type set to NONE", category: "Options")]
17 protected bool m_bIncludeSilentSmallDebris;
18
19 //------------------------------------------------------------------------------------------------
20 override void Run()
21 {
22 if (!Workbench.ScriptDialog("MultiPhase Destruction Soundless Prefab Search Options", string.Empty, this))
23 return;
24
25 DetectPrefabs();
26 }
27
28 //------------------------------------------------------------------------------------------------
29 protected void DetectPrefabs()
30 {
31 Print("==================================================", LogLevel.NORMAL);
32 Print("Looking for Prefabs using NONE as Destruction's Material Sound Type", LogLevel.NORMAL);
33
34 if (m_bIncludeSilentSmallDebris)
35 Print("Also looking for Small Debris under the same conditions", LogLevel.NORMAL);
36
37 Print("==================================================", LogLevel.NORMAL);
38
39 array<string> addonGUIDs = {};
40 GameProject.GetLoadedAddons(addonGUIDs);
41
42 array<ResourceName> resourceNames = {};
43 foreach (string addonGUID : addonGUIDs)
44 {
45 string addonID = GameProject.GetAddonID(addonGUID);
46 Print("Looking into " + addonID + "/Prefabs", LogLevel.NORMAL);
47 resourceNames.InsertAll(SCR_WorkbenchHelper.SearchWorkbenchResources({ "et" }, null, SCR_AddonTool.ToFileSystem(addonID) + "Prefabs/"));
48 }
49
50// resourceNames.Insert("{54CE51ABCAEF05C0}PrefabLibrary/Props/Civilian/TableOld_01/TableOld_01_white.et"); // GenericEntity w/ component
51// resourceNames.Insert("{4A1FAB7E3F610EA9}PrefabLibrary/Infrastructure/Roads/CrashBarrier_01_4m_V1.et"); // SCR_DestructibleEntity
52// resourceNames.Insert("{4546AD2CC984193B}PrefabLibrary/Walls/Brick/BrickWall_02_2m.et"); // SCR_DestructibleEntity w/ Debris
53
54 Resource resource;
55 BaseContainer baseContainer;
56 BaseContainer childContainer;
57 BaseContainer childSubContainer;
58 BaseContainerList baseContainerList;
59 BaseContainerList childContainerList;
60 SCR_EMaterialSoundTypeBreak value;
61 bool found;
62 bool isComponentEnabled;
63 bool isDestructibleEntity;
64 array<ResourceName> resultsGeneric = {};
65 array<ResourceName> resultsDestructible = {};
66 array<ResourceName> resultsGenericDebris = {};
67 array<ResourceName> resultsDestructibleDestroySpawnObjectDebris = {};
68 array<ResourceName> resultsDestructibleDestructionPhaseDebris = {};
69
70 foreach (ResourceName resourceName : resourceNames)
71 {
72 resource = Resource.Load(resourceName);
73 if (!resource.IsValid())
74 {
75 Print("INVALID PREFAB: error loading " + resourceName, LogLevel.ERROR);
76 continue;
77 }
78
79 baseContainer = resource.GetResource().ToBaseContainer();
80 if (!baseContainer)
81 {
82 Print("INVALID PREFAB: error loading " + resourceName, LogLevel.ERROR);
83 continue;
84 }
85
86 if (baseContainer.GetClassName() == "Tree")
87 continue;
88
89 isDestructibleEntity = baseContainer.GetClassName() == "SCR_DestructibleEntity";
90 if (isDestructibleEntity)
91 {
92 if (m_bIgnoreDestructibleEntitiesWithDisabledDestruction)
93 {
94 if (!baseContainer.Get("Enabled", isComponentEnabled) || !isComponentEnabled)
95 continue;
96 }
97 }
98 else
99 {
100 baseContainerList = baseContainer.GetObjectArray("components");
101 if (!baseContainerList)
102 continue;
103
104 for (int i, count = baseContainerList.Count(); i < count; i++)
105 {
106 childContainer = baseContainerList.Get(i);
107 if (!childContainer)
108 continue;
109
110 if (childContainer.GetClassName() == "SCR_DestructionMultiPhaseComponent")
111 {
112 baseContainer = childContainer;
113 break;
114 }
115 }
116
117 if (!baseContainer)
118 continue;
119
120 if (m_bIgnoreDisabledComponents)
121 {
122 if (!baseContainer.Get("Enabled", isComponentEnabled) || !isComponentEnabled)
123 continue;
124 }
125 }
126
127 if (!baseContainer.Get("m_eMaterialSoundType", value))
128 continue;
129
130 if (value == SCR_EMaterialSoundTypeBreak.NONE)
131 {
132 if (isDestructibleEntity)
133 resultsDestructible.Insert(resourceName);
134 else
135 resultsGeneric.Insert(resourceName);
136
137 continue;
138 }
139
140 if (!m_bIncludeSilentSmallDebris)
141 continue;
142
143 // let's check for Small Debris
144
145 if (isDestructibleEntity)
146 {
147 found = false;
148 baseContainerList = baseContainer.GetObjectArray("m_aDestroySpawnObjects");
149 if (baseContainerList)
150 {
151 // Small Debris iteration
152 for (int i, count = baseContainerList.Count(); i < count; i++)
153 {
154 childContainer = baseContainerList.Get(i);
155 if (!childContainer)
156 continue;
157
158 if (childContainer.GetClassName() != "SCR_DebrisSpawnable")
159 continue;
160
161 if (!childContainer.Get("m_eMaterialSoundType", value))
162 continue;
163
164 if (value == SCR_EMaterialSoundTypeBreak.NONE)
165 {
166 resultsDestructibleDestroySpawnObjectDebris.Insert(resourceName);
167 found = true;
168 break;
169 }
170 }
171
172 if (found)
173 continue;
174 }
175
176 baseContainerList = baseContainer.GetObjectArray("DamagePhases");
177 if (!baseContainerList)
178 continue;
179
180 // Damage Phases iteration
181 found = false;
182 for (int i, count = baseContainerList.Count(); i < count; i++)
183 {
184 childContainer = baseContainerList.Get(i);
185 if (!childContainer)
186 continue;
187
188 if (childContainer.GetClassName() != "SCR_BaseDestructionPhase")
189 continue;
190
191 childContainerList = childContainer.GetObjectArray("m_aPhaseDestroySpawnObjects");
192 if (!childContainerList)
193 continue;
194
195 // Phase Destroy Spawn Objects iteration
196 for (int j, countJ = childContainerList.Count(); j < countJ; j++)
197 {
198 childSubContainer = childContainerList.Get(j);
199 if (!childSubContainer)
200 continue;
201
202 if (childSubContainer.GetClassName() != "SCR_DebrisSpawnable")
203 continue;
204
205 if (!childSubContainer.Get("m_eMaterialSoundType", value))
206 continue;
207
208 if (value == SCR_EMaterialSoundTypeBreak.NONE)
209 {
210 resultsDestructibleDestructionPhaseDebris.Insert(resourceName);
211 found = true;
212 break;
213 }
214 }
215
216 if (found)
217 break;
218 }
219
220 if (found)
221 continue; // safety if code is added after these scopes
222 }
223 else
224 {
225 baseContainerList = baseContainer.GetObjectArray("m_DestroySpawnObjects");
226 if (!baseContainerList)
227 continue;
228
229 // Phase Destroy Spawn Objects iteration
230 found = false;
231 for (int i, count = baseContainerList.Count(); i < count; i++)
232 {
233 childContainer = baseContainerList.Get(i);
234 if (!childContainer)
235 continue;
236
237 if (childContainer.GetClassName() != "SCR_DebrisSpawnable")
238 continue;
239
240 if (!childContainer.Get("m_eMaterialSoundType", value))
241 continue;
242
243 if (value == SCR_EMaterialSoundTypeBreak.NONE)
244 {
245 resultsGenericDebris.Insert(resourceName);
246 found = true;
247 break;
248 }
249 }
250
251 if (found)
252 continue; // safety if code is added after these scopes
253 }
254 }
255
256 foreach (ResourceName result : resultsGeneric)
257 {
258 Print("GenericEntity: NONE used as Material Sound Type in " + result, LogLevel.WARNING);
259 }
260
261 foreach (ResourceName result : resultsGenericDebris)
262 {
263 Print("GenericEntity Debris: NONE used as Material Sound Type in " + result, LogLevel.WARNING);
264 }
265
266 foreach (ResourceName result : resultsDestructible)
267 {
268 Print("DestructibleEntity: NONE used as Material Sound Type in " + result, LogLevel.WARNING);
269 }
270
271 foreach (ResourceName result : resultsDestructibleDestroySpawnObjectDebris)
272 {
273 Print("DestructibleEntity SpawnObject Debris: NONE used as Material Sound Type in " + result, LogLevel.WARNING);
274 }
275
276 foreach (ResourceName result : resultsDestructibleDestructionPhaseDebris)
277 {
278 Print("DestructibleEntity DestructionPhase Debris: NONE used as Material Sound Type in " + result, LogLevel.WARNING);
279 }
280
281 int genericCount = resultsGeneric.Count();
282 int genericDebrisCount = resultsGenericDebris.Count();
283 int destructibleCount = resultsDestructible.Count();
284 int destructibleDestroySpawnObjectDebrisCount = resultsDestructibleDestroySpawnObjectDebris.Count();
285 int destructibleDestructionPhaseDebrisCount = resultsDestructibleDestructionPhaseDebris.Count();
286
287 int total = genericCount +
288 genericDebrisCount +
289 destructibleCount +
290 destructibleDestroySpawnObjectDebrisCount +
291 destructibleDestructionPhaseDebrisCount;
292
293 PrintFormat("%1/%2 Prefabs found using NONE as Destruction's Material Sound Type", total, resourceNames.Count(), level: LogLevel.NORMAL);
294
295 if (genericCount > 0)
296 Print("" + genericCount + " Generic Entities", LogLevel.NORMAL);
297
298 if (genericDebrisCount > 0)
299 Print("" + genericDebrisCount + " Generic Entity Debris", LogLevel.NORMAL);
300
301 if (destructibleCount > 0)
302 Print("" + destructibleCount + " Destructible Entities", LogLevel.NORMAL);
303
304 if (destructibleDestroySpawnObjectDebrisCount > 0)
305 Print("" + destructibleDestroySpawnObjectDebrisCount + " Destructible Entity SpawnObject Debris", LogLevel.NORMAL);
306
307 if (destructibleDestructionPhaseDebrisCount > 0)
308 Print("" + destructibleDestructionPhaseDebrisCount + " Destructible Entity DestructionPhase Debris", LogLevel.NORMAL);
309 }
310
311 //------------------------------------------------------------------------------------------------
312 [ButtonAttribute("Process", true)]
313 protected bool ButtonOK()
314 {
315 return true;
316 }
317
318 //------------------------------------------------------------------------------------------------
319 [ButtonAttribute("Cancel")]
320 protected bool ButtonCancel()
321 {
322 return false;
323 }
324}
325#endif // WORKBENCH
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
ResourceName resourceName
Definition SCR_AIGroup.c:66
override void Run()
bool ButtonCancel()
bool ButtonOK()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
static array< ResourceName > SearchWorkbenchResources(array< string > fileExtensions=null, array< string > searchStrArray=null, string rootPath="", bool recursive=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
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute