cosmic/scripts/Ship/weapons.gd

25 lines
606 B
GDScript

extends Node2D
# TODO: implement add_weapon
## Shortcut to get_parent()
@onready var ship = get_parent()
## List of weapons
var list: Array[Weapon] = get_children() as Array[Weapon]
## Updates list with actual children of this node
func update_weapon_list() -> void:
list = get_children() as Array[Weapon]
## Removes weapon with given ID and returns true if successful
func remove_weapon(id: String) -> bool:
for weapon in list:
if weapon.id == id:
list.erase(weapon)
weapon.free()
return true
return false
## Adds weapon with given ID to list
func add_weapon(id: String) -> void:
pass