Create a Component – Arma Reforger
A World Editor Component is a code element that can be placed as a child (well, as a component) of an entity from the World Editor's Add Component button.
In this example, we will create a Component that does something.
Declaration
Component
Create a new file and name it as your component - here, we will go with TAG_Component so the file should be TAG_Component.c.
Component Class
Like an Entity, a Component requires a Component Class declaration. This allows it to be visible in World Editor. The name must be exactly the Component name suffixed by Class, here TAG_ComponentClass. A Component Class is usually placed just above the Component definition as such:
The class is decorated using ComponentEditorProps; the category is where the Component will be found using e.g the Add Component button - see below.
ComponentEditorProps
- category
- the "Create" tab's category in which the Component can be found
- description
- unused (for now)
- color
- the bounding box's unselected line colour - useful only when visible is set to true
- visible
- have the bounding box always visible - drawn in color
- insertable
- configRoot
- unused
- icon
- unused: direct path to a png file, e.g WBData
/EntityEditorProps /entityEditor.png
Filling
The Component is now visible in World Editor's "Add Component" UI, the next step is to make it do something.
Add Code
Let's use the Component's OnPostInit() method to call code.
Add Properties
Now, we can declare properties with the Attribute in order to be able to adjust some settings from the World Editor interface. The following code only contains the added attributes:
The following code contains code with the implemented attributes:
Now all there is to do is to attach a TAG_Component component to a world entity and see its effects!
Final Code
The final file content can be found here: