Updated architecture so WeaponComponent uses an exported array to store

weapon resources.
This commit is contained in:
Henry Faber 2026-06-20 13:05:18 +01:00
parent 63ed0aae3a
commit cf172bc546
7 changed files with 88 additions and 36 deletions

View file

@ -1,34 +1,20 @@
class_name WeaponComponent extends Node
enum WeaponType {
STOCK,
NONE,
}
@export var weapon_data: WeaponShot = null
@export var available_weapons: Array[WeaponShot] = []
@export_enum("STOCK", "NONE") var loaded_weapon: int = WeaponType.STOCK
var data: WeaponShot = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
var _current_weapon_index: int = 0
func get_bullet_scene() -> PackedScene:
if loaded_weapon == WeaponType.STOCK:
return preload("res://scenes/player_weapons/weapon_stock.tscn")
else:
return null
return weapon_data.bullet_scene if weapon_data else null
func get_weapon_resource() -> Resource:
var weapon_resource_path: String
return weapon_data
if loaded_weapon == WeaponType.STOCK:
weapon_resource_path = "res://resources/player_weapon_resources/weapon_shot_stock.tres"
data = load(weapon_resource_path)
return data
else:
return null
func cycle_weapon() -> void:
if available_weapons.is_empty():
return
#var data : WeaponShot = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
#func get_bullet_scene() -> PackedScene:
#return data.weapon_shot # Reference to the Shot scene from the resource
_current_weapon_index = (_current_weapon_index + 1) % available_weapons.size()
weapon_data = available_weapons[_current_weapon_index]
print("Switched to: ", weapon_data.shot_name)