mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 15:44:23 +00:00
Tweak a few more things
This commit is contained in:
parent
4fbf8c6d8d
commit
4b3e05b74f
6 changed files with 43 additions and 35 deletions
|
@ -11,6 +11,9 @@ signal eaten(edible: Edible)
|
|||
@export var acceptable_diets: Array[StringName] = []
|
||||
|
||||
|
||||
func log_eaten(edible: Edible) -> void:
|
||||
Log.p(self, "Eaten: %s" % edible)
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
var edibles: Array = body.find_children("Edible", "Edible", false, false)
|
||||
|
@ -18,7 +21,3 @@ func _on_body_entered(body: Node2D) -> void:
|
|||
if edible.diet in acceptable_diets:
|
||||
eaten.emit(edible)
|
||||
edible.eat()
|
||||
|
||||
|
||||
func _on_eaten(edible: Edible) -> void:
|
||||
Log.p(self, "Eaten: %s" % edible)
|
||||
|
|
|
@ -9,4 +9,3 @@ monitorable = false
|
|||
script = ExtResource("1_urx5y")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="eaten" from="." to="." method="_on_eaten"]
|
||||
|
|
|
@ -17,7 +17,3 @@ func randomize_wait_time() -> void:
|
|||
Random.rng.randfn(mean_secs, deviation),
|
||||
max_secs
|
||||
)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
randomize_wait_time()
|
||||
|
|
|
@ -5,6 +5,9 @@ class_name Imp
|
|||
@onready var sprite: SpriteLeftRight = $"Sprite"
|
||||
|
||||
|
||||
func _on_move(movement:Vector2):
|
||||
func _on_move(movement: Vector2):
|
||||
move_and_collide(movement)
|
||||
sprite.handle_move(movement)
|
||||
|
||||
func _on_eater_eaten(edible: Edible) -> void:
|
||||
edible.get_parent().queue_free()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://4d3ksr3171x4"]
|
||||
[gd_scene load_steps=18 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,6 +13,7 @@
|
|||
[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://jg7qkbswgqjc" path="res://behaviours/eater.tscn" id="14_w2h8x"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"]
|
||||
radius = 8.0
|
||||
|
@ -20,6 +21,9 @@ radius = 8.0
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_1bmhf"]
|
||||
radius = 256.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_qhk1q"]
|
||||
radius = 40.0
|
||||
|
||||
[node name="Imp" type="CharacterBody2D"]
|
||||
collision_layer = 8
|
||||
collision_mask = 14
|
||||
|
@ -54,6 +58,7 @@ default_priority = 10
|
|||
alternative_priority = 10
|
||||
|
||||
[node name="ChangeDirectionTimer" parent="MovementWander" instance=ExtResource("10_phvea")]
|
||||
wait_time = 0.001
|
||||
autostart = true
|
||||
mean_secs = 2.0
|
||||
deviation = 2.0
|
||||
|
@ -61,6 +66,7 @@ min_secs = 0.6
|
|||
max_secs = 3.0
|
||||
|
||||
[node name="MovementHunt" parent="." instance=ExtResource("11_4ra22")]
|
||||
speed = 140.0
|
||||
enabled = false
|
||||
|
||||
[node name="HuntPriority" parent="MovementHunt" instance=ExtResource("9_2wb1b")]
|
||||
|
@ -76,12 +82,17 @@ 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="Eater" parent="." instance=ExtResource("14_w2h8x")]
|
||||
acceptable_diets = Array[StringName]([&"Meat"])
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="Eater"]
|
||||
shape = SubResource("CircleShape2D_qhk1q")
|
||||
debug_color = Color(1, 0, 0, 0)
|
||||
|
||||
[connection signal="timeout" from="CoinSpawner/Timer" to="CoinSpawner" method="spawn"]
|
||||
[connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"]
|
||||
[connection signal="changed_direction" from="MovementWander" to="MovementWander/WanderPriority" method="priority_conditional"]
|
||||
[connection signal="move" from="MovementWander" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="stop"]
|
||||
[connection signal="move_enabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="start"]
|
||||
[connection signal="priority_changed_no_args" from="MovementWander/WanderPriority" to="MovementSampler" method="enable"]
|
||||
[connection signal="timeout" from="MovementWander/ChangeDirectionTimer" to="MovementWander" method="randomize_direction"]
|
||||
[connection signal="changed_target" from="MovementHunt" to="MovementHunt/HuntPriority" method="priority_conditional"]
|
||||
|
@ -90,3 +101,4 @@ tracker = NodePath("..")
|
|||
[connection signal="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=1]
|
||||
[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="eaten" from="Eater" to="." method="_on_eater_eaten"]
|
||||
|
|
|
@ -131,30 +131,30 @@ one_shot = true
|
|||
min_secs = 0.3
|
||||
max_secs = 1.5
|
||||
|
||||
[node name="MovementRunFromHunter" parent="." instance=ExtResource("12_x2g3x")]
|
||||
speed = -66.0
|
||||
enabled = false
|
||||
|
||||
[node name="RunFromHunterPriority" parent="MovementRunFromHunter" instance=ExtResource("11_0jlmk")]
|
||||
alternative_priority = 30
|
||||
|
||||
[node name="HunterSense" parent="MovementRunFromHunter" instance=ExtResource("14_eqowb")]
|
||||
|
||||
[node name="TargetPicker" parent="MovementRunFromHunter/HunterSense" node_paths=PackedStringArray("tracker") instance=ExtResource("13_jf6em")]
|
||||
tracker = NodePath("..")
|
||||
|
||||
[node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")]
|
||||
speed = -66.0
|
||||
enabled = false
|
||||
|
||||
[node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")]
|
||||
alternative_priority = 40
|
||||
alternative_priority = 30
|
||||
|
||||
[node name="CursorSense" parent="MovementRunFromMouse" instance=ExtResource("13_5fkdr")]
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="MovementRunFromMouse/CursorSense"]
|
||||
shape = SubResource("CircleShape2D_etpf6")
|
||||
debug_color = Color(1, 0, 0, 0.0470588)
|
||||
debug_color = Color(1, 1, 0, 0)
|
||||
|
||||
[node name="MovementRunFromHunter" parent="." instance=ExtResource("12_x2g3x")]
|
||||
speed = -66.0
|
||||
enabled = false
|
||||
|
||||
[node name="RunFromHunterPriority" parent="MovementRunFromHunter" instance=ExtResource("11_0jlmk")]
|
||||
alternative_priority = 40
|
||||
|
||||
[node name="HunterSense" parent="MovementRunFromHunter" instance=ExtResource("14_eqowb")]
|
||||
|
||||
[node name="TargetPicker" parent="MovementRunFromHunter/HunterSense" node_paths=PackedStringArray("tracker") instance=ExtResource("13_jf6em")]
|
||||
tracker = NodePath("..")
|
||||
|
||||
[connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"]
|
||||
[connection signal="move" from="MovementIdle" to="." method="_on_move"]
|
||||
|
@ -168,17 +168,16 @@ debug_color = Color(1, 0, 0, 0.0470588)
|
|||
[connection signal="move_enabled" from="MovementWander" to="MovementWander/TiredTimer" method="start"]
|
||||
[connection signal="priority_changed_no_args" from="MovementWander/WanderPriority" to="MovementSampler" method="enable"]
|
||||
[connection signal="timeout" from="MovementWander/TiredTimer" to="MovementWander" method="clear_direction"]
|
||||
[connection signal="changed_target" from="MovementRunFromHunter" to="MovementRunFromHunter/RunFromHunterPriority" method="priority_conditional"]
|
||||
[connection signal="changed_target" from="MovementRunFromHunter" to="MovementRunFromHunter" method="log_target" unbinds=1]
|
||||
[connection signal="move" from="MovementRunFromHunter" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementRunFromHunter" to="MovementWander" method="clear_direction"]
|
||||
[connection signal="priority_changed_no_args" from="MovementRunFromHunter/RunFromHunterPriority" to="MovementSampler" method="enable"]
|
||||
[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="changed_target" from="MovementRunFromMouse" to="MovementRunFromMouse/RunFromMousePriority" method="priority_conditional"]
|
||||
[connection signal="move" from="MovementRunFromMouse" to="." method="_on_move"]
|
||||
[connection signal="move_enabled" from="MovementRunFromMouse" to="MovementWander" method="clear_direction"]
|
||||
[connection signal="priority_changed_no_args" from="MovementRunFromMouse/RunFromMousePriority" to="MovementSampler" method="enable"]
|
||||
[connection signal="cursor_entered" from="MovementRunFromMouse/CursorSense" to="MovementRunFromMouse" method="set_target"]
|
||||
[connection signal="cursor_exited" from="MovementRunFromMouse/CursorSense" to="MovementRunFromMouse" method="clear_target" unbinds=1]
|
||||
[connection signal="changed_target" from="MovementRunFromHunter" to="MovementRunFromHunter/RunFromHunterPriority" method="priority_conditional"]
|
||||
[connection signal="move" from="MovementRunFromHunter" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementRunFromHunter" to="MovementWander" method="clear_direction"]
|
||||
[connection signal="priority_changed_no_args" from="MovementRunFromHunter/RunFromHunterPriority" to="MovementSampler" method="enable"]
|
||||
[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]
|
||||
|
|
Loading…
Reference in a new issue