GrappleTest/Player/DebugTrail/Recorder.gd

43 lines
952 B
GDScript3
Raw Normal View History

2024-03-13 16:15:55 -05:00
extends Node2D
@onready var player = get_parent()
@onready var sprite = player.find_child("Sprite")
@export var tracking = false
var active = false
@export var finished = false
@export var saved = []
#func _ready():
#await get_tree().create_timer(30).timeout
#finished = true
func track():
saved.append(gen.getCurrentActions())
func _physics_process(delta):
if tracking:
track()
if finished:
print("TIME!!!!")
var dict = {"actions": [], "data": {}}
for frameNumb in len(saved):
var frame = saved[frameNumb]
for action in frame:
if not action in dict.actions:
dict.actions.append(action)
var actID = dict.actions.find(action)
if not frameNumb in dict.data:
dict.data[frameNumb] = {}
dict.data[frameNumb][actID] = frame[action]
dict.data[saved.size() - 1] = {}
var packed = PackedDataContainer.new()
packed.pack(dict)
ResourceSaver.save(packed, "ghostRecording.res")
queue_free()