Rewriting ships: Added shields and weapons holder
This commit is contained in:
parent
e2b9fa6c69
commit
95274d0a5b
17 changed files with 396 additions and 24 deletions
25
scripts/Ship/weapons.gd
Normal file
25
scripts/Ship/weapons.gd
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue