summaryrefslogtreecommitdiff
path: root/Effects/SlowEffect.gd
blob: fd33fe6bdfecdcd982aa2998ac4015ee3e4e7f13 (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
extends Effect


@onready var unit: Unit = get_parent()

var level := 1

var base_speed: float


var magnitude: float:
	set(value):
		magnitude = clamp(value, 0.0, 1.0)


func _ready():
	magnitude = 0.1 * level
	
	add()
	set_duration(5.0 + ((level - 1) * 0.1))
	duration_finished.connect(func():
		remove()
	)


func add():
	unit.sprite.modulate += Color(0, 0, 1, 0)
	unit.speed -= unit.base_speed * magnitude


func remove():
	unit.sprite.modulate -= Color(0, 0, 1, 0)
	unit.speed += unit.base_speed * magnitude