Added state component

This commit is contained in:
2024-02-15 13:45:17 +01:00
parent 17a507d07c
commit 37ed8890ec
19 changed files with 172 additions and 86 deletions

View File

@ -1,14 +1,15 @@
class_name SkillInstance
extends Node3D
extends Node
func play_animation(animation_name: String, duration: float, speed: float):
var character := get_parent()
var animation := character.get_node("Animation") as AnimationComponent
animation.play_with_duration(animation_name, duration, speed)
var state: StateComponent
var animation: AnimationComponent
func melee_damage(wait_time: float):
var area := get_node("Area")
await get_tree().create_timer(wait_time).timeout
area.monitoring = true
await get_tree().create_timer(0.1).timeout
area.monitoring = false
func _enter_tree():
state = get_parent().get_node("State") as StateComponent
animation = get_parent().get_node("Animation") as AnimationComponent
state.current = StateComponent.State.Skill
func end():
animation.player.speed_scale = 1.0
state.current = state.next_state()
queue_free()