mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 23:54:23 +00:00
I got lost hunting for a bug and i forgor commits
This commit is contained in:
parent
9e85baa1cb
commit
496977996c
6 changed files with 77 additions and 40 deletions
|
@ -19,7 +19,7 @@ var target: Node2D:
|
||||||
if target != value:
|
if target != value:
|
||||||
var old = target
|
var old = target
|
||||||
target = value
|
target = value
|
||||||
target_changed.emit(old, target)
|
target_changed.emit(target, old)
|
||||||
|
|
||||||
|
|
||||||
func set_target(body: Node2D) -> void:
|
func set_target(body: Node2D) -> void:
|
||||||
|
@ -42,3 +42,7 @@ func sample_target() -> void:
|
||||||
func sample_target_if_null() -> void:
|
func sample_target_if_null() -> void:
|
||||||
if target == null:
|
if target == null:
|
||||||
sample_target()
|
sample_target()
|
||||||
|
|
||||||
|
|
||||||
|
func log_target() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
|
@ -17,7 +17,7 @@ func track(body: Node2D) -> bool:
|
||||||
tracking.push_back(body)
|
tracking.push_back(body)
|
||||||
tracked.emit(body)
|
tracked.emit(body)
|
||||||
# Handle TrackerTracker
|
# Handle TrackerTracker
|
||||||
for tracker_tracker in body.find_children("*", "TrackerTracker", false, false):
|
for tracker_tracker in body.find_children("*", "TrackerTracker", true, false):
|
||||||
tracker_tracker.track(self)
|
tracker_tracker.track(self)
|
||||||
return act
|
return act
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func untrack(body: Node2D) -> bool:
|
||||||
tracking.erase(body)
|
tracking.erase(body)
|
||||||
untracked.emit(body)
|
untracked.emit(body)
|
||||||
# Handle TrackerTracker
|
# Handle TrackerTracker
|
||||||
for tracker_tracker in body.find_children("*", "TrackerTracker", false, false):
|
for tracker_tracker in body.find_children("*", "TrackerTracker", true, false):
|
||||||
tracker_tracker.untrack(self)
|
tracker_tracker.untrack(self)
|
||||||
return act
|
return act
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ default_priority = 10
|
||||||
alternative_priority = 10
|
alternative_priority = 10
|
||||||
|
|
||||||
[node name="ChangeDirectionTimer" parent="MovementWander" instance=ExtResource("10_phvea")]
|
[node name="ChangeDirectionTimer" parent="MovementWander" instance=ExtResource("10_phvea")]
|
||||||
one_shot = true
|
|
||||||
autostart = true
|
autostart = true
|
||||||
mean_secs = 2.0
|
mean_secs = 2.0
|
||||||
deviation = 2.0
|
deviation = 2.0
|
||||||
|
@ -62,7 +61,6 @@ min_secs = 0.6
|
||||||
max_secs = 3.0
|
max_secs = 3.0
|
||||||
|
|
||||||
[node name="MovementHunt" parent="." instance=ExtResource("11_4ra22")]
|
[node name="MovementHunt" parent="." instance=ExtResource("11_4ra22")]
|
||||||
speed = -100.0
|
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="HuntPriority" parent="MovementHunt" instance=ExtResource("9_2wb1b")]
|
[node name="HuntPriority" parent="MovementHunt" instance=ExtResource("9_2wb1b")]
|
||||||
|
@ -84,11 +82,11 @@ tracker = NodePath("..")
|
||||||
[connection signal="move" from="MovementWander" to="." method="_on_move"]
|
[connection signal="move" from="MovementWander" to="." method="_on_move"]
|
||||||
[connection signal="move_disabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="stop"]
|
[connection signal="move_disabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="stop"]
|
||||||
[connection signal="move_enabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="start"]
|
[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="timeout" from="MovementWander/ChangeDirectionTimer" to="MovementWander" method="randomize_direction"]
|
||||||
[connection signal="changed_target" from="MovementHunt" to="MovementHunt/HuntPriority" method="priority_conditional"]
|
[connection signal="changed_target" from="MovementHunt" to="MovementHunt/HuntPriority" method="priority_conditional"]
|
||||||
[connection signal="move" from="MovementHunt" to="." method="_on_move"]
|
[connection signal="move" from="MovementHunt" to="." method="_on_move"]
|
||||||
[connection signal="priority_changed" from="MovementHunt/HuntPriority" to="MovementHunt/HuntPriority" method="log_priority" unbinds=2]
|
[connection signal="priority_changed_no_args" from="MovementHunt/HuntPriority" to="MovementSampler" method="enable"]
|
||||||
[connection signal="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=1]
|
[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="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" method="set_target" unbinds=1]
|
||||||
[connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=2]
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=19 format=3 uid="uid://bc2bm8lbol18w"]
|
[gd_scene load_steps=20 format=3 uid="uid://bc2bm8lbol18w"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"]
|
[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"]
|
[ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"]
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="12_c45uk"]
|
[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="12_c45uk"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="12_x2g3x"]
|
[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://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://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"]
|
[ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"]
|
||||||
|
@ -119,7 +120,7 @@ min_secs = 1.0
|
||||||
max_secs = 5.0
|
max_secs = 5.0
|
||||||
|
|
||||||
[node name="MovementWander" parent="." instance=ExtResource("10_05kcd")]
|
[node name="MovementWander" parent="." instance=ExtResource("10_05kcd")]
|
||||||
speed = 66.0
|
speed = 33.0
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")]
|
[node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")]
|
||||||
|
@ -130,12 +131,24 @@ one_shot = true
|
||||||
min_secs = 0.3
|
min_secs = 0.3
|
||||||
max_secs = 1.5
|
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")]
|
[node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")]
|
||||||
speed = -100.0
|
speed = -66.0
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")]
|
[node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")]
|
||||||
alternative_priority = 30
|
alternative_priority = 40
|
||||||
|
|
||||||
[node name="CursorSense" parent="MovementRunFromMouse" instance=ExtResource("13_5fkdr")]
|
[node name="CursorSense" parent="MovementRunFromMouse" instance=ExtResource("13_5fkdr")]
|
||||||
|
|
||||||
|
@ -143,14 +156,6 @@ alternative_priority = 30
|
||||||
shape = SubResource("CircleShape2D_etpf6")
|
shape = SubResource("CircleShape2D_etpf6")
|
||||||
debug_color = Color(1, 0, 0, 0.0470588)
|
debug_color = Color(1, 0, 0, 0.0470588)
|
||||||
|
|
||||||
[node name="MovementRunFromHunter" parent="." instance=ExtResource("12_x2g3x")]
|
|
||||||
speed = -100.0
|
|
||||||
enabled = false
|
|
||||||
|
|
||||||
[node name="RunFromHunterPriority" parent="MovementRunFromHunter" instance=ExtResource("11_0jlmk")]
|
|
||||||
|
|
||||||
[node name="HunterSense" parent="MovementRunFromHunter" instance=ExtResource("14_eqowb")]
|
|
||||||
|
|
||||||
[connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"]
|
[connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"]
|
||||||
[connection signal="move" from="MovementIdle" to="." method="_on_move"]
|
[connection signal="move" from="MovementIdle" to="." method="_on_move"]
|
||||||
[connection signal="move_disabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="stop"]
|
[connection signal="move_disabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="stop"]
|
||||||
|
@ -163,15 +168,17 @@ enabled = false
|
||||||
[connection signal="move_enabled" from="MovementWander" to="MovementWander/TiredTimer" method="start"]
|
[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="priority_changed_no_args" from="MovementWander/WanderPriority" to="MovementSampler" method="enable"]
|
||||||
[connection signal="timeout" from="MovementWander/TiredTimer" to="MovementWander" method="clear_direction"]
|
[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="changed_target" from="MovementRunFromMouse" to="MovementRunFromMouse/RunFromMousePriority" method="priority_conditional"]
|
||||||
[connection signal="move" from="MovementRunFromMouse" to="." method="_on_move"]
|
[connection signal="move" from="MovementRunFromMouse" to="." method="_on_move"]
|
||||||
[connection signal="move_enabled" from="MovementRunFromMouse" to="MovementWander" method="clear_direction"]
|
[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="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_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="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" method="set_target"]
|
|
||||||
[connection signal="untracked" from="MovementRunFromHunter/HunterSense" to="MovementRunFromHunter" method="clear_target" unbinds=1]
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ static var rng: RandomNumberGenerator = null:
|
||||||
|
|
||||||
static func sample(array: Array[Variant], imin = null, imax = null) -> Variant:
|
static func sample(array: Array[Variant], imin = null, imax = null) -> Variant:
|
||||||
if len(array) == 0:
|
if len(array) == 0:
|
||||||
|
Log.w(null, "Sampling from an empty array.")
|
||||||
return null
|
return null
|
||||||
if imin == null:
|
if imin == null:
|
||||||
imin = 0
|
imin = 0
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=10 format=3 uid="uid://cxj5aud02f40j"]
|
[gd_scene load_steps=11 format=3 uid="uid://cxj5aud02f40j"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/game/main_game.gd" id="1_wiglu"]
|
[ext_resource type="Script" path="res://scenes/game/main_game.gd" id="1_wiglu"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_db5xs"]
|
[ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_db5xs"]
|
||||||
|
@ -811,6 +811,8 @@ terrain_set_0/terrain_1/name = "Dirt"
|
||||||
terrain_set_0/terrain_1/color = Color(0.619608, 0.407843, 0.172549, 1)
|
terrain_set_0/terrain_1/color = Color(0.619608, 0.407843, 0.172549, 1)
|
||||||
sources/0 = SubResource("TileSetAtlasSource_058kb")
|
sources/0 = SubResource("TileSetAtlasSource_058kb")
|
||||||
|
|
||||||
|
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_htttx"]
|
||||||
|
|
||||||
[node name="MainGame" type="Node2D"]
|
[node name="MainGame" type="Node2D"]
|
||||||
script = ExtResource("1_wiglu")
|
script = ExtResource("1_wiglu")
|
||||||
|
|
||||||
|
@ -830,19 +832,44 @@ unique_name_in_owner = true
|
||||||
[node name="Cursor" parent="." instance=ExtResource("5_g504x")]
|
[node name="Cursor" parent="." instance=ExtResource("5_g504x")]
|
||||||
|
|
||||||
[node name="Sheep" parent="." instance=ExtResource("6_j2kdp")]
|
[node name="Sheep" parent="." instance=ExtResource("6_j2kdp")]
|
||||||
position = Vector2(-221, -32)
|
position = Vector2(-246, 25)
|
||||||
|
|
||||||
[node name="Sheep2" parent="." instance=ExtResource("6_j2kdp")]
|
|
||||||
position = Vector2(-187, 190)
|
|
||||||
|
|
||||||
[node name="Sheep3" parent="." instance=ExtResource("6_j2kdp")]
|
|
||||||
position = Vector2(230, 216)
|
|
||||||
|
|
||||||
[node name="Sheep4" parent="." instance=ExtResource("6_j2kdp")]
|
|
||||||
position = Vector2(307, -33)
|
|
||||||
|
|
||||||
[node name="Sheep5" parent="." instance=ExtResource("6_j2kdp")]
|
|
||||||
position = Vector2(182, -217)
|
|
||||||
|
|
||||||
[node name="Imp" parent="." instance=ExtResource("7_7od2n")]
|
[node name="Imp" parent="." instance=ExtResource("7_7od2n")]
|
||||||
position = Vector2(-65, -233)
|
position = Vector2(237, 10)
|
||||||
|
|
||||||
|
[node name="Walls" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="BottomBoundary" type="StaticBody2D" parent="Walls"]
|
||||||
|
position = Vector2(0, 360)
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="Walls/BottomBoundary"]
|
||||||
|
shape = SubResource("WorldBoundaryShape2D_htttx")
|
||||||
|
|
||||||
|
[node name="TopBoundary" type="StaticBody2D" parent="Walls"]
|
||||||
|
position = Vector2(0, -360)
|
||||||
|
rotation = 3.14159
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="Walls/TopBoundary"]
|
||||||
|
shape = SubResource("WorldBoundaryShape2D_htttx")
|
||||||
|
|
||||||
|
[node name="RightBoundary" type="StaticBody2D" parent="Walls"]
|
||||||
|
position = Vector2(640, 0)
|
||||||
|
rotation = 4.71239
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="Walls/RightBoundary"]
|
||||||
|
shape = SubResource("WorldBoundaryShape2D_htttx")
|
||||||
|
|
||||||
|
[node name="LeftBoundary" type="StaticBody2D" parent="Walls"]
|
||||||
|
position = Vector2(-640, 0)
|
||||||
|
rotation = 1.5708
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"]
|
||||||
|
shape = SubResource("WorldBoundaryShape2D_htttx")
|
||||||
|
|
Loading…
Reference in a new issue