Update weapon resources, default weapon loaded; implemented call weapon
by name.
This commit is contained in:
parent
cf172bc546
commit
d0664a87fa
8 changed files with 69 additions and 30 deletions
|
|
@ -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
17
scripts/weapon_shot.gd
Normal 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
|
||||
1
scripts/weapon_shot.gd.uid
Normal file
1
scripts/weapon_shot.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://7n1itonn35fm
|
||||
Loading…
Add table
Add a link
Reference in a new issue