mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
28 lines
729 B
GDScript3
28 lines
729 B
GDScript3
|
extends Node
|
||
|
|
||
|
const BASE_NODE_PATH := "res://classes/deck/nodes/"
|
||
|
var nodes: Dictionary = {}
|
||
|
|
||
|
|
||
|
func _init() -> void:
|
||
|
var dir := DirAccess.open(BASE_NODE_PATH)
|
||
|
dir.list_dir_begin()
|
||
|
var current_file := dir.get_next()
|
||
|
while current_file != "":
|
||
|
print(current_file)
|
||
|
if current_file.ends_with(".gd"):
|
||
|
var f := FileAccess.open(BASE_NODE_PATH.path_join(current_file), FileAccess.READ)
|
||
|
var line := f.get_line()
|
||
|
if !line.begins_with("###type="):
|
||
|
current_file = dir.get_next()
|
||
|
continue
|
||
|
nodes[line.trim_prefix("###type=")] = BASE_NODE_PATH.path_join(current_file)
|
||
|
current_file = dir.get_next()
|
||
|
|
||
|
|
||
|
func instance_node(type: String) -> DeckNode:
|
||
|
if !nodes.has(type):
|
||
|
return null
|
||
|
|
||
|
return load(nodes[type]).new()
|