Show auto attack origins on the map
This commit is contained in:
@@ -3542,6 +3542,8 @@ func _draw_target_selection_markers() -> void:
|
||||
var rect := _rect_for_cell(cell)
|
||||
var marker_rect := Rect2(rect.position + Vector2(7.0, TILE_SIZE - 24.0), Vector2(TILE_SIZE - 14.0, 18.0))
|
||||
var color := _target_preview_badge_color(str(marker.get("kind", "damage")))
|
||||
if bool(marker.get("requires_move", false)):
|
||||
_draw_auto_attack_origin_marker(marker, color, font)
|
||||
draw_rect(rect.grow(-3.0), Color(color.r, color.g, color.b, 0.18))
|
||||
draw_rect(rect.grow(-6.0), color, false, 2.2)
|
||||
draw_rect(marker_rect, Color(0.025, 0.028, 0.034, 0.88))
|
||||
@@ -3549,6 +3551,55 @@ func _draw_target_selection_markers() -> void:
|
||||
_draw_ink_text(font, marker_rect.position + Vector2(0, 13), str(marker.get("text", "표")), HORIZONTAL_ALIGNMENT_CENTER, marker_rect.size.x, 12, color)
|
||||
|
||||
|
||||
func _draw_auto_attack_origin_marker(marker: Dictionary, target_color: Color, font: Font) -> void:
|
||||
var origin: Vector2i = marker.get("origin", Vector2i(-1, -1))
|
||||
var target_cell: Vector2i = marker.get("cell", Vector2i(-1, -1))
|
||||
if not state.is_inside(origin) or not state.is_inside(target_cell):
|
||||
return
|
||||
if _cell_is_in_visible_bounds(origin) and _cell_is_in_visible_bounds(target_cell):
|
||||
var route_points := _auto_attack_route_points(origin, target_cell)
|
||||
if route_points.size() >= 2:
|
||||
var from_point := route_points[0]
|
||||
var to_point := route_points[1]
|
||||
var route_color := Color(target_color.r, target_color.g, target_color.b, 0.62)
|
||||
draw_line(from_point, to_point, Color(0.02, 0.014, 0.010, 0.82), 4.0)
|
||||
draw_line(from_point, to_point, route_color, 2.2)
|
||||
var direction := (to_point - from_point).normalized()
|
||||
if direction.length() > 0.0:
|
||||
var side := Vector2(-direction.y, direction.x)
|
||||
draw_line(to_point, to_point - direction * 8.5 + side * 4.2, route_color, 2.0)
|
||||
draw_line(to_point, to_point - direction * 8.5 - side * 4.2, route_color, 2.0)
|
||||
if not _cell_is_in_visible_bounds(origin):
|
||||
return
|
||||
var origin_rect := _rect_for_cell(origin)
|
||||
var move_color := _target_preview_badge_color("move")
|
||||
var marker_rect := _auto_attack_origin_marker_rect(origin)
|
||||
draw_rect(origin_rect.grow(-8.0), Color(move_color.r, move_color.g, move_color.b, 0.17))
|
||||
draw_rect(origin_rect.grow(-10.0), move_color, false, 1.8)
|
||||
draw_rect(marker_rect, Color(0.025, 0.028, 0.034, 0.86))
|
||||
draw_rect(marker_rect, move_color, false, 1.2)
|
||||
_draw_ink_text(font, marker_rect.position + Vector2(0, 13), "진", HORIZONTAL_ALIGNMENT_CENTER, marker_rect.size.x, 12, move_color)
|
||||
|
||||
|
||||
func _auto_attack_origin_marker_rect(origin: Vector2i) -> Rect2:
|
||||
var rect := _rect_for_cell(origin)
|
||||
return Rect2(rect.position + Vector2(7.0, 5.0), Vector2(22.0, 18.0))
|
||||
|
||||
|
||||
func _auto_attack_route_points(origin: Vector2i, target_cell: Vector2i) -> PackedVector2Array:
|
||||
if not state.is_inside(origin) or not state.is_inside(target_cell):
|
||||
return PackedVector2Array()
|
||||
var from_point := _rect_for_cell(origin).get_center()
|
||||
var to_point := _rect_for_cell(target_cell).get_center()
|
||||
var delta := to_point - from_point
|
||||
var distance := delta.length()
|
||||
if distance > 1.0:
|
||||
var direction := delta / distance
|
||||
from_point += direction * 19.0
|
||||
to_point -= direction * 19.0
|
||||
return PackedVector2Array([from_point, to_point])
|
||||
|
||||
|
||||
func _draw_unit_nameplate(rect: Rect2, label: String) -> void:
|
||||
if label.is_empty():
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user