Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Jan 6, 2024
1 parent a7e986c commit 6e4e372
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
13 changes: 7 additions & 6 deletions source/match/handlers/SelectionHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 2 additions & 4 deletions source/match/units/Unit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,18 @@ 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
var unit_file_name = unit_script_path.substr(unit_script_path.rfind("/") + 1)
var unit_name = unit_file_name.split(".")[0]
return unit_name

var _action_locked = false

@onready var _match = find_parent("Match")


Expand Down
5 changes: 1 addition & 4 deletions source/match/units/actions/WaitingForTargets.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)

Expand Down

0 comments on commit 6e4e372

Please sign in to comment.