mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 23:54:23 +00:00
Make Imp
Draggable
too!
This commit is contained in:
parent
9525b65ad8
commit
704c70b355
3 changed files with 50 additions and 6 deletions
|
@ -3,6 +3,7 @@ class_name Imp
|
|||
|
||||
|
||||
@onready var sprite: SpriteLeftRight = $"Sprite"
|
||||
@onready var eater: Eater = $"Eater"
|
||||
|
||||
|
||||
func _on_move(movement: Vector2):
|
||||
|
@ -11,3 +12,16 @@ func _on_move(movement: Vector2):
|
|||
|
||||
func _on_eater_eaten(edible: Edible) -> void:
|
||||
edible.get_parent().queue_free()
|
||||
|
||||
|
||||
func _on_draggable_dragged(_cursor: Cursor) -> void:
|
||||
collision_layer = 16
|
||||
collision_mask = 18
|
||||
z_index = 1
|
||||
eater.collision_mask = 16
|
||||
|
||||
func _on_draggable_dropped() -> void:
|
||||
collision_layer = 8
|
||||
collision_mask = 14
|
||||
z_index = 0
|
||||
eater.collision_mask = 8
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=18 format=3 uid="uid://4d3ksr3171x4"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://4d3ksr3171x4"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/imp.gd" id="1_dixpc"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="2_eqcdi"]
|
||||
|
@ -13,14 +13,19 @@
|
|||
[ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="11_4ra22"]
|
||||
[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="12_dr2oe"]
|
||||
[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="13_mwxuf"]
|
||||
[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="14_p3w0g"]
|
||||
[ext_resource type="PackedScene" uid="uid://jg7qkbswgqjc" path="res://behaviours/eater.tscn" id="14_w2h8x"]
|
||||
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="15_otrbh"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"]
|
||||
radius = 8.0
|
||||
radius = 32.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_1bmhf"]
|
||||
radius = 256.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_50iad"]
|
||||
radius = 32.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_qhk1q"]
|
||||
radius = 40.0
|
||||
|
||||
|
@ -37,7 +42,6 @@ left_texture = ExtResource("3_qda0k")
|
|||
right_texture = ExtResource("4_0sckn")
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2(4, 4)
|
||||
shape = SubResource("CircleShape2D_ide4n")
|
||||
|
||||
[node name="CoinSpawner" parent="." instance=ExtResource("4_d8lgm")]
|
||||
|
@ -50,7 +54,7 @@ min_secs = 1.0
|
|||
max_secs = 9.0
|
||||
|
||||
[node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("7_ech8d")]
|
||||
possibilities = [NodePath("../MovementWander/WanderPriority"), NodePath("../MovementHunt/HuntPriority")]
|
||||
possibilities = [NodePath("../MovementWander/WanderPriority"), NodePath("../MovementHunt/HuntPriority"), NodePath("../MovementDrag/DragPriority")]
|
||||
|
||||
[node name="MovementWander" parent="." instance=ExtResource("8_ffcw0")]
|
||||
speed = 25.0
|
||||
|
@ -84,6 +88,24 @@ debug_color = Color(1, 0.498039, 0, 0)
|
|||
[node name="TargetPicker" parent="MovementHunt/TrackerMeat" node_paths=PackedStringArray("tracker") instance=ExtResource("13_mwxuf")]
|
||||
tracker = NodePath("..")
|
||||
|
||||
[node name="MovementDrag" parent="." instance=ExtResource("14_p3w0g")]
|
||||
acceleration = 450.0
|
||||
linear_damp = 25.0
|
||||
enabled = false
|
||||
|
||||
[node name="DragPriority" parent="MovementDrag" instance=ExtResource("9_2wb1b")]
|
||||
alternative_priority = 50
|
||||
|
||||
[node name="Draggable" parent="MovementDrag" instance=ExtResource("15_otrbh")]
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"]
|
||||
shape = SubResource("CircleShape2D_50iad")
|
||||
debug_color = Color(1, 1, 1, 0)
|
||||
|
||||
[node name="FallTimer" type="Timer" parent="MovementDrag"]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[node name="Eater" parent="." instance=ExtResource("14_w2h8x")]
|
||||
acceptable_diets = Array[StringName]([&"Meat"])
|
||||
|
||||
|
@ -104,4 +126,14 @@ debug_color = Color(1, 0, 0, 0)
|
|||
[connection signal="untracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="clear_if_target"]
|
||||
[connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt" method="set_target" unbinds=1]
|
||||
[connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=2]
|
||||
[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_alternative" unbinds=1]
|
||||
[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"]
|
||||
[connection signal="fallen" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_default"]
|
||||
[connection signal="move" from="MovementDrag" to="." method="_on_move"]
|
||||
[connection signal="priority_changed_no_args" from="MovementDrag/DragPriority" to="MovementSampler" method="enable"]
|
||||
[connection signal="dragged" from="MovementDrag/Draggable" to="." method="_on_draggable_dragged"]
|
||||
[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"]
|
||||
[connection signal="dropped" from="MovementDrag/Draggable" to="." method="_on_draggable_dropped"]
|
||||
[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"]
|
||||
[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"]
|
||||
[connection signal="eaten" from="Eater" to="." method="_on_eater_eaten"]
|
||||
|
|
|
@ -164,8 +164,6 @@ debug_color = Color(1, 1, 0, 0)
|
|||
tracker = NodePath("..")
|
||||
|
||||
[node name="MovementDrag" parent="." instance=ExtResource("14_3wojv")]
|
||||
acceleration = 650.0
|
||||
linear_damp = 18.0
|
||||
enabled = false
|
||||
|
||||
[node name="DragPriority" parent="MovementDrag" instance=ExtResource("11_0jlmk")]
|
||||
|
|
Loading…
Reference in a new issue