blob: fbbf97f56e5042fd9736ddca4bf83adc86f70efa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
extends Area2D
@onready var collision_shape = get_child(0) as CollisionShape2D
var colliding_nodes = []
@export var not_colliding_color: Color
@export var colliding_color: Color
func _draw():
var shape = collision_shape.shape as RectangleShape2D
draw_rect(
Rect2(
Vector2.ZERO,
shape.size.snapped(Client.current_stage.map.tile_set.tile_size)
),
colliding_color if colliding_nodes else not_colliding_color
)
func _on_area_entered(area: Area2D) -> void:
colliding_nodes.append(area)
queue_redraw()
func _on_area_exited(area: Area2D) -> void:
colliding_nodes.remove_at(colliding_nodes.find(area))
queue_redraw()
func _on_body_entered(body: Node2D) -> void:
colliding_nodes.append(body)
queue_redraw()
func _on_body_exited(body: Node2D) -> void:
colliding_nodes.remove_at(colliding_nodes.find(body))
queue_redraw()
|