2[WorkbenchToolAttribute(
"Destructible Prefab Finder Tool",
"Scans selected folder for prefabs containing MPD components or destructible entities",
"", awesomeFontCode: 0xF468)]
3class SCR_DestructiblePrefabFinderTool : WorldEditorTool
5 [
Attribute(
"1", UIWidgets.CheckBox,
"Find prefabs containing SCR_DestructionMultiPhaseComponent in given folder",
category:
"Folder Scan Filters")]
6 protected bool m_bFindMultiPhaseDestructionComponents;
8 [
Attribute(
"1", UIWidgets.CheckBox,
"Find prefabs containing SCR_DestructibleEntity in given folder",
category:
"Folder Scan Filters")]
9 protected bool m_bFindDestructibleEntities;
11 [
Attribute(
"1", UIWidgets.CheckBox,
"Find prefabs containing SCR_DestructibleEntity as well as SCR_DestructionMultiPhaseComponent",
category:
"Folder Scan Filters")]
12 protected bool m_bFindDestructibleEntitiesWithMPD;
14 [
Attribute(
"0", UIWidgets.CheckBox,
"Include disabled MPD Components",
category:
"Folder Scan Filters")]
15 protected bool m_bIncludeDisabledMPDComponents;
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;
20 [
Attribute(
"1", UIWidgets.CheckBox,
"Check if MPD Prefabs have RplComponent attached to them",
category:
"Folder Scan Filters")]
21 protected bool m_bCheckMPDForRplComponent;
23 [
Attribute(
"1", UIWidgets.CheckBox,
"Check if MPD Components have default values",
category:
"Folder Scan Filters")]
24 protected bool m_bCheckMPDForDefaultValues;
26 protected ref array<ResourceName> m_aSelection = {};
27 protected ref array<ResourceName> m_aPrefabs = {};
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 = {};
34 protected ref array<ResourceName> m_aDestructibleEntities = {};
35 protected ref array<ResourceName> m_aDestructibleEntitiesWithMPD = {};
38 protected void CheckForMPDComponent(ResourceName
resourceName, Resource resource)
40 IEntityComponentSource componentSource = SCR_BaseContainerTools.FindComponentSource(resource, SCR_DestructionMultiPhaseComponent);
46 if (m_bIncludeDisabledMPDComponents || (componentSource.Get(
"Enabled", enabled) && enabled))
50 if (m_bCheckMPDForRplComponent)
52 IEntityComponentSource rplSource = SCR_BaseContainerTools.FindComponentSource(resource, RplComponent);
57 if (m_bCheckMPDForHitzone)
59 BaseContainerList hitZoneArray = componentSource.GetObjectArray(
"Additional hit zones");
60 if (!hitZoneArray || hitZoneArray.Count() < 1)
64 if (m_bCheckMPDForDefaultValues)
66 array<string> modifiedVarNames = SCR_BaseContainerTools.GetPrefabSetValueNames(componentSource);
67 if (modifiedVarNames.IsEmpty())
74 protected void CheckForDestructibleEntity(ResourceName
resourceName, Resource resource)
76 typename className = SCR_BaseContainerTools.GetContainerClassName(resource).ToType();
82 if (m_bFindDestructibleEntitiesWithMPD)
84 IEntityComponentSource componentSource = SCR_BaseContainerTools.FindComponentSource(resource, SCR_DestructionMultiPhaseComponent);
89 if (m_bIncludeDisabledMPDComponents || (componentSource.Get(
"Enabled", enabled) && enabled))
97 protected void FolderScan()
101 m_aMPDComponents.Clear();
102 m_aMPDComponentsMissingRpl.Clear();
103 m_aMPDComponentsNoHitZone.Clear();
104 m_aMPDComponentsDefaultValues.Clear();
105 m_aDestructibleEntities.Clear();
106 m_aDestructibleEntitiesWithMPD.Clear();
108 Debug.BeginTimeMeasure();
110 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
111 worldEditor.GetResourceBrowserSelection(m_aSelection.Insert,
true);
124 if (m_bFindMultiPhaseDestructionComponents)
127 if (m_bFindDestructibleEntities)
131 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
133 if (m_bFindMultiPhaseDestructionComponents)
135 if (m_bIncludeDisabledMPDComponents)
136 Print(
"Number of *.et files containing SCR_DestructionMultiPhaseComponent: " + m_aMPDComponents.Count(),
LogLevel.NORMAL);
138 Print(
"Number of *.et files containing enabled SCR_DestructionMultiPhaseComponent: " + m_aMPDComponents.Count(),
LogLevel.NORMAL);
141 if (m_bFindDestructibleEntities)
142 Print(
"Number of *.et files containing SCR_DestructibleEntity: " + m_aDestructibleEntities.Count(),
LogLevel.NORMAL);
144 if (m_bFindDestructibleEntitiesWithMPD)
146 if (m_bIncludeDisabledMPDComponents)
147 Print(
"Number of *.et files containing SCR_DestructibleEntity and SCR_DestructionMultiPhaseComponent: " + m_aDestructibleEntitiesWithMPD.Count(),
LogLevel.NORMAL);
149 Print(
"Number of *.et files containing SCR_DestructibleEntity and enabled SCR_DestructionMultiPhaseComponent: " + m_aDestructibleEntitiesWithMPD.Count(),
LogLevel.NORMAL);
152 Debug.EndTimeMeasure(
"Folder scan done");
157 protected void PrintMPDComponents()
159 Debug.BeginTimeMeasure();
161 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
168 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
170 if (m_bIncludeDisabledMPDComponents)
171 Debug.EndTimeMeasure(
"Found " + m_aMPDComponents.Count() +
" MPD Components");
173 Debug.EndTimeMeasure(
"Found " + m_aMPDComponents.Count() +
" enabled MPD Components");
178 protected void PrintDestructibleEntities()
180 Debug.BeginTimeMeasure();
182 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
184 foreach (ResourceName
resourceName : m_aDestructibleEntities)
189 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
191 Debug.EndTimeMeasure(
"Found " + m_aDestructibleEntities.Count() +
" Destructible Entities");
196 protected void PrintDestructibleEntitiesWithMPD()
198 Debug.BeginTimeMeasure();
200 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
202 foreach (ResourceName
resourceName : m_aDestructibleEntitiesWithMPD)
207 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
209 if (m_bIncludeDisabledMPDComponents)
210 Debug.EndTimeMeasure(
"Found " + m_aDestructibleEntitiesWithMPD.Count() +
" Destructible Entities with MPD Components");
212 Debug.EndTimeMeasure(
"Found " + m_aDestructibleEntitiesWithMPD.Count() +
" Destructible Entities with enabled MPD Components");
217 protected void PrintMPDComponentsMissingRpl()
219 Debug.BeginTimeMeasure();
221 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
223 foreach (ResourceName
resourceName : m_aMPDComponentsMissingRpl)
228 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
230 if (m_bIncludeDisabledMPDComponents)
231 Debug.EndTimeMeasure(
"Found " + m_aMPDComponentsMissingRpl.Count() +
" MPD Components without RplComponent");
233 Debug.EndTimeMeasure(
"Found " + m_aMPDComponentsMissingRpl.Count() +
" enabled MPD Components without RplComponent");
238 protected void PrintMPDComponentsMissingHitZone()
240 Debug.BeginTimeMeasure();
242 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
244 foreach (ResourceName
resourceName : m_aMPDComponentsNoHitZone)
249 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
251 if (m_bIncludeDisabledMPDComponents)
252 Debug.EndTimeMeasure(
"Found " + m_aMPDComponentsNoHitZone.Count() +
" MPD Components without any HitZone");
254 Debug.EndTimeMeasure(
"Found " + m_aMPDComponentsNoHitZone.Count() +
" enabled MPD Components without any HitZone");
259 protected void PrintMPDComponentsWithDefaults()
261 Debug.BeginTimeMeasure();
263 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
265 foreach (ResourceName
resourceName : m_aMPDComponentsDefaultValues)
270 Print(
"------------------------------------------------------------------------",
LogLevel.NORMAL);
272 if (m_bIncludeDisabledMPDComponents)
273 Debug.EndTimeMeasure(
"Found " + m_aMPDComponentsDefaultValues.Count() +
" MPD Components with default values");
275 Debug.EndTimeMeasure(
"Found " + m_aMPDComponentsDefaultValues.Count() +
" enabled MPD Components with default values");
ResourceName resourceName
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.
SCR_FieldOfViewSettings Attribute