blob: 880f9047fe516aa6835bd90f8ff27ea063688efa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
extends Spatial
class_name Entity
export(bool) var actionable
var actions_queue : Array = []
func _ready():
if actionable:
add_to_group("actionables")
func get_top() -> String:
return ''
func add_action(name : String, args : Array):
actions_queue.append([name, args])
func play_actions():
while not actions_queue.empty():
var action = actions_queue[0]
var name = action[0]
var args = action[1]
yield(call(name, args), "completed")
actions_queue.pop_front()
func cor_move(args : Array): # args = [Vector3]
var next_pos = args[0]
while true:
var delta = get_process_delta_time()
translation = lerp(translation, next_pos, delta * 14)
if abs((translation - next_pos).length()) <= 10e-3:
translation = next_pos
break
yield(get_tree(), "idle_frame")
func cor_dies(args : Array):
yield()
|