Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
EntityTool.c
Go to the documentation of this file.
1[WorkbenchPluginAttribute("Change absolute Y to relative", "Modifies entity Y position from absolute value to relative.", "", "", {"WorldEditor"},"",0xf548)]
2class EntityRelativePlugin: WorkbenchPlugin
3{
4 override void Run()
5 {
6 WorldEditor we = Workbench.GetModule(WorldEditor);
7 if (!we)
8 {
9 Print("World editor module is not available.", LogLevel.ERROR);
10 return;
11 }
12
13 WorldEditorAPI api = we.GetApi();
14 int selectedCount = api.GetSelectedEntitiesCount();
15 if (selectedCount == 0)
16 {
17 Print("You need to select at least one entity.", LogLevel.ERROR);
18 return;
19 }
20
21 WBProgressDialog progress = new WBProgressDialog("Processing entities", we);
22
23 api.BeginEntityAction("Changing entity Y from absolute to relative");
24
25 Print("EntityRelativePlugin: processing " + selectedCount + " entities...");
26 for (int i = 0; i < selectedCount; i++)
27 {
28 progress.SetProgress(i / selectedCount);
29
30 IEntitySource src = api.GetSelectedEntity(i);
31 IEntity e = api.SourceToEntity(src);
32
33 vector pos;
34 src.Get("coords", pos);
35
36 float y;
37 if (api.TryGetTerrainSurfaceY(pos[0], pos[2], y))
38 {
39 pos[1] = pos[1] - y;
40 api.SetVariableValue(src, null, "coords", pos.ToString(false));
41 }
42 else
43 {
44 Print("Entity " + e.GetID() + " can't relatively positioned to the terrain.", LogLevel.WARNING);
45 }
46 }
47
48 api.EndEntityAction();
49 }
50
51 override void Configure() { }
52}
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
override void Run()
override void Configure()
proto external EntityID GetID()
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