2[
WorkbenchPluginAttribute(name:
"Optimize Damage Area Shapes", description:
"Attempts to adjust shapes of the selected damage area entities.", wbModules: {
"WorldEditor" }, awesomeFontCode: 0xf714)]
3class SCR_DamageAreaShapesPlugin : WorldEditorPlugin
5 protected const string PROPERTY_COORDS =
"coords";
6 protected const string PROPERTY_SHAPE =
"Area shape";
7 protected const string PROPERTY_AREA =
"DamageAreas";
8 protected const string PROPERTY_COMPONENTS =
"components";
13 WorldEditorAPI api = SCR_WorldEditorToolHelper.GetWorldEditorAPI();
17 if (api.GetSelectedEntity() == null)
25 SCR_DamageAreaComponent dmgAreaComp;
26 array<ref DamageArea> damageAreas = {};
28 api.BeginEntityAction();
31 for (
int i, count = api.GetSelectedEntitiesCount(); i < count; i++)
33 entSrc = api.GetSelectedEntity(i);
37 ent = api.SourceToEntity(entSrc);
41 dmgAreaComp = SCR_DamageAreaComponent.Cast(ent.
FindComponent(SCR_DamageAreaComponent));
49 array<ref ContainerIdPathEntry> finalPath;
52 dmgAreaComp.GetDamageAreas(damageAreas);
53 foreach (
int areaId,
DamageArea dmgArea : damageAreas)
63 areaPath.Index = areaId;
64 finalPath = {componentPath, areaPath, shapePath};
65 if (!shape.OptimizeShape(entSrc, api, finalPath, offset))
68 anythingChanged =
true;
71 entSrc.Get(PROPERTY_COORDS, newEntPos);
73 api.SetVariableValue(entSrc, null, PROPERTY_COORDS, newEntPos.ToString(
false));
77 api.EndEntityAction();
void ContainerIdPathEntry(string propertyName, int index=-1)
proto external Managed FindComponent(typename typeName)
static void PrintDialog(string message, string caption="", LogLevel level=LogLevel.WARNING)
LogLevel
Enum with severity of the logging message.