Skip to content

ComponentsApi

An Api for attaching persistent data to map objects.

Description

The ComponentsApi makes it possible to attach a Component to a map object such as a Prop or Wall.

Methods

NodeType node_type ( Node node )
ComponentAccessor register ( String identifier, component_script, int flags )

Signals

level_added ( node ):
Emitted when a Level is added to the World.

pattern_added ( node ):
Emitted when a PatternShape is added to any Level.

wall_added ( node ):
Emitted when a Wall is added to any Level.

portal_free_added ( node ):
Emitted when a free standing Portal is added to any Level.

portal_wall_added ( node ):
Emitted when a wall bound Portal is added to any Level.

material_added ( node ):
Emitted when a MaterialMesh is added to any Level.

path_added ( node ):
Emitted when a Pathway is added to any Level.

prop_added ( node ):
Emitted when a Prop is added to any Level.

light_added ( node ):
Emitted when a Light2D is added to any Level.

roof_added ( node ):
Emitted when a Roof is added to any Level.

text_added ( node ):
Emitted when a Text is added to any Level.

Enumerations

enum NodeType:

  • TYPE_WORLD = 0
  • TYPE_LEVEL = 1
  • TYPE_PATTERN = 2
  • TYPE_WALL = 3
  • TYPE_PORTAL_FREE = 4
  • TYPE_PORTAL_WALL = 5
  • TYPE_MATERIAL = 6
  • TYPE_PATH = 7
  • TYPE_PROP = 8
  • TYPE_LIGHT = 9
  • TYPE_ROOF = 10
  • TYPE_TEXT = 11
Denotes the type of a map node. May be directly converted to the corresponding flag using bit shift:
var prop_flag = 1 << TYPE_PROP

Constants

int FLAG_ALL 0b111111111111
int FLAG_LEVEL 0b000000000010
int FLAG_LIGHT 0b001000000000
int FLAG_MATERIAL 0b000001000000
int FLAG_PATH 0b000010000000
int FLAG_PATTERN 0b000000000100
int FLAG_PORTAL 0b000000110000
int FLAG_PORTAL_FREE 0b000000010000
int FLAG_PORTAL_WALL 0b000000100000
int FLAG_PROP 0b000100000000
int FLAG_ROOF 0b010000000000
int FLAG_TEXT 0b100000000000
int FLAG_WALL 0b000000001000
int FLAG_WITH_NODE_ID 0b111110111100
int FLAG_WORLD 0b000000000001

Method Descriptions

ComponentAccessor register ( String identifier, component_script, int flags ):
Registers a new component with identifier as its unique identifier. component_factory may be either the GDScript of a Component or a ComponentFactory. It will be used to instantiate and deserialize the Component. flags is any combination of node type flags to determine which types of nodes the component is applicable to. Setting lazy to false will cause the component to be automatically attached to any node shortly after it enters the scene. The returned ComponentAccessor can be used to access the Component on applicable nodes.

NodeType node_type ( Node node ):
Returns the NodeType of node.