]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Character/class_dialogic_animation.gd
Updated export config options
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Character / class_dialogic_animation.gd
1 class_name DialogicAnimation
2 extends Node
3
4 ## Class that can be used to animate portraits. Can be extended to create animations.
5
6 enum AnimationType {IN=1, OUT=2, ACTION=3, CROSSFADE=4}
7
8 signal finished_once
9 signal finished
10
11 ## Set at runtime, will be the node to animate.
12 var node: Node
13
14 ## Set at runtime, will be the length of the animation.
15 var time: float
16
17 ## Set at runtime, will be the base position of the node.
18 ## Depending on the animation, this might be the start, end or both.
19 var base_position: Vector2
20 ## Set at runtime, will be the base scale of the node.
21 var base_scale: Vector2
22
23 ## Used to repeate the animation for a number of times.
24 var repeats: int
25
26 ## If `true`, the animation will be reversed.
27 ## This must be implemented by each animation or it will have no effect.
28 var is_reversed: bool = false
29
30
31 func _ready() -> void:
32         finished_once.connect(finished_one_loop)
33
34
35 ## To be overridden. Do the actual animating/tweening in here.
36 ## Use the properties [member node], [member time], [member base_position], etc.
37 func animate() -> void:
38         pass
39
40
41 ## This method controls whether to repeat the animation or not.
42 ## Animations must call this once they finished an animation.
43 func finished_one_loop() -> void:
44         repeats -= 1
45
46         if repeats > 0:
47                 animate()
48
49         else:
50                 finished.emit()
51
52
53 func pause() -> void:
54         if node:
55                 node.process_mode = Node.PROCESS_MODE_DISABLED
56
57
58 func resume() -> void:
59         if node:
60                 node.process_mode = Node.PROCESS_MODE_INHERIT
61
62
63 func _get_named_variations() -> Dictionary:
64         return {}
65
66
67 ## If the animation wants to change the modulation, this method
68 ## will return the property to change.
69 ##
70 ## The [class CanvasGroup] can use `self_modulate` instead of `modulate`
71 ## to uniformly change the modulation of all children without additively
72 ## overlaying the modulations.
73 func get_modulation_property() -> String:
74         if node is CanvasGroup:
75                 return "self_modulate"
76         else:
77                 return "modulate"