checheche/Robo-Bus-A31-HMI/common/func_tool.gd
2024-12-06 21:22:11 +08:00

40 lines
1.1 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class_name FuncTool
extends Node
static func cal(event_arr,node,data_arr = {}):
#先创建一个先前数据的空数列存储 方便来回加减
var the_previous = []
#执行每一个触发条件下的方法名称
for item in event_arr:
#调用Func脚本中的方法名称对应上方
var callable = Callable(Func,item["func_name"])
var arr = []
#如果方法中写了value 则在数列arr中连续存储对应对象使用者全局对象上一个数值
if item.has("value"):
for value in item["value"]:
match value:
"User","Node":
arr.append(node)
"Scene":
arr.append(Global.scene)
"Playe":
arr.append(Global.playe)
"selectRoleData":
arr.append(Global.select_role_data)
"thePrevious":
arr.append(the_previous)
"Select":
arr.append(Global.select)
_:
if data_arr.has(value):
arr.append(data_arr[value])
else:
arr.append(value)
#逐个执行方法
the_previous = await callable.callv(arr)
if the_previous is String and the_previous == "return":
return