Skip to content

@tool YggdrasilNodesService API

Service for creating, loading, duplicating, and updating YggdrasilNodeButton instances for a tree view.


Signals

Name
node_created(node: YggdrasilNodeButton)
node_pressed(node: YggdrasilNodeButton)
node_hovered(node: YggdrasilNodeButton, is_hovered: bool)

Properties

Type Name Default
Dictionary[int, YggdrasilNodeButton] _nodes {}

Methods

Type Name
void load_tree(tree_data: YggdrasilTree)
void delete_node(node: YggdrasilNodeButton)
YggdrasilNodeButton create_node(position: Vector2, node_type: NodeType)
YggdrasilNodeButton create_from_prefab(position: Vector2, prefab: YggdrasilPrefab)
YggdrasilNodeButton duplicate_node(original_node: YggdrasilNodeButton)
void on_node_preallocated(node: YggdrasilNodeButton)
void on_node_unpreallocated(node: YggdrasilNodeButton)
void on_node_allocated(node: YggdrasilNodeButton)
void on_node_deallocated(node: YggdrasilNodeButton)
void on_node_refund_added(node: YggdrasilNodeButton)
void on_node_refund_removed(node: YggdrasilNodeButton)
YggdrasilNodeButton get_node(node_id: int)

Signal Descriptions

node_created(node: YggdrasilNodeButton)

Emitted when a node button is created.

node_pressed(node: YggdrasilNodeButton)

Emitted when a node button is pressed.

node_hovered(node: YggdrasilNodeButton, is_hovered: bool)

Emitted when a node button hover state changes.

Property Descriptions

Dictionary[int, YggdrasilNodeButton] _nodes = {}

Maps node ids to created node button instances.

Method Descriptions

void load_tree(tree_data: YggdrasilTree)

Loads all nodes from tree_data by creating button instances for each stored node resource.

void delete_node(node: YggdrasilNodeButton)

Removes node from the internal node id map.

YggdrasilNodeButton create_node(position: Vector2, node_type: NodeType)

Creates a new node at position with node_type, adds it to the tree data and node container, connects press handling, emits node_created, and returns it.

YggdrasilNodeButton create_from_prefab(position: Vector2, prefab: YggdrasilPrefab)

Creates a new node from prefab at position, copies prefab visuals and data, adds it to the tree, optionally links it back to the prefab by reference id, emits node_created, and returns it.

YggdrasilNodeButton duplicate_node(original_node: YggdrasilNodeButton)

Duplicates original_node into a new node with a new id, copied visuals and attributes, offset position, optional prefab linkage, emits node_created, and returns it.

void on_node_preallocated(node: YggdrasilNodeButton)

Updates node and its neighbors after the node becomes preallocated.

void on_node_unpreallocated(node: YggdrasilNodeButton)

Updates node and its neighbors after the node is removed from the preallocated state.

void on_node_allocated(node: YggdrasilNodeButton)

Updates node and its neighbors after the node becomes allocated.

void on_node_deallocated(node: YggdrasilNodeButton)

Updates node and its neighbors after the node becomes deallocated.

void on_node_refund_added(node: YggdrasilNodeButton)

Updates node and its neighbors after the node is staged for refund.

void on_node_refund_removed(node: YggdrasilNodeButton)

Updates node and its neighbors after the node is removed from refund staging.

YggdrasilNodeButton get_node(node_id: int)

Returns the node button for node_id, or null if it is not found.