Skip to content

Commit

Permalink
Improve cleanup of 'UnitMenus'
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Aug 27, 2023
1 parent 35f1d04 commit 1620feb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/match/MatchSignals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ signal unit_spawned(unit)
signal unit_targeted(unit)
signal unit_selected(unit)
signal unit_deselected(unit)
signal unit_died(unit)
signal controlled_player_changed(player)
3 changes: 2 additions & 1 deletion source/match/debug/UnitsManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ func _unhandled_input(event):
return
if event.is_action_pressed("god_mode_delete_units"):
for unit in get_tree().get_nodes_in_group("selected_units"):
unit.queue_free()
if "hp" in unit:
unit.hp = 0


func _get_requested_units():
Expand Down
1 change: 1 addition & 0 deletions source/match/hud/UnitMenus.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func _ready():
_reset_menus()
MatchSignals.unit_selected.connect(func(_unit): _reset_menus())
MatchSignals.unit_deselected.connect(func(_unit): _reset_menus())
MatchSignals.unit_died.connect(func(_unit): _reset_menus())


func _reset_menus():
Expand Down
1 change: 1 addition & 0 deletions source/match/units/Unit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func _teardown_current_action():


func _handle_unit_death():
tree_exited.connect(func(): MatchSignals.unit_died.emit(self))
queue_free()


Expand Down
1 change: 0 additions & 1 deletion source/match/units/traits/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func _ready():
return
MatchSignals.deselect_all_units.connect(deselect)
_unit.input_event.connect(_on_input_event)
_unit.tree_exiting.connect(deselect)
_circle.hide()


Expand Down

0 comments on commit 1620feb

Please sign in to comment.