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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue