forked from bitbrain/beehave
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetModulateColor.gd
More file actions
31 lines (25 loc) · 820 Bytes
/
Copy pathSetModulateColor.gd
File metadata and controls
31 lines (25 loc) · 820 Bytes
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
extends BeehaveAction
class_name SetModulateColor
@export var modulate_color:Color = Color.WHITE
@export var interpolation_time:float = 3.0
var current_color
var tween
func tick(context: BeehaveContext) -> int:
if current_color != modulate_color and context.get_actor().modulate != modulate_color:
if tween != null:
tween.stop()
current_color = modulate_color
tween = create_tween()\
.set_ease(Tween.EASE_IN_OUT)\
.set_trans(Tween.TRANS_CUBIC)
tween.tween_property(context.get_actor(), "modulate", current_color, interpolation_time)\
.finished.connect(_finished.bind(context.get_actor()))
if current_color != null:
return RUNNING
else:
return SUCCESS
func _finished(actor: Node) -> void:
current_color = null
tween = null
if actor is ColorChangingSprite:
actor.color_changed.emit()