Implemented basic notification system for weapons changing.

This commit is contained in:
Henry Faber 2026-06-21 17:55:47 +01:00
parent a6d137bf7a
commit 18dc548dd6
16 changed files with 300 additions and 2 deletions

View file

@ -15,6 +15,13 @@ func _ready() -> void:
return
func _emit_weapon_changed() -> void:
var ship: Sprite2D = get_parent().get_node("Ship")
var sprite_size = ship.get_rect().size
var origin_offset = weapon_data.origin if weapon_data else 0.0
EventBus.weapon_changed.emit(weapon_data.shot_name, get_parent(), sprite_size, origin_offset)
func get_bullet_scene() -> PackedScene:
return weapon_data.bullet_scene if weapon_data else null
@ -27,6 +34,8 @@ func select_weapon_by_name(name: String) -> bool:
_current_weapon_index = i
weapon_data = available_weapons[i]
print("Switched to: ", name)
_emit_weapon_changed()
return true
return false
@ -39,3 +48,5 @@ func cycle_weapon() -> void: # Used for testing weapon cycling
_current_weapon_index = (_current_weapon_index + 1) % available_weapons.size()
weapon_data = available_weapons[_current_weapon_index]
print("Switched to: ", weapon_data.shot_name)
_emit_weapon_changed()