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