26 lines
502 B
GDScript

class_name SkillsComponent
extends CharacterComponent
@export var skills: Array[Skill]
func _ready():
character.controlled.connect(on_controlled)
func on_controlled(controller: Controller):
controller.used_skill.connect(use_skill)
func use_skill(slot: int):
if slot < 0 || slot >= skills.size():
return
if character.state.current == StateComponent.State.Skill:
return
var skill := skills[slot]
if !skill:
return
var scene := skill.scene.instantiate()
character.add_child(scene)