diff --git a/classes/deck/deck_holder.gd b/classes/deck/deck_holder.gd index 49e7ba8..a918eab 100644 --- a/classes/deck/deck_holder.gd +++ b/classes/deck/deck_holder.gd @@ -296,14 +296,23 @@ static func pre_exit_cleanup() -> void: static func send_event(event_name: StringName, event_data: Dictionary = {}) -> void: for deck_id: String in decks: if decks[deck_id] is Deck: - (decks[deck_id] as Deck).send_event(event_name, event_data) + var deck: Deck = (decks[deck_id] as Deck) + if not is_instance_valid(deck): + continue + deck.send_event(event_name, event_data) else: for deck_instance_id: String in decks[deck_id]: - (decks[deck_id][deck_instance_id] as Deck).send_event(event_name, event_data) + var deck: Deck = (decks[deck_id][deck_instance_id] as Deck) + if not is_instance_valid(deck): + continue + deck.send_event(event_name, event_data) for lib_group_id: String in lib_groups: for lib_instance_id: String in lib_groups[lib_group_id]: - (lib_groups[lib_group_id][lib_instance_id] as Deck).send_event(event_name, event_data) + var deck: Deck = (lib_groups[lib_group_id][lib_instance_id] as Deck) + if not is_instance_valid(deck): + continue + deck.send_event(event_name, event_data) #region group signal callbacks