29 lines
529 B
GDScript3
Raw Normal View History

2024-02-12 23:22:27 +00:00
class_name SkillsComponent
extends Node
2024-02-15 15:28:27 +00:00
@export var skills: Array[Skill]
2024-02-12 23:22:27 +00:00
2024-02-16 13:45:49 +00:00
var character: Character
2024-02-12 23:22:27 +00:00
func _ready():
2024-02-16 13:45:49 +00:00
character = owner
2024-02-24 14:30:41 +00:00
character.controlled.connect(on_controlled)
func on_controlled(controller: Controller):
controller.used_skill.connect(use_skill)
2024-02-15 15:28:27 +00:00
func use_skill(slot: int):
if slot < 0 || slot >= skills.size():
return
2024-02-16 13:45:49 +00:00
if character.state.current == StateComponent.State.Skill:
return
2024-02-15 15:28:27 +00:00
var skill := skills[slot]
2024-02-12 23:22:27 +00:00
2024-02-13 22:12:32 +00:00
if !skill:
return
var scene := skill.scene.instantiate()
2024-02-15 15:28:27 +00:00
owner.add_child(scene)