Add skill type enumeration and update skill management for throw skills

This commit is contained in:
2025-06-05 01:54:32 +02:00
parent 039dc1d5e5
commit 87b85cae43
9 changed files with 36 additions and 4 deletions

View File

@@ -18,3 +18,4 @@ config = {
}
cost = 50
icon = ExtResource("2_yimbq")
type = 1

View File

@@ -19,3 +19,4 @@ config = {
}
cost = 180
icon = ExtResource("3_wkqmb")
type = 1

View File

@@ -19,3 +19,4 @@ config = {
}
cost = 150
icon = ExtResource("3_w87qb")
type = 1

View File

@@ -19,3 +19,4 @@ config = {
}
cost = 150
icon = ExtResource("3_6btth")
type = 1

View File

@@ -16,3 +16,4 @@ config = {
}
cost = 70
icon = ExtResource("1_16qcg")
type = 2

View File

@@ -163,7 +163,6 @@ func reset_current_session_state() -> void:
}
func restart_game() -> void:
reset_player_state()
reset_current_session_state()
@@ -212,3 +211,15 @@ func on_level_complete() -> void:
reset_current_session_state()
try_to_go_to_next_level()
SaveSystem.save_game()
func get_unlocked_skills() -> Array:
var skills_unlocked = player_state.get("unlocked_skills", [])
var skills_current_session = current_session_state.get("skills_unlocked", [])
if not skills_current_session:
return skills_unlocked
if not skills_unlocked:
return skills_current_session
return skills_unlocked + skills_current_session

View File

@@ -1,9 +1,15 @@
class_name SkillData
extends Resource
enum SkillType {
ATTACK,
THROW,
MISC,
}
@export var name: String = ""
@export var description: String = ""
@export var node: PackedScene
@export var config: Dictionary = {}
@export var cost: int = 0
@export var icon: Texture2D
@export var icon: Texture2D
@export var type: SkillType = SkillType.ATTACK

View File

@@ -16,6 +16,18 @@ func add_skill(skill_data: SkillData) -> void:
if active_components.has(skill_data.name):
return
if skill_data.type == SkillData.SkillType.THROW:
var unlocked_skills: Array = gm.get_unlocked_skills()
for skill in unlocked_skills:
var data = null
for s in available_skills:
if s.name == skill:
data = s
break
if data and data.type == SkillData.SkillType.THROW:
print("Removing previous throw skill: ", data.name)
remove_skill(data.name)
var skill_instance := skill_data.node.instantiate()
for key in skill_data.config.keys():
if key in skill_instance:

View File

@@ -39,8 +39,6 @@ func _input(event: InputEvent) -> void:
root.show()
for component in components_to_disable:
component.process_mode = PROCESS_MODE_DISABLED
if buttons:
buttons[0].grab_focus()
func get_button_text(skill: SkillData) -> String: