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
|
|
@ -13,25 +13,22 @@ signal destroyed
|
|||
@onready var hull: Hull = $Hull
|
||||
## Reference to the shield module
|
||||
@onready var shield: Shield = $Shield
|
||||
## Reference to primary weapon
|
||||
#@onready var primary_weapon: Weapon = $PrimaryWeapon
|
||||
## Reference to secondary weapon
|
||||
#@onready var secondary_weapon: Weapon = $SecondaryWeapon
|
||||
## Reference to weapons node
|
||||
@onready var weapons: Node2D = $Weapons
|
||||
|
||||
## Faction which this ship belongs to
|
||||
var faction : Game.Faction = Game.Faction.Player
|
||||
|
||||
func _ready():
|
||||
#shield.material = material
|
||||
func _ready() -> void:
|
||||
destroyed.connect(destroy)
|
||||
|
||||
## Reset all required variables
|
||||
func destroy():
|
||||
func destroy() -> void:
|
||||
hull.hp = hull.max_hp
|
||||
shield.capacity = shield.max_capacity
|
||||
|
||||
## Swaps old hull with the new one
|
||||
func change_hull(new_hull_id: String):
|
||||
func change_hull(new_hull_id: String) -> void:
|
||||
var new_hull: Hull = Game.get_module(new_hull_id, 'hull').instantiate()
|
||||
var old_hull: Hull = hull
|
||||
add_child(new_hull)
|
||||
|
|
@ -40,7 +37,7 @@ func change_hull(new_hull_id: String):
|
|||
get_tree().create_timer(0.05).timeout.connect(old_hull.queue_free)
|
||||
|
||||
## Swaps old engine with the new one
|
||||
func change_engine(new_engine_id: String):
|
||||
func change_engine(new_engine_id: String) -> void:
|
||||
var new_engine: ShipEngine = Game.get_module(new_engine_id, 'engine').instantiate()
|
||||
var old_engine: ShipEngine = engine
|
||||
add_child(new_engine)
|
||||
|
|
@ -48,7 +45,7 @@ func change_engine(new_engine_id: String):
|
|||
get_tree().create_timer(0.05).timeout.connect(old_engine.queue_free)
|
||||
|
||||
## Swaps old shield with the new one
|
||||
func change_shield(new_shield_id: String):
|
||||
func change_shield(new_shield_id: String) -> void:
|
||||
var new_shield: Shield = Game.get_module(new_shield_id, 'shield').instantiate()
|
||||
var old_shield: Shield = shield
|
||||
add_child(new_shield)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue