8000 Use SnapPoint.get_snapped_block instead of get_children · endlessm/godot-block-coding@b786cad · GitHub
[go: up one dir, main page]

Skip to content

Commit b786cad

Browse files
dylanmccallmanuq
authored andcommitted
Use SnapPoint.get_snapped_block instead of get_children
1 parent 0f5722b commit b786cad

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

addons/block_code/ui/block_canvas/block_canvas.gd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ func build_tree(block: Block) -> SerializedBlockTreeNode:
186186
block.update_resources(_undo_redo)
187187

188188
for snap in find_snaps(block):
189-
for child in snap.get_children():
190-
if not child is Block: # Make sure to not include preview
191-
continue
192-
path_child_pairs.append([block.get_path_to(snap), build_tree(child)])
189+
var snapped_block = snap.get_snapped_block()
190+
if snapped_block == null:
191+
continue
192+
path_child_pairs.append([block.get_path_to(snap), build_tree(snapped_block)])
193193

194194
if block.resource.path_child_pairs != path_child_pairs:
195195
_undo_redo.add_undo_property(block.resource, "path_child_pairs", block.resource.path_child_pairs)
@@ -198,10 +198,10 @@ func build_tree(block: Block) -> SerializedBlockTreeNode:
198198
return block.resource
199199

200200

201-
func find_snaps(node: Node) -> Array:
202-
var snaps := []
201+
func find_snaps(node: Node) -> Array[SnapPoint]:
202+
var snaps: Array[SnapPoint]
203203

204-
if node.is_in_group("snap_point"):
204+
if node.is_in_group("snap_point") and node is SnapPoint:
205205
snaps.append(node)
206206
else:
207207
for c in node.get_children():

0 commit comments

Comments
 (0)
0