74 lines
2.2 KiB
GDScript
74 lines
2.2 KiB
GDScript
@tool
|
|
class_name AnimPlayerEditorCalls
|
|
extends AnimationPlayer
|
|
|
|
var EDITOR_PATH: String:
|
|
get: return str(get_parent().get_path()) + "/"
|
|
|
|
var function_calls: Array[Dictionary] = []
|
|
|
|
|
|
func _ready() -> void:
|
|
animation_started.connect(animation_started_func)
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
if not is_playing():
|
|
function_calls.clear()
|
|
return
|
|
|
|
var remove_these_function_calls: Array = []
|
|
|
|
for i: int in function_calls.size():
|
|
var function_call: Dictionary = function_calls[i]
|
|
if function_call.time > current_animation_position:
|
|
continue
|
|
|
|
#print("AnimationPlayer is calling the function of another node.")
|
|
#print(" path: %s" % function_call.path)
|
|
#print(" name: %s" % function_call.name)
|
|
var node: Node = get_node(function_call.path)
|
|
node.call(function_call.name)
|
|
remove_these_function_calls.append(i)
|
|
|
|
for index: int in remove_these_function_calls:
|
|
#print("AnimationPlayer is removing function call from its queue.")
|
|
function_calls.remove_at(index)
|
|
|
|
|
|
func animation_started_func(_dismiss: Variant) -> void:
|
|
if not Engine.is_editor_hint():
|
|
return
|
|
|
|
# print("animation_started_func(_dismiss: %s)" % _dismiss)
|
|
var song_animation: Animation = get_animation(current_animation)
|
|
#print(" %s" % song_animation)
|
|
for track_index: int in song_animation.get_track_count():
|
|
if not song_animation.track_is_enabled(track_index):
|
|
continue
|
|
|
|
if song_animation.track_get_type(track_index) != Animation.TYPE_METHOD:
|
|
#print(" ...")
|
|
continue
|
|
|
|
var path: String = EDITOR_PATH + str(song_animation.track_get_path(track_index))
|
|
# print(" track_index: %s" % track_index)
|
|
# print(" path: %s" % path)
|
|
var track_key_count: int = song_animation.track_get_key_count(track_index)
|
|
for key_index: int in track_key_count:
|
|
var time: float = song_animation.track_get_key_time(track_index, key_index)
|
|
if time < current_animation_position:
|
|
#print(' ...')
|
|
continue
|
|
|
|
#print(" key_index: %s" % key_index)
|
|
var _name: StringName = song_animation.method_track_get_name(track_index, key_index)
|
|
#var params: StringName = song_animation.method_track_get_name(track_index, key_index)
|
|
#print(" name: %s" % _name)
|
|
#print(" time: %s" % time)
|
|
function_calls.append({
|
|
"path": path,
|
|
"name": _name,
|
|
"time": time
|
|
})
|