summaryrefslogtreecommitdiff
path: root/Effects/Effect.gd
blob: 0c74c2b49cc1fb993ad68888ba81761fca6c8136 (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
44
45
46
47
48
class_name Effect
extends Node


signal duration_finished
signal tick_finished

var duration: float = 0.0
var DurationTimer: Timer

var tick: float = 0.0
var TickTimer: Timer

var is_stackable := false


func _ready():
	pass


func set_duration(value: float):
	duration = value
	
	if not DurationTimer:
		DurationTimer = Timer.new()
		DurationTimer.timeout.connect(func():
			duration_finished.emit()
			queue_free()
		)
		add_child(DurationTimer)
	
	DurationTimer.wait_time = duration
	DurationTimer.start()


func set_tick(value: float):
	tick = value
	
	if not TickTimer:
		TickTimer = Timer.new()
		TickTimer.timeout.connect(func():
			tick_finished.emit()
			TickTimer.start()
		)
		add_child(TickTimer)
	
	TickTimer.wait_time = tick
	TickTimer.start()