facsimile-wing/scripts/weapon_component.gd

20 lines
615 B
GDScript

class_name WeaponComponent extends Node
@export var weapon_data: WeaponShot = null
@export var available_weapons: Array[WeaponShot] = []
var _current_weapon_index: int = 0
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:
if available_weapons.is_empty():
return
_current_weapon_index = (_current_weapon_index + 1) % available_weapons.size()
weapon_data = available_weapons[_current_weapon_index]
print("Switched to: ", weapon_data.shot_name)