Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WorldWindowDataDropPlugin.c
Go to the documentation of this file.
1#ifdef WORKBENCH
3 "World Window DataDrop Plugin",
4 "Allows to handle dropped data into a world edit window and completely reimplement default editor functionality",
5 wbModules: { "WorldEditor" })]
6class SCR_WorldWindowDataDropPlugin : WorldEditorPlugin
7{
8 protected static const string DATA_TYPE_ENTITY_CLASSNAME = "WorldEditor/EntityType"; // entity class name type
9 protected static const string DATA_TYPE_RESOURCE_FILES = "Workbench/ResourceFiles"; // registered resource files type
10
11 //------------------------------------------------------------------------------------------------
12 override bool OnWorldEditWindowDataDropped(int windowType, int posX, int posY, string dataType, array<string> data)
13 {
14 if (dataType == DATA_TYPE_ENTITY_CLASSNAME)
15 {
16 string className = data[0];
17
18 //check whether the particular dropped class is interesting for us
19 if (className == "SomeNotExistingClassAsExample")
20 {
21 //if so then we can spawn it from here with any additional customizations
22 SpawnCustomizedEntityAsExample(windowType, posX, posY, className);
23 return true; //event is processed. Editor's default implementation won't be done
24 }
25 }
26 else if (dataType == DATA_TYPE_RESOURCE_FILES)
27 {
28 //iterate over dropped resource files
29 for (int n = 0; n < data.Count(); n++)
30 {
31 string resName = data[n];
32
33 string ext;
34 FilePath.StripExtension(resName, ext);
35 ext.ToLower();
36
37 //check whether the particular dropped resoure file is interesting for us
38 if (ext == "ptc")
39 {
40 //if so then we can spawn anything custom that uses the dropped data
41 SpawnParticleEffect(windowType, posX, posY, resName);
42 return true; //means event is processed. Editor's default implementation won't be done
43 }
44 }
45 }
46
47 return false; //event not processed. Let work editor's default implementation
48 }
49
50 //------------------------------------------------------------------------------------------------
51 protected void SpawnParticleEffect(int windowType, int posX, int posY, ResourceName resName)
52 {
53 WorldEditorAPI worldEditorAPI = ((WorldEditor)Workbench.GetModule(WorldEditor)).GetApi();
54 if (worldEditorAPI.BeginEntityAction("Creating entity"))
55 {
56 worldEditorAPI.ClearEntitySelection();
57
58 //use the same creating funtion as editor does because it solves correct placing etc.
59 IEntitySource ent = worldEditorAPI.CreateEntityInWindowEx(windowType, posX, posY, "ParticleEffectEntity", "", worldEditorAPI.GetCurrentEntityLayerId());
60 if (ent)
61 {
62 worldEditorAPI.SetVariableValue(ent, null, "EffectPath", resName);
63 worldEditorAPI.AddToEntitySelection(ent);
64 }
65
66 worldEditorAPI.EndEntityAction();
67 }
68 }
69
70 //------------------------------------------------------------------------------------------------
71 protected void SpawnCustomizedEntityAsExample(int windowType, int posX, int posY, string className)
72 {
73 //this is an example how entity must be created.
74 WorldEditorAPI worldEditorAPI = ((WorldEditor)Workbench.GetModule(WorldEditor)).GetApi();
75 if (worldEditorAPI.BeginEntityAction("Creating entity"))
76 {
77 worldEditorAPI.ClearEntitySelection();
78
79 //use the same creating funtion as editor does because it solves correct placing etc.
80 IEntitySource ent = worldEditorAPI.CreateEntityInWindowEx(windowType, posX, posY, className, "", worldEditorAPI.GetCurrentEntityLayerId());
81 if (ent)
82 worldEditorAPI.AddToEntitySelection(ent);
83
84 worldEditorAPI.EndEntityAction();
85 }
86 }
87}
88#endif // WORKBENCH
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
Get all prefabs that have the spawner data
ParticleEffectEntityClass GenericEntityClass SpawnParticleEffect(ResourceName effectPath, notnull ParticleEffectEntitySpawnParams spawnParams)