Update weapon resources, default weapon loaded; implemented call weapon

by name.
This commit is contained in:
Henry Faber 2026-06-20 14:47:46 +01:00
parent cf172bc546
commit d0664a87fa
8 changed files with 69 additions and 30 deletions

View file

@ -5,13 +5,34 @@ class_name WeaponComponent extends Node
var _current_weapon_index: int = 0
func _ready() -> void:
# Set the default weapon to be stock, i.e. index 1
if weapon_data and not available_weapons.is_empty():
for i in range(available_weapons.size()):
if available_weapons[i] == weapon_data:
_current_weapon_index = i
return
func get_bullet_scene() -> PackedScene:
return weapon_data.bullet_scene if weapon_data else null
func get_weapon_resource() -> Resource:
return weapon_data
func cycle_weapon() -> void:
func select_weapon_by_name(name: String) -> bool:
for i in range(available_weapons.size()):
if available_weapons[i].shot_name == name:
_current_weapon_index = i
weapon_data = available_weapons[i]
print("Switched to: ", name)
return true
return false
func cycle_weapon() -> void: # Used for testing weapon cycling
if available_weapons.is_empty():
return

17
scripts/weapon_shot.gd Normal file
View file

@ -0,0 +1,17 @@
class_name WeaponShot
extends Resource
@export_category("Info")
@export var shot_name: String
@export var bullet_scene: PackedScene = null
@export_category("Shot Data")
@export var damage: int = 1
@export var speed: int = 135
@export var projectiles: int = 2
@export var spacing: float = 35
@export var origin: int = -23
@export_category("Spread")
@export var horizontal_offset: float = 6.5 # Horizontal distance between projectiles
@export var stagger_offset: float = 0.1 # Time delay per projectile index

View file

@ -0,0 +1 @@
uid://7n1itonn35fm