1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 01:24:23 +00:00

Refactor HoverDetector into CursorDetector

This commit is contained in:
Steffo 2024-04-16 01:56:46 +02:00
parent 446083dd73
commit e2f4ad461e
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
6 changed files with 36 additions and 27 deletions

View file

@ -0,0 +1,21 @@
@icon("res://behaviours/cursor_detector.svg")
extends Area2D
class_name CursorDetector
signal cursor_entered(cursor: Cursor)
signal cursor_exited(cursor: Cursor)
var mouse_inside = false
func _on_body_entered(body: Node2D) -> void:
if body is Cursor:
mouse_inside = true
cursor_entered.emit(body)
func _on_body_exited(body: Node2D) -> void:
if body is Cursor:
mouse_inside = true
cursor_exited.emit(body)

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -3,15 +3,15 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://6wpumqhdov4r" uid="uid://6wpumqhdov4r"
path="res://.godot/imported/hover_detector.svg-3bfd5bde28e59dd82344da683ff70f2d.ctex" path="res://.godot/imported/cursor_detector.svg-15ede4c1c6083de1d2f8a8ceb4ab532a.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://behaviours/hover_detector.svg" source_file="res://behaviours/cursor_detector.svg"
dest_files=["res://.godot/imported/hover_detector.svg-3bfd5bde28e59dd82344da683ff70f2d.ctex"] dest_files=["res://.godot/imported/cursor_detector.svg-15ede4c1c6083de1d2f8a8ceb4ab532a.ctex"]
[params] [params]

View file

@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://cbg5kgwxusvxf"]
[ext_resource type="Script" path="res://behaviours/cursor_detector.gd" id="1_4hcxj"]
[node name="CursorDetector" type="Area2D"]
collision_layer = 0
collision_mask = 64
monitorable = false
script = ExtResource("1_4hcxj")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="body_exited" from="." to="." method="_on_body_exited"]

View file

@ -1,13 +0,0 @@
@icon("res://behaviours/hover_detector.svg")
extends Area2D
class_name HoverDetector
var mouse_inside = false
func _on_mouse_entered() -> void:
mouse_inside = true
func _on_mouse_exited() -> void:
mouse_inside = false

View file

@ -1,11 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://cbg5kgwxusvxf"]
[ext_resource type="Script" path="res://behaviours/hover_detector.gd" id="1_51m5p"]
[node name="HoverDetector" type="Area2D"]
collision_mask = 0
monitorable = false
script = ExtResource("1_51m5p")
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]