diff --git a/source/match/handlers/SelectionHandler.gd b/source/match/handlers/SelectionHandler.gd index 33c62f8..a2cec89 100644 --- a/source/match/handlers/SelectionHandler.gd +++ b/source/match/handlers/SelectionHandler.gd @@ -2,11 +2,12 @@ extends Node3D @export var rectangular_selection_3d: NodePath +var double_click_last_unit = null +var double_click_timer = 0 + var _rectangular_selection_3d = null var _highlighted_units = Utils.Set.new() -var double_click_last_unit = null -var double_click_timer = 0 func _ready(): _rectangular_selection_3d = get_node_or_null(rectangular_selection_3d) @@ -117,23 +118,23 @@ func _on_selection_finished(topdown_polygon_2d): ) _select_units(units_to_select) + func _on_unit_selected(unit): if Time.get_ticks_msec() <= double_click_timer + 50: return if not unit.is_in_group("controlled_units"): return if unit == double_click_last_unit and Time.get_ticks_msec() <= double_click_timer + 600: - double_click_last_unit = unit + double_click_last_unit = unit double_click_timer = Time.get_ticks_msec() _double_click(unit) else: - double_click_last_unit = unit + double_click_last_unit = unit double_click_timer = Time.get_ticks_msec() - func _double_click(unit): - var units_to_select = Utils.Set.new(); + var units_to_select = Utils.Set.new() var camera = get_viewport().get_camera_3d() for u in get_tree().get_nodes_in_group("controlled_units"): if not u.visible or not camera.is_position_in_frustum(u.global_position): diff --git a/source/match/units/Unit.gd b/source/match/units/Unit.gd index d397658..7e01f98 100644 --- a/source/match/units/Unit.gd +++ b/source/match/units/Unit.gd @@ -36,13 +36,9 @@ var color: return player.color var action = null: set = _set_action - -var _action_locked = false - var location: get: return global_position * Vector3(1, 0, 1) - var type: get: var unit_script_path = get_script().resource_path @@ -50,6 +46,8 @@ var type: var unit_name = unit_file_name.split(".")[0] return unit_name +var _action_locked = false + @onready var _match = find_parent("Match") diff --git a/source/match/units/actions/WaitingForTargets.gd b/source/match/units/actions/WaitingForTargets.gd index 930da31..26be8a0 100644 --- a/source/match/units/actions/WaitingForTargets.gd +++ b/source/match/units/actions/WaitingForTargets.gd @@ -31,10 +31,7 @@ func _get_units_to_attack(): func(unit): return ( unit.player != _unit.player and unit.movement_domain in _unit.attack_domains - and ( - _unit.location.distance_to(unit.location) - <= _unit.sight_range - ) + and (_unit.location.distance_to(unit.location) <= _unit.sight_range) ) )