Implemented basic notification system for weapons changing.
This commit is contained in:
parent
a6d137bf7a
commit
18dc548dd6
16 changed files with 300 additions and 2 deletions
23
scripts/notification_manager.gd
Normal file
23
scripts/notification_manager.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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: float) -> 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue