29 lines
529 B
GDScript
29 lines
529 B
GDScript
class_name SkillsComponent
|
|
extends Node
|
|
|
|
@export var skills: Array[Skill]
|
|
|
|
var character: Character
|
|
|
|
func _ready():
|
|
character = owner
|
|
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()
|
|
owner.add_child(scene)
|