1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 15:44:23 +00:00

Reimplement dragging detection

This commit is contained in:
Steffo 2024-04-20 03:49:32 +02:00
parent 466a263c41
commit e2bbbccfea
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
5 changed files with 23 additions and 3 deletions

View file

@ -3,7 +3,8 @@
[ext_resource type="Script" path="res://behaviours/draggable.gd" id="1_hdedq"]
[node name="Draggable" type="Area2D"]
collision_layer = 0
collision_layer = 8
collision_mask = 0
input_pickable = false
monitoring = false
script = ExtResource("1_hdedq")

View file

@ -12,3 +12,10 @@ func _ready() -> void:
func _on_move(movement: Vector2) -> void:
move_and_collide(movement)
sprite.handle_move(movement)
func _on_draggable_dragged() -> void:
collision_layer = 16
func _on_draggable_dropped() -> void:
collision_layer = 8

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://bc2bm8lbol18w"]
[gd_scene load_steps=21 format=3 uid="uid://bc2bm8lbol18w"]
[ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"]
[ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"]
@ -12,6 +12,7 @@
[ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="12_x2g3x"]
[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="13_5fkdr"]
[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="13_jf6em"]
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="14_0b1hs"]
[ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"]
[sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"]
@ -161,6 +162,13 @@ debug_color = Color(1, 1, 0, 0)
[node name="TargetPicker" parent="MovementRunFromHunter/HunterSense" node_paths=PackedStringArray("tracker") instance=ExtResource("13_jf6em")]
tracker = NodePath("..")
[node name="Draggable" parent="." instance=ExtResource("14_0b1hs")]
[node name="Shape" type="CollisionShape2D" parent="Draggable"]
scale = Vector2(3, 3)
shape = SubResource("CircleShape2D_c5tcn")
debug_color = Color(1, 1, 1, 0)
[connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"]
[connection signal="move" from="MovementIdle" to="." method="_on_move"]
[connection signal="move_disabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="stop"]
@ -186,3 +194,5 @@ tracker = NodePath("..")
[connection signal="tracked" from="MovementRunFromHunter/HunterSense" to="MovementRunFromHunter/HunterSense/TargetPicker" method="set_target_if_null"]
[connection signal="untracked" from="MovementRunFromHunter/HunterSense" to="MovementRunFromHunter/HunterSense/TargetPicker" method="clear_if_target"]
[connection signal="target_changed" from="MovementRunFromHunter/HunterSense/TargetPicker" to="MovementRunFromHunter" method="set_target" unbinds=1]
[connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"]
[connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"]

View file

@ -7,7 +7,7 @@ radius = 4.0
[node name="Cursor" type="Area2D" groups=["cursor"]]
collision_layer = 64
collision_mask = 0
collision_mask = 8
script = ExtResource("1_1og6v")
[node name="Shape" type="CollisionShape2D" parent="."]

View file

@ -893,4 +893,6 @@ max_secs = 9.0
shape = SubResource("CircleShape2D_h5qsh")
debug_color = Color(0, 1, 0, 0.152941)
[connection signal="dragged" from="Cursor" to="Cursor" method="log_dragging" unbinds=1]
[connection signal="dropped" from="Cursor" to="Cursor" method="log_dragging" unbinds=1]
[connection signal="timeout" from="Spawner/TimerStddev" to="Spawner" method="spawn"]