@@ -6,8 +6,8 @@ extends Node2D
6
6
7
7
const BASE_LINE_WIDTH = 3.0
8
8
const DRAW_COLOR :Color = Color .WHITE
9
- const OFFSET_POSITIONS = Vector2 (10 ,30 )
10
- const OFFSET_WEIGHT = Vector2 (10 ,- 10 )
9
+ const OFFSET_POSITIONS = Vector2 (10 , 30 )
10
+ const OFFSET_WEIGHT = Vector2 (10 , - 10 )
11
11
12
12
var _debug_connections = false
13
13
var _debug_position = false
@@ -18,27 +18,26 @@ var _debug_path = true
18
18
19
19
func _process (delta ):
20
20
queue_redraw ()
21
- pass
22
21
23
22
24
23
func draw_arrow (src , dst , color , width , aa = true ):
25
24
var angle = 0.6
26
25
var size_head = 20
27
26
var head : Vector2 = (dst - src ).normalized () * size_head
28
- draw_line (src , dst - head / 2 , color , width , aa )
29
- draw_polygon ([dst , dst - head .rotated (angle ), dst - head .rotated (- angle ) ], [color ,color ,color ])
27
+ draw_line (src , dst - head / 2 , color , width , aa )
28
+ draw_polygon ([ dst , dst - head .rotated (angle ), dst - head .rotated (- angle ) ], [ color , color , color ])
30
29
31
30
32
31
func _draw ():
33
- if _debug_connections :
32
+ if _debug_connections :
34
33
_draw_connections ()
35
- if _debug_position :
34
+ if _debug_position :
36
35
_draw_positions ()
37
- if _debug_weights :
36
+ if _debug_weights :
38
37
_draw_weights ()
39
- if _debug_costs :
38
+ if _debug_costs :
40
39
_draw_costs ()
41
- if _debug_path :
40
+ if _debug_path :
42
41
_draw_path ()
43
42
44
43
@@ -61,13 +60,13 @@ func _draw_weights():
61
60
var position_weight = map .astar_node .get_point_position (id )
62
61
var cost = map .astar_node .get_point_weight_scale (id )
63
62
draw_string (
64
- font ,
65
- position_weight + OFFSET_WEIGHT ,
66
- str (cost ),
67
- HORIZONTAL_ALIGNMENT_FILL ,
68
- - 1 ,
69
- 16 ,
70
- Color .RED
63
+ font ,
64
+ position_weight + OFFSET_WEIGHT ,
65
+ str (cost ),
66
+ HORIZONTAL_ALIGNMENT_FILL ,
67
+ - 1 ,
68
+ 16 ,
69
+ Color .RED
71
70
)
72
71
73
72
@@ -76,13 +75,13 @@ func _draw_positions():
76
75
var position_label = map .astar_node .get_point_position (id )
77
76
var position_map = map .local_to_map (map .to_local (map .astar_node .get_point_position (id )))
78
77
draw_string (
79
- font ,
80
- position_label + OFFSET_POSITIONS ,
81
- str (position_map ),
82
- HORIZONTAL_ALIGNMENT_FILL ,
83
- - 1 ,
84
- 16 ,
85
- Color .RED
78
+ font ,
79
+ position_label + OFFSET_POSITIONS ,
80
+ str (position_map ),
81
+ HORIZONTAL_ALIGNMENT_FILL ,
82
+ - 1 ,
83
+ 16 ,
84
+ Color .RED
86
85
)
87
86
88
87
@@ -92,7 +91,7 @@ func _draw_connections():
92
91
var position_start = map .astar_node .get_point_position (id )
93
92
var position_end = map .astar_node .get_point_position (id_con )
94
93
var direction = (position_end - position_start )
95
- draw_arrow (position_start , position_end - direction / 4.0 , Color (0.0 , 1.0 , 1.0 , 1.0 ), BASE_LINE_WIDTH * 2 , true )
94
+ draw_arrow (position_start , position_end - direction / 4.0 , Color (0.0 , 1.0 , 1.0 , 1.0 ), BASE_LINE_WIDTH * 2 , true )
96
95
97
96
98
97
func _draw_costs ():
@@ -102,13 +101,13 @@ func _draw_costs():
102
101
var position_cost_end = map .astar_node .get_point_position (id_con )
103
102
var cost = map .astar_node ._compute_cost (id , id_con )
104
103
draw_string (
105
- font ,
106
- (position_cost_start + position_cost_end )/ 2.0 ,
107
- str ("%.2f " % cost ),
108
- HORIZONTAL_ALIGNMENT_CENTER ,
109
- - 1 ,
110
- 16 ,
111
- Color .PINK
104
+ font ,
105
+ (position_cost_start + position_cost_end ) / 2.0 ,
106
+ str ("%.2f " % cost ),
107
+ HORIZONTAL_ALIGNMENT_CENTER ,
108
+ - 1 ,
109
+ 16 ,
110
+ Color .PINK
112
111
)
113
112
114
113
0 commit comments