facsimile-wing/scripts/notification_manager.gd
2026-06-28 01:45:11 +01:00

23 lines
804 B
GDScript

class_name NotificationManager extends Node
@export var notification_scene: PackedScene
var _active_notification: NotificationDisplay = null
func _ready() -> void:
EventBus.weapon_changed.connect(_on_weapon_changed)
func _on_weapon_changed(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: Vector2) -> void:
if notification_scene == null:
return
# Free any existing notification so the new one can fade in cleanly
if _active_notification:
_active_notification.queue_free()
_active_notification = null
var notification = notification_scene.instantiate()
add_child(notification)
_active_notification = notification
notification.show_notification(weapon_name, player_node, player_sprite_size, origin_offset)