3 name:
"Prefab Structure Filling",
4 description:
"Fill Prefab structure according based on the selected type",
6 wbModules: {
"WorldEditor" },
7 awesomeFontCode: 0xF6BE)]
8class SCR_PrefabStructureFillingPlugin : WorkbenchPlugin
11 protected override void Run()
13 IEntitySource entitySource = SCR_WorldEditorToolHelper.GetPrefabEditModeEntitySource();
16 Print(
"Not in Prefab Edit mode or another error somewhere",
LogLevel.WARNING);
20 SCR_PrefabStructureFillingPlugin_TypeSelection typeSelection =
new SCR_PrefabStructureFillingPlugin_TypeSelection();
21 if (!Workbench.ScriptDialog(
"Pick your poison",
"So, whaddaya want?", typeSelection) || !typeSelection.m_sChoiceName)
24 typename selectedClass = (
"SCR_PrefabStructureFillingPlugin_" + typeSelection.m_sChoiceName).ToType();
27 Print(
"Configuration class does not exist - (SCR_PrefabStructureFillingPlugin_)" + typeSelection.m_sChoiceName,
LogLevel.WARNING);
31 SCR_PrefabStructureFillingPlugin_TypeBase configuration = SCR_PrefabStructureFillingPlugin_TypeBase.Cast(selectedClass.Spawn());
34 Print(
"Cannot create configuration instance for " + typeSelection.m_sChoiceName,
LogLevel.WARNING);
38 if (!Workbench.ScriptDialog(typeSelection.m_sChoiceName +
" Configuration",
"Please configure", configuration))
40 if (!configuration.m_bClose)
49 Print(
"Currently edited entity does not have a Prefab",
LogLevel.WARNING);
53 configuration.Process(actualPrefab);
57class SCR_PrefabStructureFillingPlugin_TypeSelection
89 protected int ButtonCharacter()
91 m_sChoiceName =
"Character";
97 protected int ButtonCar()
99 m_sChoiceName =
"Car";
105 protected int ButtonTank()
107 m_sChoiceName =
"Tank";
113 protected int ButtonHelicopter()
115 m_sChoiceName =
"Helicopter";
133class SCR_PrefabStructureFillingPlugin_TypeBase
144 protected WorldEditorAPI m_WorldEditorAPI;
150 bool Process(notnull IEntitySource prefab)
152 if (!prefab.GetResourceName())
154 Print(
"Passed value is not a Prefab - " + prefab,
LogLevel.ERROR);
158 m_WorldEditorAPI = SCR_WorldEditorToolHelper.GetWorldEditorAPI();
159 if (!m_WorldEditorAPI)
170 protected int ButtonBack()
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.