2class SCR_PrefabEditingPluginBase : WorkbenchPlugin
5 protected WBProgressDialog StartProgressWorldEditor()
7 return new WBProgressDialog(
"Processing Prefabs...", Workbench.GetModule(WorldEditor));
11 protected WBProgressDialog StartProgress()
13 return StartProgressWorldEditor();
17 protected void GetSelectedWorldEditor(out array<ResourceName> selection)
19 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
20 worldEditor.GetResourceBrowserSelection(selection.Insert,
true);
24 protected void GetSelectedResourceBrowser(out array<ResourceName> selection)
26 ResourceManager resourceManager = Workbench.GetModule(ResourceManager);
27 resourceManager.GetResourceBrowserSelection(selection.Insert,
true);
31 protected void GetSelected(out array<ResourceName> selection)
33 GetSelectedWorldEditor(selection);
37 protected bool GetPrefabs(out notnull array<ResourceName> compatiblePrefabs,
bool includeComponentPrefabs =
false)
40 array<ResourceName> selectedPrefabs = {};
42 if (selectedPrefabs.IsEmpty())
50 Resource prefabResource;
51 BaseResourceObject prefabBase;
52 BaseContainer prefabContainer;
54 foreach (ResourceName prefab : selectedPrefabs)
56 FilePath.StripExtension(prefab, extension);
57 if (includeComponentPrefabs)
59 if (extension !=
"et" && extension !=
"ct")
61 Print(
string.Format(
"Cannot load prefab '%1', it's not a prefab! Only .et and .ct files can be loaded.", prefab),
LogLevel.ERROR);
67 if (extension !=
"et")
69 Print(
string.Format(
"Cannot load prefab '%1', it's not a prefab! Only .et files can be loaded.", prefab),
LogLevel.ERROR);
74 prefabResource = Resource.Load(prefab);
75 if (!prefabResource.IsValid())
77 Print(
string.Format(
"Cannot load prefab '%1'!", prefab),
LogLevel.ERROR);
81 prefabBase = prefabResource.GetResource();
84 Print(
string.Format(
"Cannot load prefab '%1'!", prefab),
LogLevel.ERROR);
88 prefabContainer = prefabBase.ToBaseContainer();
91 Print(
string.Format(
"Cannot load prefab '%1'!", prefab),
LogLevel.ERROR);
95 prefabType = prefabContainer.GetClassName().ToType();
96 if (includeComponentPrefabs)
98 if (!prefabType.IsInherited(
IEntity) && !prefabType.IsInherited(GenericComponent))
100 Print(
string.Format(
"Cannot load prefab '%1', it's neither an entity nor a component!", prefab),
LogLevel.ERROR);
106 if (!prefabType.IsInherited(
IEntity))
108 Print(
string.Format(
"Cannot load prefab '%1', it's not an entity!", prefab),
LogLevel.ERROR);
113 compatiblePrefabs.Insert(prefab);
116 return !compatiblePrefabs.IsEmpty();
enum EVehicleType IEntity
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto external int GetSelected(out notnull array< MapItem > outItems)
Get all selected entities.