From 446083dd7349656bdd984837e2f92010fc28ab7e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 01:44:06 +0200 Subject: [PATCH 01/83] Create `Cursor` matching mouse position on every physics timestep --- scenes/game/cursor.gd | 11 +++++++++++ scenes/game/cursor.tscn | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 scenes/game/cursor.gd create mode 100644 scenes/game/cursor.tscn diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd new file mode 100644 index 0000000..79bcc35 --- /dev/null +++ b/scenes/game/cursor.gd @@ -0,0 +1,11 @@ +extends Node2D +class_name Cursor + +## A [Node2D] syncing its position with the mouse on each physics timestep. + + +@onready var game := MainGame.get_ancestor(self) + + +func _physics_process(_delta: float) -> void: + global_position = game.camera.get_global_mouse_position() diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn new file mode 100644 index 0000000..e31c98e --- /dev/null +++ b/scenes/game/cursor.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://col1q3elvkfwk"] + +[ext_resource type="Script" path="res://scenes/game/cursor.gd" id="1_1og6v"] + +[node name="Cursor" type="Node2D"] +script = ExtResource("1_1og6v") From e2f4ad461e86f13f177e023be8480d9ef95dcdc7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 01:56:46 +0200 Subject: [PATCH 02/83] Refactor `HoverDetector` into `CursorDetector` --- behaviours/cursor_detector.gd | 21 +++++++++++++++++++ ...hover_detector.svg => cursor_detector.svg} | 0 ....svg.import => cursor_detector.svg.import} | 6 +++--- behaviours/cursor_detector.tscn | 12 +++++++++++ behaviours/hover_detector.gd | 13 ------------ behaviours/hover_detector.tscn | 11 ---------- 6 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 behaviours/cursor_detector.gd rename behaviours/{hover_detector.svg => cursor_detector.svg} (100%) rename behaviours/{hover_detector.svg.import => cursor_detector.svg.import} (73%) create mode 100644 behaviours/cursor_detector.tscn delete mode 100644 behaviours/hover_detector.gd delete mode 100644 behaviours/hover_detector.tscn diff --git a/behaviours/cursor_detector.gd b/behaviours/cursor_detector.gd new file mode 100644 index 0000000..367acb4 --- /dev/null +++ b/behaviours/cursor_detector.gd @@ -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) diff --git a/behaviours/hover_detector.svg b/behaviours/cursor_detector.svg similarity index 100% rename from behaviours/hover_detector.svg rename to behaviours/cursor_detector.svg diff --git a/behaviours/hover_detector.svg.import b/behaviours/cursor_detector.svg.import similarity index 73% rename from behaviours/hover_detector.svg.import rename to behaviours/cursor_detector.svg.import index b27371a..5467a48 100644 --- a/behaviours/hover_detector.svg.import +++ b/behaviours/cursor_detector.svg.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://6wpumqhdov4r" -path="res://.godot/imported/hover_detector.svg-3bfd5bde28e59dd82344da683ff70f2d.ctex" +path="res://.godot/imported/cursor_detector.svg-15ede4c1c6083de1d2f8a8ceb4ab532a.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://behaviours/hover_detector.svg" -dest_files=["res://.godot/imported/hover_detector.svg-3bfd5bde28e59dd82344da683ff70f2d.ctex"] +source_file="res://behaviours/cursor_detector.svg" +dest_files=["res://.godot/imported/cursor_detector.svg-15ede4c1c6083de1d2f8a8ceb4ab532a.ctex"] [params] diff --git a/behaviours/cursor_detector.tscn b/behaviours/cursor_detector.tscn new file mode 100644 index 0000000..c4b4fec --- /dev/null +++ b/behaviours/cursor_detector.tscn @@ -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"] diff --git a/behaviours/hover_detector.gd b/behaviours/hover_detector.gd deleted file mode 100644 index 616e72a..0000000 --- a/behaviours/hover_detector.gd +++ /dev/null @@ -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 diff --git a/behaviours/hover_detector.tscn b/behaviours/hover_detector.tscn deleted file mode 100644 index b6800b0..0000000 --- a/behaviours/hover_detector.tscn +++ /dev/null @@ -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"] From d222e8c066495ae932e18860aa01bbe337a088eb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 01:57:22 +0200 Subject: [PATCH 03/83] Refactor `MoveTowards` so that it only handles deciding a direction --- behaviours/move_towards.gd | 44 ++++++++---------------------- behaviours/move_towards.svg | 39 ++++++++++++++++++++++++++ behaviours/move_towards.svg.import | 37 +++++++++++++++++++++++++ behaviours/move_towards.tscn | 6 ++++ 4 files changed, 93 insertions(+), 33 deletions(-) create mode 100644 behaviours/move_towards.svg create mode 100644 behaviours/move_towards.svg.import create mode 100644 behaviours/move_towards.tscn diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index 952da47..e0593a5 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -1,44 +1,22 @@ +@icon("res://behaviours/move_towards.svg") extends Node2D class_name MoveTowards -signal move(movement: Vector2) -signal detached -signal captured +## A node emitting the [signal move] signal each physics timestep to move towards the position of [field target]. -@export var speed: float = 100.0 -@export var can_detach: bool = false +signal move(norm: Vector2) -enum State { DETACHED, CAPTURED } - -var state: State = State.DETACHED - -func get_followed_global_position(): - return Vector2.ZERO # OVERRIDE ME! +@export var target: Node2D = null -func get_followed_mouse_position(): - var global_followed_position: Vector2 = get_followed_global_position() - var relative_followed_position: Vector2 = global_followed_position - global_position - return relative_followed_position +func _ready() -> void: + if target == null: + Log.w(self, "No target is set, no signals will be emitted.") - -func _physics_process(delta: float) -> void: - match state: - State.CAPTURED: - var relative_followed_position: Vector2 = get_followed_mouse_position() - var direction: Vector2 = position.direction_to(relative_followed_position) - var actual_speed: float = min(delta * speed, relative_followed_position.length()) # Don't overshoot. - var movement: Vector2 = direction * actual_speed - move.emit(movement) - -func _on_capture_area_mouse_entered() -> void: - state = State.CAPTURED - captured.emit() - -func _on_capture_area_mouse_exited() -> void: - if can_detach: - state = State.DETACHED - detached.emit() +func _physics_process(_delta: float) -> void: + var gap = target.global_position - global_position + var norm = gap.normalized() + move.emit(norm) diff --git a/behaviours/move_towards.svg b/behaviours/move_towards.svg new file mode 100644 index 0000000..af25ecb --- /dev/null +++ b/behaviours/move_towards.svg @@ -0,0 +1,39 @@ + + + + + + + diff --git a/behaviours/move_towards.svg.import b/behaviours/move_towards.svg.import new file mode 100644 index 0000000..87cd989 --- /dev/null +++ b/behaviours/move_towards.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d10wobjiuh1mm" +path="res://.godot/imported/move_towards.svg-f5d5c8fa66b43d0301cc029ecee0a291.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/move_towards.svg" +dest_files=["res://.godot/imported/move_towards.svg-f5d5c8fa66b43d0301cc029ecee0a291.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/move_towards.tscn b/behaviours/move_towards.tscn new file mode 100644 index 0000000..41b4c4a --- /dev/null +++ b/behaviours/move_towards.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cml7rqvyfuagx"] + +[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_256ue"] + +[node name="MoveTowards" type="Node2D"] +script = ExtResource("1_256ue") From 2286009079ba1ff510b30e22f6df796ee912e0e7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 02:18:47 +0200 Subject: [PATCH 04/83] Add `Random.sample` function --- random.gd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/random.gd b/random.gd index 11f0915..a0a37a0 100644 --- a/random.gd +++ b/random.gd @@ -10,3 +10,12 @@ static var rng: RandomNumberGenerator = null: return rng set(value): rng = value + + +static func sample(array: Array[Variant], imin = null, imax = null) -> Variant: + if imin == null: + imin = 0 + if imax == null: + imax = len(array) - 1 + var idx = rng.randi_range(imin, imax) + return array[idx] From d0546fb5d140fc302809117882812a71dc318518 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 02:19:01 +0200 Subject: [PATCH 05/83] Place `Cursor` in the System collision layer --- scenes/game/cursor.tscn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index e31c98e..57db1e8 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -2,5 +2,7 @@ [ext_resource type="Script" path="res://scenes/game/cursor.gd" id="1_1og6v"] -[node name="Cursor" type="Node2D"] +[node name="Cursor" type="CharacterBody2D"] +collision_layer = 64 +collision_mask = 0 script = ExtResource("1_1og6v") From a3d98df9ff78b685ed4a3d8786ee878d54c6f4c2 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 02:47:31 +0200 Subject: [PATCH 06/83] Refactor movement and entity logic --- behaviours/ai_hunter_erratic.tscn | 23 ++++++++++++ behaviours/ai_hunter_latest.tscn | 19 ++++++++++ behaviours/ai_hunter_persistent.tscn | 19 ++++++++++ behaviours/ai_hunter_random.tscn | 23 ++++++++++++ behaviours/edible_tracker.gd | 26 ++----------- behaviours/edible_tracker.tscn | 11 ++++-- behaviours/hunt_target.gd | 55 ---------------------------- behaviours/hunt_target.tscn | 18 --------- behaviours/move_towards.gd | 14 +++++-- behaviours/move_towards_mouse.tscn | 2 +- behaviours/skitter_from_mouse.tscn | 2 +- behaviours/target_picker.gd | 44 ++++++++++++++++++++++ behaviours/target_picker.svg | 39 ++++++++++++++++++++ behaviours/target_picker.svg.import | 37 +++++++++++++++++++ behaviours/target_picker.tscn | 6 +++ behaviours/tracker.gd | 31 ++++++++++++++++ 16 files changed, 265 insertions(+), 104 deletions(-) create mode 100644 behaviours/ai_hunter_erratic.tscn create mode 100644 behaviours/ai_hunter_latest.tscn create mode 100644 behaviours/ai_hunter_persistent.tscn create mode 100644 behaviours/ai_hunter_random.tscn delete mode 100644 behaviours/hunt_target.gd delete mode 100644 behaviours/hunt_target.tscn create mode 100644 behaviours/target_picker.gd create mode 100644 behaviours/target_picker.svg create mode 100644 behaviours/target_picker.svg.import create mode 100644 behaviours/target_picker.tscn create mode 100644 behaviours/tracker.gd diff --git a/behaviours/ai_hunter_erratic.tscn b/behaviours/ai_hunter_erratic.tscn new file mode 100644 index 0000000..b901118 --- /dev/null +++ b/behaviours/ai_hunter_erratic.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=3 uid="uid://cgq2jkbrw1y0o"] + +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="1_h53ag"] +[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_h4v3e"] +[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_ucief"] + +[node name="AIHunterRandom" type="Node2D"] + +[node name="EdibleTracker" parent="." instance=ExtResource("1_h53ag")] + +[node name="Timer" type="Timer" parent="."] +wait_time = 2.4 +autostart = true + +[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("2_h4v3e")] +tracker = NodePath("../EdibleTracker") + +[node name="MoveTowards" type="Node2D" parent="."] +script = ExtResource("3_ucief") + +[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] +[connection signal="timeout" from="Timer" to="TargetPicker" method="sample_target"] +[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/ai_hunter_latest.tscn b/behaviours/ai_hunter_latest.tscn new file mode 100644 index 0000000..35f9a37 --- /dev/null +++ b/behaviours/ai_hunter_latest.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://cgnvp5bmtbpxr"] + +[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_demja"] +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="2_jlt4x"] +[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="3_lfvrb"] + +[node name="AIHunterLatest" type="Node2D"] + +[node name="EdibleTracker" parent="." instance=ExtResource("2_jlt4x")] + +[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("3_lfvrb")] +tracker = NodePath("../EdibleTracker") + +[node name="MoveTowards" type="Node2D" parent="."] +script = ExtResource("1_demja") + +[connection signal="tracked" from="EdibleTracker" to="TargetPicker" method="set_target"] +[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] +[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/ai_hunter_persistent.tscn b/behaviours/ai_hunter_persistent.tscn new file mode 100644 index 0000000..7574354 --- /dev/null +++ b/behaviours/ai_hunter_persistent.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://cpq0ubwun5wec"] + +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="1_j87ny"] +[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_w2vxl"] +[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_14yk3"] + +[node name="AIHunterLatest" type="Node2D"] + +[node name="EdibleTracker" parent="." instance=ExtResource("1_j87ny")] + +[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("2_w2vxl")] +tracker = NodePath("../EdibleTracker") + +[node name="MoveTowards" type="Node2D" parent="."] +script = ExtResource("3_14yk3") + +[connection signal="tracked" from="EdibleTracker" to="TargetPicker" method="set_target_if_null"] +[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] +[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/ai_hunter_random.tscn b/behaviours/ai_hunter_random.tscn new file mode 100644 index 0000000..e97f0d4 --- /dev/null +++ b/behaviours/ai_hunter_random.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=3 uid="uid://baiq3nu3p03rh"] + +[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_wlo1a"] +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="2_suoff"] +[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="3_0uxc2"] + +[node name="AIHunterRandom" type="Node2D"] + +[node name="EdibleTracker" parent="." instance=ExtResource("2_suoff")] + +[node name="Timer" type="Timer" parent="."] +wait_time = 2.4 +autostart = true + +[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("3_0uxc2")] +tracker = NodePath("../EdibleTracker") + +[node name="MoveTowards" type="Node2D" parent="."] +script = ExtResource("1_wlo1a") + +[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] +[connection signal="timeout" from="Timer" to="TargetPicker" method="sample_target_if_null"] +[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/edible_tracker.gd b/behaviours/edible_tracker.gd index bcf1bef..6580828 100644 --- a/behaviours/edible_tracker.gd +++ b/behaviours/edible_tracker.gd @@ -1,34 +1,16 @@ @icon("res://behaviours/edible_tracker.svg") -extends Area2D +extends Tracker class_name EdibleTracker ## Keeps track of what [Edible]s are inside the area. -signal tracked(body: Node2D) -signal untracked(body: Node2D) - - @export var acceptable_diets: Array[StringName] = [] -var tracking: Array = [] - -func _on_body_entered(body: Node2D) -> void: +func check_diet_then_track(body: Node2D) -> void: var edibles: Array = body.find_children("Edible", "Edible", false, false) for edible in edibles: if edible.tag in acceptable_diets: - tracking.push_back(body) - tracked.emit(body) - -func _on_body_exited(body: Node2D) -> void: - if body in tracking: - tracking.erase(body) - untracked.emit(body) - - -func _on_tracked(body: Node2D) -> void: - Log.p(self, "Tracking a new target: %s" % body) - -func _on_untracked(body:Node2D) -> void: - Log.p(self, "Not tracking anymore target: %s" % body) + track(body) + break diff --git a/behaviours/edible_tracker.tscn b/behaviours/edible_tracker.tscn index 2d75fbd..ebad30a 100644 --- a/behaviours/edible_tracker.tscn +++ b/behaviours/edible_tracker.tscn @@ -3,9 +3,12 @@ [ext_resource type="Script" path="res://behaviours/edible_tracker.gd" id="1_vo18u"] [node name="EdibleTracker" type="Area2D"] +collision_layer = 0 +collision_mask = 56 +monitorable = false script = ExtResource("1_vo18u") -[connection signal="body_entered" from="." to="." method="_on_body_entered"] -[connection signal="body_exited" from="." to="." method="_on_body_exited"] -[connection signal="tracked" from="." to="." method="_on_tracked"] -[connection signal="untracked" from="." to="." method="_on_untracked"] +[connection signal="body_entered" from="." to="." method="check_diet_then_track"] +[connection signal="body_exited" from="." to="." method="untrack"] +[connection signal="tracked" from="." to="." method="log_tracked"] +[connection signal="untracked" from="." to="." method="log_untracked"] diff --git a/behaviours/hunt_target.gd b/behaviours/hunt_target.gd deleted file mode 100644 index cdd7f9c..0000000 --- a/behaviours/hunt_target.gd +++ /dev/null @@ -1,55 +0,0 @@ -extends Node2D -class_name HuntTarget - - -signal target_selected(target: Node2D) -signal target_abandoned(target: Node2D) - - -@export var tag: StringName: - get: - return tag - set(value): - tag = value - if hunter != null: - hunter.tag = value - -@export var give_up_secs: float = 5.0 - -@onready var give_up_timer: Timer = $"GiveUpTimer" -@onready var hunter: Hunter = $"Hunter" - -var target: Node2D = null - - -func pick_new_target(): - if hunter.possible_targets.is_empty(): - return - - var idx = Random.rng.randi_range(0, len(hunter.possible_targets) - 1) - target = hunter.possible_targets[idx] - target_selected.emit(target) - give_up_timer.start(give_up_secs) - -func _ready(): - hunter.tag = tag - -func _on_hunter_tracked(_body: Node2D): - if target == null: - pick_new_target() - -func _on_hunter_untracked(body: Node2D): - if body == target: - target = null - target_abandoned.emit(body) - pick_new_target() - -func _on_give_up_timer_timeout() -> void: - target = null - pick_new_target() - -func _on_target_selected(body: Node2D) -> void: - Log.p(self, "Target selected: %s" % body) - -func _on_target_abandoned(body: Node2D) -> void: - Log.p(self, "Target abandoned: %s" % body) diff --git a/behaviours/hunt_target.tscn b/behaviours/hunt_target.tscn deleted file mode 100644 index dc8bf57..0000000 --- a/behaviours/hunt_target.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://dxmodn8mbvw0i"] - -[ext_resource type="Script" path="res://behaviours/hunt_target.gd" id="1_1ex7u"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="2_vjdtc"] - -[node name="HuntTarget" type="Node2D"] -script = ExtResource("1_1ex7u") -give_up_secs = null - -[node name="Hunter" parent="." instance=ExtResource("2_vjdtc")] - -[node name="GiveUpTimer" type="Timer" parent="."] - -[connection signal="target_abandoned" from="." to="." method="_on_target_abandoned"] -[connection signal="target_selected" from="." to="." method="_on_target_selected"] -[connection signal="tracked" from="Hunter" to="." method="_on_hunter_tracked"] -[connection signal="untracked" from="Hunter" to="." method="_on_hunter_untracked"] -[connection signal="timeout" from="GiveUpTimer" to="." method="_on_give_up_timer_timeout"] diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index e0593a5..2c24b82 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -12,11 +12,19 @@ signal move(norm: Vector2) @export var target: Node2D = null +func set_target(value: Node2D) -> void: + target = value + +func clear_target() -> void: + target = null + + func _ready() -> void: if target == null: Log.w(self, "No target is set, no signals will be emitted.") func _physics_process(_delta: float) -> void: - var gap = target.global_position - global_position - var norm = gap.normalized() - move.emit(norm) + if target: + var gap = target.global_position - global_position + var norm = gap.normalized() + move.emit(norm) diff --git a/behaviours/move_towards_mouse.tscn b/behaviours/move_towards_mouse.tscn index ab15a6f..b971d07 100644 --- a/behaviours/move_towards_mouse.tscn +++ b/behaviours/move_towards_mouse.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://bvrxvrjlo5130"] [ext_resource type="Script" path="res://behaviours/move_towards_mouse.gd" id="1_nbja1"] -[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/hover_detector.tscn" id="2_qru2e"] +[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="2_qru2e"] [node name="MoveTowardsMouse" type="Node2D"] script = ExtResource("1_nbja1") diff --git a/behaviours/skitter_from_mouse.tscn b/behaviours/skitter_from_mouse.tscn index 8984d7a..e931c06 100644 --- a/behaviours/skitter_from_mouse.tscn +++ b/behaviours/skitter_from_mouse.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://c1wqgyakaultt"] [ext_resource type="Script" path="res://behaviours/skitter_from_mouse.gd" id="1_ftcf8"] -[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/hover_detector.tscn" id="2_cuaq0"] +[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="2_cuaq0"] [node name="SkitterFromMouse" type="Node2D"] script = ExtResource("1_ftcf8") diff --git a/behaviours/target_picker.gd b/behaviours/target_picker.gd new file mode 100644 index 0000000..d2f2f72 --- /dev/null +++ b/behaviours/target_picker.gd @@ -0,0 +1,44 @@ +@icon("res://behaviours/target_picker.svg") +extends Node +class_name TargetPicker + + +## Pick a random target at random from [field Tracker.tracked], then emit it via [signal target_changed]. + + +signal target_changed(new: Node2D, old: Node2D) + + +@export var tracker: Tracker + + +var target: Node2D: + get: + return target + set(value): + if target != value: + var old = target + target = value + target_changed.emit(old, target) + + +func set_target(body: Node2D) -> void: + target = body + +func set_target_if_null(body: Node2D) -> void: + if target == null: + target = body + +func clear_target() -> void: + target = null + +func clear_if_target(body: Node2D) -> void: + if target == body: + clear_target() + +func sample_target() -> void: + target = Random.sample(tracker.tracking) + +func sample_target_if_null() -> void: + if target == null: + sample_target() diff --git a/behaviours/target_picker.svg b/behaviours/target_picker.svg new file mode 100644 index 0000000..d8fead7 --- /dev/null +++ b/behaviours/target_picker.svg @@ -0,0 +1,39 @@ + + + + + + + diff --git a/behaviours/target_picker.svg.import b/behaviours/target_picker.svg.import new file mode 100644 index 0000000..43feff3 --- /dev/null +++ b/behaviours/target_picker.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dd7uvjl416h2k" +path="res://.godot/imported/target_picker.svg-d96365c33742930a50d2b51102fd20f0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/target_picker.svg" +dest_files=["res://.godot/imported/target_picker.svg-d96365c33742930a50d2b51102fd20f0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/target_picker.tscn b/behaviours/target_picker.tscn new file mode 100644 index 0000000..8056ebd --- /dev/null +++ b/behaviours/target_picker.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dti7l0d40hhgt"] + +[ext_resource type="Script" path="res://behaviours/target_picker.gd" id="1_ldiw7"] + +[node name="TargetPicker" type="Node"] +script = ExtResource("1_ldiw7") diff --git a/behaviours/tracker.gd b/behaviours/tracker.gd new file mode 100644 index 0000000..111072f --- /dev/null +++ b/behaviours/tracker.gd @@ -0,0 +1,31 @@ +extends Area2D +class_name Tracker + +## Abstract base class for [Area2D]s tracking a certain subset of [Node2D]s. + + +signal tracked(body: Node2D) +signal untracked(body: Node2D) + +var tracking: Array = [] + + +func track(body: Node2D) -> bool: + var act: bool = not body in tracking + if act: + tracking.push_back(body) + tracked.emit(body) + return act + +func untrack(body: Node2D) -> bool: + var act: bool = body in tracking + if act: + tracking.erase(body) + untracked.emit(body) + return act + +func log_tracked(body: Node2D) -> void: + Log.p(self, "Tracking a new target: %s" % body) + +func log_untracked(body: Node2D) -> void: + Log.p(self, "Not tracking anymore target: %s" % body) From 10f17c1e9e8df0421fc9339ebc5c5031db575beb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 03:02:19 +0200 Subject: [PATCH 07/83] Refactor `Spawner` --- behaviours/spawner.gd | 17 +++++++------ behaviours/spawner.svg | 47 +++++++++++++++++++++++++++++++++++ behaviours/spawner.svg.import | 37 +++++++++++++++++++++++++++ scenes/game/main_game.gd | 1 + scenes/game/main_game.tscn | 35 +++----------------------- 5 files changed, 97 insertions(+), 40 deletions(-) create mode 100644 behaviours/spawner.svg create mode 100644 behaviours/spawner.svg.import diff --git a/behaviours/spawner.gd b/behaviours/spawner.gd index b1c9d6e..2d8319a 100644 --- a/behaviours/spawner.gd +++ b/behaviours/spawner.gd @@ -1,19 +1,20 @@ +@icon("res://behaviours/spawner.svg") extends Node2D class_name Spawner signal spawned(entity: Node2D) @export var scene: PackedScene -@export var parent: Node2D +@export var default_target: Node2D -func spawn(): + +func spawn(target: Node2D = null): + if not target: + target = default_target + if not target: + target = MainGame.get_ancestor(self).default_spawn_parent var entity = scene.instantiate() entity.global_scale = global_scale entity.global_position = global_position entity.global_rotation = global_rotation - parent.add_child.call_deferred(entity) # Not sure why this is needed. - -func _ready(): - if parent == null: - parent = MainGame.get_ancestor(self).get_node("SpawnedEntities") - + target.add_child.call_deferred(entity) # Not sure why this is needed. diff --git a/behaviours/spawner.svg b/behaviours/spawner.svg new file mode 100644 index 0000000..1396658 --- /dev/null +++ b/behaviours/spawner.svg @@ -0,0 +1,47 @@ + + + + + + + + + diff --git a/behaviours/spawner.svg.import b/behaviours/spawner.svg.import new file mode 100644 index 0000000..85aa700 --- /dev/null +++ b/behaviours/spawner.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://2okawpk7lh5j" +path="res://.godot/imported/spawner.svg-02e649ce51fee431d04ebb532f1c81e8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/spawner.svg" +dest_files=["res://.godot/imported/spawner.svg-02e649ce51fee431d04ebb532f1c81e8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/scenes/game/main_game.gd b/scenes/game/main_game.gd index 76ba8a4..19df7f0 100644 --- a/scenes/game/main_game.gd +++ b/scenes/game/main_game.gd @@ -15,3 +15,4 @@ static func get_ancestor(start: Node) -> MainGame: @onready var gold_counter: Counter = $"GoldCounter" @onready var camera: GameCamera = $"GameCamera" +@onready var default_spawn_parent: Node2D = %"DefaultSpawnParent" diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 2878937..045553f 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,14 +1,10 @@ -[gd_scene load_steps=14 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=9 format=3 uid="uid://cxj5aud02f40j"] [ext_resource type="Script" path="res://scenes/game/main_game.gd" id="1_wiglu"] -[ext_resource type="PackedScene" path="res://behaviours/spawner.tscn" id="2_bx37o"] [ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_db5xs"] [ext_resource type="Texture2D" uid="uid://d13j4br4hxek6" path="res://scenes/game/tileset_grass.png" id="2_o7bg5"] [ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="3_p6jw3"] -[ext_resource type="PackedScene" uid="uid://eqb3vfbvjefp" path="res://entities/cloud.tscn" id="3_whlmm"] [ext_resource type="PackedScene" uid="uid://7j1b55t8tafg" path="res://scenes/game/cursor_magnet.tscn" id="3_xbolm"] -[ext_resource type="Texture2D" uid="uid://dyvkvmw7wxwe5" path="res://icon.svg" id="9_8kxq4"] -[ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="10_26rf6"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -816,9 +812,6 @@ sources/0 = SubResource("TileSetAtlasSource_058kb") [sub_resource type="RectangleShape2D" id="RectangleShape2D_p1lg5"] size = Vector2(1280, 720) -[sub_resource type="CircleShape2D" id="CircleShape2D_3du4x"] -radius = 29.14 - [node name="MainGame" type="Node2D"] script = ExtResource("1_wiglu") @@ -828,10 +821,6 @@ tile_set = SubResource("TileSet_g2dkm") format = 2 layer_0/tile_data = PackedInt32Array(720915, 196608, 9, 655379, 0, 2, 589843, 0, 4, 524307, 196608, 8, 458771, 196608, 0, 393235, 327680, 1, 327699, 327680, 2, 262163, 65536, 5, 196627, 327680, 0, 131091, 196608, 4, 65555, 0, 6, 19, 0, 6, -65517, 0, 6, -131053, 196608, 1, -196589, 327680, 2, -262125, 327680, 4, -327661, 327680, 1, -393197, 0, 3, -458733, 65536, 0, -524269, 196608, 0, -589805, 327680, 0, -655341, 0, 3, -720877, 327680, 5, -786413, 131072, 8, 720914, 327680, 1, 655378, 65536, 5, 589842, 327680, 0, 524306, 0, 5, 458770, 327680, 2, 393234, 327680, 1, 327698, 131072, 9, 262162, 327680, 0, 196626, 0, 4, 131090, 262144, 6, 65554, 196608, 2, 18, 131072, 3, -65518, 196608, 3, -131054, 196608, 1, -196590, 196608, 9, -262126, 327680, 4, -327662, 0, 4, -393198, 131072, 5, -458734, 262144, 5, -524270, 131072, 9, -589806, 0, 1, -655342, 65536, 5, -720878, 327680, 4, -786414, 262144, 0, 720913, 0, 5, 655377, 131072, 9, 589841, 196608, 9, 524305, 327680, 5, 458769, 0, 4, 393233, 0, 4, 327697, 327680, 5, 262161, 327680, 0, 196625, 262144, 4, 131089, 0, 6, 65553, 131072, 3, 17, 196608, 3, -65519, 196608, 2, -131055, 131072, 11, -196591, 327680, 1, -262127, 196608, 9, -327663, 0, 5, -393199, 262144, 0, -458735, 131072, 0, -524271, 0, 4, -589807, 0, 1, -655343, 327680, 5, -720879, 0, 3, -786415, 131072, 5, 720912, 131072, 9, 655376, 0, 2, 589840, 327680, 3, 524304, 131072, 8, 458768, 196608, 9, 393232, 196608, 5, 327696, 327680, 4, 262160, 262144, 5, 196624, 262144, 6, 131088, 196608, 3, 65552, 196608, 2, 16, 196608, 3, -65520, 131072, 2, -131056, 131072, 11, -196592, 327680, 0, -262128, 196608, 9, -327664, 262144, 0, -393200, 0, 1, -458736, 0, 5, -524272, 262144, 5, -589808, 196608, 8, -655344, 0, 2, -720880, 327680, 2, -786416, 131072, 0, 720911, 196608, 0, 655375, 327680, 2, 589839, 196608, 0, 524303, 0, 0, 458767, 0, 2, 393231, 196608, 5, 327695, 0, 5, 262159, 262144, 4, 196623, 0, 6, 131087, 131072, 2, 65551, 196608, 2, 15, 196608, 3, -65521, 131072, 2, -131057, 131072, 11, -196593, 0, 2, -262129, 262144, 0, -327665, 262144, 5, -393201, 327680, 0, -458737, 65536, 5, -524273, 196608, 5, -589809, 0, 4, -655345, 327680, 2, -720881, 0, 1, -786417, 0, 5, 720910, 131072, 0, 655374, 327680, 3, 589838, 327680, 4, 524302, 196608, 0, 458766, 327680, 0, 393230, 327680, 3, 327694, 262144, 4, 262158, 0, 6, 196622, 131072, 3, 131086, 131072, 3, 65550, 196608, 2, 14, 196608, 3, -65522, 131072, 2, -131058, 262144, 11, -196594, 65536, 0, -262130, 196608, 5, -327666, 0, 3, -393202, 327680, 3, -458738, 327680, 4, -524274, 131072, 0, -589810, 327680, 3, -655346, 131072, 0, -720882, 65536, 5, -786418, 0, 0, 720909, 131072, 9, 655373, 0, 1, 589837, 262144, 0, 524301, 0, 2, 458765, 0, 0, 393229, 196608, 0, 327693, 65536, 6, 262157, 196608, 2, 196621, 196608, 2, 131085, 131072, 3, 65549, 131072, 2, 13, 131072, 3, -65523, 196608, 2, -131059, 131072, 11, -196595, 262144, 0, -262131, 327680, 1, -327667, 196608, 9, -393203, 65536, 0, -458739, 65536, 0, -524275, 196608, 0, -589811, 0, 2, -655347, 327680, 1, -720883, 0, 4, -786419, 327680, 2, 720908, 262144, 5, 655372, 327680, 4, 589836, 196608, 8, 524300, 0, 3, 458764, 262144, 5, 393228, 262144, 4, 327692, 0, 6, 262156, 131072, 3, 196620, 131072, 2, 131084, 196608, 2, 65548, 131072, 3, 12, 196608, 3, -65524, 327680, 11, -131060, 65536, 1, -196596, 262144, 5, -262132, 131072, 9, -327668, 327680, 1, -393204, 327680, 0, -458740, 0, 3, -524276, 0, 3, -589812, 196608, 9, -655348, 327680, 2, -720884, 131072, 9, -786420, 131072, 0, 720907, 327680, 0, 655371, 65536, 0, 589835, 327680, 2, 524299, 262144, 5, 458763, 65536, 0, 393227, 196608, 6, 327691, 196608, 2, 262155, 131072, 3, 196619, 131072, 2, 131083, 131072, 2, 65547, 196608, 3, 11, 196608, 2, -65525, 262144, 11, -131061, 65536, 5, -196597, 196608, 9, -262133, 131072, 5, -327669, 327680, 5, -393205, 262144, 0, -458741, 0, 0, -524277, 0, 1, -589813, 0, 4, -655349, 327680, 4, -720885, 196608, 0, -786421, 0, 2, 720906, 327680, 4, 655370, 0, 4, 589834, 327680, 2, 524298, 327680, 4, 458762, 131072, 8, 393226, 131072, 4, 327690, 131072, 3, 262154, 196608, 2, 196618, 196608, 3, 131082, 131072, 2, 65546, 131072, 3, 10, 327680, 11, -65526, 65536, 1, -131062, 196608, 0, -196598, 196608, 0, -262134, 196608, 0, -327670, 131072, 8, -393206, 327680, 4, -458742, 327680, 4, -524278, 0, 1, -589814, 0, 0, -655350, 0, 3, -720886, 0, 3, -786422, 327680, 5, 720905, 327680, 0, 655369, 0, 0, 589833, 196608, 0, 524297, 196608, 0, 458761, 0, 1, 393225, 196608, 4, 327689, 196608, 3, 262153, 131072, 3, 196617, 196608, 2, 131081, 196608, 3, 65545, 327680, 11, 9, 65536, 1, -65527, 131072, 9, -131063, 0, 0, -196599, 327680, 0, -262135, 0, 3, -327671, 327680, 1, -393207, 65536, 5, -458743, 196608, 8, -524279, 327680, 3, -589815, 0, 1, -655351, 262144, 0, -720887, 262144, 0, -786423, 196608, 0, 720904, 0, 1, 655368, 262144, 5, 589832, 196608, 5, 524296, 0, 5, 458760, 262144, 4, 393224, 0, 6, 327688, 131072, 3, 262152, 196608, 3, 196616, 196608, 2, 131080, 131072, 2, 65544, 0, 11, 8, 327680, 3, -65528, 262144, 5, -131064, 65536, 5, -196600, 131072, 8, -262136, 327680, 5, -327672, 327680, 1, -393208, 0, 4, -458744, 131072, 0, -524280, 327680, 4, -589816, 131072, 0, -655352, 196608, 5, -720888, 327680, 3, -786424, 196608, 5, 720903, 327680, 5, 655367, 0, 5, 589831, 0, 5, 524295, 65536, 0, 458759, 196608, 4, 393223, 131072, 2, 327687, 196608, 2, 262151, 131072, 2, 196615, 196608, 3, 131079, 131072, 3, 65543, 131072, 3, 7, 262144, 5, -65529, 327680, 3, -131065, 196608, 5, -196601, 0, 2, -262137, 327680, 0, -327673, 327680, 1, -393209, 262144, 4, -458745, 0, 8, -524281, 262144, 3, -589817, 262144, 1, -655353, 327680, 5, -720889, 131072, 8, -786425, 0, 4, 720902, 327680, 2, 655366, 0, 3, 589830, 65536, 0, 524294, 0, 5, 458758, 131072, 4, 393222, 131072, 2, 327686, 196608, 3, 262150, 196608, 2, 196614, 131072, 2, 131078, 131072, 3, 65542, 131072, 3, 6, 327680, 5, -65530, 327680, 5, -131066, 327680, 0, -196602, 131072, 9, -262138, 262144, 4, -327674, 0, 8, -393210, 0, 6, -458746, 131072, 3, -524282, 327680, 11, -589818, 65536, 1, -655354, 0, 0, -720890, 327680, 2, -786426, 196608, 9, 720901, 65536, 5, 655365, 196608, 5, 589829, 196608, 0, 524293, 0, 4, 458757, 196608, 4, 393221, 131072, 2, 327685, 196608, 2, 262149, 131072, 2, 196613, 131072, 3, 131077, 131072, 2, 65541, 196608, 2, 5, 0, 3, -65531, 196608, 0, -131067, 327680, 4, -196603, 327680, 0, -262139, 131072, 6, -327675, 131072, 3, -393211, 196608, 3, -458747, 131072, 3, -524283, 196608, 11, -589819, 0, 2, -655355, 327680, 0, -720891, 131072, 9, -786427, 262144, 5, 720900, 196608, 0, 655364, 196608, 8, 589828, 0, 2, 524292, 327680, 0, 458756, 65536, 6, 393220, 131072, 3, 327684, 131072, 2, 262148, 196608, 3, 196612, 196608, 3, 131076, 196608, 2, 65540, 131072, 3, 4, 0, 3, -65532, 262144, 0, -131068, 131072, 0, -196604, 327680, 0, -262140, 65536, 6, -327676, 196608, 3, -393212, 131072, 2, -458748, 327680, 11, -524284, 65536, 1, -589820, 196608, 0, -655356, 0, 4, -720892, 65536, 5, -786428, 0, 1, 720899, 65536, 0, 655363, 131072, 5, 589827, 131072, 5, 524291, 0, 1, 458755, 65536, 4, 393219, 327680, 6, 327683, 196608, 2, 262147, 196608, 2, 196611, 131072, 3, 131075, 327680, 11, 65539, 327680, 8, 3, 0, 1, -65533, 131072, 0, -131069, 327680, 2, -196605, 65536, 0, -262141, 65536, 4, -327677, 327680, 10, -393213, 65536, 2, -458749, 65536, 1, -524285, 327680, 2, -589821, 0, 3, -655357, 131072, 9, -720893, 0, 2, -786429, 196608, 9, 720898, 131072, 0, 655362, 262144, 0, 589826, 327680, 5, 524290, 327680, 1, 458754, 262144, 0, 393218, 196608, 4, 327682, 196608, 2, 262146, 131072, 3, 196610, 196608, 2, 131074, 131072, 11, 65538, 327680, 4, 2, 0, 3, -65534, 0, 1, -131070, 0, 0, -196606, 327680, 0, -262142, 0, 5, -327678, 65536, 0, -393214, 65536, 5, -458750, 131072, 9, -524286, 196608, 0, -589822, 196608, 0, -655358, 0, 5, -720894, 196608, 9, -786430, 0, 5, 720897, 0, 4, 655361, 262144, 5, 589825, 327680, 0, 524289, 327680, 5, 458753, 327680, 5, 393217, 131072, 6, 327681, 131072, 2, 262145, 196608, 3, 196609, 131072, 2, 131073, 131072, 11, 65537, 131072, 9, 1, 0, 4, -65535, 196608, 0, -131071, 327680, 3, -196607, 196608, 0, -262143, 0, 4, -327679, 262144, 5, -393215, 196608, 5, -458751, 0, 2, -524287, 196608, 9, -589823, 196608, 0, -655359, 131072, 0, -720895, 0, 3, -786431, 196608, 8, 720896, 262144, 5, 655360, 0, 4, 589824, 0, 2, 524288, 0, 0, 458752, 196608, 9, 393216, 196608, 4, 327680, 196608, 3, 262144, 131072, 3, 196608, 131072, 3, 131072, 0, 11, 65536, 327680, 3, 0, 65536, 0, -65536, 196608, 5, -131072, 196608, 9, -196608, 65536, 0, -262144, 0, 5, -327680, 65536, 0, -393216, 0, 3, -458752, 327680, 0, -524288, 0, 3, -589824, 327680, 2, -655360, 131072, 8, -720896, 327680, 3, -786432, 196608, 8, 786431, 0, 3, 720895, 131072, 0, 655359, 196608, 8, 589823, 196608, 8, 524287, 327680, 0, 458751, 196608, 4, 393215, 131072, 3, 327679, 131072, 3, 262143, 196608, 3, 196607, 131072, 3, 131071, 262144, 0, 65535, 131072, 8, -1, 0, 0, -65537, 327680, 3, -131073, 131072, 9, -196609, 327680, 0, -262145, 131072, 0, -327681, 0, 0, -393217, 131072, 9, -458753, 196608, 8, -524289, 327680, 5, -589825, 0, 1, -655361, 196608, 0, -720897, 196608, 8, 786430, 327680, 3, 720894, 65536, 0, 655358, 262144, 0, 589822, 327680, 2, 524286, 131072, 0, 458750, 131072, 4, 393214, 131072, 2, 327678, 196608, 2, 262142, 131072, 2, 196606, 327680, 11, 131070, 327680, 2, 65534, 196608, 0, -2, 65536, 5, -65538, 196608, 8, -131074, 327680, 3, -196610, 131072, 8, -262146, 327680, 1, -327682, 262144, 5, -393218, 0, 1, -458754, 327680, 4, -524290, 262144, 5, -589826, 327680, 4, -655362, 327680, 1, -720898, 131072, 8, 786429, 0, 5, 720893, 0, 4, 655357, 196608, 5, 589821, 0, 4, 524285, 262144, 0, 458749, 262144, 6, 393213, 131072, 3, 327677, 131072, 2, 262141, 327680, 11, 196605, 65536, 1, 131069, 327680, 3, 65533, 0, 3, -3, 327680, 1, -65539, 327680, 4, -131075, 131072, 5, -196611, 262144, 4, -262147, 0, 10, -327683, 262144, 1, -393219, 196608, 8, -458755, 196608, 9, -524291, 0, 2, -589827, 262144, 0, -655363, 327680, 4, -720899, 327680, 4, 786428, 131072, 9, 720892, 131072, 0, 655356, 0, 5, 589820, 262144, 4, 524284, 0, 8, 458748, 0, 6, 393212, 131072, 3, 327676, 196608, 2, 262140, 196608, 11, 196604, 65536, 0, 131068, 196608, 0, 65532, 65536, 0, -4, 131072, 8, -65540, 196608, 5, -131076, 0, 2, -196612, 65536, 6, -262148, 196608, 2, -327684, 262144, 11, -393220, 0, 0, -458756, 131072, 9, -524292, 65536, 5, -589828, 131072, 0, -655364, 0, 2, -720900, 0, 0, 786427, 0, 3, 720891, 327680, 2, 655355, 0, 0, 589819, 65536, 6, 524283, 196608, 3, 458747, 131072, 2, 393211, 131072, 3, 327675, 327680, 11, 262139, 65536, 1, 196603, 131072, 0, 131067, 327680, 5, 65531, 0, 1, -5, 131072, 9, -65541, 196608, 5, -131077, 131072, 8, -196613, 262144, 6, -262149, 196608, 2, -327685, 0, 11, -393221, 262144, 1, -458757, 327680, 2, -524293, 196608, 0, -589829, 131072, 5, -655365, 262144, 0, -720901, 0, 4, 786426, 131072, 9, 720890, 262144, 0, 655354, 0, 0, 589818, 131072, 6, 524282, 196608, 2, 458746, 196608, 3, 393210, 196608, 3, 327674, 131072, 1, 262138, 196608, 5, 196602, 262144, 0, 131066, 196608, 8, 65530, 327680, 3, -6, 327680, 5, -65542, 0, 4, -131078, 196608, 8, -196614, 262144, 6, -262150, 131072, 3, -327686, 131072, 2, -393222, 196608, 1, -458758, 262144, 5, -524294, 0, 4, -589830, 131072, 5, -655366, 0, 5, -720902, 327680, 2, 786425, 0, 4, 720889, 0, 1, 655353, 0, 0, 589817, 131072, 6, 524281, 196608, 2, 458745, 131072, 2, 393209, 196608, 2, 327673, 262144, 11, 262137, 0, 0, 196601, 327680, 5, 131065, 65536, 0, 65529, 131072, 9, -7, 131072, 8, -65543, 131072, 0, -131079, 262144, 4, -196615, 0, 6, -262151, 131072, 3, -327687, 131072, 3, -393223, 0, 11, -458759, 262144, 1, -524295, 327680, 4, -589831, 262144, 5, -655367, 131072, 8, -720903, 0, 5, 786424, 327680, 3, 720888, 196608, 5, 655352, 131072, 9, 589816, 131072, 6, 524280, 196608, 2, 458744, 196608, 2, 393208, 196608, 2, 327672, 196608, 1, 262136, 0, 3, 196600, 0, 2, 131064, 327680, 0, 65528, 0, 5, -8, 0, 1, -65544, 196608, 5, -131080, 196608, 6, -196616, 131072, 3, -262152, 196608, 3, -327688, 196608, 3, -393224, 131072, 3, -458760, 196608, 1, -524296, 0, 3, -589832, 131072, 9, -655368, 0, 4, -720904, 131072, 5, 786423, 0, 0, 720887, 131072, 8, 655351, 0, 9, 589815, 0, 6, 524279, 196608, 2, 458743, 196608, 3, 393207, 131072, 2, 327671, 131072, 1, 262135, 0, 1, 196599, 196608, 8, 131063, 262144, 5, 65527, 262144, 5, -9, 0, 5, -65545, 262144, 4, -131081, 0, 6, -196617, 196608, 3, -262153, 196608, 3, -327689, 131072, 2, -393225, 196608, 2, -458761, 65536, 11, -524297, 131072, 8, -589833, 196608, 0, -655369, 196608, 9, -720905, 196608, 0, 786422, 196608, 9, 720886, 327680, 1, 655350, 327680, 6, 589814, 196608, 3, 524278, 131072, 2, 458742, 131072, 3, 393206, 327680, 11, 327670, 131072, 1, 262134, 131072, 9, 196598, 327680, 4, 131062, 0, 1, 65526, 196608, 9, -10, 65536, 5, -65546, 65536, 4, -131082, 327680, 6, -196618, 196608, 3, -262154, 131072, 3, -327690, 131072, 3, -393226, 327680, 11, -458762, 65536, 1, -524298, 0, 1, -589834, 196608, 9, -655370, 327680, 5, -720906, 327680, 5, 786421, 0, 0, 720885, 327680, 3, 655349, 262144, 6, 589813, 131072, 2, 524277, 196608, 3, 458741, 327680, 11, 393205, 65536, 1, 327669, 196608, 9, 262133, 0, 1, 196597, 327680, 0, 131061, 0, 5, 65525, 131072, 0, -11, 327680, 0, -65547, 131072, 0, -131083, 65536, 4, -196619, 327680, 9, -262155, 327680, 9, -327691, 327680, 7, -393227, 65536, 1, -458763, 327680, 4, -524299, 327680, 5, -589835, 196608, 8, -655371, 0, 3, -720907, 196608, 0, 786420, 131072, 0, 720884, 262144, 4, 655348, 0, 6, 589812, 131072, 2, 524276, 196608, 3, 458740, 131072, 11, 393204, 327680, 5, 327668, 196608, 9, 262132, 196608, 9, 196596, 65536, 5, 131060, 196608, 5, 65524, 131072, 8, -12, 65536, 5, -65548, 65536, 5, -131084, 262144, 5, -196620, 0, 1, -262156, 327680, 5, -327692, 0, 4, -393228, 196608, 0, -458764, 327680, 1, -524300, 65536, 0, -589836, 0, 5, -655372, 262144, 0, -720908, 327680, 4, 786419, 131072, 0, 720883, 262144, 6, 655347, 131072, 3, 589811, 131072, 2, 524275, 196608, 3, 458739, 131072, 1, 393203, 196608, 0, 327667, 0, 5, 262131, 0, 3, 196595, 0, 5, 131059, 196608, 5, 65523, 262144, 0, -13, 131072, 5, -65549, 327680, 2, -131085, 0, 5, -196621, 196608, 9, -262157, 0, 3, -327693, 131072, 8, -393229, 131072, 9, -458765, 65536, 5, -524301, 327680, 0, -589837, 65536, 0, -655373, 0, 2, -720909, 131072, 8, 786418, 327680, 5, 720882, 262144, 6, 655346, 196608, 2, 589810, 131072, 3, 524274, 131072, 2, 458738, 262144, 11, 393202, 196608, 5, 327666, 262144, 0, 262130, 262144, 0, 196594, 327680, 0, 131058, 327680, 1, 65522, 65536, 0, -14, 65536, 5, -65550, 327680, 0, -131086, 0, 0, -196622, 131072, 5, -262158, 327680, 2, -327694, 0, 3, -393230, 0, 0, -458766, 327680, 1, -524302, 327680, 1, -589838, 131072, 5, -655374, 131072, 8, -720910, 65536, 0, 786417, 262144, 4, 720881, 0, 6, 655345, 196608, 2, 589809, 196608, 2, 524273, 196608, 2, 458737, 131072, 1, 393201, 196608, 9, 327665, 65536, 0, 262129, 131072, 8, 196593, 0, 5, 131057, 0, 3, 65521, 196608, 0, -15, 131072, 5, -65551, 327680, 5, -131087, 0, 5, -196623, 131072, 9, -262159, 196608, 5, -327695, 0, 5, -393231, 0, 0, -458767, 0, 2, -524303, 131072, 0, -589839, 196608, 9, -655375, 262144, 5, -720911, 327680, 3, 786416, 196608, 2, 720880, 131072, 2, 655344, 196608, 3, 589808, 196608, 2, 524272, 327680, 11, 458736, 65536, 1, 393200, 0, 5, 327664, 131072, 0, 262128, 196608, 9, 196592, 65536, 0, 131056, 65536, 5, 65520, 327680, 1, -16, 131072, 9, -65552, 327680, 0, -131088, 0, 3, -196624, 327680, 0, -262160, 327680, 3, -327696, 65536, 0, -393232, 196608, 9, -458768, 65536, 0, -524304, 0, 0, -589840, 327680, 2, -655376, 327680, 3, -720912, 0, 5, 786415, 196608, 2, 720879, 131072, 3, 655343, 131072, 2, 589807, 196608, 2, 524271, 65536, 11, 458735, 65536, 5, 393199, 0, 4, 327663, 131072, 5, 262127, 262144, 0, 196591, 196608, 5, 131055, 327680, 4, 65519, 327680, 0, -17, 327680, 0, -65553, 262144, 5, -131089, 0, 4, -196625, 0, 2, -262161, 196608, 9, -327697, 0, 3, -393233, 196608, 5, -458769, 327680, 3, -524305, 327680, 2, -589841, 327680, 1, -655377, 327680, 3, -720913, 0, 2, 786414, 131072, 3, 720878, 131072, 2, 655342, 196608, 3, 589806, 327680, 11, 524270, 65536, 1, 458734, 0, 0, 393198, 0, 5, 327662, 131072, 5, 262126, 327680, 3, 196590, 65536, 0, 131054, 196608, 8, 65518, 0, 5, -18, 65536, 5, -65554, 327680, 0, -131090, 327680, 3, -196626, 0, 0, -262162, 0, 3, -327698, 262144, 0, -393234, 262144, 0, -458770, 65536, 0, -524306, 131072, 0, -589842, 0, 1, -655378, 327680, 2, -720914, 196608, 5, 786413, 196608, 3, 720877, 131072, 3, 655341, 327680, 11, 589805, 65536, 1, 524269, 327680, 4, 458733, 327680, 2, 393197, 0, 3, 327661, 0, 3, 262125, 196608, 9, 196589, 327680, 0, 131053, 65536, 5, 65517, 327680, 5, -19, 65536, 5, -65555, 196608, 8, -131091, 131072, 0, -196627, 131072, 5, -262163, 327680, 5, -327699, 327680, 2, -393235, 262144, 5, -458771, 196608, 8, -524307, 327680, 3, -589843, 327680, 0, -655379, 0, 3, -720915, 131072, 5, 786412, 196608, 2, 720876, 196608, 3, 655340, 262144, 11, 589804, 0, 3, 524268, 327680, 3, 458732, 0, 4, 393196, 131072, 5, 327660, 327680, 3, 262124, 131072, 5, 196588, 0, 4, 131052, 131072, 9, 65516, 0, 3, -20, 327680, 1, -65556, 0, 1, -131092, 327680, 1, -196628, 196608, 5, -262164, 131072, 8, -327700, 196608, 0, -393236, 131072, 5, -458772, 327680, 3, -524308, 327680, 4, -589844, 131072, 5, -655380, 0, 0, -720916, 0, 2) -[node name="CloudSpawner" parent="." instance=ExtResource("2_bx37o")] -position = Vector2(41.795, -60.05) -scene = ExtResource("3_whlmm") - [node name="PlayArea" type="Area2D" parent="."] [node name="Shape" type="CollisionShape2D" parent="PlayArea"] @@ -844,23 +833,5 @@ debug_color = Color(1, 1, 1, 0) [node name="GoldCounter" parent="." instance=ExtResource("3_p6jw3")] -[node name="SpawnedEntities" type="Node2D" parent="."] - -[node name="Node2D" type="Node2D" parent="."] -position = Vector2(590, 317) -scale = Vector2(11.285, 11.285) - -[node name="Sprite2D" type="Sprite2D" parent="Node2D"] -scale = Vector2(0.03, 0.029) -texture = ExtResource("9_8kxq4") - -[node name="Area2D" type="Area2D" parent="Node2D"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Node2D/Area2D"] -scale = Vector2(0.0886132, 0.0886132) -shape = SubResource("CircleShape2D_3du4x") - -[node name="Imp" parent="." instance=ExtResource("10_26rf6")] -position = Vector2(-275, 10) - -[connection signal="mouse_entered" from="Node2D/Area2D" to="CloudSpawner" method="spawn"] +[node name="DefaultSpawnParent" type="Node2D" parent="."] +unique_name_in_owner = true From b172e919d94a8e1cd39ecccf638f37dd4010a9d8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 03:11:57 +0200 Subject: [PATCH 08/83] Refactor `SpawnerChoice` --- behaviours/spawner_choice.gd | 9 +++++- behaviours/spawner_choice.svg | 41 ++++++++++++++++++++++++++++ behaviours/spawner_choice.svg.import | 37 +++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 behaviours/spawner_choice.svg create mode 100644 behaviours/spawner_choice.svg.import diff --git a/behaviours/spawner_choice.gd b/behaviours/spawner_choice.gd index 71def18..8af2a02 100644 --- a/behaviours/spawner_choice.gd +++ b/behaviours/spawner_choice.gd @@ -1,6 +1,11 @@ +@icon("res://behaviours/spawner_choice.svg") extends Node class_name SpawnerChoice +## Randomly choose a [Spawner] to use from [field spawners] considering [field weights]. +## +## If a null [Spawner] is selected, nothing is spawned. + @export var spawners: Array[Spawner] = [] @export var weights: Array[int] = [] @@ -24,7 +29,9 @@ func select_spawner() -> Spawner: return spawners[idx] func spawn(): - select_spawner().spawn() + var spawner = select_spawner() + if spawner != null: + spawner.spawn() func _ready(): diff --git a/behaviours/spawner_choice.svg b/behaviours/spawner_choice.svg new file mode 100644 index 0000000..6665d20 --- /dev/null +++ b/behaviours/spawner_choice.svg @@ -0,0 +1,41 @@ + + diff --git a/behaviours/spawner_choice.svg.import b/behaviours/spawner_choice.svg.import new file mode 100644 index 0000000..ad1beae --- /dev/null +++ b/behaviours/spawner_choice.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0f5nbe7lhib6" +path="res://.godot/imported/spawner_choice.svg-91bce9cbbb63e3eb7738ffe03834ed28.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/spawner_choice.svg" +dest_files=["res://.godot/imported/spawner_choice.svg-91bce9cbbb63e3eb7738ffe03834ed28.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false From 6d5360ec356237ae987f1f35d64006685a8ad105 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 03:20:02 +0200 Subject: [PATCH 09/83] Remove unused `SpawnerFree` --- behaviours/spawner_free.tscn | 8 -------- entities/gold.tscn | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 behaviours/spawner_free.tscn diff --git a/behaviours/spawner_free.tscn b/behaviours/spawner_free.tscn deleted file mode 100644 index 6459ce3..0000000 --- a/behaviours/spawner_free.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dv7ea2y0l46e"] - -[ext_resource type="Script" path="res://behaviours/spawner.gd" id="1_fa574"] - -[node name="SpawnerFree" type="Node2D"] -script = ExtResource("1_fa574") - -[connection signal="tree_exiting" from="." to="." method="spawn"] diff --git a/entities/gold.tscn b/entities/gold.tscn index 2a86cd3..7af1dee 100644 --- a/entities/gold.tscn +++ b/entities/gold.tscn @@ -4,7 +4,7 @@ [ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_lso1v"] [ext_resource type="Texture2D" uid="uid://bfl0tkg85cvb8" path="res://entities/gold.png" id="2_tt3v6"] [ext_resource type="PackedScene" uid="uid://dj72yshd25ucx" path="res://behaviours/collectable.tscn" id="3_q0bno"] -[ext_resource type="PackedScene" uid="uid://dv7ea2y0l46e" path="res://behaviours/spawner_free.tscn" id="5_pbaso"] +[ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="5_t7ey8"] [ext_resource type="PackedScene" uid="uid://eqg6snsgn1kh" path="res://players/gold_pickup_player.tscn" id="6_eoeje"] [node name="Gold" type="Node2D"] @@ -22,7 +22,7 @@ speed = 555.0 scale = Vector2(0.6, 0.6) tag = &"Gold" -[node name="SpawnerFree" parent="." instance=ExtResource("5_pbaso")] +[node name="Spawner" parent="." instance=ExtResource("5_t7ey8")] scene = ExtResource("6_eoeje") [connection signal="move" from="MoveTowardsMouse" to="." method="_on_move"] From 36c174397993a1d8bba6731b8c87606ac19da177 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 03:56:46 +0200 Subject: [PATCH 10/83] Break `Draggable` --- behaviours/draggable.gd | 19 ++-------------- behaviours/draggable.svg | 39 +++++++++++++++++++++++++++++++++ behaviours/draggable.svg.import | 37 +++++++++++++++++++++++++++++++ behaviours/draggable.tscn | 9 +------- behaviours/eat_target.gd | 37 ------------------------------- behaviours/eat_target.tscn | 23 ------------------- 6 files changed, 79 insertions(+), 85 deletions(-) create mode 100644 behaviours/draggable.svg create mode 100644 behaviours/draggable.svg.import delete mode 100644 behaviours/eat_target.gd delete mode 100644 behaviours/eat_target.tscn diff --git a/behaviours/draggable.gd b/behaviours/draggable.gd index c02fd6b..26ad854 100644 --- a/behaviours/draggable.gd +++ b/behaviours/draggable.gd @@ -1,21 +1,13 @@ +@icon("res://behaviours/draggable.svg") extends Area2D class_name Draggable -signal move(movement: Vector2) signal dragged signal dropped -@onready var mover: Node2D = $"MatchMousePosition" - -var being_dragged: bool: - get: - return being_dragged - set(value): - being_dragged = value - mover.set_process(being_dragged) - mover.set_physics_process(being_dragged) +var being_dragged: bool = false func drag(): @@ -25,10 +17,3 @@ func drag(): func drop(): being_dragged = false dropped.emit() - - -func _ready(): - being_dragged = false - -func _on_move(movement: Vector2): - move.emit(movement) diff --git a/behaviours/draggable.svg b/behaviours/draggable.svg new file mode 100644 index 0000000..2462527 --- /dev/null +++ b/behaviours/draggable.svg @@ -0,0 +1,39 @@ + + + + + + + diff --git a/behaviours/draggable.svg.import b/behaviours/draggable.svg.import new file mode 100644 index 0000000..c2672cd --- /dev/null +++ b/behaviours/draggable.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bepjyaq1y3g7w" +path="res://.godot/imported/draggable.svg-7f8260afa88b76990683b55fd9af07eb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/draggable.svg" +dest_files=["res://.godot/imported/draggable.svg-7f8260afa88b76990683b55fd9af07eb.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/draggable.tscn b/behaviours/draggable.tscn index 60e1f2c..f8e46d8 100644 --- a/behaviours/draggable.tscn +++ b/behaviours/draggable.tscn @@ -1,15 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://dijcjahkddudv"] +[gd_scene load_steps=2 format=3 uid="uid://dijcjahkddudv"] [ext_resource type="Script" path="res://behaviours/draggable.gd" id="1_hdedq"] -[ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_gi6xd"] [node name="Draggable" type="Area2D"] collision_layer = 0 collision_mask = 0 script = ExtResource("1_hdedq") - -[node name="MatchMousePosition" parent="." instance=ExtResource("2_gi6xd")] -scale = Vector2(10000, 10000) -speed = 3600.0 - -[connection signal="move" from="MatchMousePosition" to="." method="_on_move"] diff --git a/behaviours/eat_target.gd b/behaviours/eat_target.gd deleted file mode 100644 index 3ffd6d2..0000000 --- a/behaviours/eat_target.gd +++ /dev/null @@ -1,37 +0,0 @@ -extends Node2D -class_name EatTarget - - -signal eaten(target: Node2D) -signal move(movement: Vector2) - -@export var tag: StringName: - get: - return tag - set(value): - tag = value - if hunt_target != null: - hunt_target.tag = value - if eater != null: - eater.tag = value - - -@onready var hunt_target: HuntTarget = $"HuntTarget" -@onready var eater: Eater = $"Eater" -@onready var move_towards: MoveTowardsTarget = $"MoveTowardsTarget" - -func _ready(): - hunt_target.tag = tag - eater.tag = tag - -func _on_target_selected(body: Node2D) -> void: - move_towards.target = body - -func _on_target_abandoned(_body: Node2D) -> void: - move_towards.target = null - -func _on_eater_eaten(edible): - eaten.emit(edible) - -func _on_move_towards_target_move(movement): - move.emit(movement) diff --git a/behaviours/eat_target.tscn b/behaviours/eat_target.tscn deleted file mode 100644 index 53ab7a7..0000000 --- a/behaviours/eat_target.tscn +++ /dev/null @@ -1,23 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://b7bdlh5akhi8s"] - -[ext_resource type="Script" path="res://behaviours/eat_target.gd" id="1_tlnlt"] -[ext_resource type="PackedScene" uid="uid://dxmodn8mbvw0i" path="res://behaviours/hunt_target.tscn" id="2_c8wdv"] -[ext_resource type="PackedScene" uid="uid://jg7qkbswgqjc" path="res://behaviours/eater.tscn" id="3_ir2yh"] -[ext_resource type="PackedScene" uid="uid://kceb2v2dm0qn" path="res://behaviours/move_towards_target.tscn" id="4_1qc2q"] - -[node name="EatTarget" type="Node2D"] -script = ExtResource("1_tlnlt") - -[node name="HuntTarget" parent="." instance=ExtResource("2_c8wdv")] -scale = Vector2(16, 16) -give_up_secs = 5.0 - -[node name="Eater" parent="." instance=ExtResource("3_ir2yh")] -scale = Vector2(2.5, 2.5) - -[node name="MoveTowardsTarget" parent="." instance=ExtResource("4_1qc2q")] - -[connection signal="target_abandoned" from="HuntTarget" to="." method="_on_target_abandoned"] -[connection signal="target_selected" from="HuntTarget" to="." method="_on_target_selected"] -[connection signal="eaten" from="Eater" to="." method="_on_eater_eaten"] -[connection signal="move" from="MoveTowardsTarget" to="." method="_on_move_towards_target_move"] From 5e7fde7999abfd48afafed5f4b2746007b793fe4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 03:57:04 +0200 Subject: [PATCH 11/83] Make sure `Imp` still loads, even if some pieces are missing --- entities/imp.tscn | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index fdacd18..60a7721 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -1,12 +1,11 @@ -[gd_scene load_steps=10 format=3 uid="uid://4d3ksr3171x4"] +[gd_scene load_steps=9 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"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_4528r"] -[ext_resource type="PackedScene" uid="uid://b7bdlh5akhi8s" path="res://behaviours/eat_target.tscn" id="3_iybf3"] [ext_resource type="Texture2D" uid="uid://crhwsob76ieya" path="res://entities/imp_left.png" id="3_qda0k"] [ext_resource type="Texture2D" uid="uid://bubehid53q8h1" path="res://entities/imp_right.png" id="4_0sckn"] -[ext_resource type="PackedScene" path="res://behaviours/spawner.tscn" id="4_d8lgm"] +[ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="4_d8lgm"] [ext_resource type="PackedScene" uid="uid://uoxwjpmgg27a" path="res://entities/gold.tscn" id="5_yrfoq"] [sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"] @@ -36,13 +35,6 @@ scale = Vector2(0.5, 0.5) [node name="DropSound" type="AudioStreamPlayer2D" parent="Draggable"] scale = Vector2(0.5, 0.5) -[node name="EatTarget" parent="." instance=ExtResource("3_iybf3")] -scale = Vector2(2, 2) -tag = &"Sheep" - -[node name="SkullSpawner" parent="." instance=ExtResource("4_d8lgm")] -scene = ExtResource("5_yrfoq") - [node name="Spawner" parent="." instance=ExtResource("4_d8lgm")] scene = ExtResource("5_yrfoq") @@ -51,6 +43,4 @@ wait_time = 0.8 autostart = true [connection signal="move" from="Draggable" to="." method="_on_draggable_move"] -[connection signal="eaten" from="EatTarget" to="." method="_on_eat_target_eaten"] -[connection signal="move" from="EatTarget" to="." method="_on_move"] [connection signal="timeout" from="Spawner/Timer" to="Spawner" method="spawn"] From fd0d97365878d558f0c7d785442afc14a3c6e1e3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 04:04:46 +0200 Subject: [PATCH 12/83] Remove `MoveTowardsMouse` and `MoveTowardsTarget` --- behaviours/move_towards_mouse.gd | 46 ---------------------------- behaviours/move_towards_mouse.tscn | 12 -------- behaviours/move_towards_target.gd | 29 ------------------ behaviours/move_towards_target.tscn | 6 ---- entities/gold.tscn | 8 +---- entities/sheep.tscn | 47 ++++++++++++----------------- scenes/game/cursor_magnet.tscn | 8 +---- 7 files changed, 21 insertions(+), 135 deletions(-) delete mode 100644 behaviours/move_towards_mouse.gd delete mode 100644 behaviours/move_towards_mouse.tscn delete mode 100644 behaviours/move_towards_target.gd delete mode 100644 behaviours/move_towards_target.tscn diff --git a/behaviours/move_towards_mouse.gd b/behaviours/move_towards_mouse.gd deleted file mode 100644 index 4bbcee7..0000000 --- a/behaviours/move_towards_mouse.gd +++ /dev/null @@ -1,46 +0,0 @@ -extends Node2D -class_name MoveTowardsMouse - - -signal move(movement: Vector2) -signal detached -signal captured - -@onready var game := MainGame.get_ancestor(self) - -@export var speed: float = 100.0 -@export var can_detach: bool = false - - -enum State { DETACHED, CAPTURED } - -var state: State = State.DETACHED - -func get_followed_global_position(): - return game.camera.get_global_mouse_position() - - -func get_followed_mouse_position(): - var global_followed_position: Vector2 = get_followed_global_position() - var relative_followed_position: Vector2 = global_followed_position - global_position - return relative_followed_position - - -func _physics_process(delta: float) -> void: - match state: - State.CAPTURED: - var relative_followed_position: Vector2 = get_followed_mouse_position() - var direction: Vector2 = position.direction_to(relative_followed_position) - var actual_speed: float = min(delta * speed, relative_followed_position.length()) # Don't overshoot. - var movement: Vector2 = direction * actual_speed - move.emit(movement) - -func _on_capture_area_mouse_entered() -> void: - state = State.CAPTURED - captured.emit() - -func _on_capture_area_mouse_exited() -> void: - if can_detach: - state = State.DETACHED - detached.emit() - diff --git a/behaviours/move_towards_mouse.tscn b/behaviours/move_towards_mouse.tscn deleted file mode 100644 index b971d07..0000000 --- a/behaviours/move_towards_mouse.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://bvrxvrjlo5130"] - -[ext_resource type="Script" path="res://behaviours/move_towards_mouse.gd" id="1_nbja1"] -[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="2_qru2e"] - -[node name="MoveTowardsMouse" type="Node2D"] -script = ExtResource("1_nbja1") - -[node name="CaptureArea" parent="." instance=ExtResource("2_qru2e")] - -[connection signal="mouse_entered" from="CaptureArea" to="." method="_on_capture_area_mouse_entered"] -[connection signal="mouse_exited" from="CaptureArea" to="." method="_on_capture_area_mouse_exited"] diff --git a/behaviours/move_towards_target.gd b/behaviours/move_towards_target.gd deleted file mode 100644 index c519780..0000000 --- a/behaviours/move_towards_target.gd +++ /dev/null @@ -1,29 +0,0 @@ -extends Node2D -class_name MoveTowardsTarget - - -signal move(movement: Vector2) - - -@export var speed: float = 100.0 -@export var target: Node2D - - -func get_followed_global_position(): - return target.global_position - - -func get_followed_mouse_position(): - var global_followed_position: Vector2 = get_followed_global_position() - var relative_followed_position: Vector2 = global_followed_position - global_position - return relative_followed_position - - -func _physics_process(delta: float) -> void: - if target == null: - return - var relative_followed_position: Vector2 = get_followed_mouse_position() - var direction: Vector2 = position.direction_to(relative_followed_position) - var actual_speed: float = min(delta * speed, relative_followed_position.length()) # Don't overshoot. - var movement: Vector2 = direction * actual_speed - move.emit(movement) diff --git a/behaviours/move_towards_target.tscn b/behaviours/move_towards_target.tscn deleted file mode 100644 index d04e146..0000000 --- a/behaviours/move_towards_target.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://kceb2v2dm0qn"] - -[ext_resource type="Script" path="res://behaviours/move_towards_target.gd" id="1_703gy"] - -[node name="MoveTowardsTarget" type="Node2D"] -script = ExtResource("1_703gy") diff --git a/entities/gold.tscn b/entities/gold.tscn index 7af1dee..da6ed04 100644 --- a/entities/gold.tscn +++ b/entities/gold.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=7 format=3 uid="uid://uoxwjpmgg27a"] +[gd_scene load_steps=6 format=3 uid="uid://uoxwjpmgg27a"] [ext_resource type="Script" path="res://entities/gold.gd" id="1_lbls1"] -[ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_lso1v"] [ext_resource type="Texture2D" uid="uid://bfl0tkg85cvb8" path="res://entities/gold.png" id="2_tt3v6"] [ext_resource type="PackedScene" uid="uid://dj72yshd25ucx" path="res://behaviours/collectable.tscn" id="3_q0bno"] [ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="5_t7ey8"] @@ -14,10 +13,6 @@ script = ExtResource("1_lbls1") scale = Vector2(2, 2) texture = ExtResource("2_tt3v6") -[node name="MoveTowardsMouse" parent="." instance=ExtResource("2_lso1v")] -scale = Vector2(8, 8) -speed = 555.0 - [node name="Collectable" parent="." instance=ExtResource("3_q0bno")] scale = Vector2(0.6, 0.6) tag = &"Gold" @@ -25,5 +20,4 @@ tag = &"Gold" [node name="Spawner" parent="." instance=ExtResource("5_t7ey8")] scene = ExtResource("6_eoeje") -[connection signal="move" from="MoveTowardsMouse" to="." method="_on_move"] [connection signal="collected" from="Collectable" to="." method="_on_collected"] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 4ae08bb..d29f4ba 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=15 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=14 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"] -[ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_tfd2i"] [ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="2_xbkrm"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_8ku7r"] [ext_resource type="Texture2D" uid="uid://cxtmas4g0v6en" path="res://entities/sheep_right.png" id="4_5qoof"] @@ -13,24 +12,6 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] radius = 8.0 -[sub_resource type="Animation" id="Animation_lxieb"] -resource_name = "wobble" -length = 3.0 -loop_mode = 1 -step = 0.5 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:rotation") -tracks/0/interp = 2 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.5, 1.5, 2, 3), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1), -"update": 0, -"values": [0.0, -0.261799, 0.0, 0.261799, 0.0] -} - [sub_resource type="Animation" id="Animation_gokbg"] length = 0.001 tracks/0/type = "value" @@ -64,6 +45,24 @@ tracks/0/keys = { "values": [Vector2(0, 0), Vector2(1, 1), Vector2(-1, -1), Vector2(-1, 0), Vector2(1, -1), Vector2(-1, 1), Vector2(1, 1), Vector2(1, 0), Vector2(-1, -1), Vector2(1, 0), Vector2(0, -1)] } +[sub_resource type="Animation" id="Animation_lxieb"] +resource_name = "wobble" +length = 3.0 +loop_mode = 1 +step = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite:rotation") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5, 1.5, 2, 3), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [0.0, -0.261799, 0.0, 0.261799, 0.0] +} + [sub_resource type="AnimationLibrary" id="AnimationLibrary_6mutq"] _data = { "RESET": SubResource("Animation_gokbg"), @@ -87,11 +86,6 @@ right_texture = ExtResource("4_5qoof") scale = Vector2(3, 3) shape = SubResource("CircleShape2D_c5tcn") -[node name="MoveTowardsMouse" parent="." instance=ExtResource("2_tfd2i")] -scale = Vector2(30, 30) -speed = -30.0 -can_detach = true - [node name="Draggable" parent="." instance=ExtResource("3_8ku7r")] scale = Vector2(3, 3) @@ -104,14 +98,11 @@ scale = Vector2(0.5, 0.5) stream = ExtResource("4_nxjnl") [node name="Edible" parent="." instance=ExtResource("6_3odsh")] -tag = &"Sheep" [node name="Animator" type="AnimationPlayer" parent="."] libraries = { "": SubResource("AnimationLibrary_6mutq") } -[connection signal="move" from="MoveTowardsMouse" to="." method="_on_move"] [connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"] [connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"] -[connection signal="move" from="Draggable" to="." method="_on_drag_move"] diff --git a/scenes/game/cursor_magnet.tscn b/scenes/game/cursor_magnet.tscn index 05866a1..76093aa 100644 --- a/scenes/game/cursor_magnet.tscn +++ b/scenes/game/cursor_magnet.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=4 format=3 uid="uid://7j1b55t8tafg"] +[gd_scene load_steps=3 format=3 uid="uid://7j1b55t8tafg"] [ext_resource type="Script" path="res://scenes/game/cursor_magnet.gd" id="1_xk040"] -[ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_ljil3"] [sub_resource type="CircleShape2D" id="CircleShape2D_6mkjn"] radius = 16.0 @@ -16,10 +15,5 @@ scale = Vector2(0.5, 0.5) shape = SubResource("CircleShape2D_6mkjn") debug_color = Color(1, 1, 1, 0.67451) -[node name="MoveTowardsMouse" parent="." instance=ExtResource("2_ljil3")] -scale = Vector2(10000, 10000) -speed = 100000.0 - [connection signal="dragged" from="." to="." method="_on_dragged"] [connection signal="dropped" from="." to="." method="_on_dropped"] -[connection signal="move" from="MoveTowardsMouse" to="." method="_on_move"] From 69b08c09e77d88dce7684cccc9d488335fde9a3f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 04:29:34 +0200 Subject: [PATCH 13/83] Create `Move` and `MoveStraight` and refactor `MoveTowards` --- behaviours/move.gd | 6 ++++++ behaviours/{move_towards.svg => move.svg} | 0 ...{move_towards.svg.import => move.svg.import} | 6 +++--- behaviours/move_straight.gd | 17 +++++++++++++++++ behaviours/move_straight.tscn | 6 ++++++ behaviours/move_towards.gd | 13 ++++++------- 6 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 behaviours/move.gd rename behaviours/{move_towards.svg => move.svg} (100%) rename behaviours/{move_towards.svg.import => move.svg.import} (74%) create mode 100644 behaviours/move_straight.gd create mode 100644 behaviours/move_straight.tscn diff --git a/behaviours/move.gd b/behaviours/move.gd new file mode 100644 index 0000000..ae3e420 --- /dev/null +++ b/behaviours/move.gd @@ -0,0 +1,6 @@ +@icon("res://behaviours/move.svg") +extends Node2D +class_name Move + + +signal move(norm: Vector2) diff --git a/behaviours/move_towards.svg b/behaviours/move.svg similarity index 100% rename from behaviours/move_towards.svg rename to behaviours/move.svg diff --git a/behaviours/move_towards.svg.import b/behaviours/move.svg.import similarity index 74% rename from behaviours/move_towards.svg.import rename to behaviours/move.svg.import index 87cd989..4c4d4a8 100644 --- a/behaviours/move_towards.svg.import +++ b/behaviours/move.svg.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://d10wobjiuh1mm" -path="res://.godot/imported/move_towards.svg-f5d5c8fa66b43d0301cc029ecee0a291.ctex" +path="res://.godot/imported/move.svg-6291495a0c7bf9c3c43cbea535114f1a.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://behaviours/move_towards.svg" -dest_files=["res://.godot/imported/move_towards.svg-f5d5c8fa66b43d0301cc029ecee0a291.ctex"] +source_file="res://behaviours/move.svg" +dest_files=["res://.godot/imported/move.svg-6291495a0c7bf9c3c43cbea535114f1a.ctex"] [params] diff --git a/behaviours/move_straight.gd b/behaviours/move_straight.gd new file mode 100644 index 0000000..9c6da0f --- /dev/null +++ b/behaviours/move_straight.gd @@ -0,0 +1,17 @@ +@icon("res://behaviours/move.svg") +extends Move +class_name MoveStraight + + +## A [Move] that moves in a fixed direction. + + +@export var direction: Vector2 + + +func randomize_direction() -> void: + direction = Vector2.from_angle(Random.rng.randf_range(0, 2*PI)) + + +func _physics_process(_delta: float) -> void: + move.emit(direction) diff --git a/behaviours/move_straight.tscn b/behaviours/move_straight.tscn new file mode 100644 index 0000000..e176db3 --- /dev/null +++ b/behaviours/move_straight.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dk1ipq7dhkhf3"] + +[ext_resource type="Script" path="res://behaviours/move_straight.gd" id="1_8yf73"] + +[node name="MoveStraight" type="Node2D"] +script = ExtResource("1_8yf73") diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index 2c24b82..e46cd27 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -1,12 +1,9 @@ -@icon("res://behaviours/move_towards.svg") -extends Node2D +@icon("res://behaviours/move.svg") +extends Move class_name MoveTowards -## A node emitting the [signal move] signal each physics timestep to move towards the position of [field target]. - - -signal move(norm: Vector2) +## A [Move] that moves towards the [field position] of a [field target]. @export var target: Node2D = null @@ -27,4 +24,6 @@ func _physics_process(_delta: float) -> void: if target: var gap = target.global_position - global_position var norm = gap.normalized() - move.emit(norm) + move.emit(norm) + else: + move.emit(Vector2.ZERO) From f1ca11d8872130773c7573270f05da81cf1806cc Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 05:08:25 +0200 Subject: [PATCH 14/83] Create `Sampler`s --- behaviours/sampler.gd | 11 ++++++++ behaviours/sampler_priority.gd | 8 ++++++ behaviours/sampler_priority.tscn | 6 ++++ behaviours/sampler_random.gd | 14 ++++++++++ behaviours/sampler_random.tscn | 6 ++++ behaviours/sampler_weighted.gd | 30 ++++++++++++++++++++ behaviours/sampler_weighted.tscn | 6 ++++ behaviours/spawner_choice.gd | 41 ---------------------------- behaviours/spawner_choice.svg | 41 ---------------------------- behaviours/spawner_choice.svg.import | 37 ------------------------- behaviours/spawner_choice.tscn | 6 ---- 11 files changed, 81 insertions(+), 125 deletions(-) create mode 100644 behaviours/sampler.gd create mode 100644 behaviours/sampler_priority.gd create mode 100644 behaviours/sampler_priority.tscn create mode 100644 behaviours/sampler_random.gd create mode 100644 behaviours/sampler_random.tscn create mode 100644 behaviours/sampler_weighted.gd create mode 100644 behaviours/sampler_weighted.tscn delete mode 100644 behaviours/spawner_choice.gd delete mode 100644 behaviours/spawner_choice.svg delete mode 100644 behaviours/spawner_choice.svg.import delete mode 100644 behaviours/spawner_choice.tscn diff --git a/behaviours/sampler.gd b/behaviours/sampler.gd new file mode 100644 index 0000000..1b208a5 --- /dev/null +++ b/behaviours/sampler.gd @@ -0,0 +1,11 @@ +extends Node +class_name Sampler + + +## Abstract base class for sampling a certain reference among multiple. + + +## Get a reference. +func sample() -> Object: + Log.e(self, "Not implemented.") + return null diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd new file mode 100644 index 0000000..4aafaf5 --- /dev/null +++ b/behaviours/sampler_priority.gd @@ -0,0 +1,8 @@ +extends Sampler +class_name SamplerPriority + + +## Always sample the object with the highest priority in the queue. + + +## TODO \ No newline at end of file diff --git a/behaviours/sampler_priority.tscn b/behaviours/sampler_priority.tscn new file mode 100644 index 0000000..6865ca7 --- /dev/null +++ b/behaviours/sampler_priority.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://djcwis8ycrq85"] + +[ext_resource type="Script" path="res://behaviours/sampler_priority.gd" id="1_jy5r5"] + +[node name="SamplerPriority" type="Node"] +script = ExtResource("1_jy5r5") diff --git a/behaviours/sampler_random.gd b/behaviours/sampler_random.gd new file mode 100644 index 0000000..5380d3e --- /dev/null +++ b/behaviours/sampler_random.gd @@ -0,0 +1,14 @@ +extends Sampler +class_name SamplerRandom + + +## Sample a random reference from the array. + + +@export var possibilities: Array = [] + + +func sample() -> Object: + if len(possibilities) == 0: + return null + return Random.sample(possibilities) diff --git a/behaviours/sampler_random.tscn b/behaviours/sampler_random.tscn new file mode 100644 index 0000000..5b1695f --- /dev/null +++ b/behaviours/sampler_random.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dtiuw54ss376d"] + +[ext_resource type="Script" path="res://behaviours/sampler_random.gd" id="1_geacn"] + +[node name="SamplerRandom" type="Node"] +script = ExtResource("1_geacn") diff --git a/behaviours/sampler_weighted.gd b/behaviours/sampler_weighted.gd new file mode 100644 index 0000000..cc81bc0 --- /dev/null +++ b/behaviours/sampler_weighted.gd @@ -0,0 +1,30 @@ +extends Sampler +class_name SamplerWeighted + + +## Sample a random reference from the array, considering the given weights. + + +@export var possibilities: Array = [] +@export var weights: Array[int] = [] + + +func sample() -> Object: + var total = compute_total_weight() + if total == 0: + return null + var sampled = Random.rng.randi_range(0, total - 1) + var idx = -1 + while sampled >= 0: + idx += 1 + sampled -= weights[idx] + return possibilities[idx] + +func compute_total_weight() -> int: + var total = 0 + for weight in weights: + if weight < 0: + Log.e(self, "Weight with negative value detected.") + return 0 + total += weight + return total diff --git a/behaviours/sampler_weighted.tscn b/behaviours/sampler_weighted.tscn new file mode 100644 index 0000000..fddbae7 --- /dev/null +++ b/behaviours/sampler_weighted.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://d2ftjun7wdif0"] + +[ext_resource type="Script" path="res://behaviours/sampler_weighted.gd" id="1_hhnbk"] + +[node name="SamplerWeighted" type="Node"] +script = ExtResource("1_hhnbk") diff --git a/behaviours/spawner_choice.gd b/behaviours/spawner_choice.gd deleted file mode 100644 index 8af2a02..0000000 --- a/behaviours/spawner_choice.gd +++ /dev/null @@ -1,41 +0,0 @@ -@icon("res://behaviours/spawner_choice.svg") -extends Node -class_name SpawnerChoice - -## Randomly choose a [Spawner] to use from [field spawners] considering [field weights]. -## -## If a null [Spawner] is selected, nothing is spawned. - - -@export var spawners: Array[Spawner] = [] -@export var weights: Array[int] = [] - - -func compute_total_weight() -> int: - var total = 0 - for weight in weights: - if weight < 0: - Log.e(self, "Weight with negative value detected.") - total += weight - return total - -func select_spawner() -> Spawner: - var total = compute_total_weight() - var sampled = Random.rng.randi_range(0, total - 1) - var idx = -1 - while sampled >= 0: - idx += 1 - sampled -= weights[idx] - return spawners[idx] - -func spawn(): - var spawner = select_spawner() - if spawner != null: - spawner.spawn() - - -func _ready(): - if len(spawners) != len(weights): - Log.e(self, "Spawners and weights are different lengths.") - if compute_total_weight() <= 0: - Log.e(self, "Weight total is less or equal to 0.") diff --git a/behaviours/spawner_choice.svg b/behaviours/spawner_choice.svg deleted file mode 100644 index 6665d20..0000000 --- a/behaviours/spawner_choice.svg +++ /dev/null @@ -1,41 +0,0 @@ - - diff --git a/behaviours/spawner_choice.svg.import b/behaviours/spawner_choice.svg.import deleted file mode 100644 index ad1beae..0000000 --- a/behaviours/spawner_choice.svg.import +++ /dev/null @@ -1,37 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://c0f5nbe7lhib6" -path="res://.godot/imported/spawner_choice.svg-91bce9cbbb63e3eb7738ffe03834ed28.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://behaviours/spawner_choice.svg" -dest_files=["res://.godot/imported/spawner_choice.svg-91bce9cbbb63e3eb7738ffe03834ed28.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 -svg/scale=1.0 -editor/scale_with_editor_scale=false -editor/convert_colors_with_editor_theme=false diff --git a/behaviours/spawner_choice.tscn b/behaviours/spawner_choice.tscn deleted file mode 100644 index b11a7b0..0000000 --- a/behaviours/spawner_choice.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cokdfsk6rgeup"] - -[ext_resource type="Script" path="res://behaviours/spawner_choice.gd" id="1_jkwdb"] - -[node name="SpawnerChoice" type="Node"] -script = ExtResource("1_jkwdb") From 9c84295ac6486572828db5a8099b9d543f355fd5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 05:09:31 +0200 Subject: [PATCH 15/83] Fix `AIHunterErratic` and `AIHunterPersistent` node names --- behaviours/ai_hunter_erratic.tscn | 2 +- behaviours/ai_hunter_persistent.tscn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/behaviours/ai_hunter_erratic.tscn b/behaviours/ai_hunter_erratic.tscn index b901118..fed247f 100644 --- a/behaviours/ai_hunter_erratic.tscn +++ b/behaviours/ai_hunter_erratic.tscn @@ -4,7 +4,7 @@ [ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_h4v3e"] [ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_ucief"] -[node name="AIHunterRandom" type="Node2D"] +[node name="AIHunterErratic" type="Node2D"] [node name="EdibleTracker" parent="." instance=ExtResource("1_h53ag")] diff --git a/behaviours/ai_hunter_persistent.tscn b/behaviours/ai_hunter_persistent.tscn index 7574354..3bddc5b 100644 --- a/behaviours/ai_hunter_persistent.tscn +++ b/behaviours/ai_hunter_persistent.tscn @@ -4,7 +4,7 @@ [ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_w2vxl"] [ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_14yk3"] -[node name="AIHunterLatest" type="Node2D"] +[node name="AIHunterPersistent" type="Node2D"] [node name="EdibleTracker" parent="." instance=ExtResource("1_j87ny")] From 54076eea5742a386483cdd68ab3344af9f3c6d7e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 19:52:16 +0200 Subject: [PATCH 16/83] Remove unnecessary icon definitions --- behaviours/move_straight.gd | 1 - behaviours/move_towards.gd | 1 - 2 files changed, 2 deletions(-) diff --git a/behaviours/move_straight.gd b/behaviours/move_straight.gd index 9c6da0f..67ddc10 100644 --- a/behaviours/move_straight.gd +++ b/behaviours/move_straight.gd @@ -1,4 +1,3 @@ -@icon("res://behaviours/move.svg") extends Move class_name MoveStraight diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index e46cd27..dcb20ad 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -1,4 +1,3 @@ -@icon("res://behaviours/move.svg") extends Move class_name MoveTowards From 3c0439b2a07846fb9c033eebc2f859b512c60ef8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 00:55:17 +0200 Subject: [PATCH 17/83] Create `Priority` and `SamplerPriority` --- behaviours/priority.gd | 10 ++++++ behaviours/priority.svg | 39 ++++++++++++++++++++++ behaviours/priority.svg.import | 37 +++++++++++++++++++++ behaviours/priority.tscn | 6 ++++ behaviours/sampler.gd | 1 + behaviours/sampler.svg | 59 ++++++++++++++++++++++++++++++++++ behaviours/sampler.svg.import | 37 +++++++++++++++++++++ behaviours/sampler_priority.gd | 19 ++++++++++- 8 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 behaviours/priority.gd create mode 100644 behaviours/priority.svg create mode 100644 behaviours/priority.svg.import create mode 100644 behaviours/priority.tscn create mode 100644 behaviours/sampler.svg create mode 100644 behaviours/sampler.svg.import diff --git a/behaviours/priority.gd b/behaviours/priority.gd new file mode 100644 index 0000000..e1e9e39 --- /dev/null +++ b/behaviours/priority.gd @@ -0,0 +1,10 @@ +@icon("res://behaviours/priority.svg") +extends Node +class_name Priority + + +@export var priority: int = 0 + + +func get_ref() -> Node: + return get_parent() diff --git a/behaviours/priority.svg b/behaviours/priority.svg new file mode 100644 index 0000000..5223e43 --- /dev/null +++ b/behaviours/priority.svg @@ -0,0 +1,39 @@ + + + + + + + diff --git a/behaviours/priority.svg.import b/behaviours/priority.svg.import new file mode 100644 index 0000000..9148364 --- /dev/null +++ b/behaviours/priority.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ctc4lx571jksr" +path="res://.godot/imported/priority.svg-d16c10b6303969bc43c2b8feaccb77ae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/priority.svg" +dest_files=["res://.godot/imported/priority.svg-d16c10b6303969bc43c2b8feaccb77ae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/priority.tscn b/behaviours/priority.tscn new file mode 100644 index 0000000..1c489db --- /dev/null +++ b/behaviours/priority.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cm67ko1k6kn4u"] + +[ext_resource type="Script" path="res://behaviours/priority.gd" id="1_8u7ji"] + +[node name="Priority" type="Node"] +script = ExtResource("1_8u7ji") diff --git a/behaviours/sampler.gd b/behaviours/sampler.gd index 1b208a5..1c63eea 100644 --- a/behaviours/sampler.gd +++ b/behaviours/sampler.gd @@ -1,3 +1,4 @@ +@icon("res://behaviours/sampler.svg") extends Node class_name Sampler diff --git a/behaviours/sampler.svg b/behaviours/sampler.svg new file mode 100644 index 0000000..de84648 --- /dev/null +++ b/behaviours/sampler.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + diff --git a/behaviours/sampler.svg.import b/behaviours/sampler.svg.import new file mode 100644 index 0000000..4b58e6a --- /dev/null +++ b/behaviours/sampler.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cv32pf38ugoh1" +path="res://.godot/imported/sampler.svg-3634a55299eb9a683092cba4e7d215f9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/sampler.svg" +dest_files=["res://.godot/imported/sampler.svg-3634a55299eb9a683092cba4e7d215f9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index 4aafaf5..ca3ea44 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -5,4 +5,21 @@ class_name SamplerPriority ## Always sample the object with the highest priority in the queue. -## TODO \ No newline at end of file +@export var possibilities: Array[Priority] = [] + + +## Get a reference. +func sample() -> Priority: + if len(possibilities) == 0: + return null + + # FIXME: Change this to something more efficient when needed + var highest_possibility: Priority = null + for possibility in possibilities: + if possibility.priority > highest_possibility.priority: + highest_possibility = possibility + + if highest_possibility == null: + return null + + return highest_possibility.get_ref() From 382fe8026616f2fd327720010d7ed737111532fd Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 01:10:03 +0200 Subject: [PATCH 18/83] Rename `EdibleTracker` to `TrackerEdible` --- behaviours/ai_hunter_erratic.tscn | 2 +- behaviours/ai_hunter_latest.tscn | 2 +- behaviours/ai_hunter_persistent.tscn | 2 +- behaviours/ai_hunter_random.tscn | 2 +- behaviours/{edible_tracker.gd => tracker_edible.gd} | 2 +- behaviours/{edible_tracker.svg => tracker_edible.svg} | 0 ...{edible_tracker.svg.import => tracker_edible.svg.import} | 6 +++--- behaviours/{edible_tracker.tscn => tracker_edible.tscn} | 6 +++--- 8 files changed, 11 insertions(+), 11 deletions(-) rename behaviours/{edible_tracker.gd => tracker_edible.gd} (88%) rename behaviours/{edible_tracker.svg => tracker_edible.svg} (100%) rename behaviours/{edible_tracker.svg.import => tracker_edible.svg.import} (73%) rename behaviours/{edible_tracker.tscn => tracker_edible.tscn} (72%) diff --git a/behaviours/ai_hunter_erratic.tscn b/behaviours/ai_hunter_erratic.tscn index fed247f..728501b 100644 --- a/behaviours/ai_hunter_erratic.tscn +++ b/behaviours/ai_hunter_erratic.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cgq2jkbrw1y0o"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="1_h53ag"] +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="1_h53ag"] [ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_h4v3e"] [ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_ucief"] diff --git a/behaviours/ai_hunter_latest.tscn b/behaviours/ai_hunter_latest.tscn index 35f9a37..cd016e7 100644 --- a/behaviours/ai_hunter_latest.tscn +++ b/behaviours/ai_hunter_latest.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://cgnvp5bmtbpxr"] [ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_demja"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="2_jlt4x"] +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="2_jlt4x"] [ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="3_lfvrb"] [node name="AIHunterLatest" type="Node2D"] diff --git a/behaviours/ai_hunter_persistent.tscn b/behaviours/ai_hunter_persistent.tscn index 3bddc5b..8b77415 100644 --- a/behaviours/ai_hunter_persistent.tscn +++ b/behaviours/ai_hunter_persistent.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cpq0ubwun5wec"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="1_j87ny"] +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="1_j87ny"] [ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_w2vxl"] [ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_14yk3"] diff --git a/behaviours/ai_hunter_random.tscn b/behaviours/ai_hunter_random.tscn index e97f0d4..0d8b47f 100644 --- a/behaviours/ai_hunter_random.tscn +++ b/behaviours/ai_hunter_random.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://baiq3nu3p03rh"] [ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_wlo1a"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/edible_tracker.tscn" id="2_suoff"] +[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="2_suoff"] [ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="3_0uxc2"] [node name="AIHunterRandom" type="Node2D"] diff --git a/behaviours/edible_tracker.gd b/behaviours/tracker_edible.gd similarity index 88% rename from behaviours/edible_tracker.gd rename to behaviours/tracker_edible.gd index 6580828..a2aed3b 100644 --- a/behaviours/edible_tracker.gd +++ b/behaviours/tracker_edible.gd @@ -1,4 +1,4 @@ -@icon("res://behaviours/edible_tracker.svg") +@icon("res://behaviours/tracker_edible.svg") extends Tracker class_name EdibleTracker diff --git a/behaviours/edible_tracker.svg b/behaviours/tracker_edible.svg similarity index 100% rename from behaviours/edible_tracker.svg rename to behaviours/tracker_edible.svg diff --git a/behaviours/edible_tracker.svg.import b/behaviours/tracker_edible.svg.import similarity index 73% rename from behaviours/edible_tracker.svg.import rename to behaviours/tracker_edible.svg.import index b8c06f4..3d51dc1 100644 --- a/behaviours/edible_tracker.svg.import +++ b/behaviours/tracker_edible.svg.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://8443tt517pkv" -path="res://.godot/imported/edible_tracker.svg-9169f9c07be35f707b3c167799ba3a76.ctex" +path="res://.godot/imported/tracker_edible.svg-fb108b51d33883549e8e498a16701c4f.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://behaviours/edible_tracker.svg" -dest_files=["res://.godot/imported/edible_tracker.svg-9169f9c07be35f707b3c167799ba3a76.ctex"] +source_file="res://behaviours/tracker_edible.svg" +dest_files=["res://.godot/imported/tracker_edible.svg-fb108b51d33883549e8e498a16701c4f.ctex"] [params] diff --git a/behaviours/edible_tracker.tscn b/behaviours/tracker_edible.tscn similarity index 72% rename from behaviours/edible_tracker.tscn rename to behaviours/tracker_edible.tscn index ebad30a..6987647 100644 --- a/behaviours/edible_tracker.tscn +++ b/behaviours/tracker_edible.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=2 format=3 uid="uid://ctpn4hvkhxoi3"] -[ext_resource type="Script" path="res://behaviours/edible_tracker.gd" id="1_vo18u"] +[ext_resource type="Script" path="res://behaviours/tracker_edible.gd" id="1_vmdw6"] -[node name="EdibleTracker" type="Area2D"] +[node name="TrackerEdible" type="Area2D"] collision_layer = 0 collision_mask = 56 monitorable = false -script = ExtResource("1_vo18u") +script = ExtResource("1_vmdw6") [connection signal="body_entered" from="." to="." method="check_diet_then_track"] [connection signal="body_exited" from="." to="." method="untrack"] From 44f5556e74940f545327f0332bfc328b5f08b483 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 01:54:12 +0200 Subject: [PATCH 19/83] Delete `SkitterFromMouse` --- behaviours/skitter_from_mouse.gd | 68 ------------------------------ behaviours/skitter_from_mouse.tscn | 18 -------- 2 files changed, 86 deletions(-) delete mode 100644 behaviours/skitter_from_mouse.gd delete mode 100644 behaviours/skitter_from_mouse.tscn diff --git a/behaviours/skitter_from_mouse.gd b/behaviours/skitter_from_mouse.gd deleted file mode 100644 index b7ee4b8..0000000 --- a/behaviours/skitter_from_mouse.gd +++ /dev/null @@ -1,68 +0,0 @@ -extends Node2D -class_name SkitterFromMouse - - -signal move(movement: Vector2) -signal scared -signal calmed - - -@export_range(1, 500, 1) var speed: float = 300.0 -@export_range(0.1, 5, 0.1) var scare_secs: float = 0.2 -@export var directions: Array[Vector2] = [] - -@onready var calm_timer: Timer = $"CalmTimer" -@onready var scare_area: HoverDetector = $"ScareArea" - - -enum State { CALM, SCARED } - -var state := State.CALM -var direction := Vector2.ZERO - - -func recheck(): - if scare_area.mouse_inside: - scare() - else: - calm() - -func calm(): - state = State.CALM - calmed.emit() - -func scare(): - state = State.SCARED - # Pick a direction - var idx := Random.rng.randi_range(0, len(directions) - 1) - direction = directions[idx] - # Start the timeout for calming down - calm_timer.start(scare_secs) - scared.emit() - - -func _ready(): - if not directions: - Log.w(self, "No directions defined, object won't skitter.") - -func _physics_process(delta: float) -> void: - match state: - State.SCARED: - if len(directions) > 0: - var movement: Vector2 = direction * delta * speed - move.emit(movement) - -func _on_calm_timer_timeout() -> void: - recheck() - -func _on_hover_detector_mouse_entered() -> void: - scare() - -func _on_move(movement: Vector2) -> void: - Log.p(self, "Moving by: %s" % movement) - -func _on_scared() -> void: - Log.p(self, "Scared!") - -func _on_calmed() -> void: - Log.p(self, "Calmed down.") diff --git a/behaviours/skitter_from_mouse.tscn b/behaviours/skitter_from_mouse.tscn deleted file mode 100644 index e931c06..0000000 --- a/behaviours/skitter_from_mouse.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://c1wqgyakaultt"] - -[ext_resource type="Script" path="res://behaviours/skitter_from_mouse.gd" id="1_ftcf8"] -[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="2_cuaq0"] - -[node name="SkitterFromMouse" type="Node2D"] -script = ExtResource("1_ftcf8") - -[node name="ScareArea" parent="." instance=ExtResource("2_cuaq0")] - -[node name="CalmTimer" type="Timer" parent="."] -one_shot = true - -[connection signal="calmed" from="." to="." method="_on_calmed"] -[connection signal="move" from="." to="." method="_on_move"] -[connection signal="scared" from="." to="." method="_on_scared"] -[connection signal="mouse_entered" from="ScareArea" to="." method="_on_hover_detector_mouse_entered"] -[connection signal="timeout" from="CalmTimer" to="." method="_on_calm_timer_timeout"] From 6328c2ef0dc63974ca31143ad3a04051114c0c84 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 04:14:50 +0200 Subject: [PATCH 20/83] Create VSCode run configs --- .vscode/launch.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..23c5875 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Project", + "type": "godot", + "request": "launch", + "project": "${workspaceFolder}", + }, + { + "name": "Launch Scene", + "type": "godot", + "request": "launch", + "scene": "current", + "project": "${workspaceFolder}", + } + ] +} \ No newline at end of file From 1f8a5532942c6fab7afff60c2a928579aad1bfc9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 04:52:11 +0200 Subject: [PATCH 21/83] Implement the new behaviour system on `Sheep` to test it out --- behaviours/move.gd | 3 + behaviours/move_straight.gd | 14 +++- behaviours/move_towards.gd | 27 +++++--- behaviours/priority.gd | 23 +++++++ behaviours/priority.tscn | 2 + behaviours/sampler.gd | 19 ++++- behaviours/sampler_priority.gd | 12 ++-- behaviours/sampler_random.gd | 5 +- behaviours/sampler_weighted.gd | 3 +- behaviours/tracker.gd | 7 ++ behaviours/tracker.svg | 39 +++++++++++ ...r_edible.svg.import => tracker.svg.import} | 8 +-- behaviours/tracker_edible.gd | 3 +- behaviours/tracker_edible.svg | 39 ----------- behaviours/tracker_tracker.gd | 6 ++ behaviours/tracker_tracker.tscn | 10 +++ entities/sheep.tscn | 69 ++++++++++++++++++- 17 files changed, 216 insertions(+), 73 deletions(-) create mode 100644 behaviours/tracker.svg rename behaviours/{tracker_edible.svg.import => tracker.svg.import} (71%) delete mode 100644 behaviours/tracker_edible.svg create mode 100644 behaviours/tracker_tracker.gd create mode 100644 behaviours/tracker_tracker.tscn diff --git a/behaviours/move.gd b/behaviours/move.gd index ae3e420..38787cd 100644 --- a/behaviours/move.gd +++ b/behaviours/move.gd @@ -4,3 +4,6 @@ class_name Move signal move(norm: Vector2) + +## Whether this component should emit [signal move]. +@export var enabled: bool = true diff --git a/behaviours/move_straight.gd b/behaviours/move_straight.gd index 67ddc10..761b7fd 100644 --- a/behaviours/move_straight.gd +++ b/behaviours/move_straight.gd @@ -1,11 +1,18 @@ extends Move class_name MoveStraight - ## A [Move] that moves in a fixed direction. -@export var direction: Vector2 +signal changed_direction(new: Vector2) + + +@export var direction: Vector2: + get: + return direction + set(value): + direction = value + changed_direction.emit(direction) func randomize_direction() -> void: @@ -13,4 +20,5 @@ func randomize_direction() -> void: func _physics_process(_delta: float) -> void: - move.emit(direction) + if enabled: + move.emit(direction) diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index dcb20ad..c2f8ca0 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -5,7 +5,15 @@ class_name MoveTowards ## A [Move] that moves towards the [field position] of a [field target]. -@export var target: Node2D = null +signal changed_target(target: Node2D) + + +@export var target: Node2D = null: + get: + return target + set(value): + value = target + changed_target.emit() func set_target(value: Node2D) -> void: @@ -15,14 +23,11 @@ func clear_target() -> void: target = null -func _ready() -> void: - if target == null: - Log.w(self, "No target is set, no signals will be emitted.") - func _physics_process(_delta: float) -> void: - if target: - var gap = target.global_position - global_position - var norm = gap.normalized() - move.emit(norm) - else: - move.emit(Vector2.ZERO) + if enabled: + if target: + var gap = target.global_position - global_position + var norm = gap.normalized() + move.emit(norm) + else: + move.emit(Vector2.ZERO) diff --git a/behaviours/priority.gd b/behaviours/priority.gd index e1e9e39..6be6430 100644 --- a/behaviours/priority.gd +++ b/behaviours/priority.gd @@ -3,8 +3,31 @@ extends Node class_name Priority +## Keeps track of the object's priority + + +signal priority_changed(new: int, old: int) +signal priority_changed_no_args + + @export var priority: int = 0 +func set_priority(value: int): + var old = priority + priority = value + priority_changed.emit(priority, old) + +func set_priority_if_truthy(variant: Variant, truthy: int, falsy: int = 0): + if variant: + set_priority(truthy) + else: + set_priority(falsy) + func get_ref() -> Node: return get_parent() + + +func _on_priority_changed(new: int, _old: int) -> void: + Log.p(self, "Priority changed to: %s" % new) + priority_changed_no_args.emit() diff --git a/behaviours/priority.tscn b/behaviours/priority.tscn index 1c489db..e240944 100644 --- a/behaviours/priority.tscn +++ b/behaviours/priority.tscn @@ -4,3 +4,5 @@ [node name="Priority" type="Node"] script = ExtResource("1_8u7ji") + +[connection signal="priority_changed" from="." to="." method="_on_priority_changed"] diff --git a/behaviours/sampler.gd b/behaviours/sampler.gd index 1c63eea..4e08e7f 100644 --- a/behaviours/sampler.gd +++ b/behaviours/sampler.gd @@ -6,7 +6,24 @@ class_name Sampler ## Abstract base class for sampling a certain reference among multiple. +signal notify_selected(node: Node) +signal notify_deselected(node: Node) + + +@export var possibilities: Array[Node] = [] + + ## Get a reference. -func sample() -> Object: +func sample() -> Node: Log.e(self, "Not implemented.") return null + +## Get all possible nodes referenced by [field possibilities]. +func get_refs() -> Array[Node]: + return possibilities + +## Set the "enabled" property on +func enable() -> void: + var selected = sample() + for possibility in get_refs(): + possibility.enabled = (selected == possibility) diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index ca3ea44..e2d36bd 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -5,9 +5,6 @@ class_name SamplerPriority ## Always sample the object with the highest priority in the queue. -@export var possibilities: Array[Priority] = [] - - ## Get a reference. func sample() -> Priority: if len(possibilities) == 0: @@ -16,10 +13,17 @@ func sample() -> Priority: # FIXME: Change this to something more efficient when needed var highest_possibility: Priority = null for possibility in possibilities: - if possibility.priority > highest_possibility.priority: + if highest_possibility == null or possibility.priority > highest_possibility.priority: highest_possibility = possibility if highest_possibility == null: return null + Log.p(self, "Sampled: %s" % highest_possibility) return highest_possibility.get_ref() + +func get_refs() -> Array[Node]: + var refs: Array[Node] = [] + for possibility in possibilities: + refs.append(possibility.get_ref()) + return refs diff --git a/behaviours/sampler_random.gd b/behaviours/sampler_random.gd index 5380d3e..88e4e82 100644 --- a/behaviours/sampler_random.gd +++ b/behaviours/sampler_random.gd @@ -5,10 +5,7 @@ class_name SamplerRandom ## Sample a random reference from the array. -@export var possibilities: Array = [] - - -func sample() -> Object: +func sample() -> Node: if len(possibilities) == 0: return null return Random.sample(possibilities) diff --git a/behaviours/sampler_weighted.gd b/behaviours/sampler_weighted.gd index cc81bc0..84bbc0d 100644 --- a/behaviours/sampler_weighted.gd +++ b/behaviours/sampler_weighted.gd @@ -5,11 +5,10 @@ class_name SamplerWeighted ## Sample a random reference from the array, considering the given weights. -@export var possibilities: Array = [] @export var weights: Array[int] = [] -func sample() -> Object: +func sample() -> Node: var total = compute_total_weight() if total == 0: return null diff --git a/behaviours/tracker.gd b/behaviours/tracker.gd index 111072f..deaf1a9 100644 --- a/behaviours/tracker.gd +++ b/behaviours/tracker.gd @@ -1,3 +1,4 @@ +@icon("res://behaviours/tracker.svg") extends Area2D class_name Tracker @@ -15,6 +16,9 @@ func track(body: Node2D) -> bool: if act: tracking.push_back(body) tracked.emit(body) + # Handle TrackerTracker + for tracker_tracker in body.find_children("*", "TrackerTracker", false, false): + tracker_tracker.track(self) return act func untrack(body: Node2D) -> bool: @@ -22,6 +26,9 @@ func untrack(body: Node2D) -> bool: if act: tracking.erase(body) untracked.emit(body) + # Handle TrackerTracker + for tracker_tracker in body.find_children("*", "TrackerTracker", false, false): + tracker_tracker.untrack(self) return act func log_tracked(body: Node2D) -> void: diff --git a/behaviours/tracker.svg b/behaviours/tracker.svg new file mode 100644 index 0000000..327b1f2 --- /dev/null +++ b/behaviours/tracker.svg @@ -0,0 +1,39 @@ + + + + + + + diff --git a/behaviours/tracker_edible.svg.import b/behaviours/tracker.svg.import similarity index 71% rename from behaviours/tracker_edible.svg.import rename to behaviours/tracker.svg.import index 3d51dc1..32be8d3 100644 --- a/behaviours/tracker_edible.svg.import +++ b/behaviours/tracker.svg.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://8443tt517pkv" -path="res://.godot/imported/tracker_edible.svg-fb108b51d33883549e8e498a16701c4f.ctex" +uid="uid://b3myvaqud7w0p" +path="res://.godot/imported/tracker.svg-98e9b55805c6d630e7da524610510efd.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://behaviours/tracker_edible.svg" -dest_files=["res://.godot/imported/tracker_edible.svg-fb108b51d33883549e8e498a16701c4f.ctex"] +source_file="res://behaviours/tracker.svg" +dest_files=["res://.godot/imported/tracker.svg-98e9b55805c6d630e7da524610510efd.ctex"] [params] diff --git a/behaviours/tracker_edible.gd b/behaviours/tracker_edible.gd index a2aed3b..da5ece4 100644 --- a/behaviours/tracker_edible.gd +++ b/behaviours/tracker_edible.gd @@ -1,4 +1,3 @@ -@icon("res://behaviours/tracker_edible.svg") extends Tracker class_name EdibleTracker @@ -9,7 +8,7 @@ class_name EdibleTracker func check_diet_then_track(body: Node2D) -> void: - var edibles: Array = body.find_children("Edible", "Edible", false, false) + var edibles: Array = body.find_children("*", "Edible", false, false) for edible in edibles: if edible.tag in acceptable_diets: track(body) diff --git a/behaviours/tracker_edible.svg b/behaviours/tracker_edible.svg deleted file mode 100644 index 34115c7..0000000 --- a/behaviours/tracker_edible.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - diff --git a/behaviours/tracker_tracker.gd b/behaviours/tracker_tracker.gd new file mode 100644 index 0000000..98c08c7 --- /dev/null +++ b/behaviours/tracker_tracker.gd @@ -0,0 +1,6 @@ +extends Tracker +class_name TrackerTracker + +## Tracks [Tracker]s tracking the parent. +## +## Shape is ignored. diff --git a/behaviours/tracker_tracker.tscn b/behaviours/tracker_tracker.tscn new file mode 100644 index 0000000..beadebe --- /dev/null +++ b/behaviours/tracker_tracker.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://c5pyp5hvthdof"] + +[ext_resource type="Script" path="res://behaviours/tracker_tracker.gd" id="1_7b21r"] + +[node name="TrackerTracker" type="Area2D"] +collision_layer = 0 +collision_mask = 0 +monitoring = false +monitorable = false +script = ExtResource("1_7b21r") diff --git a/entities/sheep.tscn b/entities/sheep.tscn index d29f4ba..065360d 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 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"] @@ -8,6 +8,12 @@ [ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/drop.wav" id="4_nxjnl"] [ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="4_oalqu"] [ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="6_3odsh"] +[ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"] +[ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"] +[ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="11_0jlmk"] +[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://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] radius = 8.0 @@ -70,6 +76,9 @@ _data = { "wobble": SubResource("Animation_lxieb") } +[sub_resource type="CircleShape2D" id="CircleShape2D_etpf6"] +radius = 144.0 + [node name="Sheep" type="CharacterBody2D"] collision_layer = 8 collision_mask = 14 @@ -97,12 +106,66 @@ stream = ExtResource("4_oalqu") scale = Vector2(0.5, 0.5) stream = ExtResource("4_nxjnl") -[node name="Edible" parent="." instance=ExtResource("6_3odsh")] - [node name="Animator" type="AnimationPlayer" parent="."] libraries = { "": SubResource("AnimationLibrary_6mutq") } +[node name="Edible" parent="." instance=ExtResource("6_3odsh")] + +[node name="Movement" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("9_s5lod")] +possibilities = [NodePath("Idle/IdlePriority"), NodePath("Wander/WanderPriority"), NodePath("RunFromMouse/RunFromMousePriority"), NodePath("RunFromHunter/RunFromHunterPriority")] + +[node name="Idle" parent="Movement" instance=ExtResource("10_05kcd")] +enabled = false + +[node name="IdlePriority" parent="Movement/Idle" instance=ExtResource("11_0jlmk")] +priority = 10 + +[node name="BoredTimer" type="Timer" parent="Movement/Idle"] +one_shot = true +autostart = true + +[node name="Wander" parent="Movement" instance=ExtResource("10_05kcd")] +enabled = false + +[node name="WanderPriority" parent="Movement/Wander" instance=ExtResource("11_0jlmk")] + +[node name="TiredTimer" type="Timer" parent="Movement/Wander"] +one_shot = true + +[node name="RunFromMouse" parent="Movement" instance=ExtResource("12_x2g3x")] +enabled = false + +[node name="RunFromMousePriority" parent="Movement/RunFromMouse" instance=ExtResource("11_0jlmk")] + +[node name="CursorDetector" parent="Movement/RunFromMouse" instance=ExtResource("13_5fkdr")] + +[node name="Shape" type="CollisionShape2D" parent="Movement/RunFromMouse/CursorDetector"] +shape = SubResource("CircleShape2D_etpf6") +debug_color = Color(1, 0, 0, 0.0470588) + +[node name="RunFromHunter" parent="Movement" instance=ExtResource("12_x2g3x")] +enabled = false + +[node name="RunFromHunterPriority" parent="Movement/RunFromHunter" instance=ExtResource("11_0jlmk")] + +[node name="TrackerTracker" parent="Movement/RunFromHunter" instance=ExtResource("14_eqowb")] + [connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"] [connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"] +[connection signal="ready" from="Movement" to="Movement" method="enable"] +[connection signal="priority_changed_no_args" from="Movement/Idle/IdlePriority" to="Movement" method="enable"] +[connection signal="timeout" from="Movement/Idle/BoredTimer" to="Movement/Wander" method="randomize_direction"] +[connection signal="changed_direction" from="Movement/Wander" to="Movement/Wander/WanderPriority" method="set_priority_if_truthy" binds= [20]] +[connection signal="changed_direction" from="Movement/Wander" to="Movement/Wander/TiredTimer" method="start" unbinds=1] +[connection signal="priority_changed_no_args" from="Movement/Wander/WanderPriority" to="Movement" method="enable"] +[connection signal="timeout" from="Movement/Wander/TiredTimer" to="Movement/Wander/WanderPriority" method="set_priority" binds= [0]] +[connection signal="changed_target" from="Movement/RunFromMouse" to="Movement/RunFromMouse/RunFromMousePriority" method="set_priority_if_truthy" binds= [30]] +[connection signal="priority_changed_no_args" from="Movement/RunFromMouse/RunFromMousePriority" to="Movement" method="enable"] +[connection signal="cursor_entered" from="Movement/RunFromMouse/CursorDetector" to="Movement/RunFromMouse" method="set_target"] +[connection signal="cursor_exited" from="Movement/RunFromMouse/CursorDetector" to="Movement/RunFromMouse" method="clear_target" unbinds=1] +[connection signal="changed_target" from="Movement/RunFromHunter" to="Movement/RunFromHunter/RunFromHunterPriority" method="set_priority_if_truthy" binds= [40]] +[connection signal="priority_changed_no_args" from="Movement/RunFromHunter/RunFromHunterPriority" to="Movement" method="enable"] +[connection signal="tracked" from="Movement/RunFromHunter/TrackerTracker" to="Movement/RunFromHunter" method="set_target"] +[connection signal="untracked" from="Movement/RunFromHunter/TrackerTracker" to="Movement/RunFromHunter" method="clear_target" unbinds=1] From 17e87b06d09349fefb9cfaa5c04596fa7ba6d67e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 05:01:02 +0200 Subject: [PATCH 22/83] Alter `Move` a bit... --- behaviours/move.gd | 15 ++++++++++++++- entities/sheep.tscn | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/behaviours/move.gd b/behaviours/move.gd index 38787cd..fb033cd 100644 --- a/behaviours/move.gd +++ b/behaviours/move.gd @@ -4,6 +4,19 @@ class_name Move signal move(norm: Vector2) +signal move_toggled(value: bool) +signal move_enabled +signal move_disabled ## Whether this component should emit [signal move]. -@export var enabled: bool = true +@export var enabled: bool = true: + get: + return enabled + set(value): + if enabled != value: + enabled = value + move_toggled.emit(value) + if value: + move_enabled.emit() + else: + move_disabled.emit() diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 065360d..6b6c7da 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -124,7 +124,6 @@ priority = 10 [node name="BoredTimer" type="Timer" parent="Movement/Idle"] one_shot = true -autostart = true [node name="Wander" parent="Movement" instance=ExtResource("10_05kcd")] enabled = false @@ -152,20 +151,31 @@ enabled = false [node name="TrackerTracker" parent="Movement/RunFromHunter" instance=ExtResource("14_eqowb")] +[node name="Camera2D" type="Camera2D" parent="."] +position_smoothing_enabled = true +position_smoothing_speed = 1.0 + [connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"] [connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"] [connection signal="ready" from="Movement" to="Movement" method="enable"] +[connection signal="move" from="Movement/Idle" to="." method="_on_move"] +[connection signal="move_disabled" from="Movement/Idle" to="Movement/Idle/BoredTimer" method="stop"] +[connection signal="move_enabled" from="Movement/Idle" to="Movement/Idle/BoredTimer" method="start"] [connection signal="priority_changed_no_args" from="Movement/Idle/IdlePriority" to="Movement" method="enable"] [connection signal="timeout" from="Movement/Idle/BoredTimer" to="Movement/Wander" method="randomize_direction"] [connection signal="changed_direction" from="Movement/Wander" to="Movement/Wander/WanderPriority" method="set_priority_if_truthy" binds= [20]] -[connection signal="changed_direction" from="Movement/Wander" to="Movement/Wander/TiredTimer" method="start" unbinds=1] +[connection signal="move" from="Movement/Wander" to="." method="_on_move"] +[connection signal="move_disabled" from="Movement/Wander" to="Movement/Wander/TiredTimer" method="stop"] +[connection signal="move_enabled" from="Movement/Wander" to="Movement/Wander/TiredTimer" method="start"] [connection signal="priority_changed_no_args" from="Movement/Wander/WanderPriority" to="Movement" method="enable"] [connection signal="timeout" from="Movement/Wander/TiredTimer" to="Movement/Wander/WanderPriority" method="set_priority" binds= [0]] [connection signal="changed_target" from="Movement/RunFromMouse" to="Movement/RunFromMouse/RunFromMousePriority" method="set_priority_if_truthy" binds= [30]] +[connection signal="move" from="Movement/RunFromMouse" to="." method="_on_move"] [connection signal="priority_changed_no_args" from="Movement/RunFromMouse/RunFromMousePriority" to="Movement" method="enable"] [connection signal="cursor_entered" from="Movement/RunFromMouse/CursorDetector" to="Movement/RunFromMouse" method="set_target"] [connection signal="cursor_exited" from="Movement/RunFromMouse/CursorDetector" to="Movement/RunFromMouse" method="clear_target" unbinds=1] [connection signal="changed_target" from="Movement/RunFromHunter" to="Movement/RunFromHunter/RunFromHunterPriority" method="set_priority_if_truthy" binds= [40]] +[connection signal="move" from="Movement/RunFromHunter" to="." method="_on_move"] [connection signal="priority_changed_no_args" from="Movement/RunFromHunter/RunFromHunterPriority" to="Movement" method="enable"] [connection signal="tracked" from="Movement/RunFromHunter/TrackerTracker" to="Movement/RunFromHunter" method="set_target"] [connection signal="untracked" from="Movement/RunFromHunter/TrackerTracker" to="Movement/RunFromHunter" method="clear_target" unbinds=1] From 3341c86e39ed60ed274fb600fe20a86a92cc0c33 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 05:26:13 +0200 Subject: [PATCH 23/83] Sheep now work! Almost. Missing speed. --- behaviours/cursor_detector.gd | 7 +++ behaviours/cursor_detector.tscn | 2 + behaviours/move_straight.gd | 9 ++++ behaviours/move_straight.tscn | 2 + behaviours/move_towards.gd | 9 ++-- behaviours/move_towards.tscn | 2 + behaviours/sampler_priority.gd | 3 +- entities/sheep.tscn | 80 ++++++++++++++++----------------- scenes/game/cursor.gd | 6 +-- scenes/game/cursor.tscn | 10 ++++- scenes/game/main_game.tscn | 31 ++++++++----- 11 files changed, 100 insertions(+), 61 deletions(-) diff --git a/behaviours/cursor_detector.gd b/behaviours/cursor_detector.gd index 367acb4..c37a9ec 100644 --- a/behaviours/cursor_detector.gd +++ b/behaviours/cursor_detector.gd @@ -19,3 +19,10 @@ func _on_body_exited(body: Node2D) -> void: if body is Cursor: mouse_inside = true cursor_exited.emit(body) + + +func _on_cursor_entered(cursor: Cursor) -> void: + Log.p(self, "Cursor entered: %s" % cursor) + +func _on_cursor_exited(cursor: Cursor) -> void: + Log.p(self, "Cursor exited: %s" % cursor) diff --git a/behaviours/cursor_detector.tscn b/behaviours/cursor_detector.tscn index c4b4fec..99ca786 100644 --- a/behaviours/cursor_detector.tscn +++ b/behaviours/cursor_detector.tscn @@ -10,3 +10,5 @@ script = ExtResource("1_4hcxj") [connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="body_exited" from="." to="." method="_on_body_exited"] +[connection signal="cursor_entered" from="." to="." method="_on_cursor_entered"] +[connection signal="cursor_exited" from="." to="." method="_on_cursor_exited"] diff --git a/behaviours/move_straight.gd b/behaviours/move_straight.gd index 761b7fd..86f5bc1 100644 --- a/behaviours/move_straight.gd +++ b/behaviours/move_straight.gd @@ -15,6 +15,12 @@ signal changed_direction(new: Vector2) changed_direction.emit(direction) +func set_direction(value: Vector2) -> void: + direction = value + +func clear_direction() -> void: + direction = Vector2.ZERO + func randomize_direction() -> void: direction = Vector2.from_angle(Random.rng.randf_range(0, 2*PI)) @@ -22,3 +28,6 @@ func randomize_direction() -> void: func _physics_process(_delta: float) -> void: if enabled: move.emit(direction) + +func _on_changed_direction(new: Vector2) -> void: + Log.p(self, "Changed direction to: %s" % new) diff --git a/behaviours/move_straight.tscn b/behaviours/move_straight.tscn index e176db3..11a2a41 100644 --- a/behaviours/move_straight.tscn +++ b/behaviours/move_straight.tscn @@ -4,3 +4,5 @@ [node name="MoveStraight" type="Node2D"] script = ExtResource("1_8yf73") + +[connection signal="changed_direction" from="." to="." method="_on_changed_direction"] diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index c2f8ca0..058b20e 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -5,15 +5,15 @@ class_name MoveTowards ## A [Move] that moves towards the [field position] of a [field target]. -signal changed_target(target: Node2D) +signal changed_target(new: Node2D) @export var target: Node2D = null: get: return target set(value): - value = target - changed_target.emit() + target = value + changed_target.emit(value) func set_target(value: Node2D) -> void: @@ -31,3 +31,6 @@ func _physics_process(_delta: float) -> void: move.emit(norm) else: move.emit(Vector2.ZERO) + +func _on_changed_target(new: Node2D) -> void: + Log.p(self, "Changed target to: %s" % new) diff --git a/behaviours/move_towards.tscn b/behaviours/move_towards.tscn index 41b4c4a..2c7f758 100644 --- a/behaviours/move_towards.tscn +++ b/behaviours/move_towards.tscn @@ -4,3 +4,5 @@ [node name="MoveTowards" type="Node2D"] script = ExtResource("1_256ue") + +[connection signal="changed_target" from="." to="." method="_on_changed_target"] diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index e2d36bd..4903981 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -13,13 +13,14 @@ func sample() -> Priority: # FIXME: Change this to something more efficient when needed var highest_possibility: Priority = null for possibility in possibilities: + Log.p(self, "Possibility: %s (%d)" % [possibility, possibility.priority]) if highest_possibility == null or possibility.priority > highest_possibility.priority: highest_possibility = possibility if highest_possibility == null: return null - Log.p(self, "Sampled: %s" % highest_possibility) + Log.p(self, "Sampled: %s (%d)" % [highest_possibility, highest_possibility.priority]) return highest_possibility.get_ref() func get_refs() -> Array[Node]: diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 6b6c7da..d71578e 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -113,69 +113,67 @@ libraries = { [node name="Edible" parent="." instance=ExtResource("6_3odsh")] -[node name="Movement" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("9_s5lod")] -possibilities = [NodePath("Idle/IdlePriority"), NodePath("Wander/WanderPriority"), NodePath("RunFromMouse/RunFromMousePriority"), NodePath("RunFromHunter/RunFromHunterPriority")] +[node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("9_s5lod")] +possibilities = [NodePath("../MovementIdle/IdlePriority"), NodePath("../MovementWander/WanderPriority"), NodePath("../MovementRunFromMouse/RunFromMousePriority"), NodePath("../MovementRunFromHunter/RunFromHunterPriority")] -[node name="Idle" parent="Movement" instance=ExtResource("10_05kcd")] +[node name="MovementIdle" parent="." instance=ExtResource("10_05kcd")] enabled = false -[node name="IdlePriority" parent="Movement/Idle" instance=ExtResource("11_0jlmk")] +[node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")] priority = 10 -[node name="BoredTimer" type="Timer" parent="Movement/Idle"] +[node name="BoredTimer" type="Timer" parent="MovementIdle"] one_shot = true -[node name="Wander" parent="Movement" instance=ExtResource("10_05kcd")] +[node name="MovementWander" parent="." instance=ExtResource("10_05kcd")] enabled = false -[node name="WanderPriority" parent="Movement/Wander" instance=ExtResource("11_0jlmk")] +[node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")] -[node name="TiredTimer" type="Timer" parent="Movement/Wander"] +[node name="TiredTimer" type="Timer" parent="MovementWander"] one_shot = true -[node name="RunFromMouse" parent="Movement" instance=ExtResource("12_x2g3x")] +[node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")] enabled = false -[node name="RunFromMousePriority" parent="Movement/RunFromMouse" instance=ExtResource("11_0jlmk")] +[node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")] -[node name="CursorDetector" parent="Movement/RunFromMouse" instance=ExtResource("13_5fkdr")] +[node name="CursorSense" parent="MovementRunFromMouse" instance=ExtResource("13_5fkdr")] -[node name="Shape" type="CollisionShape2D" parent="Movement/RunFromMouse/CursorDetector"] +[node name="Shape" type="CollisionShape2D" parent="MovementRunFromMouse/CursorSense"] shape = SubResource("CircleShape2D_etpf6") debug_color = Color(1, 0, 0, 0.0470588) -[node name="RunFromHunter" parent="Movement" instance=ExtResource("12_x2g3x")] +[node name="MovementRunFromHunter" parent="." instance=ExtResource("12_x2g3x")] enabled = false -[node name="RunFromHunterPriority" parent="Movement/RunFromHunter" instance=ExtResource("11_0jlmk")] +[node name="RunFromHunterPriority" parent="MovementRunFromHunter" instance=ExtResource("11_0jlmk")] -[node name="TrackerTracker" parent="Movement/RunFromHunter" instance=ExtResource("14_eqowb")] - -[node name="Camera2D" type="Camera2D" parent="."] -position_smoothing_enabled = true -position_smoothing_speed = 1.0 +[node name="HunterSense" parent="MovementRunFromHunter" instance=ExtResource("14_eqowb")] [connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"] [connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"] -[connection signal="ready" from="Movement" to="Movement" method="enable"] -[connection signal="move" from="Movement/Idle" to="." method="_on_move"] -[connection signal="move_disabled" from="Movement/Idle" to="Movement/Idle/BoredTimer" method="stop"] -[connection signal="move_enabled" from="Movement/Idle" to="Movement/Idle/BoredTimer" method="start"] -[connection signal="priority_changed_no_args" from="Movement/Idle/IdlePriority" to="Movement" method="enable"] -[connection signal="timeout" from="Movement/Idle/BoredTimer" to="Movement/Wander" method="randomize_direction"] -[connection signal="changed_direction" from="Movement/Wander" to="Movement/Wander/WanderPriority" method="set_priority_if_truthy" binds= [20]] -[connection signal="move" from="Movement/Wander" to="." method="_on_move"] -[connection signal="move_disabled" from="Movement/Wander" to="Movement/Wander/TiredTimer" method="stop"] -[connection signal="move_enabled" from="Movement/Wander" to="Movement/Wander/TiredTimer" method="start"] -[connection signal="priority_changed_no_args" from="Movement/Wander/WanderPriority" to="Movement" method="enable"] -[connection signal="timeout" from="Movement/Wander/TiredTimer" to="Movement/Wander/WanderPriority" method="set_priority" binds= [0]] -[connection signal="changed_target" from="Movement/RunFromMouse" to="Movement/RunFromMouse/RunFromMousePriority" method="set_priority_if_truthy" binds= [30]] -[connection signal="move" from="Movement/RunFromMouse" to="." method="_on_move"] -[connection signal="priority_changed_no_args" from="Movement/RunFromMouse/RunFromMousePriority" to="Movement" method="enable"] -[connection signal="cursor_entered" from="Movement/RunFromMouse/CursorDetector" to="Movement/RunFromMouse" method="set_target"] -[connection signal="cursor_exited" from="Movement/RunFromMouse/CursorDetector" to="Movement/RunFromMouse" method="clear_target" unbinds=1] -[connection signal="changed_target" from="Movement/RunFromHunter" to="Movement/RunFromHunter/RunFromHunterPriority" method="set_priority_if_truthy" binds= [40]] -[connection signal="move" from="Movement/RunFromHunter" to="." method="_on_move"] -[connection signal="priority_changed_no_args" from="Movement/RunFromHunter/RunFromHunterPriority" to="Movement" method="enable"] -[connection signal="tracked" from="Movement/RunFromHunter/TrackerTracker" to="Movement/RunFromHunter" method="set_target"] -[connection signal="untracked" from="Movement/RunFromHunter/TrackerTracker" to="Movement/RunFromHunter" method="clear_target" unbinds=1] +[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"] +[connection signal="move_enabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="start"] +[connection signal="priority_changed_no_args" from="MovementIdle/IdlePriority" to="MovementSampler" method="enable"] +[connection signal="timeout" from="MovementIdle/BoredTimer" to="MovementWander" method="randomize_direction"] +[connection signal="changed_direction" from="MovementWander" to="MovementWander/WanderPriority" method="set_priority_if_truthy" binds= [20]] +[connection signal="move" from="MovementWander" to="." method="_on_move"] +[connection signal="move_disabled" from="MovementWander" to="MovementWander/TiredTimer" method="stop"] +[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="MovementRunFromMouse" to="MovementRunFromMouse/RunFromMousePriority" method="set_priority_if_truthy" binds= [30]] +[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="set_priority_if_truthy" binds= [40]] +[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] diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 79bcc35..120ecf9 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -1,11 +1,11 @@ -extends Node2D +extends CharacterBody2D class_name Cursor -## A [Node2D] syncing its position with the mouse on each physics timestep. +## A [CharacterBody2D] syncing its position with the mouse on each physics timestep. @onready var game := MainGame.get_ancestor(self) func _physics_process(_delta: float) -> void: - global_position = game.camera.get_global_mouse_position() + move_and_collide(game.camera.get_global_mouse_position() - global_position) diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 57db1e8..d2feb08 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -1,8 +1,16 @@ -[gd_scene load_steps=2 format=3 uid="uid://col1q3elvkfwk"] +[gd_scene load_steps=3 format=3 uid="uid://col1q3elvkfwk"] [ext_resource type="Script" path="res://scenes/game/cursor.gd" id="1_1og6v"] +[sub_resource type="CircleShape2D" id="CircleShape2D_j2mj5"] +radius = 4.0 + [node name="Cursor" type="CharacterBody2D"] collision_layer = 64 collision_mask = 0 +motion_mode = 1 script = ExtResource("1_1og6v") + +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_j2mj5") +debug_color = Color(1, 1, 1, 1) diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 045553f..0fcecdc 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -4,7 +4,8 @@ [ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_db5xs"] [ext_resource type="Texture2D" uid="uid://d13j4br4hxek6" path="res://scenes/game/tileset_grass.png" id="2_o7bg5"] [ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="3_p6jw3"] -[ext_resource type="PackedScene" uid="uid://7j1b55t8tafg" path="res://scenes/game/cursor_magnet.tscn" id="3_xbolm"] +[ext_resource type="PackedScene" uid="uid://col1q3elvkfwk" path="res://scenes/game/cursor.tscn" id="5_g504x"] +[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="6_j2kdp"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -809,9 +810,6 @@ terrain_set_0/terrain_1/name = "Dirt" terrain_set_0/terrain_1/color = Color(0.619608, 0.407843, 0.172549, 1) sources/0 = SubResource("TileSetAtlasSource_058kb") -[sub_resource type="RectangleShape2D" id="RectangleShape2D_p1lg5"] -size = Vector2(1280, 720) - [node name="MainGame" type="Node2D"] script = ExtResource("1_wiglu") @@ -821,17 +819,26 @@ tile_set = SubResource("TileSet_g2dkm") format = 2 layer_0/tile_data = PackedInt32Array(720915, 196608, 9, 655379, 0, 2, 589843, 0, 4, 524307, 196608, 8, 458771, 196608, 0, 393235, 327680, 1, 327699, 327680, 2, 262163, 65536, 5, 196627, 327680, 0, 131091, 196608, 4, 65555, 0, 6, 19, 0, 6, -65517, 0, 6, -131053, 196608, 1, -196589, 327680, 2, -262125, 327680, 4, -327661, 327680, 1, -393197, 0, 3, -458733, 65536, 0, -524269, 196608, 0, -589805, 327680, 0, -655341, 0, 3, -720877, 327680, 5, -786413, 131072, 8, 720914, 327680, 1, 655378, 65536, 5, 589842, 327680, 0, 524306, 0, 5, 458770, 327680, 2, 393234, 327680, 1, 327698, 131072, 9, 262162, 327680, 0, 196626, 0, 4, 131090, 262144, 6, 65554, 196608, 2, 18, 131072, 3, -65518, 196608, 3, -131054, 196608, 1, -196590, 196608, 9, -262126, 327680, 4, -327662, 0, 4, -393198, 131072, 5, -458734, 262144, 5, -524270, 131072, 9, -589806, 0, 1, -655342, 65536, 5, -720878, 327680, 4, -786414, 262144, 0, 720913, 0, 5, 655377, 131072, 9, 589841, 196608, 9, 524305, 327680, 5, 458769, 0, 4, 393233, 0, 4, 327697, 327680, 5, 262161, 327680, 0, 196625, 262144, 4, 131089, 0, 6, 65553, 131072, 3, 17, 196608, 3, -65519, 196608, 2, -131055, 131072, 11, -196591, 327680, 1, -262127, 196608, 9, -327663, 0, 5, -393199, 262144, 0, -458735, 131072, 0, -524271, 0, 4, -589807, 0, 1, -655343, 327680, 5, -720879, 0, 3, -786415, 131072, 5, 720912, 131072, 9, 655376, 0, 2, 589840, 327680, 3, 524304, 131072, 8, 458768, 196608, 9, 393232, 196608, 5, 327696, 327680, 4, 262160, 262144, 5, 196624, 262144, 6, 131088, 196608, 3, 65552, 196608, 2, 16, 196608, 3, -65520, 131072, 2, -131056, 131072, 11, -196592, 327680, 0, -262128, 196608, 9, -327664, 262144, 0, -393200, 0, 1, -458736, 0, 5, -524272, 262144, 5, -589808, 196608, 8, -655344, 0, 2, -720880, 327680, 2, -786416, 131072, 0, 720911, 196608, 0, 655375, 327680, 2, 589839, 196608, 0, 524303, 0, 0, 458767, 0, 2, 393231, 196608, 5, 327695, 0, 5, 262159, 262144, 4, 196623, 0, 6, 131087, 131072, 2, 65551, 196608, 2, 15, 196608, 3, -65521, 131072, 2, -131057, 131072, 11, -196593, 0, 2, -262129, 262144, 0, -327665, 262144, 5, -393201, 327680, 0, -458737, 65536, 5, -524273, 196608, 5, -589809, 0, 4, -655345, 327680, 2, -720881, 0, 1, -786417, 0, 5, 720910, 131072, 0, 655374, 327680, 3, 589838, 327680, 4, 524302, 196608, 0, 458766, 327680, 0, 393230, 327680, 3, 327694, 262144, 4, 262158, 0, 6, 196622, 131072, 3, 131086, 131072, 3, 65550, 196608, 2, 14, 196608, 3, -65522, 131072, 2, -131058, 262144, 11, -196594, 65536, 0, -262130, 196608, 5, -327666, 0, 3, -393202, 327680, 3, -458738, 327680, 4, -524274, 131072, 0, -589810, 327680, 3, -655346, 131072, 0, -720882, 65536, 5, -786418, 0, 0, 720909, 131072, 9, 655373, 0, 1, 589837, 262144, 0, 524301, 0, 2, 458765, 0, 0, 393229, 196608, 0, 327693, 65536, 6, 262157, 196608, 2, 196621, 196608, 2, 131085, 131072, 3, 65549, 131072, 2, 13, 131072, 3, -65523, 196608, 2, -131059, 131072, 11, -196595, 262144, 0, -262131, 327680, 1, -327667, 196608, 9, -393203, 65536, 0, -458739, 65536, 0, -524275, 196608, 0, -589811, 0, 2, -655347, 327680, 1, -720883, 0, 4, -786419, 327680, 2, 720908, 262144, 5, 655372, 327680, 4, 589836, 196608, 8, 524300, 0, 3, 458764, 262144, 5, 393228, 262144, 4, 327692, 0, 6, 262156, 131072, 3, 196620, 131072, 2, 131084, 196608, 2, 65548, 131072, 3, 12, 196608, 3, -65524, 327680, 11, -131060, 65536, 1, -196596, 262144, 5, -262132, 131072, 9, -327668, 327680, 1, -393204, 327680, 0, -458740, 0, 3, -524276, 0, 3, -589812, 196608, 9, -655348, 327680, 2, -720884, 131072, 9, -786420, 131072, 0, 720907, 327680, 0, 655371, 65536, 0, 589835, 327680, 2, 524299, 262144, 5, 458763, 65536, 0, 393227, 196608, 6, 327691, 196608, 2, 262155, 131072, 3, 196619, 131072, 2, 131083, 131072, 2, 65547, 196608, 3, 11, 196608, 2, -65525, 262144, 11, -131061, 65536, 5, -196597, 196608, 9, -262133, 131072, 5, -327669, 327680, 5, -393205, 262144, 0, -458741, 0, 0, -524277, 0, 1, -589813, 0, 4, -655349, 327680, 4, -720885, 196608, 0, -786421, 0, 2, 720906, 327680, 4, 655370, 0, 4, 589834, 327680, 2, 524298, 327680, 4, 458762, 131072, 8, 393226, 131072, 4, 327690, 131072, 3, 262154, 196608, 2, 196618, 196608, 3, 131082, 131072, 2, 65546, 131072, 3, 10, 327680, 11, -65526, 65536, 1, -131062, 196608, 0, -196598, 196608, 0, -262134, 196608, 0, -327670, 131072, 8, -393206, 327680, 4, -458742, 327680, 4, -524278, 0, 1, -589814, 0, 0, -655350, 0, 3, -720886, 0, 3, -786422, 327680, 5, 720905, 327680, 0, 655369, 0, 0, 589833, 196608, 0, 524297, 196608, 0, 458761, 0, 1, 393225, 196608, 4, 327689, 196608, 3, 262153, 131072, 3, 196617, 196608, 2, 131081, 196608, 3, 65545, 327680, 11, 9, 65536, 1, -65527, 131072, 9, -131063, 0, 0, -196599, 327680, 0, -262135, 0, 3, -327671, 327680, 1, -393207, 65536, 5, -458743, 196608, 8, -524279, 327680, 3, -589815, 0, 1, -655351, 262144, 0, -720887, 262144, 0, -786423, 196608, 0, 720904, 0, 1, 655368, 262144, 5, 589832, 196608, 5, 524296, 0, 5, 458760, 262144, 4, 393224, 0, 6, 327688, 131072, 3, 262152, 196608, 3, 196616, 196608, 2, 131080, 131072, 2, 65544, 0, 11, 8, 327680, 3, -65528, 262144, 5, -131064, 65536, 5, -196600, 131072, 8, -262136, 327680, 5, -327672, 327680, 1, -393208, 0, 4, -458744, 131072, 0, -524280, 327680, 4, -589816, 131072, 0, -655352, 196608, 5, -720888, 327680, 3, -786424, 196608, 5, 720903, 327680, 5, 655367, 0, 5, 589831, 0, 5, 524295, 65536, 0, 458759, 196608, 4, 393223, 131072, 2, 327687, 196608, 2, 262151, 131072, 2, 196615, 196608, 3, 131079, 131072, 3, 65543, 131072, 3, 7, 262144, 5, -65529, 327680, 3, -131065, 196608, 5, -196601, 0, 2, -262137, 327680, 0, -327673, 327680, 1, -393209, 262144, 4, -458745, 0, 8, -524281, 262144, 3, -589817, 262144, 1, -655353, 327680, 5, -720889, 131072, 8, -786425, 0, 4, 720902, 327680, 2, 655366, 0, 3, 589830, 65536, 0, 524294, 0, 5, 458758, 131072, 4, 393222, 131072, 2, 327686, 196608, 3, 262150, 196608, 2, 196614, 131072, 2, 131078, 131072, 3, 65542, 131072, 3, 6, 327680, 5, -65530, 327680, 5, -131066, 327680, 0, -196602, 131072, 9, -262138, 262144, 4, -327674, 0, 8, -393210, 0, 6, -458746, 131072, 3, -524282, 327680, 11, -589818, 65536, 1, -655354, 0, 0, -720890, 327680, 2, -786426, 196608, 9, 720901, 65536, 5, 655365, 196608, 5, 589829, 196608, 0, 524293, 0, 4, 458757, 196608, 4, 393221, 131072, 2, 327685, 196608, 2, 262149, 131072, 2, 196613, 131072, 3, 131077, 131072, 2, 65541, 196608, 2, 5, 0, 3, -65531, 196608, 0, -131067, 327680, 4, -196603, 327680, 0, -262139, 131072, 6, -327675, 131072, 3, -393211, 196608, 3, -458747, 131072, 3, -524283, 196608, 11, -589819, 0, 2, -655355, 327680, 0, -720891, 131072, 9, -786427, 262144, 5, 720900, 196608, 0, 655364, 196608, 8, 589828, 0, 2, 524292, 327680, 0, 458756, 65536, 6, 393220, 131072, 3, 327684, 131072, 2, 262148, 196608, 3, 196612, 196608, 3, 131076, 196608, 2, 65540, 131072, 3, 4, 0, 3, -65532, 262144, 0, -131068, 131072, 0, -196604, 327680, 0, -262140, 65536, 6, -327676, 196608, 3, -393212, 131072, 2, -458748, 327680, 11, -524284, 65536, 1, -589820, 196608, 0, -655356, 0, 4, -720892, 65536, 5, -786428, 0, 1, 720899, 65536, 0, 655363, 131072, 5, 589827, 131072, 5, 524291, 0, 1, 458755, 65536, 4, 393219, 327680, 6, 327683, 196608, 2, 262147, 196608, 2, 196611, 131072, 3, 131075, 327680, 11, 65539, 327680, 8, 3, 0, 1, -65533, 131072, 0, -131069, 327680, 2, -196605, 65536, 0, -262141, 65536, 4, -327677, 327680, 10, -393213, 65536, 2, -458749, 65536, 1, -524285, 327680, 2, -589821, 0, 3, -655357, 131072, 9, -720893, 0, 2, -786429, 196608, 9, 720898, 131072, 0, 655362, 262144, 0, 589826, 327680, 5, 524290, 327680, 1, 458754, 262144, 0, 393218, 196608, 4, 327682, 196608, 2, 262146, 131072, 3, 196610, 196608, 2, 131074, 131072, 11, 65538, 327680, 4, 2, 0, 3, -65534, 0, 1, -131070, 0, 0, -196606, 327680, 0, -262142, 0, 5, -327678, 65536, 0, -393214, 65536, 5, -458750, 131072, 9, -524286, 196608, 0, -589822, 196608, 0, -655358, 0, 5, -720894, 196608, 9, -786430, 0, 5, 720897, 0, 4, 655361, 262144, 5, 589825, 327680, 0, 524289, 327680, 5, 458753, 327680, 5, 393217, 131072, 6, 327681, 131072, 2, 262145, 196608, 3, 196609, 131072, 2, 131073, 131072, 11, 65537, 131072, 9, 1, 0, 4, -65535, 196608, 0, -131071, 327680, 3, -196607, 196608, 0, -262143, 0, 4, -327679, 262144, 5, -393215, 196608, 5, -458751, 0, 2, -524287, 196608, 9, -589823, 196608, 0, -655359, 131072, 0, -720895, 0, 3, -786431, 196608, 8, 720896, 262144, 5, 655360, 0, 4, 589824, 0, 2, 524288, 0, 0, 458752, 196608, 9, 393216, 196608, 4, 327680, 196608, 3, 262144, 131072, 3, 196608, 131072, 3, 131072, 0, 11, 65536, 327680, 3, 0, 65536, 0, -65536, 196608, 5, -131072, 196608, 9, -196608, 65536, 0, -262144, 0, 5, -327680, 65536, 0, -393216, 0, 3, -458752, 327680, 0, -524288, 0, 3, -589824, 327680, 2, -655360, 131072, 8, -720896, 327680, 3, -786432, 196608, 8, 786431, 0, 3, 720895, 131072, 0, 655359, 196608, 8, 589823, 196608, 8, 524287, 327680, 0, 458751, 196608, 4, 393215, 131072, 3, 327679, 131072, 3, 262143, 196608, 3, 196607, 131072, 3, 131071, 262144, 0, 65535, 131072, 8, -1, 0, 0, -65537, 327680, 3, -131073, 131072, 9, -196609, 327680, 0, -262145, 131072, 0, -327681, 0, 0, -393217, 131072, 9, -458753, 196608, 8, -524289, 327680, 5, -589825, 0, 1, -655361, 196608, 0, -720897, 196608, 8, 786430, 327680, 3, 720894, 65536, 0, 655358, 262144, 0, 589822, 327680, 2, 524286, 131072, 0, 458750, 131072, 4, 393214, 131072, 2, 327678, 196608, 2, 262142, 131072, 2, 196606, 327680, 11, 131070, 327680, 2, 65534, 196608, 0, -2, 65536, 5, -65538, 196608, 8, -131074, 327680, 3, -196610, 131072, 8, -262146, 327680, 1, -327682, 262144, 5, -393218, 0, 1, -458754, 327680, 4, -524290, 262144, 5, -589826, 327680, 4, -655362, 327680, 1, -720898, 131072, 8, 786429, 0, 5, 720893, 0, 4, 655357, 196608, 5, 589821, 0, 4, 524285, 262144, 0, 458749, 262144, 6, 393213, 131072, 3, 327677, 131072, 2, 262141, 327680, 11, 196605, 65536, 1, 131069, 327680, 3, 65533, 0, 3, -3, 327680, 1, -65539, 327680, 4, -131075, 131072, 5, -196611, 262144, 4, -262147, 0, 10, -327683, 262144, 1, -393219, 196608, 8, -458755, 196608, 9, -524291, 0, 2, -589827, 262144, 0, -655363, 327680, 4, -720899, 327680, 4, 786428, 131072, 9, 720892, 131072, 0, 655356, 0, 5, 589820, 262144, 4, 524284, 0, 8, 458748, 0, 6, 393212, 131072, 3, 327676, 196608, 2, 262140, 196608, 11, 196604, 65536, 0, 131068, 196608, 0, 65532, 65536, 0, -4, 131072, 8, -65540, 196608, 5, -131076, 0, 2, -196612, 65536, 6, -262148, 196608, 2, -327684, 262144, 11, -393220, 0, 0, -458756, 131072, 9, -524292, 65536, 5, -589828, 131072, 0, -655364, 0, 2, -720900, 0, 0, 786427, 0, 3, 720891, 327680, 2, 655355, 0, 0, 589819, 65536, 6, 524283, 196608, 3, 458747, 131072, 2, 393211, 131072, 3, 327675, 327680, 11, 262139, 65536, 1, 196603, 131072, 0, 131067, 327680, 5, 65531, 0, 1, -5, 131072, 9, -65541, 196608, 5, -131077, 131072, 8, -196613, 262144, 6, -262149, 196608, 2, -327685, 0, 11, -393221, 262144, 1, -458757, 327680, 2, -524293, 196608, 0, -589829, 131072, 5, -655365, 262144, 0, -720901, 0, 4, 786426, 131072, 9, 720890, 262144, 0, 655354, 0, 0, 589818, 131072, 6, 524282, 196608, 2, 458746, 196608, 3, 393210, 196608, 3, 327674, 131072, 1, 262138, 196608, 5, 196602, 262144, 0, 131066, 196608, 8, 65530, 327680, 3, -6, 327680, 5, -65542, 0, 4, -131078, 196608, 8, -196614, 262144, 6, -262150, 131072, 3, -327686, 131072, 2, -393222, 196608, 1, -458758, 262144, 5, -524294, 0, 4, -589830, 131072, 5, -655366, 0, 5, -720902, 327680, 2, 786425, 0, 4, 720889, 0, 1, 655353, 0, 0, 589817, 131072, 6, 524281, 196608, 2, 458745, 131072, 2, 393209, 196608, 2, 327673, 262144, 11, 262137, 0, 0, 196601, 327680, 5, 131065, 65536, 0, 65529, 131072, 9, -7, 131072, 8, -65543, 131072, 0, -131079, 262144, 4, -196615, 0, 6, -262151, 131072, 3, -327687, 131072, 3, -393223, 0, 11, -458759, 262144, 1, -524295, 327680, 4, -589831, 262144, 5, -655367, 131072, 8, -720903, 0, 5, 786424, 327680, 3, 720888, 196608, 5, 655352, 131072, 9, 589816, 131072, 6, 524280, 196608, 2, 458744, 196608, 2, 393208, 196608, 2, 327672, 196608, 1, 262136, 0, 3, 196600, 0, 2, 131064, 327680, 0, 65528, 0, 5, -8, 0, 1, -65544, 196608, 5, -131080, 196608, 6, -196616, 131072, 3, -262152, 196608, 3, -327688, 196608, 3, -393224, 131072, 3, -458760, 196608, 1, -524296, 0, 3, -589832, 131072, 9, -655368, 0, 4, -720904, 131072, 5, 786423, 0, 0, 720887, 131072, 8, 655351, 0, 9, 589815, 0, 6, 524279, 196608, 2, 458743, 196608, 3, 393207, 131072, 2, 327671, 131072, 1, 262135, 0, 1, 196599, 196608, 8, 131063, 262144, 5, 65527, 262144, 5, -9, 0, 5, -65545, 262144, 4, -131081, 0, 6, -196617, 196608, 3, -262153, 196608, 3, -327689, 131072, 2, -393225, 196608, 2, -458761, 65536, 11, -524297, 131072, 8, -589833, 196608, 0, -655369, 196608, 9, -720905, 196608, 0, 786422, 196608, 9, 720886, 327680, 1, 655350, 327680, 6, 589814, 196608, 3, 524278, 131072, 2, 458742, 131072, 3, 393206, 327680, 11, 327670, 131072, 1, 262134, 131072, 9, 196598, 327680, 4, 131062, 0, 1, 65526, 196608, 9, -10, 65536, 5, -65546, 65536, 4, -131082, 327680, 6, -196618, 196608, 3, -262154, 131072, 3, -327690, 131072, 3, -393226, 327680, 11, -458762, 65536, 1, -524298, 0, 1, -589834, 196608, 9, -655370, 327680, 5, -720906, 327680, 5, 786421, 0, 0, 720885, 327680, 3, 655349, 262144, 6, 589813, 131072, 2, 524277, 196608, 3, 458741, 327680, 11, 393205, 65536, 1, 327669, 196608, 9, 262133, 0, 1, 196597, 327680, 0, 131061, 0, 5, 65525, 131072, 0, -11, 327680, 0, -65547, 131072, 0, -131083, 65536, 4, -196619, 327680, 9, -262155, 327680, 9, -327691, 327680, 7, -393227, 65536, 1, -458763, 327680, 4, -524299, 327680, 5, -589835, 196608, 8, -655371, 0, 3, -720907, 196608, 0, 786420, 131072, 0, 720884, 262144, 4, 655348, 0, 6, 589812, 131072, 2, 524276, 196608, 3, 458740, 131072, 11, 393204, 327680, 5, 327668, 196608, 9, 262132, 196608, 9, 196596, 65536, 5, 131060, 196608, 5, 65524, 131072, 8, -12, 65536, 5, -65548, 65536, 5, -131084, 262144, 5, -196620, 0, 1, -262156, 327680, 5, -327692, 0, 4, -393228, 196608, 0, -458764, 327680, 1, -524300, 65536, 0, -589836, 0, 5, -655372, 262144, 0, -720908, 327680, 4, 786419, 131072, 0, 720883, 262144, 6, 655347, 131072, 3, 589811, 131072, 2, 524275, 196608, 3, 458739, 131072, 1, 393203, 196608, 0, 327667, 0, 5, 262131, 0, 3, 196595, 0, 5, 131059, 196608, 5, 65523, 262144, 0, -13, 131072, 5, -65549, 327680, 2, -131085, 0, 5, -196621, 196608, 9, -262157, 0, 3, -327693, 131072, 8, -393229, 131072, 9, -458765, 65536, 5, -524301, 327680, 0, -589837, 65536, 0, -655373, 0, 2, -720909, 131072, 8, 786418, 327680, 5, 720882, 262144, 6, 655346, 196608, 2, 589810, 131072, 3, 524274, 131072, 2, 458738, 262144, 11, 393202, 196608, 5, 327666, 262144, 0, 262130, 262144, 0, 196594, 327680, 0, 131058, 327680, 1, 65522, 65536, 0, -14, 65536, 5, -65550, 327680, 0, -131086, 0, 0, -196622, 131072, 5, -262158, 327680, 2, -327694, 0, 3, -393230, 0, 0, -458766, 327680, 1, -524302, 327680, 1, -589838, 131072, 5, -655374, 131072, 8, -720910, 65536, 0, 786417, 262144, 4, 720881, 0, 6, 655345, 196608, 2, 589809, 196608, 2, 524273, 196608, 2, 458737, 131072, 1, 393201, 196608, 9, 327665, 65536, 0, 262129, 131072, 8, 196593, 0, 5, 131057, 0, 3, 65521, 196608, 0, -15, 131072, 5, -65551, 327680, 5, -131087, 0, 5, -196623, 131072, 9, -262159, 196608, 5, -327695, 0, 5, -393231, 0, 0, -458767, 0, 2, -524303, 131072, 0, -589839, 196608, 9, -655375, 262144, 5, -720911, 327680, 3, 786416, 196608, 2, 720880, 131072, 2, 655344, 196608, 3, 589808, 196608, 2, 524272, 327680, 11, 458736, 65536, 1, 393200, 0, 5, 327664, 131072, 0, 262128, 196608, 9, 196592, 65536, 0, 131056, 65536, 5, 65520, 327680, 1, -16, 131072, 9, -65552, 327680, 0, -131088, 0, 3, -196624, 327680, 0, -262160, 327680, 3, -327696, 65536, 0, -393232, 196608, 9, -458768, 65536, 0, -524304, 0, 0, -589840, 327680, 2, -655376, 327680, 3, -720912, 0, 5, 786415, 196608, 2, 720879, 131072, 3, 655343, 131072, 2, 589807, 196608, 2, 524271, 65536, 11, 458735, 65536, 5, 393199, 0, 4, 327663, 131072, 5, 262127, 262144, 0, 196591, 196608, 5, 131055, 327680, 4, 65519, 327680, 0, -17, 327680, 0, -65553, 262144, 5, -131089, 0, 4, -196625, 0, 2, -262161, 196608, 9, -327697, 0, 3, -393233, 196608, 5, -458769, 327680, 3, -524305, 327680, 2, -589841, 327680, 1, -655377, 327680, 3, -720913, 0, 2, 786414, 131072, 3, 720878, 131072, 2, 655342, 196608, 3, 589806, 327680, 11, 524270, 65536, 1, 458734, 0, 0, 393198, 0, 5, 327662, 131072, 5, 262126, 327680, 3, 196590, 65536, 0, 131054, 196608, 8, 65518, 0, 5, -18, 65536, 5, -65554, 327680, 0, -131090, 327680, 3, -196626, 0, 0, -262162, 0, 3, -327698, 262144, 0, -393234, 262144, 0, -458770, 65536, 0, -524306, 131072, 0, -589842, 0, 1, -655378, 327680, 2, -720914, 196608, 5, 786413, 196608, 3, 720877, 131072, 3, 655341, 327680, 11, 589805, 65536, 1, 524269, 327680, 4, 458733, 327680, 2, 393197, 0, 3, 327661, 0, 3, 262125, 196608, 9, 196589, 327680, 0, 131053, 65536, 5, 65517, 327680, 5, -19, 65536, 5, -65555, 196608, 8, -131091, 131072, 0, -196627, 131072, 5, -262163, 327680, 5, -327699, 327680, 2, -393235, 262144, 5, -458771, 196608, 8, -524307, 327680, 3, -589843, 327680, 0, -655379, 0, 3, -720915, 131072, 5, 786412, 196608, 2, 720876, 196608, 3, 655340, 262144, 11, 589804, 0, 3, 524268, 327680, 3, 458732, 0, 4, 393196, 131072, 5, 327660, 327680, 3, 262124, 131072, 5, 196588, 0, 4, 131052, 131072, 9, 65516, 0, 3, -20, 327680, 1, -65556, 0, 1, -131092, 327680, 1, -196628, 196608, 5, -262164, 131072, 8, -327700, 196608, 0, -393236, 131072, 5, -458772, 327680, 3, -524308, 327680, 4, -589844, 131072, 5, -655380, 0, 0, -720916, 0, 2) -[node name="PlayArea" type="Area2D" parent="."] - -[node name="Shape" type="CollisionShape2D" parent="PlayArea"] -shape = SubResource("RectangleShape2D_p1lg5") -debug_color = Color(1, 1, 1, 0) - [node name="GameCamera" parent="." instance=ExtResource("2_db5xs")] -[node name="CursorMagnet" parent="." instance=ExtResource("3_xbolm")] - [node name="GoldCounter" parent="." instance=ExtResource("3_p6jw3")] [node name="DefaultSpawnParent" type="Node2D" parent="."] unique_name_in_owner = true + +[node name="Cursor" parent="." instance=ExtResource("5_g504x")] + +[node name="Sheep" parent="." instance=ExtResource("6_j2kdp")] +position = Vector2(-221, -32) + +[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) From 8278a55069dcffc617c1f4a713835fe1e44e8898 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 05:29:45 +0200 Subject: [PATCH 24/83] It works --- behaviours/move_straight.gd | 6 ++++-- behaviours/move_towards.gd | 6 ++++-- entities/sheep.tscn | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/behaviours/move_straight.gd b/behaviours/move_straight.gd index 86f5bc1..a483c31 100644 --- a/behaviours/move_straight.gd +++ b/behaviours/move_straight.gd @@ -7,6 +7,8 @@ class_name MoveStraight signal changed_direction(new: Vector2) +@export var speed: float = 100.0 + @export var direction: Vector2: get: return direction @@ -25,9 +27,9 @@ func randomize_direction() -> void: direction = Vector2.from_angle(Random.rng.randf_range(0, 2*PI)) -func _physics_process(_delta: float) -> void: +func _physics_process(delta: float) -> void: if enabled: - move.emit(direction) + move.emit(direction * delta * speed) func _on_changed_direction(new: Vector2) -> void: Log.p(self, "Changed direction to: %s" % new) diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index 058b20e..5e07d57 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -8,6 +8,8 @@ class_name MoveTowards signal changed_target(new: Node2D) +@export var speed: float = 100.0 + @export var target: Node2D = null: get: return target @@ -23,12 +25,12 @@ func clear_target() -> void: target = null -func _physics_process(_delta: float) -> void: +func _physics_process(delta: float) -> void: if enabled: if target: var gap = target.global_position - global_position var norm = gap.normalized() - move.emit(norm) + move.emit(norm * delta * speed) else: move.emit(Vector2.ZERO) diff --git a/entities/sheep.tscn b/entities/sheep.tscn index d71578e..fef9b2e 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -117,6 +117,7 @@ libraries = { possibilities = [NodePath("../MovementIdle/IdlePriority"), NodePath("../MovementWander/WanderPriority"), NodePath("../MovementRunFromMouse/RunFromMousePriority"), NodePath("../MovementRunFromHunter/RunFromHunterPriority")] [node name="MovementIdle" parent="." instance=ExtResource("10_05kcd")] +speed = 0.0 enabled = false [node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")] @@ -126,6 +127,7 @@ priority = 10 one_shot = true [node name="MovementWander" parent="." instance=ExtResource("10_05kcd")] +speed = 66.0 enabled = false [node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")] @@ -134,6 +136,7 @@ enabled = false one_shot = true [node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")] +speed = -100.0 enabled = false [node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")] @@ -145,6 +148,7 @@ shape = SubResource("CircleShape2D_etpf6") 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")] From 8142f399bd546963a138dbd20684b94e4928d895 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 05:45:34 +0200 Subject: [PATCH 25/83] Add `TimerStddev` --- behaviours/timer_stddev.gd | 23 +++++++++++++++++++++++ behaviours/timer_stddev.tscn | 8 ++++++++ entities/sheep.tscn | 13 ++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 behaviours/timer_stddev.gd create mode 100644 behaviours/timer_stddev.tscn diff --git a/behaviours/timer_stddev.gd b/behaviours/timer_stddev.gd new file mode 100644 index 0000000..ef3418a --- /dev/null +++ b/behaviours/timer_stddev.gd @@ -0,0 +1,23 @@ +extends Timer +class_name TimerStddev + + +## A [Timer] which randomizes its [field wait_time] at each timeout. + + +@export_range(0, 10, 0.1, "or_greater") var mean_secs: float = 1.0 +@export var deviation: float = 1.0 +@export_range(0, 10, 0.1, "or_greater") var min_secs: float = 0.0 +@export_range(0, 10, 0.1, "or_greater") var max_secs: float = 2.0 + + +func randomize_wait_time() -> void: + wait_time = clampf( + min_secs, + Random.rng.randfn(mean_secs, deviation), + max_secs + ) + + +func _ready() -> void: + randomize_wait_time() diff --git a/behaviours/timer_stddev.tscn b/behaviours/timer_stddev.tscn new file mode 100644 index 0000000..b124203 --- /dev/null +++ b/behaviours/timer_stddev.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://g8t6dt0ye6n3"] + +[ext_resource type="Script" path="res://behaviours/timer_stddev.gd" id="1_rvemn"] + +[node name="TimerStddev" type="Timer"] +script = ExtResource("1_rvemn") + +[connection signal="timeout" from="." to="." method="randomize_wait_time"] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index fef9b2e..147589f 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=22 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"] @@ -11,6 +11,7 @@ [ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"] [ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"] [ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="11_0jlmk"] +[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://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="13_5fkdr"] [ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] @@ -123,8 +124,12 @@ enabled = false [node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")] priority = 10 -[node name="BoredTimer" type="Timer" parent="MovementIdle"] +[node name="BoredTimer" parent="MovementIdle" instance=ExtResource("12_c45uk")] one_shot = true +autostart = true +mean_secs = 3.0 +min_secs = 1.0 +max_secs = 5.0 [node name="MovementWander" parent="." instance=ExtResource("10_05kcd")] speed = 66.0 @@ -132,8 +137,10 @@ enabled = false [node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")] -[node name="TiredTimer" type="Timer" parent="MovementWander"] +[node name="TiredTimer" parent="MovementWander" instance=ExtResource("12_c45uk")] one_shot = true +min_secs = 0.3 +max_secs = 1.5 [node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")] speed = -100.0 From 4fee4d56484b739658f66b20a65c12c00a9e0d9c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Apr 2024 05:54:16 +0200 Subject: [PATCH 26/83] Remove `Draggable` from `Sheep` as it isn't working right now --- entities/sheep.tscn | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 147589f..f4f9ca0 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,12 +1,9 @@ -[gd_scene load_steps=22 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=19 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"] [ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="2_xbkrm"] -[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_8ku7r"] [ext_resource type="Texture2D" uid="uid://cxtmas4g0v6en" path="res://entities/sheep_right.png" id="4_5qoof"] -[ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/drop.wav" id="4_nxjnl"] -[ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="4_oalqu"] [ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="6_3odsh"] [ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"] [ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"] @@ -96,17 +93,6 @@ right_texture = ExtResource("4_5qoof") scale = Vector2(3, 3) shape = SubResource("CircleShape2D_c5tcn") -[node name="Draggable" parent="." instance=ExtResource("3_8ku7r")] -scale = Vector2(3, 3) - -[node name="DragSound" type="AudioStreamPlayer2D" parent="Draggable"] -scale = Vector2(0.5, 0.5) -stream = ExtResource("4_oalqu") - -[node name="DropSound" type="AudioStreamPlayer2D" parent="Draggable"] -scale = Vector2(0.5, 0.5) -stream = ExtResource("4_nxjnl") - [node name="Animator" type="AnimationPlayer" parent="."] libraries = { "": SubResource("AnimationLibrary_6mutq") @@ -162,8 +148,6 @@ enabled = false [node name="HunterSense" parent="MovementRunFromHunter" instance=ExtResource("14_eqowb")] -[connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"] -[connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"] [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"] From 564477e5e99d979d72a05af03089d99291a641cb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:22:03 +0200 Subject: [PATCH 27/83] Improve `Priority` with some suggestions by @SnowyCoder --- behaviours/priority.gd | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/behaviours/priority.gd b/behaviours/priority.gd index 6be6430..97c6de7 100644 --- a/behaviours/priority.gd +++ b/behaviours/priority.gd @@ -3,27 +3,51 @@ extends Node class_name Priority -## Keeps track of the object's priority +## Keeps track of the object's priority for [SamplerPriority] purposes. +## Emitted when the priority is changed. signal priority_changed(new: int, old: int) + +## Emitted when the priority is changed. No args are provided to work around a Godot bug. signal priority_changed_no_args -@export var priority: int = 0 +@export var default_priority: int = 0 +@export var alternative_priority: int = 1 + +var priority: int = 0 +## Set [field priority] to [field default_priority]. +func default() -> void: + set_priority(default_priority) + +## Set [field priority] to [field alternative_priority] +func alternative() -> void: + set_priority(alternative_priority) + +## Toggle [field priority] between [field default_priority] and [field alternative_priority]. +func toggle_priority() -> void: + if priority == default_priority: + set_priority(alternative_priority) + else: + set_priority(default_priority) + +## Set the [field priority] to a specific value. func set_priority(value: int): var old = priority priority = value priority_changed.emit(priority, old) +## Set the [field priority] to a specific value if the [param variant] is truthy, otherwise set it to a different value. func set_priority_if_truthy(variant: Variant, truthy: int, falsy: int = 0): if variant: set_priority(truthy) else: set_priority(falsy) +## Get the node to which the [field priority] of this one applies to. func get_ref() -> Node: return get_parent() @@ -31,3 +55,6 @@ func get_ref() -> Node: func _on_priority_changed(new: int, _old: int) -> void: Log.p(self, "Priority changed to: %s" % new) priority_changed_no_args.emit() + +func _ready() -> void: + priority = default_priority From 32e00ede01d57ca3c6f058fc2440aec217be79c9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:26:02 +0200 Subject: [PATCH 28/83] Improve and cleanup `Sampler` and `SamplerPriority` --- behaviours/sampler.gd | 20 ++++++++++---------- behaviours/sampler_priority.gd | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/behaviours/sampler.gd b/behaviours/sampler.gd index 4e08e7f..00b87eb 100644 --- a/behaviours/sampler.gd +++ b/behaviours/sampler.gd @@ -6,10 +6,7 @@ class_name Sampler ## Abstract base class for sampling a certain reference among multiple. -signal notify_selected(node: Node) -signal notify_deselected(node: Node) - - +## [Array] of [Node]s that can be [func sample]d by this [Sampler]. @export var possibilities: Array[Node] = [] @@ -18,12 +15,15 @@ func sample() -> Node: Log.e(self, "Not implemented.") return null -## Get all possible nodes referenced by [field possibilities]. -func get_refs() -> Array[Node]: - return possibilities - -## Set the "enabled" property on +## Set the [field enabled] property to true on a [method sample]d node, and to false on all others. func enable() -> void: var selected = sample() - for possibility in get_refs(): + for possibility in get_all_refs(): possibility.enabled = (selected == possibility) + + +## Get all possible nodes referenced by [field possibilities]. +## +## Useful as it may be overridden by some other [Sampler]s, such as [SamplerPriority]. +func get_all_refs() -> Array[Node]: + return possibilities \ No newline at end of file diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index 4903981..e3bf47c 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -23,7 +23,7 @@ func sample() -> Priority: Log.p(self, "Sampled: %s (%d)" % [highest_possibility, highest_possibility.priority]) return highest_possibility.get_ref() -func get_refs() -> Array[Node]: +func get_all_refs() -> Array[Node]: var refs: Array[Node] = [] for possibility in possibilities: refs.append(possibility.get_ref()) From f1871a02ae6c7500aa12a9866378c3b8f7fdbdd5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:30:03 +0200 Subject: [PATCH 29/83] Rename methods and improve `Priority` --- behaviours/priority.gd | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/behaviours/priority.gd b/behaviours/priority.gd index 97c6de7..831330c 100644 --- a/behaviours/priority.gd +++ b/behaviours/priority.gd @@ -16,36 +16,42 @@ signal priority_changed_no_args @export var default_priority: int = 0 @export var alternative_priority: int = 1 -var priority: int = 0 +var priority: int = 0: + get: + return priority + set(value): + var old = priority + priority = value + priority_changed.emit(priority, old) ## Set [field priority] to [field default_priority]. -func default() -> void: - set_priority(default_priority) +func priority_default() -> void: + priority = default_priority ## Set [field priority] to [field alternative_priority] -func alternative() -> void: - set_priority(alternative_priority) +func priority_alternative() -> void: + priority = alternative_priority ## Toggle [field priority] between [field default_priority] and [field alternative_priority]. -func toggle_priority() -> void: +func priority_toggle() -> void: if priority == default_priority: - set_priority(alternative_priority) + priority = alternative_priority else: - set_priority(default_priority) + priority = default_priority ## Set the [field priority] to a specific value. -func set_priority(value: int): - var old = priority +func priority_set(value: int): priority = value - priority_changed.emit(priority, old) ## Set the [field priority] to a specific value if the [param variant] is truthy, otherwise set it to a different value. -func set_priority_if_truthy(variant: Variant, truthy: int, falsy: int = 0): +## +## Defaults to using [field alternative_priority] for truthy, and [field default_priority] for falsy +func priority_conditional(variant: Variant, truthy: int = alternative_priority, falsy: int = default_priority): if variant: - set_priority(truthy) + priority = truthy else: - set_priority(falsy) + priority = falsy ## Get the node to which the [field priority] of this one applies to. func get_ref() -> Node: From a1053e13a9df9b6aa1a02aa03b25f5f47c8d7987 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:33:44 +0200 Subject: [PATCH 30/83] Temporarily remove `Draggable` from `Sheep` --- entities/sheep.gd | 19 ++----------------- entities/sheep.tscn | 10 ++++++---- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/entities/sheep.gd b/entities/sheep.gd index b38d4ea..83b1170 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -2,7 +2,6 @@ extends CharacterBody2D class_name Sheep -@onready var draggable: Draggable = $"Draggable" @onready var sprite: SpriteLeftRight = $"Sprite" @onready var drag_sound: AudioStreamPlayer2D = $"Draggable/DragSound" @onready var drop_sound: AudioStreamPlayer2D = $"Draggable/DropSound" @@ -13,19 +12,5 @@ func _ready() -> void: animator.play("RESET") func _on_move(movement: Vector2) -> void: - if not draggable.being_dragged: - move_and_collide(movement) - sprite.handle_move(movement) - -func _on_drag_move(movement: Vector2) -> void: - if draggable.being_dragged: - move_and_collide(movement) - sprite.handle_move(movement) - -func _on_draggable_dragged() -> void: - drag_sound.play() - animator.play("wobble") - -func _on_draggable_dropped() -> void: - drop_sound.play() - animator.play("RESET") + move_and_collide(movement) + sprite.handle_move(movement) diff --git a/entities/sheep.tscn b/entities/sheep.tscn index f4f9ca0..dc3ae37 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -108,7 +108,7 @@ speed = 0.0 enabled = false [node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")] -priority = 10 +alternative_priority = 0 [node name="BoredTimer" parent="MovementIdle" instance=ExtResource("12_c45uk")] one_shot = true @@ -122,6 +122,7 @@ speed = 66.0 enabled = false [node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")] +alternative_priority = 20 [node name="TiredTimer" parent="MovementWander" instance=ExtResource("12_c45uk")] one_shot = true @@ -133,6 +134,7 @@ speed = -100.0 enabled = false [node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")] +alternative_priority = 30 [node name="CursorSense" parent="MovementRunFromMouse" instance=ExtResource("13_5fkdr")] @@ -154,19 +156,19 @@ enabled = false [connection signal="move_enabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="start"] [connection signal="priority_changed_no_args" from="MovementIdle/IdlePriority" to="MovementSampler" method="enable"] [connection signal="timeout" from="MovementIdle/BoredTimer" to="MovementWander" method="randomize_direction"] -[connection signal="changed_direction" from="MovementWander" to="MovementWander/WanderPriority" method="set_priority_if_truthy" binds= [20]] +[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/TiredTimer" method="stop"] [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="MovementRunFromMouse" to="MovementRunFromMouse/RunFromMousePriority" method="set_priority_if_truthy" binds= [30]] +[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="set_priority_if_truthy" binds= [40]] +[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"] From 70aad55a414e9fe71d0df6ca8ce58c4ec5a2e8e9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:41:30 +0200 Subject: [PATCH 31/83] `Sheep` is a `&Meat` diet --- entities/sheep.tscn | 1 + 1 file changed, 1 insertion(+) diff --git a/entities/sheep.tscn b/entities/sheep.tscn index dc3ae37..2eb2f86 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -99,6 +99,7 @@ libraries = { } [node name="Edible" parent="." instance=ExtResource("6_3odsh")] +diet = &"Meat" [node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("9_s5lod")] possibilities = [NodePath("../MovementIdle/IdlePriority"), NodePath("../MovementWander/WanderPriority"), NodePath("../MovementRunFromMouse/RunFromMousePriority"), NodePath("../MovementRunFromHunter/RunFromHunterPriority")] From 3b761f2611a7a575b9ba978d312be5b700be5297 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:45:43 +0200 Subject: [PATCH 32/83] Attempt 1 at re-implementing an hunting `Imp` --- entities/imp.tscn | 74 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index 60a7721..dba8281 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -1,16 +1,25 @@ -[gd_scene load_steps=9 format=3 uid="uid://4d3ksr3171x4"] +[gd_scene load_steps=16 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"] -[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_4528r"] [ext_resource type="Texture2D" uid="uid://crhwsob76ieya" path="res://entities/imp_left.png" id="3_qda0k"] [ext_resource type="Texture2D" uid="uid://bubehid53q8h1" path="res://entities/imp_right.png" id="4_0sckn"] [ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="4_d8lgm"] [ext_resource type="PackedScene" uid="uid://uoxwjpmgg27a" path="res://entities/gold.tscn" id="5_yrfoq"] +[ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="7_ech8d"] +[ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="8_ffcw0"] +[ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="9_2wb1b"] +[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="10_phvea"] +[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"] [sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"] radius = 8.0 +[sub_resource type="CircleShape2D" id="CircleShape2D_1bmhf"] +radius = 256.0 + [node name="Imp" type="CharacterBody2D"] collision_layer = 8 collision_mask = 14 @@ -26,21 +35,56 @@ right_texture = ExtResource("4_0sckn") scale = Vector2(4, 4) shape = SubResource("CircleShape2D_ide4n") -[node name="Draggable" parent="." instance=ExtResource("3_4528r")] -scale = Vector2(4, 4) - -[node name="DragSound" type="AudioStreamPlayer2D" parent="Draggable"] -scale = Vector2(0.5, 0.5) - -[node name="DropSound" type="AudioStreamPlayer2D" parent="Draggable"] -scale = Vector2(0.5, 0.5) - -[node name="Spawner" parent="." instance=ExtResource("4_d8lgm")] +[node name="CoinSpawner" parent="." instance=ExtResource("4_d8lgm")] scene = ExtResource("5_yrfoq") -[node name="Timer" type="Timer" parent="Spawner"] +[node name="Timer" type="Timer" parent="CoinSpawner"] wait_time = 0.8 autostart = true -[connection signal="move" from="Draggable" to="." method="_on_draggable_move"] -[connection signal="timeout" from="Spawner/Timer" to="Spawner" method="spawn"] +[node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("7_ech8d")] +possibilities = [null, null, null, null] + +[node name="MovementWander" parent="." instance=ExtResource("8_ffcw0")] +speed = 25.0 +enabled = false + +[node name="WanderPriority" parent="MovementWander" instance=ExtResource("9_2wb1b")] +default_priority = 10 +alternative_priority = 10 + +[node name="ChangeDirectionTimer" parent="MovementWander" instance=ExtResource("10_phvea")] +one_shot = true +mean_secs = 2.0 +deviation = 2.0 +min_secs = 0.6 +max_secs = 3.0 + +[node name="MovementHunt" parent="." instance=ExtResource("11_4ra22")] +speed = -100.0 +enabled = false + +[node name="HuntPriority" parent="MovementHunt" instance=ExtResource("9_2wb1b")] +alternative_priority = 40 + +[node name="TrackerMeat" parent="MovementHunt" instance=ExtResource("12_dr2oe")] +acceptable_diets = Array[StringName]([&"Meat"]) + +[node name="Shape" type="CollisionShape2D" parent="MovementHunt/TrackerMeat"] +shape = SubResource("CircleShape2D_1bmhf") +debug_color = Color(1, 0.498039, 0, 0) + +[node name="TargetPicker" parent="MovementHunt/TrackerMeat" node_paths=PackedStringArray("tracker") instance=ExtResource("13_mwxuf")] +tracker = NodePath("..") + +[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_disabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="stop"] +[connection signal="move_enabled" from="MovementWander" to="MovementWander/ChangeDirectionTimer" method="start"] +[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="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] +[connection signal="untracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="clear_if_target"] +[connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] +[connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt" method="set_target" unbinds=1] From c20eb76fb985efcd477de63aacd4e62b5d6ae8f7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:46:25 +0200 Subject: [PATCH 33/83] Again, remove `Draggable` from `Imp` --- entities/imp.gd | 12 ++---------- scenes/game/main_game.tscn | 6 +++++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/entities/imp.gd b/entities/imp.gd index bbbd025..ee93ec7 100644 --- a/entities/imp.gd +++ b/entities/imp.gd @@ -5,7 +5,6 @@ class_name Imp @onready var skull_spawner: Spawner = $"SkullSpawner" @onready var sprite: SpriteLeftRight = $"Sprite" -@onready var draggable: Draggable = $"Draggable" func _on_eat_target_eaten(target: Edible): @@ -13,13 +12,6 @@ func _on_eat_target_eaten(target: Edible): if Random.rng.randf() < skull_chance: skull_spawner.spawn() - -func _on_draggable_move(movement:Vector2): - if draggable.being_dragged: - move_and_collide(movement) - sprite.handle_move(movement) - func _on_move(movement:Vector2): - if not draggable.being_dragged: - move_and_collide(movement) - sprite.handle_move(movement) + move_and_collide(movement) + sprite.handle_move(movement) diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 0fcecdc..6e95fcd 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=10 format=3 uid="uid://cxj5aud02f40j"] [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"] @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="3_p6jw3"] [ext_resource type="PackedScene" uid="uid://col1q3elvkfwk" path="res://scenes/game/cursor.tscn" id="5_g504x"] [ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="6_j2kdp"] +[ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="7_7od2n"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -842,3 +843,6 @@ position = Vector2(307, -33) [node name="Sheep5" parent="." instance=ExtResource("6_j2kdp")] position = Vector2(182, -217) + +[node name="Imp" parent="." instance=ExtResource("7_7od2n")] +position = Vector2(-65, -233) From 4f89893c29ac129a4dfd043aeea948ff7f1a007d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:47:34 +0200 Subject: [PATCH 34/83] Remove some more references to `Draggable` --- entities/imp.tscn | 4 +++- entities/sheep.gd | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index dba8281..08e5ec3 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -43,7 +43,7 @@ wait_time = 0.8 autostart = true [node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("7_ech8d")] -possibilities = [null, null, null, null] +possibilities = [NodePath("../MovementWander/WanderPriority"), NodePath("../MovementHunt/HuntPriority")] [node name="MovementWander" parent="." instance=ExtResource("8_ffcw0")] speed = 25.0 @@ -80,10 +80,12 @@ tracker = NodePath("..") [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="timeout" from="MovementWander/ChangeDirectionTimer" to="MovementWander" method="randomize_direction"] [connection signal="changed_target" from="MovementHunt" to="MovementHunt/HuntPriority" method="priority_conditional"] +[connection signal="move" from="MovementHunt" to="." method="_on_move"] [connection signal="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] [connection signal="untracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="clear_if_target"] [connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] diff --git a/entities/sheep.gd b/entities/sheep.gd index 83b1170..8d3a888 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -3,8 +3,6 @@ class_name Sheep @onready var sprite: SpriteLeftRight = $"Sprite" -@onready var drag_sound: AudioStreamPlayer2D = $"Draggable/DragSound" -@onready var drop_sound: AudioStreamPlayer2D = $"Draggable/DropSound" @onready var animator: AnimationPlayer = $"Animator" From c2dd8a61cd714d48fa2a204dacac9fa9d864b6c1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:48:11 +0200 Subject: [PATCH 35/83] Fix `TrackerEdible` still looking for `tag` instead of `diet` --- behaviours/tracker_edible.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/behaviours/tracker_edible.gd b/behaviours/tracker_edible.gd index da5ece4..810feb2 100644 --- a/behaviours/tracker_edible.gd +++ b/behaviours/tracker_edible.gd @@ -10,6 +10,6 @@ class_name EdibleTracker func check_diet_then_track(body: Node2D) -> void: var edibles: Array = body.find_children("*", "Edible", false, false) for edible in edibles: - if edible.tag in acceptable_diets: + if edible.diet in acceptable_diets: track(body) break From 782d752c3ed0a726d74a32a3a1f2f95cc6026b54 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:49:22 +0200 Subject: [PATCH 36/83] Remove debug logging from `SamplerPriority` --- behaviours/sampler_priority.gd | 2 -- 1 file changed, 2 deletions(-) diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index e3bf47c..c925afb 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -13,14 +13,12 @@ func sample() -> Priority: # FIXME: Change this to something more efficient when needed var highest_possibility: Priority = null for possibility in possibilities: - Log.p(self, "Possibility: %s (%d)" % [possibility, possibility.priority]) if highest_possibility == null or possibility.priority > highest_possibility.priority: highest_possibility = possibility if highest_possibility == null: return null - Log.p(self, "Sampled: %s (%d)" % [highest_possibility, highest_possibility.priority]) return highest_possibility.get_ref() func get_all_refs() -> Array[Node]: From 1100f60db8a8eb331f50eb56b5fffd8577c753d4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:49:49 +0200 Subject: [PATCH 37/83] Remove debug logging from `Priority` --- behaviours/priority.gd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/behaviours/priority.gd b/behaviours/priority.gd index 831330c..08e5ba7 100644 --- a/behaviours/priority.gd +++ b/behaviours/priority.gd @@ -58,8 +58,7 @@ func get_ref() -> Node: return get_parent() -func _on_priority_changed(new: int, _old: int) -> void: - Log.p(self, "Priority changed to: %s" % new) +func _on_priority_changed(_new: int, _old: int) -> void: priority_changed_no_args.emit() func _ready() -> void: From 2b39bb455161db8932abc497c631c0792a175be5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:50:53 +0200 Subject: [PATCH 38/83] Add a `log_priority` method to log the priority of a specific node --- behaviours/priority.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/behaviours/priority.gd b/behaviours/priority.gd index 08e5ba7..54509b1 100644 --- a/behaviours/priority.gd +++ b/behaviours/priority.gd @@ -57,6 +57,10 @@ func priority_conditional(variant: Variant, truthy: int = alternative_priority, func get_ref() -> Node: return get_parent() +## Log the current [field priority] value. +func log_priority() -> void: + Log.p(self, "Priority: %d" % priority) + func _on_priority_changed(_new: int, _old: int) -> void: priority_changed_no_args.emit() From 081a4f905dc407b79494cd749ddcfb231b9c5d58 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:52:35 +0200 Subject: [PATCH 39/83] Remove more unused references in `Imp` --- entities/imp.gd | 7 ------- entities/imp.tscn | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/entities/imp.gd b/entities/imp.gd index ee93ec7..e87d76e 100644 --- a/entities/imp.gd +++ b/entities/imp.gd @@ -1,17 +1,10 @@ extends CharacterBody2D class_name Imp -@export var skull_chance: float = 0.2 -@onready var skull_spawner: Spawner = $"SkullSpawner" @onready var sprite: SpriteLeftRight = $"Sprite" -func _on_eat_target_eaten(target: Edible): - target.queue_free() - if Random.rng.randf() < skull_chance: - skull_spawner.spawn() - func _on_move(movement:Vector2): move_and_collide(movement) sprite.handle_move(movement) diff --git a/entities/imp.tscn b/entities/imp.tscn index 08e5ec3..dd65ee4 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -55,6 +55,7 @@ alternative_priority = 10 [node name="ChangeDirectionTimer" parent="MovementWander" instance=ExtResource("10_phvea")] one_shot = true +autostart = true mean_secs = 2.0 deviation = 2.0 min_secs = 0.6 @@ -86,6 +87,7 @@ tracker = NodePath("..") [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="move" from="MovementHunt" to="." method="_on_move"] +[connection signal="priority_changed" from="MovementHunt/HuntPriority" to="MovementHunt/HuntPriority" method="log_priority"] [connection signal="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] [connection signal="untracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="clear_if_target"] [connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] From 26ec8320d2c0013013e1c45e44c88d9781a67270 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:54:25 +0200 Subject: [PATCH 40/83] Have `Random.sample` return null when the given array is empty --- random.gd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/random.gd b/random.gd index a0a37a0..2e9b2cb 100644 --- a/random.gd +++ b/random.gd @@ -13,6 +13,8 @@ static var rng: RandomNumberGenerator = null: static func sample(array: Array[Variant], imin = null, imax = null) -> Variant: + if len(array) == 0: + return null if imin == null: imin = 0 if imax == null: From 3d5bb824b71d21096e5e863f89b7fe51edee05f5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:54:36 +0200 Subject: [PATCH 41/83] Fix signals in `Imp` --- entities/imp.tscn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index dd65ee4..5a028f8 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -87,8 +87,8 @@ tracker = NodePath("..") [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="move" from="MovementHunt" to="." method="_on_move"] -[connection signal="priority_changed" from="MovementHunt/HuntPriority" to="MovementHunt/HuntPriority" method="log_priority"] -[connection signal="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null"] +[connection signal="priority_changed" from="MovementHunt/HuntPriority" to="MovementHunt/HuntPriority" method="log_priority" unbinds=2] +[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/TrackerMeat/TargetPicker" method="sample_target_if_null"] [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] From ed6047834a816fcdbe6f415ef46d5a8bb18a5dea Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:55:25 +0200 Subject: [PATCH 42/83] Remove debug logging from `CursorDetector` --- behaviours/cursor_detector.gd | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/behaviours/cursor_detector.gd b/behaviours/cursor_detector.gd index c37a9ec..599201b 100644 --- a/behaviours/cursor_detector.gd +++ b/behaviours/cursor_detector.gd @@ -20,9 +20,5 @@ func _on_body_exited(body: Node2D) -> void: mouse_inside = true cursor_exited.emit(body) - -func _on_cursor_entered(cursor: Cursor) -> void: - Log.p(self, "Cursor entered: %s" % cursor) - -func _on_cursor_exited(cursor: Cursor) -> void: - Log.p(self, "Cursor exited: %s" % cursor) +func log_cursor(cursor: Cursor) -> void: + Log.p(self, "Cursor: %s" % cursor) From d270501f083dab1be27b73e09a7d5c2cd8e2f6f9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:56:03 +0200 Subject: [PATCH 43/83] Remove unused test behaviours --- behaviours/ai_hunter_erratic.tscn | 23 ----------------------- behaviours/ai_hunter_latest.tscn | 19 ------------------- behaviours/ai_hunter_persistent.tscn | 19 ------------------- behaviours/ai_hunter_random.tscn | 23 ----------------------- 4 files changed, 84 deletions(-) delete mode 100644 behaviours/ai_hunter_erratic.tscn delete mode 100644 behaviours/ai_hunter_latest.tscn delete mode 100644 behaviours/ai_hunter_persistent.tscn delete mode 100644 behaviours/ai_hunter_random.tscn diff --git a/behaviours/ai_hunter_erratic.tscn b/behaviours/ai_hunter_erratic.tscn deleted file mode 100644 index 728501b..0000000 --- a/behaviours/ai_hunter_erratic.tscn +++ /dev/null @@ -1,23 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://cgq2jkbrw1y0o"] - -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="1_h53ag"] -[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_h4v3e"] -[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_ucief"] - -[node name="AIHunterErratic" type="Node2D"] - -[node name="EdibleTracker" parent="." instance=ExtResource("1_h53ag")] - -[node name="Timer" type="Timer" parent="."] -wait_time = 2.4 -autostart = true - -[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("2_h4v3e")] -tracker = NodePath("../EdibleTracker") - -[node name="MoveTowards" type="Node2D" parent="."] -script = ExtResource("3_ucief") - -[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] -[connection signal="timeout" from="Timer" to="TargetPicker" method="sample_target"] -[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/ai_hunter_latest.tscn b/behaviours/ai_hunter_latest.tscn deleted file mode 100644 index cd016e7..0000000 --- a/behaviours/ai_hunter_latest.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://cgnvp5bmtbpxr"] - -[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_demja"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="2_jlt4x"] -[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="3_lfvrb"] - -[node name="AIHunterLatest" type="Node2D"] - -[node name="EdibleTracker" parent="." instance=ExtResource("2_jlt4x")] - -[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("3_lfvrb")] -tracker = NodePath("../EdibleTracker") - -[node name="MoveTowards" type="Node2D" parent="."] -script = ExtResource("1_demja") - -[connection signal="tracked" from="EdibleTracker" to="TargetPicker" method="set_target"] -[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] -[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/ai_hunter_persistent.tscn b/behaviours/ai_hunter_persistent.tscn deleted file mode 100644 index 8b77415..0000000 --- a/behaviours/ai_hunter_persistent.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://cpq0ubwun5wec"] - -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="1_j87ny"] -[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="2_w2vxl"] -[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="3_14yk3"] - -[node name="AIHunterPersistent" type="Node2D"] - -[node name="EdibleTracker" parent="." instance=ExtResource("1_j87ny")] - -[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("2_w2vxl")] -tracker = NodePath("../EdibleTracker") - -[node name="MoveTowards" type="Node2D" parent="."] -script = ExtResource("3_14yk3") - -[connection signal="tracked" from="EdibleTracker" to="TargetPicker" method="set_target_if_null"] -[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] -[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] diff --git a/behaviours/ai_hunter_random.tscn b/behaviours/ai_hunter_random.tscn deleted file mode 100644 index 0d8b47f..0000000 --- a/behaviours/ai_hunter_random.tscn +++ /dev/null @@ -1,23 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://baiq3nu3p03rh"] - -[ext_resource type="Script" path="res://behaviours/move_towards.gd" id="1_wlo1a"] -[ext_resource type="PackedScene" uid="uid://ctpn4hvkhxoi3" path="res://behaviours/tracker_edible.tscn" id="2_suoff"] -[ext_resource type="PackedScene" uid="uid://dti7l0d40hhgt" path="res://behaviours/target_picker.tscn" id="3_0uxc2"] - -[node name="AIHunterRandom" type="Node2D"] - -[node name="EdibleTracker" parent="." instance=ExtResource("2_suoff")] - -[node name="Timer" type="Timer" parent="."] -wait_time = 2.4 -autostart = true - -[node name="TargetPicker" parent="." node_paths=PackedStringArray("tracker") instance=ExtResource("3_0uxc2")] -tracker = NodePath("../EdibleTracker") - -[node name="MoveTowards" type="Node2D" parent="."] -script = ExtResource("1_wlo1a") - -[connection signal="untracked" from="EdibleTracker" to="TargetPicker" method="clear_if_target"] -[connection signal="timeout" from="Timer" to="TargetPicker" method="sample_target_if_null"] -[connection signal="target_changed" from="TargetPicker" to="MoveTowards" method="set_target" unbinds=1] From 0b68127747762c45cae61e22736c2218e083496d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:56:46 +0200 Subject: [PATCH 44/83] Remove logging signals from `CursorDetector` --- behaviours/cursor_detector.tscn | 2 -- 1 file changed, 2 deletions(-) diff --git a/behaviours/cursor_detector.tscn b/behaviours/cursor_detector.tscn index 99ca786..c4b4fec 100644 --- a/behaviours/cursor_detector.tscn +++ b/behaviours/cursor_detector.tscn @@ -10,5 +10,3 @@ script = ExtResource("1_4hcxj") [connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="body_exited" from="." to="." method="_on_body_exited"] -[connection signal="cursor_entered" from="." to="." method="_on_cursor_entered"] -[connection signal="cursor_exited" from="." to="." method="_on_cursor_exited"] From 7683d45747ab1cdbce7efb1c0ac34bd6c1d6e416 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:57:26 +0200 Subject: [PATCH 45/83] Remove logging from `MoveTowards` --- behaviours/move_towards.gd | 6 +++--- behaviours/move_towards.tscn | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index 5e07d57..4dad3a0 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -24,6 +24,9 @@ func set_target(value: Node2D) -> void: func clear_target() -> void: target = null +func log_target() -> void: + Log.p(self, "Target: %s" % target) + func _physics_process(delta: float) -> void: if enabled: @@ -33,6 +36,3 @@ func _physics_process(delta: float) -> void: move.emit(norm * delta * speed) else: move.emit(Vector2.ZERO) - -func _on_changed_target(new: Node2D) -> void: - Log.p(self, "Changed target to: %s" % new) diff --git a/behaviours/move_towards.tscn b/behaviours/move_towards.tscn index 2c7f758..41b4c4a 100644 --- a/behaviours/move_towards.tscn +++ b/behaviours/move_towards.tscn @@ -4,5 +4,3 @@ [node name="MoveTowards" type="Node2D"] script = ExtResource("1_256ue") - -[connection signal="changed_target" from="." to="." method="_on_changed_target"] From 91c4776a33e2827682a0bc638eb7ce2a2208e848 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:58:33 +0200 Subject: [PATCH 46/83] Remove debug logging from `MoveStraight` --- behaviours/move_straight.gd | 6 +++--- behaviours/move_straight.tscn | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/behaviours/move_straight.gd b/behaviours/move_straight.gd index a483c31..4e6ec30 100644 --- a/behaviours/move_straight.gd +++ b/behaviours/move_straight.gd @@ -26,10 +26,10 @@ func clear_direction() -> void: func randomize_direction() -> void: direction = Vector2.from_angle(Random.rng.randf_range(0, 2*PI)) +func log_state() -> void: + Log.p(self, "Direction: %s | Speed: %s" % [direction, speed]) + func _physics_process(delta: float) -> void: if enabled: move.emit(direction * delta * speed) - -func _on_changed_direction(new: Vector2) -> void: - Log.p(self, "Changed direction to: %s" % new) diff --git a/behaviours/move_straight.tscn b/behaviours/move_straight.tscn index 11a2a41..e176db3 100644 --- a/behaviours/move_straight.tscn +++ b/behaviours/move_straight.tscn @@ -4,5 +4,3 @@ [node name="MoveStraight" type="Node2D"] script = ExtResource("1_8yf73") - -[connection signal="changed_direction" from="." to="." method="_on_changed_direction"] From 9e85baa1cb7ee576a49be7096ed2d0e7d549c2ed Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 02:04:35 +0200 Subject: [PATCH 47/83] `TrackerEdible` do not log by default --- behaviours/tracker_edible.tscn | 2 -- 1 file changed, 2 deletions(-) diff --git a/behaviours/tracker_edible.tscn b/behaviours/tracker_edible.tscn index 6987647..fd2e609 100644 --- a/behaviours/tracker_edible.tscn +++ b/behaviours/tracker_edible.tscn @@ -10,5 +10,3 @@ script = ExtResource("1_vmdw6") [connection signal="body_entered" from="." to="." method="check_diet_then_track"] [connection signal="body_exited" from="." to="." method="untrack"] -[connection signal="tracked" from="." to="." method="log_tracked"] -[connection signal="untracked" from="." to="." method="log_untracked"] From 496977996c458f6689493ac71ee9114bafe9b1b8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:23:24 +0200 Subject: [PATCH 48/83] I got lost hunting for a bug and i forgor commits --- behaviours/target_picker.gd | 6 +++- behaviours/tracker.gd | 4 +-- entities/imp.tscn | 6 ++-- entities/sheep.tscn | 43 ++++++++++++++++------------ random.gd | 1 + scenes/game/main_game.tscn | 57 +++++++++++++++++++++++++++---------- 6 files changed, 77 insertions(+), 40 deletions(-) diff --git a/behaviours/target_picker.gd b/behaviours/target_picker.gd index d2f2f72..0f4d041 100644 --- a/behaviours/target_picker.gd +++ b/behaviours/target_picker.gd @@ -19,7 +19,7 @@ var target: Node2D: if target != value: var old = target target = value - target_changed.emit(old, target) + target_changed.emit(target, old) func set_target(body: Node2D) -> void: @@ -42,3 +42,7 @@ func sample_target() -> void: func sample_target_if_null() -> void: if target == null: sample_target() + + +func log_target() -> void: + pass # Replace with function body. diff --git a/behaviours/tracker.gd b/behaviours/tracker.gd index deaf1a9..92824ff 100644 --- a/behaviours/tracker.gd +++ b/behaviours/tracker.gd @@ -17,7 +17,7 @@ func track(body: Node2D) -> bool: tracking.push_back(body) tracked.emit(body) # 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) return act @@ -27,7 +27,7 @@ func untrack(body: Node2D) -> bool: tracking.erase(body) untracked.emit(body) # 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) return act diff --git a/entities/imp.tscn b/entities/imp.tscn index 5a028f8..dc0c5ac 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -54,7 +54,6 @@ default_priority = 10 alternative_priority = 10 [node name="ChangeDirectionTimer" parent="MovementWander" instance=ExtResource("10_phvea")] -one_shot = true autostart = true mean_secs = 2.0 deviation = 2.0 @@ -62,7 +61,6 @@ min_secs = 0.6 max_secs = 3.0 [node name="MovementHunt" parent="." instance=ExtResource("11_4ra22")] -speed = -100.0 enabled = false [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_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"] [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="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] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 2eb2f86..aca8877 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -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="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://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://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] @@ -119,7 +120,7 @@ min_secs = 1.0 max_secs = 5.0 [node name="MovementWander" parent="." instance=ExtResource("10_05kcd")] -speed = 66.0 +speed = 33.0 enabled = false [node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")] @@ -130,12 +131,24 @@ 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 = -100.0 +speed = -66.0 enabled = false [node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")] -alternative_priority = 30 +alternative_priority = 40 [node name="CursorSense" parent="MovementRunFromMouse" instance=ExtResource("13_5fkdr")] @@ -143,14 +156,6 @@ alternative_priority = 30 shape = SubResource("CircleShape2D_etpf6") 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="move" from="MovementIdle" to="." method="_on_move"] [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="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" method="set_target"] -[connection signal="untracked" from="MovementRunFromHunter/HunterSense" to="MovementRunFromHunter" method="clear_target" unbinds=1] diff --git a/random.gd b/random.gd index 2e9b2cb..baed659 100644 --- a/random.gd +++ b/random.gd @@ -14,6 +14,7 @@ static var rng: RandomNumberGenerator = null: static func sample(array: Array[Variant], imin = null, imax = null) -> Variant: if len(array) == 0: + Log.w(null, "Sampling from an empty array.") return null if imin == null: imin = 0 diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 6e95fcd..f8af012 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -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="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) sources/0 = SubResource("TileSetAtlasSource_058kb") +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_htttx"] + [node name="MainGame" type="Node2D"] script = ExtResource("1_wiglu") @@ -830,19 +832,44 @@ unique_name_in_owner = true [node name="Cursor" parent="." instance=ExtResource("5_g504x")] [node name="Sheep" parent="." instance=ExtResource("6_j2kdp")] -position = Vector2(-221, -32) - -[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) +position = Vector2(-246, 25) [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") From 4fbf8c6d8dfbe7c6afed49923dc63e3bf3c3bfff Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:32:05 +0200 Subject: [PATCH 49/83] Remove debug logging from `Edible` --- behaviours/edible.gd | 3 --- behaviours/edible.tscn | 2 -- 2 files changed, 5 deletions(-) diff --git a/behaviours/edible.gd b/behaviours/edible.gd index 5926b07..88bc469 100644 --- a/behaviours/edible.gd +++ b/behaviours/edible.gd @@ -14,6 +14,3 @@ signal eaten func eat(): eaten.emit() - -func _on_eaten() -> void: - Log.p(self, "Got eaten.") diff --git a/behaviours/edible.tscn b/behaviours/edible.tscn index 5a4b405..d8fa24f 100644 --- a/behaviours/edible.tscn +++ b/behaviours/edible.tscn @@ -4,5 +4,3 @@ [node name="Edible" type="Node"] script = ExtResource("1_l6vtr") - -[connection signal="eaten" from="." to="." method="_on_eaten"] From 4b3e05b74fec984fdb09aab0acf8295458ec6bca Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:39:07 +0200 Subject: [PATCH 50/83] Tweak a few more things --- behaviours/eater.gd | 7 +++---- behaviours/eater.tscn | 1 - behaviours/timer_stddev.gd | 4 ---- entities/imp.gd | 5 ++++- entities/imp.tscn | 18 +++++++++++++--- entities/sheep.tscn | 43 +++++++++++++++++++------------------- 6 files changed, 43 insertions(+), 35 deletions(-) diff --git a/behaviours/eater.gd b/behaviours/eater.gd index 4bd5392..2a0c563 100644 --- a/behaviours/eater.gd +++ b/behaviours/eater.gd @@ -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) diff --git a/behaviours/eater.tscn b/behaviours/eater.tscn index d1f79ab..765b510 100644 --- a/behaviours/eater.tscn +++ b/behaviours/eater.tscn @@ -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"] diff --git a/behaviours/timer_stddev.gd b/behaviours/timer_stddev.gd index ef3418a..6a05b64 100644 --- a/behaviours/timer_stddev.gd +++ b/behaviours/timer_stddev.gd @@ -17,7 +17,3 @@ func randomize_wait_time() -> void: Random.rng.randfn(mean_secs, deviation), max_secs ) - - -func _ready() -> void: - randomize_wait_time() diff --git a/entities/imp.gd b/entities/imp.gd index e87d76e..57ffea1 100644 --- a/entities/imp.gd +++ b/entities/imp.gd @@ -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() diff --git a/entities/imp.tscn b/entities/imp.tscn index dc0c5ac..a083533 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -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"] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index aca8877..7f76420 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -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] From fd91909d0475c68aa25e41212693f0444ea6605a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:46:21 +0200 Subject: [PATCH 51/83] Setup a nice little scene --- entities/imp.tscn | 11 +++++++---- scenes/game/main_game.tscn | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index a083533..ee9d5a7 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -42,9 +42,11 @@ shape = SubResource("CircleShape2D_ide4n") [node name="CoinSpawner" parent="." instance=ExtResource("4_d8lgm")] scene = ExtResource("5_yrfoq") -[node name="Timer" type="Timer" parent="CoinSpawner"] -wait_time = 0.8 -autostart = true +[node name="TimerStddev" parent="CoinSpawner" instance=ExtResource("10_phvea")] +mean_secs = 5.0 +deviation = 4.0 +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")] @@ -89,7 +91,7 @@ acceptable_diets = Array[StringName]([&"Meat"]) shape = SubResource("CircleShape2D_qhk1q") debug_color = Color(1, 0, 0, 0) -[connection signal="timeout" from="CoinSpawner/Timer" to="CoinSpawner" method="spawn"] +[connection signal="timeout" from="CoinSpawner/TimerStddev" 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"] @@ -101,4 +103,5 @@ debug_color = Color(1, 0, 0, 0) [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="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=2] [connection signal="eaten" from="Eater" to="." method="_on_eater_eaten"] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index f8af012..5a407d8 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=13 format=3 uid="uid://cxj5aud02f40j"] [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"] @@ -7,6 +7,8 @@ [ext_resource type="PackedScene" uid="uid://col1q3elvkfwk" path="res://scenes/game/cursor.tscn" id="5_g504x"] [ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="6_j2kdp"] [ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="7_7od2n"] +[ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="7_kqc55"] +[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="9_8875b"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -831,11 +833,8 @@ unique_name_in_owner = true [node name="Cursor" parent="." instance=ExtResource("5_g504x")] -[node name="Sheep" parent="." instance=ExtResource("6_j2kdp")] -position = Vector2(-246, 25) - [node name="Imp" parent="." instance=ExtResource("7_7od2n")] -position = Vector2(237, 10) +position = Vector2(102, -21) [node name="Walls" type="Node2D" parent="."] @@ -873,3 +872,15 @@ collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"] shape = SubResource("WorldBoundaryShape2D_htttx") + +[node name="Spawner" parent="." instance=ExtResource("7_kqc55")] +position = Vector2(-386, 162) +scene = ExtResource("6_j2kdp") + +[node name="TimerStddev" parent="Spawner" instance=ExtResource("9_8875b")] +autostart = true +mean_secs = 6.0 +min_secs = 3.0 +max_secs = 9.0 + +[connection signal="timeout" from="Spawner/TimerStddev" to="Spawner" method="spawn"] From ba8dd72ed5ff0abdb38dccbfb505dba908002d0d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:47:34 +0200 Subject: [PATCH 52/83] Remove `target` parameter from `spawn` --- behaviours/spawner.gd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/behaviours/spawner.gd b/behaviours/spawner.gd index 2d8319a..d4680d0 100644 --- a/behaviours/spawner.gd +++ b/behaviours/spawner.gd @@ -1,16 +1,14 @@ @icon("res://behaviours/spawner.svg") -extends Node2D +extends Area2D class_name Spawner signal spawned(entity: Node2D) @export var scene: PackedScene -@export var default_target: Node2D +@export var target: Node2D -func spawn(target: Node2D = null): - if not target: - target = default_target +func spawn(): if not target: target = MainGame.get_ancestor(self).default_spawn_parent var entity = scene.instantiate() From 9739a089d53572c072a6d4ee68536d01126554d1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:48:25 +0200 Subject: [PATCH 53/83] `Spawner`: spawn things on self if no MainGame is found --- behaviours/spawner.gd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/behaviours/spawner.gd b/behaviours/spawner.gd index d4680d0..2bbbee5 100644 --- a/behaviours/spawner.gd +++ b/behaviours/spawner.gd @@ -11,6 +11,8 @@ signal spawned(entity: Node2D) func spawn(): if not target: target = MainGame.get_ancestor(self).default_spawn_parent + if not target: + target = self var entity = scene.instantiate() entity.global_scale = global_scale entity.global_position = global_position From da0180c5be85d8df478f1d217658b368be9c1353 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 04:30:35 +0200 Subject: [PATCH 54/83] THINGS YAY --- behaviours/spawner.gd | 21 +++++++++++++++++++-- behaviours/tracker.gd | 10 ++++++++-- behaviours/tracker.tscn | 12 ++++++++++++ behaviours/tracker_tracker.gd | 24 +++++++++++++++++++++--- behaviours/tracker_tracker.tscn | 6 ++++-- entities/gold.gd | 2 +- entities/imp.tscn | 1 - entities/sheep.tscn | 4 ++++ scenes/game/cursor.gd | 2 +- scenes/game/main_game.gd | 18 +++++++----------- scenes/game/main_game.tscn | 18 ++++++++++++++---- traversal.gd | 11 +++++++++++ 12 files changed, 102 insertions(+), 27 deletions(-) create mode 100644 behaviours/tracker.tscn create mode 100644 traversal.gd diff --git a/behaviours/spawner.gd b/behaviours/spawner.gd index 2bbbee5..fbf5d8a 100644 --- a/behaviours/spawner.gd +++ b/behaviours/spawner.gd @@ -1,16 +1,33 @@ @icon("res://behaviours/spawner.svg") -extends Area2D +extends Node2D class_name Spawner + +## Emitted when a new scene is spawned. signal spawned(entity: Node2D) +## Emitted when the [field blocking_tracker] prevents something from spawning. +signal spawn_blocked + + +## The scene to spawn. @export var scene: PackedScene + +## Where the scene should be parented to in the tree. @export var target: Node2D +## If set, requires the tracker to not be tracking anything before spawning a scene. +@export var blocking_tracker: Tracker + +## Spawn [field scene] at [field target] and the position of this node. func spawn(): + if blocking_tracker != null: + if not blocking_tracker.tracking.is_empty(): + spawn_blocked.emit() + return # Perhaps enqueue the spawn? if not target: - target = MainGame.get_ancestor(self).default_spawn_parent + target = MainGame.get_via_group(self).default_spawn_parent if not target: target = self var entity = scene.instantiate() diff --git a/behaviours/tracker.gd b/behaviours/tracker.gd index 92824ff..b2dfbf5 100644 --- a/behaviours/tracker.gd +++ b/behaviours/tracker.gd @@ -2,7 +2,7 @@ extends Area2D class_name Tracker -## Abstract base class for [Area2D]s tracking a certain subset of [Node2D]s. +## [Area2D]s tracking a certain subset of [Node2D]s. signal tracked(body: Node2D) @@ -11,6 +11,9 @@ signal untracked(body: Node2D) var tracking: Array = [] +## Start [field tracking] a [Node2D]. +## +## Returns whether the body was added to the [field tracking] array. func track(body: Node2D) -> bool: var act: bool = not body in tracking if act: @@ -18,9 +21,12 @@ func track(body: Node2D) -> bool: tracked.emit(body) # Handle TrackerTracker for tracker_tracker in body.find_children("*", "TrackerTracker", true, false): - tracker_tracker.track(self) + tracker_tracker.track_if_detected(self) return act +## Stop [field tracking] a [Node2D]. +## +## Returns whether the body was removed from the [field tracking] array. func untrack(body: Node2D) -> bool: var act: bool = body in tracking if act: diff --git a/behaviours/tracker.tscn b/behaviours/tracker.tscn new file mode 100644 index 0000000..416f465 --- /dev/null +++ b/behaviours/tracker.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://8jkesanu4hrn"] + +[ext_resource type="Script" path="res://behaviours/tracker.gd" id="1_4joji"] + +[node name="Tracker" type="Area2D"] +collision_layer = 0 +collision_mask = 56 +monitorable = false +script = ExtResource("1_4joji") + +[connection signal="body_entered" from="." to="." method="track"] +[connection signal="body_exited" from="." to="." method="untrack"] diff --git a/behaviours/tracker_tracker.gd b/behaviours/tracker_tracker.gd index 98c08c7..b7940ad 100644 --- a/behaviours/tracker_tracker.gd +++ b/behaviours/tracker_tracker.gd @@ -1,6 +1,24 @@ extends Tracker class_name TrackerTracker -## Tracks [Tracker]s tracking the parent. -## -## Shape is ignored. +## Tracks [Tracker]s tracking the parent. + + +## Start [field tracking] a [Node2D] if it overlaps this [Area2D]. +## +## Returns whether the body was added to the [field tracking] array. +func track_if_detected(body: Node2D) -> bool: + if overlaps_body(body): + return track(body) + return false + +## Start [field tracking] a [Node2D] if it has a [Tracker] tracking this node or one of its ancestors. +## +## Returns whether the body was added to the [field tracking] array. +func track_if_tracked(body: Node2D) -> bool: + var act: bool = false + for tracker in body.find_children("*", "Tracker", true, false): + for ancestor in Traversal.get_ancestors(self): # Make more efficient, perhaps? + if ancestor in tracker.tracking: + act = track(body) or act + return act diff --git a/behaviours/tracker_tracker.tscn b/behaviours/tracker_tracker.tscn index beadebe..fccb77d 100644 --- a/behaviours/tracker_tracker.tscn +++ b/behaviours/tracker_tracker.tscn @@ -4,7 +4,9 @@ [node name="TrackerTracker" type="Area2D"] collision_layer = 0 -collision_mask = 0 -monitoring = false +collision_mask = 24 monitorable = false script = ExtResource("1_7b21r") + +[connection signal="body_entered" from="." to="." method="track_if_tracked"] +[connection signal="body_exited" from="." to="." method="untrack"] diff --git a/entities/gold.gd b/entities/gold.gd index c184a37..cd5d640 100644 --- a/entities/gold.gd +++ b/entities/gold.gd @@ -9,7 +9,7 @@ func _on_move(movement: Vector2) -> void: position += movement func _on_collected(tag: StringName) -> void: - var game = MainGame.get_ancestor(self) + var game = MainGame.get_via_group(self) # TODO: Perhaps use a dictionary in game to store multiple currencies? match tag: diff --git a/entities/imp.tscn b/entities/imp.tscn index ee9d5a7..f1ab3d8 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -60,7 +60,6 @@ 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 diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 7f76420..b49be9d 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -153,6 +153,10 @@ alternative_priority = 40 [node name="HunterSense" parent="MovementRunFromHunter" instance=ExtResource("14_eqowb")] +[node name="Shape" type="CollisionShape2D" parent="MovementRunFromHunter/HunterSense"] +shape = SubResource("CircleShape2D_etpf6") +debug_color = Color(1, 1, 0, 0) + [node name="TargetPicker" parent="MovementRunFromHunter/HunterSense" node_paths=PackedStringArray("tracker") instance=ExtResource("13_jf6em")] tracker = NodePath("..") diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 120ecf9..8fec76f 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -4,7 +4,7 @@ class_name Cursor ## A [CharacterBody2D] syncing its position with the mouse on each physics timestep. -@onready var game := MainGame.get_ancestor(self) +@onready var game := MainGame.get_via_group(self) func _physics_process(_delta: float) -> void: diff --git a/scenes/game/main_game.gd b/scenes/game/main_game.gd index 19df7f0..ef5172c 100644 --- a/scenes/game/main_game.gd +++ b/scenes/game/main_game.gd @@ -2,17 +2,13 @@ extends Node2D class_name MainGame -## Get the first possible [MainGame] instance by climbing the scene tree one ancestor at a time. -static func get_ancestor(start: Node) -> MainGame: - var current = start - while current is Node: - if current is MainGame: - return current - current = current.get_parent() - Log.w(start, "MainGame ancestor not found.") - return null - - @onready var gold_counter: Counter = $"GoldCounter" @onready var camera: GameCamera = $"GameCamera" @onready var default_spawn_parent: Node2D = %"DefaultSpawnParent" + + +static func get_via_group(node: Node) -> MainGame: + var result = node.get_tree().get_nodes_in_group("game") + if result.is_empty(): + return null + return result[0] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 5a407d8..cfd6081 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=15 format=3 uid="uid://cxj5aud02f40j"] [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"] @@ -9,6 +9,7 @@ [ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="7_7od2n"] [ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="7_kqc55"] [ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="9_8875b"] +[ext_resource type="PackedScene" uid="uid://8jkesanu4hrn" path="res://behaviours/tracker.tscn" id="10_bm07a"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -815,14 +816,16 @@ sources/0 = SubResource("TileSetAtlasSource_058kb") [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_htttx"] -[node name="MainGame" type="Node2D"] +[sub_resource type="CircleShape2D" id="CircleShape2D_h5qsh"] +radius = 48.0 + +[node name="MainGame" type="Node2D" groups=["game"]] script = ExtResource("1_wiglu") [node name="TileMap" type="TileMap" parent="."] scale = Vector2(2, 2) tile_set = SubResource("TileSet_g2dkm") format = 2 -layer_0/tile_data = PackedInt32Array(720915, 196608, 9, 655379, 0, 2, 589843, 0, 4, 524307, 196608, 8, 458771, 196608, 0, 393235, 327680, 1, 327699, 327680, 2, 262163, 65536, 5, 196627, 327680, 0, 131091, 196608, 4, 65555, 0, 6, 19, 0, 6, -65517, 0, 6, -131053, 196608, 1, -196589, 327680, 2, -262125, 327680, 4, -327661, 327680, 1, -393197, 0, 3, -458733, 65536, 0, -524269, 196608, 0, -589805, 327680, 0, -655341, 0, 3, -720877, 327680, 5, -786413, 131072, 8, 720914, 327680, 1, 655378, 65536, 5, 589842, 327680, 0, 524306, 0, 5, 458770, 327680, 2, 393234, 327680, 1, 327698, 131072, 9, 262162, 327680, 0, 196626, 0, 4, 131090, 262144, 6, 65554, 196608, 2, 18, 131072, 3, -65518, 196608, 3, -131054, 196608, 1, -196590, 196608, 9, -262126, 327680, 4, -327662, 0, 4, -393198, 131072, 5, -458734, 262144, 5, -524270, 131072, 9, -589806, 0, 1, -655342, 65536, 5, -720878, 327680, 4, -786414, 262144, 0, 720913, 0, 5, 655377, 131072, 9, 589841, 196608, 9, 524305, 327680, 5, 458769, 0, 4, 393233, 0, 4, 327697, 327680, 5, 262161, 327680, 0, 196625, 262144, 4, 131089, 0, 6, 65553, 131072, 3, 17, 196608, 3, -65519, 196608, 2, -131055, 131072, 11, -196591, 327680, 1, -262127, 196608, 9, -327663, 0, 5, -393199, 262144, 0, -458735, 131072, 0, -524271, 0, 4, -589807, 0, 1, -655343, 327680, 5, -720879, 0, 3, -786415, 131072, 5, 720912, 131072, 9, 655376, 0, 2, 589840, 327680, 3, 524304, 131072, 8, 458768, 196608, 9, 393232, 196608, 5, 327696, 327680, 4, 262160, 262144, 5, 196624, 262144, 6, 131088, 196608, 3, 65552, 196608, 2, 16, 196608, 3, -65520, 131072, 2, -131056, 131072, 11, -196592, 327680, 0, -262128, 196608, 9, -327664, 262144, 0, -393200, 0, 1, -458736, 0, 5, -524272, 262144, 5, -589808, 196608, 8, -655344, 0, 2, -720880, 327680, 2, -786416, 131072, 0, 720911, 196608, 0, 655375, 327680, 2, 589839, 196608, 0, 524303, 0, 0, 458767, 0, 2, 393231, 196608, 5, 327695, 0, 5, 262159, 262144, 4, 196623, 0, 6, 131087, 131072, 2, 65551, 196608, 2, 15, 196608, 3, -65521, 131072, 2, -131057, 131072, 11, -196593, 0, 2, -262129, 262144, 0, -327665, 262144, 5, -393201, 327680, 0, -458737, 65536, 5, -524273, 196608, 5, -589809, 0, 4, -655345, 327680, 2, -720881, 0, 1, -786417, 0, 5, 720910, 131072, 0, 655374, 327680, 3, 589838, 327680, 4, 524302, 196608, 0, 458766, 327680, 0, 393230, 327680, 3, 327694, 262144, 4, 262158, 0, 6, 196622, 131072, 3, 131086, 131072, 3, 65550, 196608, 2, 14, 196608, 3, -65522, 131072, 2, -131058, 262144, 11, -196594, 65536, 0, -262130, 196608, 5, -327666, 0, 3, -393202, 327680, 3, -458738, 327680, 4, -524274, 131072, 0, -589810, 327680, 3, -655346, 131072, 0, -720882, 65536, 5, -786418, 0, 0, 720909, 131072, 9, 655373, 0, 1, 589837, 262144, 0, 524301, 0, 2, 458765, 0, 0, 393229, 196608, 0, 327693, 65536, 6, 262157, 196608, 2, 196621, 196608, 2, 131085, 131072, 3, 65549, 131072, 2, 13, 131072, 3, -65523, 196608, 2, -131059, 131072, 11, -196595, 262144, 0, -262131, 327680, 1, -327667, 196608, 9, -393203, 65536, 0, -458739, 65536, 0, -524275, 196608, 0, -589811, 0, 2, -655347, 327680, 1, -720883, 0, 4, -786419, 327680, 2, 720908, 262144, 5, 655372, 327680, 4, 589836, 196608, 8, 524300, 0, 3, 458764, 262144, 5, 393228, 262144, 4, 327692, 0, 6, 262156, 131072, 3, 196620, 131072, 2, 131084, 196608, 2, 65548, 131072, 3, 12, 196608, 3, -65524, 327680, 11, -131060, 65536, 1, -196596, 262144, 5, -262132, 131072, 9, -327668, 327680, 1, -393204, 327680, 0, -458740, 0, 3, -524276, 0, 3, -589812, 196608, 9, -655348, 327680, 2, -720884, 131072, 9, -786420, 131072, 0, 720907, 327680, 0, 655371, 65536, 0, 589835, 327680, 2, 524299, 262144, 5, 458763, 65536, 0, 393227, 196608, 6, 327691, 196608, 2, 262155, 131072, 3, 196619, 131072, 2, 131083, 131072, 2, 65547, 196608, 3, 11, 196608, 2, -65525, 262144, 11, -131061, 65536, 5, -196597, 196608, 9, -262133, 131072, 5, -327669, 327680, 5, -393205, 262144, 0, -458741, 0, 0, -524277, 0, 1, -589813, 0, 4, -655349, 327680, 4, -720885, 196608, 0, -786421, 0, 2, 720906, 327680, 4, 655370, 0, 4, 589834, 327680, 2, 524298, 327680, 4, 458762, 131072, 8, 393226, 131072, 4, 327690, 131072, 3, 262154, 196608, 2, 196618, 196608, 3, 131082, 131072, 2, 65546, 131072, 3, 10, 327680, 11, -65526, 65536, 1, -131062, 196608, 0, -196598, 196608, 0, -262134, 196608, 0, -327670, 131072, 8, -393206, 327680, 4, -458742, 327680, 4, -524278, 0, 1, -589814, 0, 0, -655350, 0, 3, -720886, 0, 3, -786422, 327680, 5, 720905, 327680, 0, 655369, 0, 0, 589833, 196608, 0, 524297, 196608, 0, 458761, 0, 1, 393225, 196608, 4, 327689, 196608, 3, 262153, 131072, 3, 196617, 196608, 2, 131081, 196608, 3, 65545, 327680, 11, 9, 65536, 1, -65527, 131072, 9, -131063, 0, 0, -196599, 327680, 0, -262135, 0, 3, -327671, 327680, 1, -393207, 65536, 5, -458743, 196608, 8, -524279, 327680, 3, -589815, 0, 1, -655351, 262144, 0, -720887, 262144, 0, -786423, 196608, 0, 720904, 0, 1, 655368, 262144, 5, 589832, 196608, 5, 524296, 0, 5, 458760, 262144, 4, 393224, 0, 6, 327688, 131072, 3, 262152, 196608, 3, 196616, 196608, 2, 131080, 131072, 2, 65544, 0, 11, 8, 327680, 3, -65528, 262144, 5, -131064, 65536, 5, -196600, 131072, 8, -262136, 327680, 5, -327672, 327680, 1, -393208, 0, 4, -458744, 131072, 0, -524280, 327680, 4, -589816, 131072, 0, -655352, 196608, 5, -720888, 327680, 3, -786424, 196608, 5, 720903, 327680, 5, 655367, 0, 5, 589831, 0, 5, 524295, 65536, 0, 458759, 196608, 4, 393223, 131072, 2, 327687, 196608, 2, 262151, 131072, 2, 196615, 196608, 3, 131079, 131072, 3, 65543, 131072, 3, 7, 262144, 5, -65529, 327680, 3, -131065, 196608, 5, -196601, 0, 2, -262137, 327680, 0, -327673, 327680, 1, -393209, 262144, 4, -458745, 0, 8, -524281, 262144, 3, -589817, 262144, 1, -655353, 327680, 5, -720889, 131072, 8, -786425, 0, 4, 720902, 327680, 2, 655366, 0, 3, 589830, 65536, 0, 524294, 0, 5, 458758, 131072, 4, 393222, 131072, 2, 327686, 196608, 3, 262150, 196608, 2, 196614, 131072, 2, 131078, 131072, 3, 65542, 131072, 3, 6, 327680, 5, -65530, 327680, 5, -131066, 327680, 0, -196602, 131072, 9, -262138, 262144, 4, -327674, 0, 8, -393210, 0, 6, -458746, 131072, 3, -524282, 327680, 11, -589818, 65536, 1, -655354, 0, 0, -720890, 327680, 2, -786426, 196608, 9, 720901, 65536, 5, 655365, 196608, 5, 589829, 196608, 0, 524293, 0, 4, 458757, 196608, 4, 393221, 131072, 2, 327685, 196608, 2, 262149, 131072, 2, 196613, 131072, 3, 131077, 131072, 2, 65541, 196608, 2, 5, 0, 3, -65531, 196608, 0, -131067, 327680, 4, -196603, 327680, 0, -262139, 131072, 6, -327675, 131072, 3, -393211, 196608, 3, -458747, 131072, 3, -524283, 196608, 11, -589819, 0, 2, -655355, 327680, 0, -720891, 131072, 9, -786427, 262144, 5, 720900, 196608, 0, 655364, 196608, 8, 589828, 0, 2, 524292, 327680, 0, 458756, 65536, 6, 393220, 131072, 3, 327684, 131072, 2, 262148, 196608, 3, 196612, 196608, 3, 131076, 196608, 2, 65540, 131072, 3, 4, 0, 3, -65532, 262144, 0, -131068, 131072, 0, -196604, 327680, 0, -262140, 65536, 6, -327676, 196608, 3, -393212, 131072, 2, -458748, 327680, 11, -524284, 65536, 1, -589820, 196608, 0, -655356, 0, 4, -720892, 65536, 5, -786428, 0, 1, 720899, 65536, 0, 655363, 131072, 5, 589827, 131072, 5, 524291, 0, 1, 458755, 65536, 4, 393219, 327680, 6, 327683, 196608, 2, 262147, 196608, 2, 196611, 131072, 3, 131075, 327680, 11, 65539, 327680, 8, 3, 0, 1, -65533, 131072, 0, -131069, 327680, 2, -196605, 65536, 0, -262141, 65536, 4, -327677, 327680, 10, -393213, 65536, 2, -458749, 65536, 1, -524285, 327680, 2, -589821, 0, 3, -655357, 131072, 9, -720893, 0, 2, -786429, 196608, 9, 720898, 131072, 0, 655362, 262144, 0, 589826, 327680, 5, 524290, 327680, 1, 458754, 262144, 0, 393218, 196608, 4, 327682, 196608, 2, 262146, 131072, 3, 196610, 196608, 2, 131074, 131072, 11, 65538, 327680, 4, 2, 0, 3, -65534, 0, 1, -131070, 0, 0, -196606, 327680, 0, -262142, 0, 5, -327678, 65536, 0, -393214, 65536, 5, -458750, 131072, 9, -524286, 196608, 0, -589822, 196608, 0, -655358, 0, 5, -720894, 196608, 9, -786430, 0, 5, 720897, 0, 4, 655361, 262144, 5, 589825, 327680, 0, 524289, 327680, 5, 458753, 327680, 5, 393217, 131072, 6, 327681, 131072, 2, 262145, 196608, 3, 196609, 131072, 2, 131073, 131072, 11, 65537, 131072, 9, 1, 0, 4, -65535, 196608, 0, -131071, 327680, 3, -196607, 196608, 0, -262143, 0, 4, -327679, 262144, 5, -393215, 196608, 5, -458751, 0, 2, -524287, 196608, 9, -589823, 196608, 0, -655359, 131072, 0, -720895, 0, 3, -786431, 196608, 8, 720896, 262144, 5, 655360, 0, 4, 589824, 0, 2, 524288, 0, 0, 458752, 196608, 9, 393216, 196608, 4, 327680, 196608, 3, 262144, 131072, 3, 196608, 131072, 3, 131072, 0, 11, 65536, 327680, 3, 0, 65536, 0, -65536, 196608, 5, -131072, 196608, 9, -196608, 65536, 0, -262144, 0, 5, -327680, 65536, 0, -393216, 0, 3, -458752, 327680, 0, -524288, 0, 3, -589824, 327680, 2, -655360, 131072, 8, -720896, 327680, 3, -786432, 196608, 8, 786431, 0, 3, 720895, 131072, 0, 655359, 196608, 8, 589823, 196608, 8, 524287, 327680, 0, 458751, 196608, 4, 393215, 131072, 3, 327679, 131072, 3, 262143, 196608, 3, 196607, 131072, 3, 131071, 262144, 0, 65535, 131072, 8, -1, 0, 0, -65537, 327680, 3, -131073, 131072, 9, -196609, 327680, 0, -262145, 131072, 0, -327681, 0, 0, -393217, 131072, 9, -458753, 196608, 8, -524289, 327680, 5, -589825, 0, 1, -655361, 196608, 0, -720897, 196608, 8, 786430, 327680, 3, 720894, 65536, 0, 655358, 262144, 0, 589822, 327680, 2, 524286, 131072, 0, 458750, 131072, 4, 393214, 131072, 2, 327678, 196608, 2, 262142, 131072, 2, 196606, 327680, 11, 131070, 327680, 2, 65534, 196608, 0, -2, 65536, 5, -65538, 196608, 8, -131074, 327680, 3, -196610, 131072, 8, -262146, 327680, 1, -327682, 262144, 5, -393218, 0, 1, -458754, 327680, 4, -524290, 262144, 5, -589826, 327680, 4, -655362, 327680, 1, -720898, 131072, 8, 786429, 0, 5, 720893, 0, 4, 655357, 196608, 5, 589821, 0, 4, 524285, 262144, 0, 458749, 262144, 6, 393213, 131072, 3, 327677, 131072, 2, 262141, 327680, 11, 196605, 65536, 1, 131069, 327680, 3, 65533, 0, 3, -3, 327680, 1, -65539, 327680, 4, -131075, 131072, 5, -196611, 262144, 4, -262147, 0, 10, -327683, 262144, 1, -393219, 196608, 8, -458755, 196608, 9, -524291, 0, 2, -589827, 262144, 0, -655363, 327680, 4, -720899, 327680, 4, 786428, 131072, 9, 720892, 131072, 0, 655356, 0, 5, 589820, 262144, 4, 524284, 0, 8, 458748, 0, 6, 393212, 131072, 3, 327676, 196608, 2, 262140, 196608, 11, 196604, 65536, 0, 131068, 196608, 0, 65532, 65536, 0, -4, 131072, 8, -65540, 196608, 5, -131076, 0, 2, -196612, 65536, 6, -262148, 196608, 2, -327684, 262144, 11, -393220, 0, 0, -458756, 131072, 9, -524292, 65536, 5, -589828, 131072, 0, -655364, 0, 2, -720900, 0, 0, 786427, 0, 3, 720891, 327680, 2, 655355, 0, 0, 589819, 65536, 6, 524283, 196608, 3, 458747, 131072, 2, 393211, 131072, 3, 327675, 327680, 11, 262139, 65536, 1, 196603, 131072, 0, 131067, 327680, 5, 65531, 0, 1, -5, 131072, 9, -65541, 196608, 5, -131077, 131072, 8, -196613, 262144, 6, -262149, 196608, 2, -327685, 0, 11, -393221, 262144, 1, -458757, 327680, 2, -524293, 196608, 0, -589829, 131072, 5, -655365, 262144, 0, -720901, 0, 4, 786426, 131072, 9, 720890, 262144, 0, 655354, 0, 0, 589818, 131072, 6, 524282, 196608, 2, 458746, 196608, 3, 393210, 196608, 3, 327674, 131072, 1, 262138, 196608, 5, 196602, 262144, 0, 131066, 196608, 8, 65530, 327680, 3, -6, 327680, 5, -65542, 0, 4, -131078, 196608, 8, -196614, 262144, 6, -262150, 131072, 3, -327686, 131072, 2, -393222, 196608, 1, -458758, 262144, 5, -524294, 0, 4, -589830, 131072, 5, -655366, 0, 5, -720902, 327680, 2, 786425, 0, 4, 720889, 0, 1, 655353, 0, 0, 589817, 131072, 6, 524281, 196608, 2, 458745, 131072, 2, 393209, 196608, 2, 327673, 262144, 11, 262137, 0, 0, 196601, 327680, 5, 131065, 65536, 0, 65529, 131072, 9, -7, 131072, 8, -65543, 131072, 0, -131079, 262144, 4, -196615, 0, 6, -262151, 131072, 3, -327687, 131072, 3, -393223, 0, 11, -458759, 262144, 1, -524295, 327680, 4, -589831, 262144, 5, -655367, 131072, 8, -720903, 0, 5, 786424, 327680, 3, 720888, 196608, 5, 655352, 131072, 9, 589816, 131072, 6, 524280, 196608, 2, 458744, 196608, 2, 393208, 196608, 2, 327672, 196608, 1, 262136, 0, 3, 196600, 0, 2, 131064, 327680, 0, 65528, 0, 5, -8, 0, 1, -65544, 196608, 5, -131080, 196608, 6, -196616, 131072, 3, -262152, 196608, 3, -327688, 196608, 3, -393224, 131072, 3, -458760, 196608, 1, -524296, 0, 3, -589832, 131072, 9, -655368, 0, 4, -720904, 131072, 5, 786423, 0, 0, 720887, 131072, 8, 655351, 0, 9, 589815, 0, 6, 524279, 196608, 2, 458743, 196608, 3, 393207, 131072, 2, 327671, 131072, 1, 262135, 0, 1, 196599, 196608, 8, 131063, 262144, 5, 65527, 262144, 5, -9, 0, 5, -65545, 262144, 4, -131081, 0, 6, -196617, 196608, 3, -262153, 196608, 3, -327689, 131072, 2, -393225, 196608, 2, -458761, 65536, 11, -524297, 131072, 8, -589833, 196608, 0, -655369, 196608, 9, -720905, 196608, 0, 786422, 196608, 9, 720886, 327680, 1, 655350, 327680, 6, 589814, 196608, 3, 524278, 131072, 2, 458742, 131072, 3, 393206, 327680, 11, 327670, 131072, 1, 262134, 131072, 9, 196598, 327680, 4, 131062, 0, 1, 65526, 196608, 9, -10, 65536, 5, -65546, 65536, 4, -131082, 327680, 6, -196618, 196608, 3, -262154, 131072, 3, -327690, 131072, 3, -393226, 327680, 11, -458762, 65536, 1, -524298, 0, 1, -589834, 196608, 9, -655370, 327680, 5, -720906, 327680, 5, 786421, 0, 0, 720885, 327680, 3, 655349, 262144, 6, 589813, 131072, 2, 524277, 196608, 3, 458741, 327680, 11, 393205, 65536, 1, 327669, 196608, 9, 262133, 0, 1, 196597, 327680, 0, 131061, 0, 5, 65525, 131072, 0, -11, 327680, 0, -65547, 131072, 0, -131083, 65536, 4, -196619, 327680, 9, -262155, 327680, 9, -327691, 327680, 7, -393227, 65536, 1, -458763, 327680, 4, -524299, 327680, 5, -589835, 196608, 8, -655371, 0, 3, -720907, 196608, 0, 786420, 131072, 0, 720884, 262144, 4, 655348, 0, 6, 589812, 131072, 2, 524276, 196608, 3, 458740, 131072, 11, 393204, 327680, 5, 327668, 196608, 9, 262132, 196608, 9, 196596, 65536, 5, 131060, 196608, 5, 65524, 131072, 8, -12, 65536, 5, -65548, 65536, 5, -131084, 262144, 5, -196620, 0, 1, -262156, 327680, 5, -327692, 0, 4, -393228, 196608, 0, -458764, 327680, 1, -524300, 65536, 0, -589836, 0, 5, -655372, 262144, 0, -720908, 327680, 4, 786419, 131072, 0, 720883, 262144, 6, 655347, 131072, 3, 589811, 131072, 2, 524275, 196608, 3, 458739, 131072, 1, 393203, 196608, 0, 327667, 0, 5, 262131, 0, 3, 196595, 0, 5, 131059, 196608, 5, 65523, 262144, 0, -13, 131072, 5, -65549, 327680, 2, -131085, 0, 5, -196621, 196608, 9, -262157, 0, 3, -327693, 131072, 8, -393229, 131072, 9, -458765, 65536, 5, -524301, 327680, 0, -589837, 65536, 0, -655373, 0, 2, -720909, 131072, 8, 786418, 327680, 5, 720882, 262144, 6, 655346, 196608, 2, 589810, 131072, 3, 524274, 131072, 2, 458738, 262144, 11, 393202, 196608, 5, 327666, 262144, 0, 262130, 262144, 0, 196594, 327680, 0, 131058, 327680, 1, 65522, 65536, 0, -14, 65536, 5, -65550, 327680, 0, -131086, 0, 0, -196622, 131072, 5, -262158, 327680, 2, -327694, 0, 3, -393230, 0, 0, -458766, 327680, 1, -524302, 327680, 1, -589838, 131072, 5, -655374, 131072, 8, -720910, 65536, 0, 786417, 262144, 4, 720881, 0, 6, 655345, 196608, 2, 589809, 196608, 2, 524273, 196608, 2, 458737, 131072, 1, 393201, 196608, 9, 327665, 65536, 0, 262129, 131072, 8, 196593, 0, 5, 131057, 0, 3, 65521, 196608, 0, -15, 131072, 5, -65551, 327680, 5, -131087, 0, 5, -196623, 131072, 9, -262159, 196608, 5, -327695, 0, 5, -393231, 0, 0, -458767, 0, 2, -524303, 131072, 0, -589839, 196608, 9, -655375, 262144, 5, -720911, 327680, 3, 786416, 196608, 2, 720880, 131072, 2, 655344, 196608, 3, 589808, 196608, 2, 524272, 327680, 11, 458736, 65536, 1, 393200, 0, 5, 327664, 131072, 0, 262128, 196608, 9, 196592, 65536, 0, 131056, 65536, 5, 65520, 327680, 1, -16, 131072, 9, -65552, 327680, 0, -131088, 0, 3, -196624, 327680, 0, -262160, 327680, 3, -327696, 65536, 0, -393232, 196608, 9, -458768, 65536, 0, -524304, 0, 0, -589840, 327680, 2, -655376, 327680, 3, -720912, 0, 5, 786415, 196608, 2, 720879, 131072, 3, 655343, 131072, 2, 589807, 196608, 2, 524271, 65536, 11, 458735, 65536, 5, 393199, 0, 4, 327663, 131072, 5, 262127, 262144, 0, 196591, 196608, 5, 131055, 327680, 4, 65519, 327680, 0, -17, 327680, 0, -65553, 262144, 5, -131089, 0, 4, -196625, 0, 2, -262161, 196608, 9, -327697, 0, 3, -393233, 196608, 5, -458769, 327680, 3, -524305, 327680, 2, -589841, 327680, 1, -655377, 327680, 3, -720913, 0, 2, 786414, 131072, 3, 720878, 131072, 2, 655342, 196608, 3, 589806, 327680, 11, 524270, 65536, 1, 458734, 0, 0, 393198, 0, 5, 327662, 131072, 5, 262126, 327680, 3, 196590, 65536, 0, 131054, 196608, 8, 65518, 0, 5, -18, 65536, 5, -65554, 327680, 0, -131090, 327680, 3, -196626, 0, 0, -262162, 0, 3, -327698, 262144, 0, -393234, 262144, 0, -458770, 65536, 0, -524306, 131072, 0, -589842, 0, 1, -655378, 327680, 2, -720914, 196608, 5, 786413, 196608, 3, 720877, 131072, 3, 655341, 327680, 11, 589805, 65536, 1, 524269, 327680, 4, 458733, 327680, 2, 393197, 0, 3, 327661, 0, 3, 262125, 196608, 9, 196589, 327680, 0, 131053, 65536, 5, 65517, 327680, 5, -19, 65536, 5, -65555, 196608, 8, -131091, 131072, 0, -196627, 131072, 5, -262163, 327680, 5, -327699, 327680, 2, -393235, 262144, 5, -458771, 196608, 8, -524307, 327680, 3, -589843, 327680, 0, -655379, 0, 3, -720915, 131072, 5, 786412, 196608, 2, 720876, 196608, 3, 655340, 262144, 11, 589804, 0, 3, 524268, 327680, 3, 458732, 0, 4, 393196, 131072, 5, 327660, 327680, 3, 262124, 131072, 5, 196588, 0, 4, 131052, 131072, 9, 65516, 0, 3, -20, 327680, 1, -65556, 0, 1, -131092, 327680, 1, -196628, 196608, 5, -262164, 131072, 8, -327700, 196608, 0, -393236, 131072, 5, -458772, 327680, 3, -524308, 327680, 4, -589844, 131072, 5, -655380, 0, 0, -720916, 0, 2) [node name="GameCamera" parent="." instance=ExtResource("2_db5xs")] @@ -873,9 +876,10 @@ collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"] shape = SubResource("WorldBoundaryShape2D_htttx") -[node name="Spawner" parent="." instance=ExtResource("7_kqc55")] +[node name="Spawner" parent="." node_paths=PackedStringArray("blocking_tracker") instance=ExtResource("7_kqc55")] position = Vector2(-386, 162) scene = ExtResource("6_j2kdp") +blocking_tracker = NodePath("Tracker") [node name="TimerStddev" parent="Spawner" instance=ExtResource("9_8875b")] autostart = true @@ -883,4 +887,10 @@ mean_secs = 6.0 min_secs = 3.0 max_secs = 9.0 +[node name="Tracker" parent="Spawner" instance=ExtResource("10_bm07a")] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Spawner/Tracker"] +shape = SubResource("CircleShape2D_h5qsh") +debug_color = Color(0, 1, 0, 0.152941) + [connection signal="timeout" from="Spawner/TimerStddev" to="Spawner" method="spawn"] diff --git a/traversal.gd b/traversal.gd new file mode 100644 index 0000000..f9ba9d6 --- /dev/null +++ b/traversal.gd @@ -0,0 +1,11 @@ +class_name Traversal + + +## Get the first possible [MainGame] instance by climbing the scene tree one ancestor at a time. +static func get_ancestors(start: Node) -> Array[Node]: + var result: Array[Node] = [] + var current = start + while current is Node: + result.push_back(current) + current = current.get_parent() + return result From 9c73dd7ebbb5f742c0ed56b17c5f2810f8475d7e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 18:19:37 +0200 Subject: [PATCH 55/83] Change `CharacterBody2D` `motion_mode` for `Imp` and `Sheep` to `FLOATING` --- entities/imp.tscn | 1 + entities/sheep.tscn | 1 + 2 files changed, 2 insertions(+) diff --git a/entities/imp.tscn b/entities/imp.tscn index f1ab3d8..fe5ecdf 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -27,6 +27,7 @@ radius = 40.0 [node name="Imp" type="CharacterBody2D"] collision_layer = 8 collision_mask = 14 +motion_mode = 1 script = ExtResource("1_dixpc") [node name="Sprite" parent="." instance=ExtResource("2_eqcdi")] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index b49be9d..a3a324d 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -81,6 +81,7 @@ radius = 144.0 [node name="Sheep" type="CharacterBody2D"] collision_layer = 8 collision_mask = 14 +motion_mode = 1 script = ExtResource("1_4dmll") [node name="Sprite" parent="." instance=ExtResource("2_xbkrm")] From 0fa269cde5d66868382c30c4a273189a2d98fbeb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 18:25:39 +0200 Subject: [PATCH 56/83] Unset `pickable` from all `Area2D` --- behaviours/cursor_detector.tscn | 1 + behaviours/draggable.tscn | 1 + behaviours/eater.tscn | 1 + behaviours/tracker.tscn | 1 + behaviours/tracker_edible.tscn | 1 + behaviours/tracker_tracker.tscn | 1 + 6 files changed, 6 insertions(+) diff --git a/behaviours/cursor_detector.tscn b/behaviours/cursor_detector.tscn index c4b4fec..cf22039 100644 --- a/behaviours/cursor_detector.tscn +++ b/behaviours/cursor_detector.tscn @@ -5,6 +5,7 @@ [node name="CursorDetector" type="Area2D"] collision_layer = 0 collision_mask = 64 +input_pickable = false monitorable = false script = ExtResource("1_4hcxj") diff --git a/behaviours/draggable.tscn b/behaviours/draggable.tscn index f8e46d8..05758af 100644 --- a/behaviours/draggable.tscn +++ b/behaviours/draggable.tscn @@ -5,4 +5,5 @@ [node name="Draggable" type="Area2D"] collision_layer = 0 collision_mask = 0 +input_pickable = false script = ExtResource("1_hdedq") diff --git a/behaviours/eater.tscn b/behaviours/eater.tscn index 765b510..076639c 100644 --- a/behaviours/eater.tscn +++ b/behaviours/eater.tscn @@ -5,6 +5,7 @@ [node name="Eater" type="Area2D"] collision_layer = 0 collision_mask = 8 +input_pickable = false monitorable = false script = ExtResource("1_urx5y") diff --git a/behaviours/tracker.tscn b/behaviours/tracker.tscn index 416f465..a2c6eec 100644 --- a/behaviours/tracker.tscn +++ b/behaviours/tracker.tscn @@ -5,6 +5,7 @@ [node name="Tracker" type="Area2D"] collision_layer = 0 collision_mask = 56 +input_pickable = false monitorable = false script = ExtResource("1_4joji") diff --git a/behaviours/tracker_edible.tscn b/behaviours/tracker_edible.tscn index fd2e609..f9eb935 100644 --- a/behaviours/tracker_edible.tscn +++ b/behaviours/tracker_edible.tscn @@ -5,6 +5,7 @@ [node name="TrackerEdible" type="Area2D"] collision_layer = 0 collision_mask = 56 +input_pickable = false monitorable = false script = ExtResource("1_vmdw6") diff --git a/behaviours/tracker_tracker.tscn b/behaviours/tracker_tracker.tscn index fccb77d..e6763aa 100644 --- a/behaviours/tracker_tracker.tscn +++ b/behaviours/tracker_tracker.tscn @@ -5,6 +5,7 @@ [node name="TrackerTracker" type="Area2D"] collision_layer = 0 collision_mask = 24 +input_pickable = false monitorable = false script = ExtResource("1_7b21r") From 240314ca8e3660b3a7a6779155bb9a8c51ac7a4a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 18:25:48 +0200 Subject: [PATCH 57/83] Remove legacy `CursorMagnet` scene --- scenes/game/cursor_magnet.tscn | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 scenes/game/cursor_magnet.tscn diff --git a/scenes/game/cursor_magnet.tscn b/scenes/game/cursor_magnet.tscn deleted file mode 100644 index 76093aa..0000000 --- a/scenes/game/cursor_magnet.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://7j1b55t8tafg"] - -[ext_resource type="Script" path="res://scenes/game/cursor_magnet.gd" id="1_xk040"] - -[sub_resource type="CircleShape2D" id="CircleShape2D_6mkjn"] -radius = 16.0 - -[node name="CursorMagnet" type="Area2D"] -collision_layer = 64 -collision_mask = 8 -script = ExtResource("1_xk040") - -[node name="Shape" type="CollisionShape2D" parent="."] -scale = Vector2(0.5, 0.5) -shape = SubResource("CircleShape2D_6mkjn") -debug_color = Color(1, 1, 1, 0.67451) - -[connection signal="dragged" from="." to="." method="_on_dragged"] -[connection signal="dropped" from="." to="." method="_on_dropped"] From 549dc2a1b3ebba3c659fdc49746ee3aa5224080d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 02:16:39 +0200 Subject: [PATCH 58/83] Add `Cursor` to the `cursor` group --- scenes/game/cursor.tscn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index d2feb08..664d3fb 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -5,7 +5,7 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_j2mj5"] radius = 4.0 -[node name="Cursor" type="CharacterBody2D"] +[node name="Cursor" type="CharacterBody2D" groups=["cursor"]] collision_layer = 64 collision_mask = 0 motion_mode = 1 From 3d9233f01fff211fb67668b10c3e1873ee57682f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 02:17:40 +0200 Subject: [PATCH 59/83] Add a `get_via_group` method to `Cursor` --- scenes/game/cursor.gd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 8fec76f..7a8909f 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -7,5 +7,12 @@ class_name Cursor @onready var game := MainGame.get_via_group(self) +static func get_via_group(node: Node) -> MainGame: + var result = node.get_tree().get_nodes_in_group("cursor") + if result.is_empty(): + return null + return result[0] + + func _physics_process(_delta: float) -> void: move_and_collide(game.camera.get_global_mouse_position() - global_position) From b222f9a7ffc92cc9da8e832c64097b20f357bc8c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 02:23:01 +0200 Subject: [PATCH 60/83] Refactor `Cursor` to be an `Area2D` --- behaviours/cursor_detector.gd | 4 ++-- behaviours/cursor_detector.tscn | 4 ++-- scenes/game/cursor.gd | 21 +++++++++++++++++++-- scenes/game/cursor.tscn | 3 +-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/behaviours/cursor_detector.gd b/behaviours/cursor_detector.gd index 599201b..a80f04f 100644 --- a/behaviours/cursor_detector.gd +++ b/behaviours/cursor_detector.gd @@ -10,12 +10,12 @@ signal cursor_exited(cursor: Cursor) var mouse_inside = false -func _on_body_entered(body: Node2D) -> void: +func _on_area_entered(body: Area2D) -> void: if body is Cursor: mouse_inside = true cursor_entered.emit(body) -func _on_body_exited(body: Node2D) -> void: +func _on_area_exited(body: Area2D) -> void: if body is Cursor: mouse_inside = true cursor_exited.emit(body) diff --git a/behaviours/cursor_detector.tscn b/behaviours/cursor_detector.tscn index cf22039..d5cf13a 100644 --- a/behaviours/cursor_detector.tscn +++ b/behaviours/cursor_detector.tscn @@ -9,5 +9,5 @@ input_pickable = false 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"] +[connection signal="area_entered" from="." to="." method="_on_area_entered"] +[connection signal="area_exited" from="." to="." method="_on_area_exited"] diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 7a8909f..23f78e2 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -1,9 +1,13 @@ -extends CharacterBody2D +extends Area2D class_name Cursor ## A [CharacterBody2D] syncing its position with the mouse on each physics timestep. +signal dragged(node: Draggable) +signal dropped(node: Draggable) + + @onready var game := MainGame.get_via_group(self) @@ -14,5 +18,18 @@ static func get_via_group(node: Node) -> MainGame: return result[0] +func find_closest_target() -> Draggable: + var bodies = get_overlapping_bodies() + var min_distance: float = INF + var to_drag: Node = null + for body in bodies: + for target in body.find_children("Draggable", "Draggable", false, false): + var distance = position.distance_to(target.position) + if distance < min_distance: + min_distance = distance + to_drag = target + return to_drag + + func _physics_process(_delta: float) -> void: - move_and_collide(game.camera.get_global_mouse_position() - global_position) + position += (game.camera.get_global_mouse_position() - global_position) diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 664d3fb..4a4dfbf 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -5,10 +5,9 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_j2mj5"] radius = 4.0 -[node name="Cursor" type="CharacterBody2D" groups=["cursor"]] +[node name="Cursor" type="Area2D" groups=["cursor"]] collision_layer = 64 collision_mask = 0 -motion_mode = 1 script = ExtResource("1_1og6v") [node name="Shape" type="CollisionShape2D" parent="."] From 6d30d123d61f9afb81922f354897cd555777d7cb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 02:23:45 +0200 Subject: [PATCH 61/83] Allow `find_closest_target` to find `Draggable`s of any name --- scenes/game/cursor.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 23f78e2..ccf8426 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -23,7 +23,7 @@ func find_closest_target() -> Draggable: var min_distance: float = INF var to_drag: Node = null for body in bodies: - for target in body.find_children("Draggable", "Draggable", false, false): + for target in body.find_children("*", "Draggable", true, false): var distance = position.distance_to(target.position) if distance < min_distance: min_distance = distance From 466a263c410f99f7910f5b3f4b50f866a4ce1372 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 02:50:47 +0200 Subject: [PATCH 62/83] Import things from `CursorMagnet` into `Cursor` --- scenes/game/cursor.gd | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index ccf8426..2bb2622 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -10,6 +10,8 @@ signal dropped(node: Draggable) @onready var game := MainGame.get_via_group(self) +var dragging: Draggable = null + static func get_via_group(node: Node) -> MainGame: var result = node.get_tree().get_nodes_in_group("cursor") @@ -30,6 +32,31 @@ func find_closest_target() -> Draggable: to_drag = target return to_drag +func drag(): + var target = find_closest_target() + if target and not dragging: + dragging = target + target.drag() + dragged.emit(target) + +func drop(): + if dragging: + var target = dragging + dragging = null + target.drop() + dropped.emit(target) + +func log_dragging() -> void: + Log.p(self, "Dragging: %s" % dragging) + + +func _input(event: InputEvent) -> void: + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + drag() + else: + drop() func _physics_process(_delta: float) -> void: position += (game.camera.get_global_mouse_position() - global_position) From e2bbbccfeaddda3869a92d9f2625e98ca68fb7f8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 03:49:32 +0200 Subject: [PATCH 63/83] Reimplement dragging detection --- behaviours/draggable.tscn | 3 ++- entities/sheep.gd | 7 +++++++ entities/sheep.tscn | 12 +++++++++++- scenes/game/cursor.tscn | 2 +- scenes/game/main_game.tscn | 2 ++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/behaviours/draggable.tscn b/behaviours/draggable.tscn index 05758af..659366f 100644 --- a/behaviours/draggable.tscn +++ b/behaviours/draggable.tscn @@ -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") diff --git a/entities/sheep.gd b/entities/sheep.gd index 8d3a888..a8ba3e3 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -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 diff --git a/entities/sheep.tscn b/entities/sheep.tscn index a3a324d..cd39098 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -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"] diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 4a4dfbf..01422ec 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -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="."] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index cfd6081..91b2b5c 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -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"] From 9e25d08020e6b75c4bd7a61a3ce055e2d515bb91 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 04:11:14 +0200 Subject: [PATCH 64/83] Add a `Cursor` parameter to `drag` and `drop` --- behaviours/draggable.gd | 12 ++++++------ scenes/game/cursor.gd | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/behaviours/draggable.gd b/behaviours/draggable.gd index 26ad854..5587747 100644 --- a/behaviours/draggable.gd +++ b/behaviours/draggable.gd @@ -3,17 +3,17 @@ extends Area2D class_name Draggable -signal dragged -signal dropped +signal dragged(cursor: Cursor) +signal dropped(cursor: Cursor) var being_dragged: bool = false -func drag(): +func drag(cursor: Cursor): being_dragged = true - dragged.emit() + dragged.emit(cursor) -func drop(): +func drop(cursor: Cursor): being_dragged = false - dropped.emit() + dropped.emit(cursor) diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 2bb2622..7f9a360 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -36,14 +36,14 @@ func drag(): var target = find_closest_target() if target and not dragging: dragging = target - target.drag() + target.drag(self) dragged.emit(target) func drop(): if dragging: var target = dragging dragging = null - target.drop() + target.drop(self) dropped.emit(target) func log_dragging() -> void: From f9f52c4f4a99c34d302836bd70891533928d3f82 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 04:31:59 +0200 Subject: [PATCH 65/83] Start working on `MoveTowardsPhysics` --- behaviours/draggable.gd | 6 +++--- behaviours/move_towards_physics.gd | 17 +++++++++++++++++ behaviours/move_towards_physics.tscn | 6 ++++++ entities/sheep.gd | 6 +++++- entities/sheep.tscn | 25 +++++++++++++++++++------ scenes/game/cursor.gd | 2 +- scenes/game/main_game.tscn | 2 -- 7 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 behaviours/move_towards_physics.gd create mode 100644 behaviours/move_towards_physics.tscn diff --git a/behaviours/draggable.gd b/behaviours/draggable.gd index 5587747..d52eaad 100644 --- a/behaviours/draggable.gd +++ b/behaviours/draggable.gd @@ -4,7 +4,7 @@ class_name Draggable signal dragged(cursor: Cursor) -signal dropped(cursor: Cursor) +signal dropped var being_dragged: bool = false @@ -14,6 +14,6 @@ func drag(cursor: Cursor): being_dragged = true dragged.emit(cursor) -func drop(cursor: Cursor): +func drop(): being_dragged = false - dropped.emit(cursor) + dropped.emit() diff --git a/behaviours/move_towards_physics.gd b/behaviours/move_towards_physics.gd new file mode 100644 index 0000000..22069cb --- /dev/null +++ b/behaviours/move_towards_physics.gd @@ -0,0 +1,17 @@ +extends MoveTowards +class_name MoveTowardsGravity + + +# [field speed] is actually used as acceleration. Oh well. + +var velocity := Vector2.ZERO + + +func _physics_process(delta: float) -> void: + if enabled: + if target: + var gap = target.global_position - global_position + var norm = gap.normalized() + velocity += norm * delta * speed + Log.p(self, "Velocity: %s" % velocity) + move.emit(velocity * delta) diff --git a/behaviours/move_towards_physics.tscn b/behaviours/move_towards_physics.tscn new file mode 100644 index 0000000..bc2bedf --- /dev/null +++ b/behaviours/move_towards_physics.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://rx24bppccih7"] + +[ext_resource type="Script" path="res://behaviours/move_towards_physics.gd" id="1_u02i3"] + +[node name="MoveTowardsPhysics" type="Node2D"] +script = ExtResource("1_u02i3") diff --git a/entities/sheep.gd b/entities/sheep.gd index a8ba3e3..68aa731 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -14,8 +14,12 @@ func _on_move(movement: Vector2) -> void: sprite.handle_move(movement) -func _on_draggable_dragged() -> void: +func _on_draggable_dragged(_cursor: Cursor) -> void: collision_layer = 16 + collision_mask = 18 + z_index = 1 func _on_draggable_dropped() -> void: collision_layer = 8 + collision_mask = 14 + z_index = 0 diff --git a/entities/sheep.tscn b/entities/sheep.tscn index cd39098..79d5516 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=22 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"] @@ -13,6 +13,7 @@ [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://rx24bppccih7" path="res://behaviours/move_towards_physics.tscn" id="14_3wojv"] [ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] @@ -105,7 +106,7 @@ libraries = { diet = &"Meat" [node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("9_s5lod")] -possibilities = [NodePath("../MovementIdle/IdlePriority"), NodePath("../MovementWander/WanderPriority"), NodePath("../MovementRunFromMouse/RunFromMousePriority"), NodePath("../MovementRunFromHunter/RunFromHunterPriority")] +possibilities = [NodePath("../MovementIdle/IdlePriority"), NodePath("../MovementWander/WanderPriority"), NodePath("../MovementRunFromMouse/RunFromMousePriority"), NodePath("../MovementRunFromHunter/RunFromHunterPriority"), NodePath("../MovementDrag/DragPriority")] [node name="MovementIdle" parent="." instance=ExtResource("10_05kcd")] speed = 0.0 @@ -162,9 +163,15 @@ 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="MovementDrag" parent="." instance=ExtResource("14_3wojv")] +speed = 1200.0 -[node name="Shape" type="CollisionShape2D" parent="Draggable"] +[node name="DragPriority" parent="MovementDrag" instance=ExtResource("11_0jlmk")] +alternative_priority = 50 + +[node name="Draggable" parent="MovementDrag" instance=ExtResource("14_0b1hs")] + +[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] scale = Vector2(3, 3) shape = SubResource("CircleShape2D_c5tcn") debug_color = Color(1, 1, 1, 0) @@ -194,5 +201,11 @@ debug_color = Color(1, 1, 1, 0) [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"] +[connection signal="changed_target" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_conditional"] +[connection signal="move" from="MovementDrag" to="." method="_on_move"] +[connection signal="move_enabled" from="MovementDrag" to="MovementWander" method="clear_direction"] +[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="set_target"] +[connection signal="dropped" from="MovementDrag/Draggable" to="." method="_on_draggable_dropped"] +[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="clear_target"] diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 7f9a360..d211b0f 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -43,7 +43,7 @@ func drop(): if dragging: var target = dragging dragging = null - target.drop(self) + target.drop() dropped.emit(target) func log_dragging() -> void: diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 91b2b5c..cfd6081 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -893,6 +893,4 @@ 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"] From 6e14678239663cc81e388e15299d6c7f06e83047 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 04:54:33 +0200 Subject: [PATCH 66/83] Make `Sheep` throwable! --- behaviours/move_physics.gd | 39 +++++++++++++++++++ ...towards_physics.tscn => move_physics.tscn} | 2 +- behaviours/move_towards_physics.gd | 17 -------- entities/sheep.tscn | 19 ++++++--- 4 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 behaviours/move_physics.gd rename behaviours/{move_towards_physics.tscn => move_physics.tscn} (60%) delete mode 100644 behaviours/move_towards_physics.gd diff --git a/behaviours/move_physics.gd b/behaviours/move_physics.gd new file mode 100644 index 0000000..b979b76 --- /dev/null +++ b/behaviours/move_physics.gd @@ -0,0 +1,39 @@ +extends Move +class_name MoveTowardsGravity + + +signal dragged(cursor: Cursor) +signal dropped +signal fallen + + +@export var acceleration = 2500.0 +@export var linear_damp = 50.0 + +var cursor: Cursor = null + +var velocity := Vector2.ZERO + +@onready var ticks_per_second = ProjectSettings.get_setting("physics/common/physics_ticks_per_second") + + +func drag(value: Cursor) -> void: + cursor = value + dragged.emit(value) + +func drop() -> void: + cursor = null + dropped.emit() + +func fall() -> void: + velocity = Vector2.ZERO + fallen.emit() + + +func _physics_process(delta: float) -> void: + if enabled: + if cursor: + var gap = cursor.global_position - global_position + velocity += gap * delta * acceleration + velocity *= 1.0 - linear_damp / ticks_per_second + move.emit(velocity * delta) diff --git a/behaviours/move_towards_physics.tscn b/behaviours/move_physics.tscn similarity index 60% rename from behaviours/move_towards_physics.tscn rename to behaviours/move_physics.tscn index bc2bedf..2a31113 100644 --- a/behaviours/move_towards_physics.tscn +++ b/behaviours/move_physics.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://rx24bppccih7"] -[ext_resource type="Script" path="res://behaviours/move_towards_physics.gd" id="1_u02i3"] +[ext_resource type="Script" path="res://behaviours/move_physics.gd" id="1_u02i3"] [node name="MoveTowardsPhysics" type="Node2D"] script = ExtResource("1_u02i3") diff --git a/behaviours/move_towards_physics.gd b/behaviours/move_towards_physics.gd deleted file mode 100644 index 22069cb..0000000 --- a/behaviours/move_towards_physics.gd +++ /dev/null @@ -1,17 +0,0 @@ -extends MoveTowards -class_name MoveTowardsGravity - - -# [field speed] is actually used as acceleration. Oh well. - -var velocity := Vector2.ZERO - - -func _physics_process(delta: float) -> void: - if enabled: - if target: - var gap = target.global_position - global_position - var norm = gap.normalized() - velocity += norm * delta * speed - Log.p(self, "Velocity: %s" % velocity) - move.emit(velocity * delta) diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 79d5516..a393680 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -13,7 +13,7 @@ [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://rx24bppccih7" path="res://behaviours/move_towards_physics.tscn" id="14_3wojv"] +[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="14_3wojv"] [ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] @@ -164,7 +164,9 @@ debug_color = Color(1, 1, 0, 0) tracker = NodePath("..") [node name="MovementDrag" parent="." instance=ExtResource("14_3wojv")] -speed = 1200.0 +acceleration = 650.0 +linear_damp = 18.0 +enabled = false [node name="DragPriority" parent="MovementDrag" instance=ExtResource("11_0jlmk")] alternative_priority = 50 @@ -176,6 +178,10 @@ scale = Vector2(3, 3) shape = SubResource("CircleShape2D_c5tcn") debug_color = Color(1, 1, 1, 0) +[node name="FallTimer" type="Timer" parent="MovementDrag"] +wait_time = 0.5 +one_shot = true + [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"] @@ -201,11 +207,14 @@ debug_color = Color(1, 1, 1, 0) [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="MovementDrag" to="MovementDrag/DragPriority" method="priority_conditional"] +[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="move_enabled" from="MovementDrag" to="MovementWander" method="clear_direction"] [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="set_target"] +[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="clear_target"] +[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] +[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] From 67c17808b8f877420fa080714ca29dd327046851 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 04:54:56 +0200 Subject: [PATCH 67/83] Tune `MovePhysics` default parameters --- behaviours/move_physics.gd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/behaviours/move_physics.gd b/behaviours/move_physics.gd index b979b76..18e05a3 100644 --- a/behaviours/move_physics.gd +++ b/behaviours/move_physics.gd @@ -7,8 +7,8 @@ signal dropped signal fallen -@export var acceleration = 2500.0 -@export var linear_damp = 50.0 +@export var acceleration = 650.0 +@export var linear_damp = 18.0 var cursor: Cursor = null From 9525b65ad8477ecb6cd14dfbfe0e8ad7ae467f32 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 04:55:09 +0200 Subject: [PATCH 68/83] Fix `MovePhysics` name --- behaviours/move_physics.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/behaviours/move_physics.gd b/behaviours/move_physics.gd index 18e05a3..7e51e39 100644 --- a/behaviours/move_physics.gd +++ b/behaviours/move_physics.gd @@ -1,5 +1,5 @@ extends Move -class_name MoveTowardsGravity +class_name MovePhysics signal dragged(cursor: Cursor) From 704c70b355044376b6d9c4b2258de43a761db7e1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 05:00:23 +0200 Subject: [PATCH 69/83] Make `Imp` `Draggable` too! --- entities/imp.gd | 14 ++++++++++++++ entities/imp.tscn | 40 ++++++++++++++++++++++++++++++++++++---- entities/sheep.tscn | 2 -- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/entities/imp.gd b/entities/imp.gd index 57ffea1..b269e7d 100644 --- a/entities/imp.gd +++ b/entities/imp.gd @@ -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 diff --git a/entities/imp.tscn b/entities/imp.tscn index fe5ecdf..72075b5 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -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"] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index a393680..285e785 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -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")] From d16126b48ae017bb28d9d786714fcb5ed92e5fe0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 20 Apr 2024 05:08:16 +0200 Subject: [PATCH 70/83] Make a nice preview scene --- scenes/game/main_game.tscn | 1 + 1 file changed, 1 insertion(+) diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index cfd6081..87d2515 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -826,6 +826,7 @@ script = ExtResource("1_wiglu") scale = Vector2(2, 2) tile_set = SubResource("TileSet_g2dkm") format = 2 +layer_0/tile_data = PackedInt32Array(720915, 262144, 4, 655379, 0, 8, 589843, 262144, 3, 524307, 0, 8, 458771, 0, 8, 393235, 262144, 3, 327699, 0, 8, 262163, 262144, 2, 196627, 0, 7, 131091, 262144, 3, 65555, 0, 10, 19, 0, 8, -65517, 0, 7, -131053, 262144, 3, -196589, 0, 10, -262125, 262144, 2, -327661, 0, 8, -393197, 262144, 2, -458733, 262144, 2, -524269, 0, 7, -589805, 0, 7, -655341, 0, 10, -720877, 262144, 3, 720914, 131072, 6, 655378, 131072, 2, 589842, 196608, 3, 524306, 196608, 2, 458770, 131072, 3, 393234, 196608, 3, 327698, 196608, 3, 262162, 131072, 3, 196626, 131072, 3, 131090, 131072, 3, 65554, 131072, 2, 18, 196608, 2, -65518, 131072, 3, -131054, 196608, 2, -196590, 131072, 2, -262126, 196608, 3, -327662, 131072, 2, -393198, 196608, 3, -458734, 131072, 3, -524270, 196608, 2, -589806, 131072, 3, -655342, 131072, 2, -720878, 131072, 3, 720913, 131072, 6, 655377, 131072, 2, 589841, 196608, 3, 524305, 196608, 2, 458769, 196608, 3, 393233, 131072, 2, 327697, 131072, 2, 262161, 131072, 3, 196625, 196608, 3, 131089, 131072, 3, 65553, 196608, 2, 17, 131072, 2, -65519, 196608, 2, -131055, 131072, 3, -196591, 131072, 2, -262127, 131072, 3, -327663, 196608, 3, -393199, 196608, 2, -458735, 131072, 3, -524271, 196608, 2, -589807, 131072, 2, -655343, 196608, 2, -720879, 131072, 2, 720912, 196608, 4, 655376, 131072, 2, 589840, 131072, 3, 524304, 196608, 3, 458768, 131072, 3, 393232, 196608, 2, 327696, 131072, 2, 262160, 196608, 2, 196624, 131072, 2, 131088, 196608, 3, 65552, 131072, 3, 16, 131072, 3, -65520, 196608, 2, -131056, 196608, 3, -196592, 131072, 2, -262128, 131072, 2, -327664, 131072, 2, -393200, 131072, 2, -458736, 196608, 2, -524272, 131072, 2, -589808, 196608, 2, -655344, 131072, 3, -720880, 131072, 3, 720911, 131072, 6, 655375, 196608, 2, 589839, 131072, 3, 524303, 196608, 3, 458767, 196608, 3, 393231, 131072, 3, 327695, 196608, 2, 262159, 196608, 3, 196623, 131072, 2, 131087, 131072, 3, 65551, 196608, 2, 15, 196608, 3, -65521, 131072, 3, -131057, 131072, 2, -196593, 131072, 2, -262129, 131072, 3, -327665, 196608, 3, -393201, 196608, 2, -458737, 196608, 2, -524273, 196608, 3, -589809, 196608, 3, -655345, 196608, 2, -720881, 196608, 3, 720910, 131072, 6, 655374, 131072, 2, 589838, 131072, 3, 524302, 196608, 3, 458766, 131072, 3, 393230, 196608, 2, 327694, 196608, 2, 262158, 131072, 2, 196622, 196608, 2, 131086, 196608, 3, 65550, 131072, 2, 14, 131072, 3, -65522, 196608, 3, -131058, 196608, 3, -196594, 131072, 3, -262130, 196608, 3, -327666, 131072, 3, -393202, 196608, 3, -458738, 131072, 3, -524274, 196608, 3, -589810, 196608, 2, -655346, 196608, 2, -720882, 131072, 2, 720909, 262144, 6, 655373, 131072, 2, 589837, 196608, 3, 524301, 196608, 3, 458765, 196608, 3, 393229, 131072, 2, 327693, 196608, 2, 262157, 131072, 2, 196621, 196608, 3, 131085, 131072, 2, 65549, 131072, 3, 13, 196608, 3, -65523, 131072, 2, -131059, 196608, 2, -196595, 131072, 2, -262131, 196608, 3, -327667, 196608, 3, -393203, 131072, 3, -458739, 196608, 2, -524275, 131072, 2, -589811, 196608, 3, -655347, 131072, 3, -720883, 196608, 2, 720908, 196608, 6, 655372, 196608, 3, 589836, 196608, 2, 524300, 131072, 2, 458764, 196608, 2, 393228, 131072, 2, 327692, 131072, 3, 262156, 131072, 3, 196620, 131072, 3, 131084, 131072, 2, 65548, 196608, 2, 12, 196608, 3, -65524, 131072, 2, -131060, 196608, 2, -196596, 196608, 2, -262132, 131072, 3, -327668, 196608, 2, -393204, 131072, 3, -458740, 196608, 2, -524276, 131072, 2, -589812, 196608, 2, -655348, 131072, 3, -720884, 131072, 2, 720907, 131072, 4, 655371, 196608, 3, 589835, 131072, 3, 524299, 131072, 3, 458763, 196608, 2, 393227, 131072, 2, 327691, 131072, 2, 262155, 196608, 3, 196619, 131072, 2, 131083, 131072, 3, 65547, 131072, 3, 11, 196608, 2, -65525, 131072, 3, -131061, 131072, 3, -196597, 131072, 3, -262133, 196608, 3, -327669, 131072, 2, -393205, 196608, 2, -458741, 196608, 3, -524277, 131072, 3, -589813, 131072, 3, -655349, 131072, 2, -720885, 196608, 2, 720906, 262144, 6, 655370, 196608, 3, 589834, 131072, 3, 524298, 131072, 3, 458762, 131072, 2, 393226, 196608, 2, 327690, 196608, 2, 262154, 196608, 2, 196618, 131072, 3, 131082, 196608, 2, 65546, 196608, 2, 10, 131072, 2, -65526, 131072, 3, -131062, 196608, 3, -196598, 196608, 2, -262134, 131072, 2, -327670, 196608, 3, -393206, 196608, 2, -458742, 131072, 3, -524278, 131072, 3, -589814, 196608, 2, -655350, 131072, 2, -720886, 196608, 2, 720905, 65536, 6, 655369, 196608, 3, 589833, 196608, 3, 524297, 196608, 3, 458761, 196608, 3, 393225, 196608, 3, 327689, 196608, 3, 262153, 131072, 3, 196617, 131072, 3, 131081, 196608, 2, 65545, 131072, 3, 9, 131072, 3, -65527, 131072, 2, -131063, 131072, 2, -196599, 196608, 2, -262135, 131072, 2, -327671, 196608, 2, -393207, 131072, 3, -458743, 131072, 2, -524279, 131072, 2, -589815, 131072, 3, -655351, 196608, 2, -720887, 196608, 2, 720904, 196608, 4, 655368, 196608, 2, 589832, 131072, 3, 524296, 131072, 3, 458760, 196608, 2, 393224, 196608, 3, 327688, 131072, 2, 262152, 131072, 3, 196616, 196608, 3, 131080, 196608, 3, 65544, 196608, 2, 8, 196608, 2, -65528, 131072, 2, -131064, 131072, 3, -196600, 196608, 3, -262136, 196608, 2, -327672, 196608, 2, -393208, 196608, 2, -458744, 196608, 2, -524280, 131072, 3, -589816, 196608, 2, -655352, 196608, 3, -720888, 196608, 2, 720903, 131072, 4, 655367, 196608, 3, 589831, 196608, 2, 524295, 196608, 3, 458759, 196608, 3, 393223, 196608, 3, 327687, 196608, 3, 262151, 196608, 3, 196615, 196608, 3, 131079, 131072, 2, 65543, 131072, 2, 7, 196608, 3, -65529, 196608, 3, -131065, 131072, 3, -196601, 196608, 3, -262137, 196608, 3, -327673, 131072, 2, -393209, 196608, 3, -458745, 196608, 2, -524281, 131072, 3, -589817, 131072, 3, -655353, 131072, 3, -720889, 196608, 2, 720902, 262144, 6, 655366, 131072, 3, 589830, 131072, 3, 524294, 196608, 2, 458758, 131072, 3, 393222, 131072, 3, 327686, 196608, 3, 262150, 196608, 3, 196614, 196608, 2, 131078, 196608, 3, 65542, 131072, 2, 6, 131072, 3, -65530, 131072, 2, -131066, 131072, 3, -196602, 196608, 2, -262138, 131072, 3, -327674, 196608, 3, -393210, 131072, 3, -458746, 131072, 2, -524282, 196608, 3, -589818, 131072, 2, -655354, 131072, 2, -720890, 131072, 3, 720901, 131072, 6, 655365, 131072, 2, 589829, 131072, 2, 524293, 131072, 3, 458757, 131072, 2, 393221, 131072, 2, 327685, 131072, 3, 262149, 131072, 3, 196613, 196608, 2, 131077, 131072, 3, 65541, 196608, 2, 5, 131072, 3, -65531, 131072, 2, -131067, 196608, 3, -196603, 131072, 3, -262139, 196608, 2, -327675, 196608, 2, -393211, 131072, 3, -458747, 131072, 3, -524283, 131072, 2, -589819, 131072, 2, -655355, 131072, 2, -720891, 131072, 2, 720900, 131072, 6, 655364, 196608, 2, 589828, 131072, 3, 524292, 131072, 3, 458756, 196608, 2, 393220, 131072, 2, 327684, 131072, 2, 262148, 196608, 2, 196612, 131072, 3, 131076, 131072, 3, 65540, 196608, 2, 4, 196608, 3, -65532, 131072, 3, -131068, 131072, 2, -196604, 196608, 3, -262140, 131072, 2, -327676, 196608, 2, -393212, 131072, 3, -458748, 196608, 2, -524284, 131072, 2, -589820, 196608, 3, -655356, 196608, 2, -720892, 196608, 2, 720899, 131072, 6, 655363, 196608, 2, 589827, 196608, 2, 524291, 131072, 2, 458755, 131072, 2, 393219, 131072, 3, 327683, 196608, 3, 262147, 196608, 3, 196611, 196608, 2, 131075, 131072, 3, 65539, 196608, 3, 3, 196608, 3, -65533, 131072, 2, -131069, 196608, 2, -196605, 196608, 3, -262141, 131072, 2, -327677, 196608, 3, -393213, 131072, 2, -458749, 196608, 3, -524285, 196608, 2, -589821, 131072, 3, -655357, 131072, 3, -720893, 196608, 2, 720898, 196608, 4, 655362, 196608, 2, 589826, 196608, 3, 524290, 196608, 3, 458754, 196608, 2, 393218, 131072, 3, 327682, 131072, 3, 262146, 196608, 3, 196610, 131072, 2, 131074, 131072, 3, 65538, 131072, 2, 2, 131072, 2, -65534, 196608, 2, -131070, 196608, 2, -196606, 131072, 3, -262142, 131072, 2, -327678, 131072, 3, -393214, 196608, 3, -458750, 196608, 3, -524286, 131072, 3, -589822, 196608, 2, -655358, 131072, 3, -720894, 196608, 2, 720897, 196608, 4, 655361, 131072, 3, 589825, 131072, 2, 524289, 131072, 3, 458753, 196608, 2, 393217, 131072, 3, 327681, 196608, 2, 262145, 131072, 3, 196609, 196608, 2, 131073, 196608, 3, 65537, 196608, 3, 1, 196608, 2, -65535, 131072, 2, -131071, 196608, 3, -196607, 131072, 2, -262143, 131072, 3, -327679, 196608, 2, -393215, 131072, 2, -458751, 196608, 2, -524287, 131072, 2, -589823, 196608, 3, -655359, 131072, 2, -720895, 131072, 2, 720896, 131072, 4, 655360, 131072, 2, 589824, 196608, 3, 524288, 196608, 2, 458752, 131072, 2, 393216, 196608, 3, 327680, 196608, 3, 262144, 131072, 2, 196608, 131072, 2, 131072, 131072, 2, 65536, 196608, 2, 0, 196608, 3, -65536, 196608, 3, -131072, 131072, 2, -196608, 131072, 3, -262144, 196608, 3, -327680, 196608, 2, -393216, 196608, 2, -458752, 131072, 3, -524288, 131072, 2, -589824, 131072, 2, -655360, 131072, 3, -720896, 131072, 2, 786431, 196608, 4, 720895, 196608, 2, 655359, 131072, 2, 589823, 131072, 2, 524287, 131072, 3, 458751, 196608, 3, 393215, 196608, 2, 327679, 196608, 2, 262143, 131072, 2, 196607, 196608, 2, 131071, 196608, 2, 65535, 196608, 2, -1, 131072, 3, -65537, 196608, 2, -131073, 196608, 3, -196609, 196608, 2, -262145, 196608, 3, -327681, 196608, 2, -393217, 196608, 2, -458753, 131072, 2, -524289, 196608, 3, -589825, 196608, 2, -655361, 131072, 3, 786430, 131072, 6, 720894, 196608, 3, 655358, 196608, 2, 589822, 131072, 2, 524286, 196608, 3, 458750, 196608, 3, 393214, 131072, 2, 327678, 131072, 3, 262142, 131072, 2, 196606, 131072, 2, 131070, 131072, 2, 65534, 131072, 3, -2, 196608, 3, -65538, 131072, 3, -131074, 131072, 3, -196610, 131072, 3, -262146, 196608, 3, -327682, 131072, 2, -393218, 196608, 2, -458754, 131072, 2, -524290, 131072, 2, -589826, 131072, 2, -655362, 131072, 2, 786429, 131072, 4, 720893, 131072, 3, 655357, 131072, 2, 589821, 131072, 3, 524285, 196608, 3, 458749, 131072, 3, 393213, 131072, 2, 327677, 196608, 3, 262141, 196608, 2, 196605, 196608, 2, 131069, 196608, 3, 65533, 131072, 2, -3, 131072, 2, -65539, 131072, 2, -131075, 131072, 2, -196611, 196608, 2, -262147, 131072, 3, -327683, 131072, 3, -393219, 131072, 3, -458755, 196608, 3, -524291, 196608, 3, -589827, 196608, 2, -655363, 196608, 2, 786428, 65536, 6, 720892, 131072, 2, 655356, 196608, 2, 589820, 131072, 2, 524284, 131072, 3, 458748, 196608, 2, 393212, 196608, 2, 327676, 131072, 2, 262140, 196608, 3, 196604, 196608, 2, 131068, 196608, 2, 65532, 131072, 3, -4, 196608, 2, -65540, 196608, 3, -131076, 196608, 2, -196612, 196608, 2, -262148, 131072, 2, -327684, 131072, 3, -393220, 131072, 3, -458756, 131072, 2, -524292, 196608, 3, -589828, 196608, 2, -655364, 131072, 2, 786427, 131072, 6, 720891, 196608, 3, 655355, 196608, 3, 589819, 196608, 3, 524283, 131072, 3, 458747, 196608, 2, 393211, 196608, 2, 327675, 196608, 2, 262139, 131072, 3, 196603, 131072, 2, 131067, 196608, 3, 65531, 131072, 3, -5, 196608, 3, -65541, 196608, 3, -131077, 196608, 3, -196613, 131072, 2, -262149, 196608, 3, -327685, 196608, 2, -393221, 131072, 2, -458757, 131072, 2, -524293, 131072, 3, -589829, 196608, 3, -655365, 196608, 2, 786426, 262144, 6, 720890, 131072, 3, 655354, 131072, 3, 589818, 196608, 2, 524282, 196608, 3, 458746, 196608, 2, 393210, 196608, 3, 327674, 131072, 2, 262138, 196608, 2, 196602, 131072, 2, 131066, 131072, 3, 65530, 196608, 3, -6, 131072, 3, -65542, 196608, 3, -131078, 196608, 2, -196614, 196608, 2, -262150, 196608, 3, -327686, 131072, 3, -393222, 131072, 3, -458758, 196608, 3, -524294, 196608, 3, -589830, 196608, 2, -655366, 196608, 2, 786425, 131072, 6, 720889, 196608, 2, 655353, 131072, 2, 589817, 196608, 2, 524281, 196608, 2, 458745, 196608, 2, 393209, 131072, 2, 327673, 131072, 3, 262137, 131072, 3, 196601, 131072, 2, 131065, 196608, 2, 65529, 131072, 2, -7, 196608, 2, -65543, 131072, 3, -131079, 131072, 2, -196615, 196608, 3, -262151, 196608, 3, -327687, 131072, 3, -393223, 131072, 2, -458759, 131072, 2, -524295, 131072, 2, -589831, 131072, 3, -655367, 131072, 3, 786424, 262144, 6, 720888, 131072, 3, 655352, 131072, 3, 589816, 196608, 3, 524280, 196608, 2, 458744, 196608, 3, 393208, 196608, 2, 327672, 196608, 3, 262136, 196608, 3, 196600, 196608, 2, 131064, 196608, 3, 65528, 131072, 3, -8, 131072, 2, -65544, 196608, 2, -131080, 196608, 2, -196616, 196608, 2, -262152, 196608, 2, -327688, 196608, 2, -393224, 196608, 2, -458760, 196608, 2, -524296, 196608, 3, -589832, 131072, 2, -655368, 131072, 3, 786423, 262144, 6, 720887, 196608, 2, 655351, 196608, 3, 589815, 131072, 2, 524279, 131072, 3, 458743, 131072, 3, 393207, 131072, 2, 327671, 196608, 3, 262135, 131072, 2, 196599, 196608, 2, 131063, 131072, 3, 65527, 131072, 2, -9, 131072, 3, -65545, 196608, 2, -131081, 131072, 3, -196617, 131072, 2, -262153, 131072, 3, -327689, 131072, 3, -393225, 131072, 3, -458761, 196608, 2, -524297, 131072, 2, -589833, 196608, 3, -655369, 196608, 3, 786422, 131072, 6, 720886, 131072, 2, 655350, 131072, 2, 589814, 131072, 3, 524278, 327680, 11, 458742, 65536, 3, 393206, 327680, 10, 327670, 327680, 10, 262134, 327680, 10, 196598, 327680, 6, 131062, 131072, 2, 65526, 131072, 3, -10, 196608, 3, -65546, 196608, 2, -131082, 131072, 2, -196618, 131072, 2, -262154, 131072, 3, -327690, 131072, 3, -393226, 131072, 2, -458762, 131072, 2, -524298, 196608, 2, -589834, 196608, 3, -655370, 131072, 3, 786421, 262144, 6, 720885, 131072, 2, 655349, 196608, 3, 589813, 196608, 3, 524277, 196608, 11, 458741, 65536, 8, 393205, 196608, 8, 327669, 65536, 0, 262133, 65536, 7, 196597, 131072, 4, 131061, 196608, 3, 65525, 131072, 3, -11, 196608, 2, -65547, 131072, 3, -131083, 196608, 2, -196619, 196608, 2, -262155, 196608, 2, -327691, 131072, 3, -393227, 131072, 2, -458763, 131072, 2, -524299, 131072, 3, -589835, 196608, 3, -655371, 196608, 3, 786420, 262144, 6, 720884, 131072, 3, 655348, 131072, 3, 589812, 196608, 2, 524276, 196608, 1, 458740, 327680, 4, 393204, 131072, 0, 327668, 262144, 9, 262132, 131072, 10, 196596, 196608, 4, 131060, 131072, 2, 65524, 131072, 2, -12, 131072, 2, -65548, 131072, 3, -131084, 131072, 3, -196620, 131072, 2, -262156, 131072, 2, -327692, 131072, 3, -393228, 196608, 3, -458764, 131072, 3, -524300, 131072, 3, -589836, 131072, 2, -655372, 196608, 3, 786419, 196608, 6, 720883, 196608, 2, 655347, 131072, 3, 589811, 131072, 3, 524275, 196608, 11, 458739, 262144, 8, 393203, 65536, 5, 327667, 131072, 7, 262131, 0, 0, 196595, 131072, 4, 131059, 131072, 3, 65523, 131072, 3, -13, 131072, 2, -65549, 196608, 2, -131085, 131072, 2, -196621, 131072, 3, -262157, 131072, 3, -327693, 196608, 3, -393229, 131072, 2, -458765, 131072, 2, -524301, 196608, 2, -589837, 196608, 2, -655373, 196608, 2, 786418, 131072, 6, 720882, 196608, 2, 655346, 196608, 3, 589810, 196608, 3, 524274, 262144, 11, 458738, 0, 1, 393202, 327680, 4, 327666, 196608, 5, 262130, 65536, 7, 196594, 262144, 6, 131058, 196608, 3, 65522, 196608, 2, -14, 196608, 3, -65550, 131072, 2, -131086, 196608, 2, -196622, 131072, 2, -262158, 131072, 2, -327694, 196608, 3, -393230, 131072, 2, -458766, 196608, 3, -524302, 196608, 3, -589838, 196608, 3, -655374, 196608, 3, 786417, 65536, 6, 720881, 196608, 2, 655345, 131072, 3, 589809, 131072, 3, 524273, 0, 11, 458737, 0, 8, 393201, 0, 9, 327665, 0, 9, 262129, 262144, 2, 196593, 0, 6, 131057, 131072, 3, 65521, 196608, 2, -15, 131072, 2, -65551, 131072, 2, -131087, 131072, 3, -196623, 196608, 2, -262159, 196608, 2, -327695, 196608, 3, -393231, 196608, 3, -458767, 196608, 2, -524303, 131072, 3, -589839, 196608, 3, -655375, 131072, 2, 786416, 131072, 4, 720880, 131072, 2, 655344, 196608, 2, 589808, 196608, 2, 524272, 196608, 2, 458736, 196608, 3, 393200, 196608, 2, 327664, 131072, 3, 262128, 196608, 3, 196592, 196608, 2, 131056, 131072, 2, 65520, 131072, 3, -16, 131072, 3, -65552, 196608, 3, -131088, 196608, 3, -196624, 196608, 3, -262160, 196608, 3, -327696, 196608, 3, -393232, 131072, 2, -458768, 196608, 3, -524304, 196608, 3, -589840, 131072, 3, -655376, 131072, 3, 786415, 196608, 4, 720879, 196608, 2, 655343, 131072, 3, 589807, 196608, 2, 524271, 196608, 3, 458735, 196608, 2, 393199, 131072, 3, 327663, 131072, 3, 262127, 196608, 2, 196591, 131072, 2, 131055, 196608, 3, 65519, 196608, 2, -17, 196608, 3, -65553, 196608, 3, -131089, 196608, 2, -196625, 131072, 2, -262161, 196608, 3, -327697, 131072, 2, -393233, 196608, 3, -458769, 131072, 2, -524305, 196608, 3, -589841, 131072, 3, -655377, 131072, 2, 786414, 131072, 4, 720878, 196608, 2, 655342, 196608, 2, 589806, 131072, 2, 524270, 131072, 2, 458734, 196608, 2, 393198, 196608, 2, 327662, 131072, 2, 262126, 196608, 2, 196590, 196608, 2, 131054, 131072, 3, 65518, 196608, 3, -18, 196608, 2, -65554, 196608, 3, -131090, 131072, 2, -196626, 196608, 3, -262162, 131072, 3, -327698, 131072, 3, -393234, 131072, 3, -458770, 196608, 3, -524306, 196608, 2, -589842, 196608, 3, -655378, 196608, 2, 786413, 196608, 4, 720877, 196608, 2, 655341, 196608, 3, 589805, 131072, 3, 524269, 131072, 2, 458733, 196608, 2, 393197, 131072, 2, 327661, 131072, 2, 262125, 131072, 2, 196589, 131072, 3, 131053, 131072, 2, 65517, 196608, 2, -19, 196608, 2, -65555, 196608, 3, -131091, 131072, 3, -196627, 131072, 2, -262163, 196608, 3, -327699, 131072, 3, -393235, 196608, 3, -458771, 196608, 2, -524307, 196608, 3, -589843, 131072, 2, -655379, 196608, 3, 786412, 65536, 4, 720876, 327680, 7, 655340, 65536, 2, 589804, 327680, 10, 524268, 65536, 3, 458732, 327680, 10, 393196, 327680, 7, 327660, 327680, 8, 262124, 65536, 2, 196588, 65536, 3, 131052, 327680, 8, 65516, 327680, 8, -20, 65536, 2, -65556, 327680, 10, -131092, 327680, 8, -196628, 327680, 7, -262164, 65536, 2, -327700, 65536, 2, -393236, 327680, 10, -458772, 65536, 2, -524308, 65536, 3, -589844, 65536, 2, -655380, 327680, 7, -786413, 262144, 1, -786414, 262144, 11, -786415, 65536, 11, -786416, 65536, 11, -786417, 131072, 11, -786418, 196608, 11, -786419, 131072, 11, -786420, 131072, 1, -786421, 65536, 11, -786422, 196608, 11, -786423, 131072, 1, -786424, 65536, 11, -786425, 131072, 11, -786426, 131072, 1, -786427, 262144, 11, -786428, 262144, 11, -786429, 65536, 11, -786430, 262144, 11, -786431, 131072, 11, -786432, 262144, 11, -720897, 131072, 1, -720898, 196608, 1, -720899, 262144, 11, -720900, 131072, 1, -720901, 196608, 1, -720902, 262144, 11, -720903, 196608, 11, -720904, 262144, 11, -720905, 196608, 1, -720906, 196608, 1, -720907, 131072, 11, -720908, 196608, 1, -720909, 262144, 11, -720910, 131072, 11, -720911, 196608, 1, -720912, 131072, 1, -720913, 131072, 1, -720914, 131072, 11, -720915, 196608, 11, -720916, 65536, 1) [node name="GameCamera" parent="." instance=ExtResource("2_db5xs")] From 522f0beed8a8afb97822fbf74d167f53c968d057 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 21 Apr 2024 23:13:02 +0200 Subject: [PATCH 71/83] Turn `Collectable` into `Collectible`, a marker class --- behaviours/collectable.gd | 18 ------------------ behaviours/collectable.tscn | 9 --------- behaviours/collectible.gd | 13 +++++++++++++ .../{collectable.svg => collectible.svg} | 8 ++++---- ...table.svg.import => collectible.svg.import} | 6 +++--- behaviours/collectible.tscn | 6 ++++++ 6 files changed, 26 insertions(+), 34 deletions(-) delete mode 100644 behaviours/collectable.gd delete mode 100644 behaviours/collectable.tscn create mode 100644 behaviours/collectible.gd rename behaviours/{collectable.svg => collectible.svg} (92%) rename behaviours/{collectable.svg.import => collectible.svg.import} (74%) create mode 100644 behaviours/collectible.tscn diff --git a/behaviours/collectable.gd b/behaviours/collectable.gd deleted file mode 100644 index 42cd58b..0000000 --- a/behaviours/collectable.gd +++ /dev/null @@ -1,18 +0,0 @@ -@icon("res://behaviours/collectable.svg") -extends Area2D -class_name Collectable - -## Emits [signal collected] when the mouse enters the given [CollisionShape2D]. - - -signal collected - -@export var qty: int = 1 -@export var tag: StringName = &"" - - -func _on_mouse_entered() -> void: - collected.emit(tag) - -func _on_collected() -> void: - Log.p(self, "Collected: %sx %s" % [qty, tag]) diff --git a/behaviours/collectable.tscn b/behaviours/collectable.tscn deleted file mode 100644 index 775501a..0000000 --- a/behaviours/collectable.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dj72yshd25ucx"] - -[ext_resource type="Script" path="res://behaviours/collectable.gd" id="1_p0pc3"] - -[node name="Collectable" type="Area2D"] -script = ExtResource("1_p0pc3") - -[connection signal="collected" from="." to="." method="_on_collected"] -[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] diff --git a/behaviours/collectible.gd b/behaviours/collectible.gd new file mode 100644 index 0000000..2ed6967 --- /dev/null +++ b/behaviours/collectible.gd @@ -0,0 +1,13 @@ +@icon("res://behaviours/collectible.svg") +extends Node +class_name Collectible + + +## Marker class that stores the value of a collectible item. + + +## How many of that item this [Collectible] represents. +@export var quantity: int = 1 + +## What kind of item this [Collectible] represents. +@export var kind: StringName = &"" \ No newline at end of file diff --git a/behaviours/collectable.svg b/behaviours/collectible.svg similarity index 92% rename from behaviours/collectable.svg rename to behaviours/collectible.svg index 1625126..699f33f 100644 --- a/behaviours/collectable.svg +++ b/behaviours/collectible.svg @@ -3,7 +3,7 @@ viewBox="0 0 512 512" version="1.1" id="svg1" - sodipodi:docname="hand.svg" + sodipodi:docname="collectable.svg" width="16" height="16" inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" @@ -23,8 +23,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="1.1642403" - inkscape:cx="350.01366" - inkscape:cy="213.44391" + inkscape:cx="350.01365" + inkscape:cy="-130.12778" inkscape:window-width="1920" inkscape:window-height="1020" inkscape:window-x="1280" @@ -35,5 +35,5 @@ + style="fill:#e0e0e0;fill-opacity:1" /> diff --git a/behaviours/collectable.svg.import b/behaviours/collectible.svg.import similarity index 74% rename from behaviours/collectable.svg.import rename to behaviours/collectible.svg.import index 70b9a6e..f6b10da 100644 --- a/behaviours/collectable.svg.import +++ b/behaviours/collectible.svg.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://ds6w6y6v8ywg2" -path="res://.godot/imported/collectable.svg-5b05e2ea83b32a2349a97b4d9981d066.ctex" +path="res://.godot/imported/collectible.svg-c540ac452c425e9fd16afd6982ebfbf2.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://behaviours/collectable.svg" -dest_files=["res://.godot/imported/collectable.svg-5b05e2ea83b32a2349a97b4d9981d066.ctex"] +source_file="res://behaviours/collectible.svg" +dest_files=["res://.godot/imported/collectible.svg-c540ac452c425e9fd16afd6982ebfbf2.ctex"] [params] diff --git a/behaviours/collectible.tscn b/behaviours/collectible.tscn new file mode 100644 index 0000000..906e7e5 --- /dev/null +++ b/behaviours/collectible.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dj72yshd25ucx"] + +[ext_resource type="Script" path="res://behaviours/collectible.gd" id="1_5ipmg"] + +[node name="Collectible" type="Node"] +script = ExtResource("1_5ipmg") From 3e0b6fbc003fb35f3fbd5db78e4bb0427c67dae0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 21 Apr 2024 23:20:02 +0200 Subject: [PATCH 72/83] Fix gold collection --- entities/gold.gd | 24 +++++++++++++----------- entities/gold.tscn | 40 +++++++++++++++++++++++++++++++++------- entities/imp.tscn | 7 ++++--- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/entities/gold.gd b/entities/gold.gd index cd5d640..97e8bcb 100644 --- a/entities/gold.gd +++ b/entities/gold.gd @@ -2,18 +2,20 @@ extends Node2D class_name Gold -@export var value: int = 1 +@onready var move_towards: MoveTowards = $"%MoveTowards" +@onready var collect_sound_spawner: Spawner = $"%CollectSoundSpawner" + + +func magnetize(cursor: Cursor) -> void: + move_towards.target = cursor + +func demagnetize() -> void: + move_towards.target = null + +func collect() -> void: + collect_sound_spawner.spawn() + queue_free() func _on_move(movement: Vector2) -> void: position += movement - -func _on_collected(tag: StringName) -> void: - var game = MainGame.get_via_group(self) - - # TODO: Perhaps use a dictionary in game to store multiple currencies? - match tag: - &"Gold": - game.gold_counter.increase(value) - - queue_free() diff --git a/entities/gold.tscn b/entities/gold.tscn index da6ed04..e0617b8 100644 --- a/entities/gold.tscn +++ b/entities/gold.tscn @@ -1,23 +1,49 @@ -[gd_scene load_steps=6 format=3 uid="uid://uoxwjpmgg27a"] +[gd_scene load_steps=10 format=3 uid="uid://uoxwjpmgg27a"] [ext_resource type="Script" path="res://entities/gold.gd" id="1_lbls1"] +[ext_resource type="PackedScene" uid="uid://dj72yshd25ucx" path="res://behaviours/collectible.tscn" id="2_j75yq"] [ext_resource type="Texture2D" uid="uid://bfl0tkg85cvb8" path="res://entities/gold.png" id="2_tt3v6"] -[ext_resource type="PackedScene" uid="uid://dj72yshd25ucx" path="res://behaviours/collectable.tscn" id="3_q0bno"] +[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="3_ne3sj"] +[ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="5_bcbgf"] [ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="5_t7ey8"] [ext_resource type="PackedScene" uid="uid://eqg6snsgn1kh" path="res://players/gold_pickup_player.tscn" id="6_eoeje"] +[sub_resource type="CircleShape2D" id="CircleShape2D_w1h35"] +radius = 64.0 + +[sub_resource type="CircleShape2D" id="CircleShape2D_jm7yp"] + [node name="Gold" type="Node2D"] script = ExtResource("1_lbls1") +[node name="Collectable" parent="." instance=ExtResource("2_j75yq")] +kind = &"Gold" + [node name="Sprite" type="Sprite2D" parent="."] scale = Vector2(2, 2) texture = ExtResource("2_tt3v6") -[node name="Collectable" parent="." instance=ExtResource("3_q0bno")] -scale = Vector2(0.6, 0.6) -tag = &"Gold" +[node name="MagnetizeArea" parent="." instance=ExtResource("3_ne3sj")] -[node name="Spawner" parent="." instance=ExtResource("5_t7ey8")] +[node name="Shape" type="CollisionShape2D" parent="MagnetizeArea"] +shape = SubResource("CircleShape2D_w1h35") +debug_color = Color(0.337255, 0.611765, 1, 0) + +[node name="CollectArea" parent="." instance=ExtResource("3_ne3sj")] + +[node name="Shape" type="CollisionShape2D" parent="CollectArea"] +shape = SubResource("CircleShape2D_jm7yp") +debug_color = Color(0, 0.388235, 0.815686, 0.219608) + +[node name="MoveTowards" parent="." instance=ExtResource("5_bcbgf")] +unique_name_in_owner = true +speed = 184.0 + +[node name="CollectSoundSpawner" parent="." instance=ExtResource("5_t7ey8")] +unique_name_in_owner = true +scale = Vector2(1.66667, 1.66667) scene = ExtResource("6_eoeje") -[connection signal="collected" from="Collectable" to="." method="_on_collected"] +[connection signal="cursor_entered" from="MagnetizeArea" to="." method="magnetize"] +[connection signal="cursor_entered" from="CollectArea" to="." method="collect" unbinds=1] +[connection signal="move" from="MoveTowards" to="." method="_on_move"] diff --git a/entities/imp.tscn b/entities/imp.tscn index 72075b5..d097666 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -44,10 +44,11 @@ right_texture = ExtResource("4_0sckn") [node name="Shape" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_ide4n") -[node name="CoinSpawner" parent="." instance=ExtResource("4_d8lgm")] +[node name="GoldSpawner" parent="." instance=ExtResource("4_d8lgm")] scene = ExtResource("5_yrfoq") -[node name="TimerStddev" parent="CoinSpawner" instance=ExtResource("10_phvea")] +[node name="TimerStddev" parent="GoldSpawner" instance=ExtResource("10_phvea")] +autostart = true mean_secs = 5.0 deviation = 4.0 min_secs = 1.0 @@ -113,7 +114,7 @@ acceptable_diets = Array[StringName]([&"Meat"]) shape = SubResource("CircleShape2D_qhk1q") debug_color = Color(1, 0, 0, 0) -[connection signal="timeout" from="CoinSpawner/TimerStddev" to="CoinSpawner" method="spawn"] +[connection signal="timeout" from="GoldSpawner/TimerStddev" to="GoldSpawner" 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"] From 92550ba86559e9862fc3f76b0cc4abe1f80d3841 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 21 Apr 2024 23:26:51 +0200 Subject: [PATCH 73/83] Delete `sheep_snowy.gd` --- entities/sheep_snowy.gd | 119 ---------------------------------------- 1 file changed, 119 deletions(-) delete mode 100644 entities/sheep_snowy.gd diff --git a/entities/sheep_snowy.gd b/entities/sheep_snowy.gd deleted file mode 100644 index cd0a871..0000000 --- a/entities/sheep_snowy.gd +++ /dev/null @@ -1,119 +0,0 @@ -extends RigidBody2D - -var initial_self_position: Vector2 = Vector2.ZERO -var initial_mouse_position: Vector2 = Vector2.ZERO - -@onready var rand_walk_timer: Timer = Timer.new() -var rng = RandomNumberGenerator.new() -enum State {STATE_IDLE, STATE_WALK, STATE_PICKED, STATE_RUN, STATE_THROWN} -var state: State = State.STATE_IDLE -var walk_dir: Vector2 = Vector2.ZERO -var last_dir: int = 1 -var last_mouse_pos: Vector2 = Vector2.ZERO - - -@export var min_run_dist = 200 -@export var max_run_dist = 250 - -@export var walk_speed = 150 -@export var run_speed = 500 - -@export var drag_damp = 40 -@export var normal_damp = 4 -@export var thrown_damp = 2 - - -# Called when the node enters the scene tree for the first time. -func _ready(): - add_child(rand_walk_timer) - rand_walk_timer.one_shot = true; - rand_walk_timer.connect("timeout", _on_timer_timeout) - init_timer() - -func init_timer(): - if state == State.STATE_IDLE: - var rand_time = max(0, rng.randfn(4, 1.5)) - rand_walk_timer.start(rand_time) - elif state == State.STATE_WALK: - rand_walk_timer.start(5) - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - # Update state - var curr_mpos = get_viewport().get_mouse_position() - last_mouse_pos = curr_mpos - - if state == State.STATE_PICKED and not Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): - pick_down() - - var mouse_dis = position.distance_to(curr_mpos) - if (state == State.STATE_IDLE or state == State.STATE_WALK) and mouse_dis < min_run_dist: - # Run away from mouse - state = State.STATE_RUN - rand_walk_timer.stop() - elif state == State.STATE_RUN and mouse_dis > max_run_dist: - state = State.STATE_IDLE - init_timer() - -func _physics_process(delta): - gravity_scale = 0 - if state == State.STATE_THROWN and linear_velocity.length() < 300: - linear_velocity = Vector2.ZERO - state = State.STATE_WALK - init_timer() - - var force = Vector2.ZERO - - if state == State.STATE_WALK: - force = walk_speed * walk_dir - elif state == State.STATE_RUN: - var run_dir = -position.direction_to(last_mouse_pos) - force = run_speed * run_dir - elif state == State.STATE_PICKED: - var dest_position = initial_self_position + (last_mouse_pos - initial_mouse_position) - apply_central_force(50 * (dest_position - position) * dest_position.distance_to(position) * delta) - else: - pass - - if force.length_squared() > 0.001: - apply_central_force(force) - last_dir = sign(force.dot(Vector2.LEFT)) - - scale.x = last_dir - - if state == State.STATE_PICKED: - linear_damp = drag_damp - elif state == State.STATE_THROWN: - linear_damp = thrown_damp - else: - linear_damp = normal_damp - - -func _on_input_event(viewport, event, shape_idx): - if event is InputEventMouseButton: - var was_picked_up = state == State.STATE_PICKED - var is_picked_up = event.pressed - initial_mouse_position = event.position - initial_self_position = position - - if not was_picked_up and is_picked_up: - state = State.STATE_PICKED - rand_walk_timer.stop() - elif was_picked_up and not is_picked_up: - pick_down() - -func pick_down(): - state = State.STATE_THROWN - init_timer() - - -func _on_timer_timeout(): - if state == State.STATE_IDLE: - state = State.STATE_WALK - walk_dir = Vector2.from_angle(rng.randf_range(0, 2*PI)) - elif state == State.STATE_WALK: - state = State.STATE_IDLE - init_timer() - - From e9f5c982b195946a4b1329a89834d5f82159aa96 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 21 Apr 2024 23:49:34 +0200 Subject: [PATCH 74/83] Add inventory system, with only `Gold` for now --- behaviours/collectible.gd | 12 ++++++++---- entities/gold.gd | 7 +++++-- entities/gold.tscn | 3 ++- scenes/game/inventory.gd | 20 ++++++++++++++++++++ scenes/game/inventory.tscn | 9 +++++++++ scenes/game/main_game.gd | 2 +- scenes/game/main_game.tscn | 7 ++++--- 7 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 scenes/game/inventory.gd create mode 100644 scenes/game/inventory.tscn diff --git a/behaviours/collectible.gd b/behaviours/collectible.gd index 2ed6967..63d85c4 100644 --- a/behaviours/collectible.gd +++ b/behaviours/collectible.gd @@ -3,11 +3,15 @@ extends Node class_name Collectible -## Marker class that stores the value of a collectible item. - - ## How many of that item this [Collectible] represents. @export var quantity: int = 1 ## What kind of item this [Collectible] represents. -@export var kind: StringName = &"" \ No newline at end of file +@export var kind: StringName = &"" + + +@onready var game: MainGame = MainGame.get_via_group(self) + + +func apply(): + game.inventory.get_counter(kind).increase(quantity) \ No newline at end of file diff --git a/entities/gold.gd b/entities/gold.gd index 97e8bcb..9edb2dd 100644 --- a/entities/gold.gd +++ b/entities/gold.gd @@ -2,8 +2,10 @@ extends Node2D class_name Gold -@onready var move_towards: MoveTowards = $"%MoveTowards" -@onready var collect_sound_spawner: Spawner = $"%CollectSoundSpawner" +@onready var game: MainGame = MainGame.get_via_group(self) +@onready var move_towards: MoveTowards = %"MoveTowards" +@onready var collect_sound_spawner: Spawner = %"CollectSoundSpawner" +@onready var collectible: Collectible = %"Collectible" func magnetize(cursor: Cursor) -> void: @@ -13,6 +15,7 @@ func demagnetize() -> void: move_towards.target = null func collect() -> void: + collectible.apply() collect_sound_spawner.spawn() queue_free() diff --git a/entities/gold.tscn b/entities/gold.tscn index e0617b8..44584a3 100644 --- a/entities/gold.tscn +++ b/entities/gold.tscn @@ -16,7 +16,8 @@ radius = 64.0 [node name="Gold" type="Node2D"] script = ExtResource("1_lbls1") -[node name="Collectable" parent="." instance=ExtResource("2_j75yq")] +[node name="Collectible" parent="." instance=ExtResource("2_j75yq")] +unique_name_in_owner = true kind = &"Gold" [node name="Sprite" type="Sprite2D" parent="."] diff --git a/scenes/game/inventory.gd b/scenes/game/inventory.gd new file mode 100644 index 0000000..eaa56e9 --- /dev/null +++ b/scenes/game/inventory.gd @@ -0,0 +1,20 @@ +extends Node +class_name Inventory + + +signal new_counter_created(kind: StringName, counter: Counter) + + +@export var counter_scene: PackedScene + + +func get_counter(kind: StringName) -> Counter: + var path: NodePath = NodePath(kind) + var counter: Counter = get_node_or_null(path) + if counter != null: + return counter + counter = counter_scene.instantiate() + counter.name = kind + add_child(counter) + new_counter_created.emit(kind, counter) + return counter diff --git a/scenes/game/inventory.tscn b/scenes/game/inventory.tscn new file mode 100644 index 0000000..1864338 --- /dev/null +++ b/scenes/game/inventory.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=3 uid="uid://cu6mvnfa01nb6"] + +[ext_resource type="Script" path="res://scenes/game/inventory.gd" id="1_yji81"] +[ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="2_vhog3"] + +[node name="Inventory" type="Node"] +script = ExtResource("1_yji81") + +[node name="Gold" parent="." instance=ExtResource("2_vhog3")] diff --git a/scenes/game/main_game.gd b/scenes/game/main_game.gd index ef5172c..c6612e2 100644 --- a/scenes/game/main_game.gd +++ b/scenes/game/main_game.gd @@ -2,9 +2,9 @@ extends Node2D class_name MainGame -@onready var gold_counter: Counter = $"GoldCounter" @onready var camera: GameCamera = $"GameCamera" @onready var default_spawn_parent: Node2D = %"DefaultSpawnParent" +@onready var inventory: Inventory = %"Inventory" static func get_via_group(node: Node) -> MainGame: diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 87d2515..b0f24fe 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -2,8 +2,8 @@ [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://cu6mvnfa01nb6" path="res://scenes/game/inventory.tscn" id="2_jhbbf"] [ext_resource type="Texture2D" uid="uid://d13j4br4hxek6" path="res://scenes/game/tileset_grass.png" id="2_o7bg5"] -[ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="3_p6jw3"] [ext_resource type="PackedScene" uid="uid://col1q3elvkfwk" path="res://scenes/game/cursor.tscn" id="5_g504x"] [ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="6_j2kdp"] [ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="7_7od2n"] @@ -822,6 +822,9 @@ radius = 48.0 [node name="MainGame" type="Node2D" groups=["game"]] script = ExtResource("1_wiglu") +[node name="Inventory" parent="." instance=ExtResource("2_jhbbf")] +unique_name_in_owner = true + [node name="TileMap" type="TileMap" parent="."] scale = Vector2(2, 2) tile_set = SubResource("TileSet_g2dkm") @@ -830,8 +833,6 @@ layer_0/tile_data = PackedInt32Array(720915, 262144, 4, 655379, 0, 8, 589843, 26 [node name="GameCamera" parent="." instance=ExtResource("2_db5xs")] -[node name="GoldCounter" parent="." instance=ExtResource("3_p6jw3")] - [node name="DefaultSpawnParent" type="Node2D" parent="."] unique_name_in_owner = true From edc367825b8d51736fd3f6eebc19a5fb2dc57e6d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 00:09:04 +0200 Subject: [PATCH 75/83] Add non-functional `Monocle`, `Skull` and `TopHat` --- entities/monocle.gd | 6 +++ .../monocle.png | 0 .../monocle.png.import | 6 +-- entities/monocle.tscn | 43 +++++++++++++++++++ entities/skull.gd | 6 +++ temp/pickup_skull.png => entities/skull.png | 0 .../skull.png.import | 6 +-- entities/skull.tscn | 43 +++++++++++++++++++ entities/top_hat.gd | 6 +++ .../pickup_tophat.png => entities/top_hat.png | 0 .../top_hat.png.import | 6 +-- entities/top_hat.tscn | 43 +++++++++++++++++++ scenes/game/cursor.tscn | 2 +- scenes/game/main_game.tscn | 40 +++++------------ 14 files changed, 168 insertions(+), 39 deletions(-) create mode 100644 entities/monocle.gd rename temp/pickup_monocle.png => entities/monocle.png (100%) rename temp/pickup_monocle.png.import => entities/monocle.png.import (71%) create mode 100644 entities/monocle.tscn create mode 100644 entities/skull.gd rename temp/pickup_skull.png => entities/skull.png (100%) rename temp/pickup_skull.png.import => entities/skull.png.import (71%) create mode 100644 entities/skull.tscn create mode 100644 entities/top_hat.gd rename temp/pickup_tophat.png => entities/top_hat.png (100%) rename temp/pickup_tophat.png.import => entities/top_hat.png.import (71%) create mode 100644 entities/top_hat.tscn diff --git a/entities/monocle.gd b/entities/monocle.gd new file mode 100644 index 0000000..f129c22 --- /dev/null +++ b/entities/monocle.gd @@ -0,0 +1,6 @@ +extends CharacterBody2D +class_name Monocle + + +func _on_move(movement: Vector2) -> void: + move_and_collide(movement) diff --git a/temp/pickup_monocle.png b/entities/monocle.png similarity index 100% rename from temp/pickup_monocle.png rename to entities/monocle.png diff --git a/temp/pickup_monocle.png.import b/entities/monocle.png.import similarity index 71% rename from temp/pickup_monocle.png.import rename to entities/monocle.png.import index f945286..6588bf2 100644 --- a/temp/pickup_monocle.png.import +++ b/entities/monocle.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://d3tb6ypb36v8e" -path="res://.godot/imported/pickup_monocle.png-7a9e8cda4415a7ebfbddb870020ff730.ctex" +path="res://.godot/imported/monocle.png-2e39f2ebd2473082b74edcdb99c2e85d.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://temp/pickup_monocle.png" -dest_files=["res://.godot/imported/pickup_monocle.png-7a9e8cda4415a7ebfbddb870020ff730.ctex"] +source_file="res://entities/monocle.png" +dest_files=["res://.godot/imported/monocle.png-2e39f2ebd2473082b74edcdb99c2e85d.ctex"] [params] diff --git a/entities/monocle.tscn b/entities/monocle.tscn new file mode 100644 index 0000000..89c27db --- /dev/null +++ b/entities/monocle.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=7 format=3 uid="uid://b04xhv32ypi42"] + +[ext_resource type="Script" path="res://entities/monocle.gd" id="1_ehpfj"] +[ext_resource type="Texture2D" uid="uid://d3tb6ypb36v8e" path="res://entities/monocle.png" id="1_omrit"] +[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="2_jgnsw"] +[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_e0ni5"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] +radius = 12.0 + +[sub_resource type="CircleShape2D" id="CircleShape2D_juisb"] +radius = 24.0 + +[node name="Monocle" type="CharacterBody2D"] +collision_layer = 32 +collision_mask = 38 +script = ExtResource("1_ehpfj") + +[node name="Sprite" type="Sprite2D" parent="."] +scale = Vector2(2, 2) +texture = ExtResource("1_omrit") + +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_o7chm") + +[node name="MovementDrag" parent="." instance=ExtResource("2_jgnsw")] + +[node name="Draggable" parent="MovementDrag" instance=ExtResource("3_e0ni5")] +collision_layer = 32 + +[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] +shape = SubResource("CircleShape2D_juisb") +debug_color = Color(1, 1, 1, 0) + +[node name="FallTimer" type="Timer" parent="MovementDrag"] +wait_time = 0.5 +one_shot = true + +[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] +[connection signal="move" from="MovementDrag" to="." method="_on_move"] +[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] +[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] +[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] diff --git a/entities/skull.gd b/entities/skull.gd new file mode 100644 index 0000000..2f6a16a --- /dev/null +++ b/entities/skull.gd @@ -0,0 +1,6 @@ +extends CharacterBody2D +class_name Skull + + +func _on_move(movement: Vector2) -> void: + move_and_collide(movement) diff --git a/temp/pickup_skull.png b/entities/skull.png similarity index 100% rename from temp/pickup_skull.png rename to entities/skull.png diff --git a/temp/pickup_skull.png.import b/entities/skull.png.import similarity index 71% rename from temp/pickup_skull.png.import rename to entities/skull.png.import index b8c9c3f..66a5843 100644 --- a/temp/pickup_skull.png.import +++ b/entities/skull.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://dwvvwjdexdywh" -path="res://.godot/imported/pickup_skull.png-c05653658414d7be9a8a5454887e620a.ctex" +path="res://.godot/imported/skull.png-eb9ec0d464004e0ca27a71e2a33a9dd3.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://temp/pickup_skull.png" -dest_files=["res://.godot/imported/pickup_skull.png-c05653658414d7be9a8a5454887e620a.ctex"] +source_file="res://entities/skull.png" +dest_files=["res://.godot/imported/skull.png-eb9ec0d464004e0ca27a71e2a33a9dd3.ctex"] [params] diff --git a/entities/skull.tscn b/entities/skull.tscn new file mode 100644 index 0000000..318604b --- /dev/null +++ b/entities/skull.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=7 format=3 uid="uid://b3gydtrenbw3n"] + +[ext_resource type="Script" path="res://entities/skull.gd" id="1_7g8bu"] +[ext_resource type="Texture2D" uid="uid://dwvvwjdexdywh" path="res://entities/skull.png" id="1_v6qk3"] +[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="2_h0icd"] +[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_83m1a"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_ypibs"] +radius = 12.0 + +[sub_resource type="CircleShape2D" id="CircleShape2D_1c7gd"] +radius = 24.0 + +[node name="Skull" type="CharacterBody2D"] +collision_layer = 32 +collision_mask = 38 +script = ExtResource("1_7g8bu") + +[node name="Sprite" type="Sprite2D" parent="."] +scale = Vector2(2, 2) +texture = ExtResource("1_v6qk3") + +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_ypibs") + +[node name="MovementDrag" parent="." instance=ExtResource("3_83m1a")] + +[node name="Draggable" parent="MovementDrag" instance=ExtResource("2_h0icd")] +collision_layer = 32 + +[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] +shape = SubResource("CircleShape2D_1c7gd") +debug_color = Color(1, 1, 1, 0) + +[node name="FallTimer" type="Timer" parent="MovementDrag"] +wait_time = 0.5 +one_shot = true + +[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] +[connection signal="move" from="MovementDrag" to="." method="_on_move"] +[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] +[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] +[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] diff --git a/entities/top_hat.gd b/entities/top_hat.gd new file mode 100644 index 0000000..407bacc --- /dev/null +++ b/entities/top_hat.gd @@ -0,0 +1,6 @@ +extends CharacterBody2D +class_name TopHat + + +func _on_move(movement: Vector2) -> void: + move_and_collide(movement) diff --git a/temp/pickup_tophat.png b/entities/top_hat.png similarity index 100% rename from temp/pickup_tophat.png rename to entities/top_hat.png diff --git a/temp/pickup_tophat.png.import b/entities/top_hat.png.import similarity index 71% rename from temp/pickup_tophat.png.import rename to entities/top_hat.png.import index fbf98b0..c07aa55 100644 --- a/temp/pickup_tophat.png.import +++ b/entities/top_hat.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://deqvgvf66grr4" -path="res://.godot/imported/pickup_tophat.png-cd26d2618474ae83136bd7a01c578302.ctex" +path="res://.godot/imported/top_hat.png-f606d6a390df7c1cf302806971027b77.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://temp/pickup_tophat.png" -dest_files=["res://.godot/imported/pickup_tophat.png-cd26d2618474ae83136bd7a01c578302.ctex"] +source_file="res://entities/top_hat.png" +dest_files=["res://.godot/imported/top_hat.png-f606d6a390df7c1cf302806971027b77.ctex"] [params] diff --git a/entities/top_hat.tscn b/entities/top_hat.tscn new file mode 100644 index 0000000..03a626e --- /dev/null +++ b/entities/top_hat.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=7 format=3 uid="uid://8ejgwtkpaa44"] + +[ext_resource type="Script" path="res://entities/top_hat.gd" id="1_0eh11"] +[ext_resource type="Texture2D" uid="uid://deqvgvf66grr4" path="res://entities/top_hat.png" id="1_gbqic"] +[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_gy414"] +[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="4_fcvjo"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] +radius = 12.0 + +[sub_resource type="CircleShape2D" id="CircleShape2D_juisb"] +radius = 24.0 + +[node name="TopHat" type="CharacterBody2D"] +collision_layer = 32 +collision_mask = 38 +script = ExtResource("1_0eh11") + +[node name="Sprite" type="Sprite2D" parent="."] +scale = Vector2(2, 2) +texture = ExtResource("1_gbqic") + +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_o7chm") + +[node name="MovementDrag" parent="." instance=ExtResource("3_gy414")] + +[node name="Draggable" parent="MovementDrag" instance=ExtResource("4_fcvjo")] +collision_layer = 32 + +[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] +shape = SubResource("CircleShape2D_juisb") +debug_color = Color(1, 1, 1, 0) + +[node name="FallTimer" type="Timer" parent="MovementDrag"] +wait_time = 0.5 +one_shot = true + +[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] +[connection signal="move" from="MovementDrag" to="." method="_on_move"] +[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] +[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] +[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 01422ec..53c56f9 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -7,7 +7,7 @@ radius = 4.0 [node name="Cursor" type="Area2D" groups=["cursor"]] collision_layer = 64 -collision_mask = 8 +collision_mask = 40 script = ExtResource("1_1og6v") [node name="Shape" type="CollisionShape2D" parent="."] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index b0f24fe..e1c11ea 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,15 +1,13 @@ -[gd_scene load_steps=15 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=12 format=3 uid="uid://cxj5aud02f40j"] [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://cu6mvnfa01nb6" path="res://scenes/game/inventory.tscn" id="2_jhbbf"] [ext_resource type="Texture2D" uid="uid://d13j4br4hxek6" path="res://scenes/game/tileset_grass.png" id="2_o7bg5"] [ext_resource type="PackedScene" uid="uid://col1q3elvkfwk" path="res://scenes/game/cursor.tscn" id="5_g504x"] -[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="6_j2kdp"] -[ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="7_7od2n"] -[ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="7_kqc55"] -[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="9_8875b"] -[ext_resource type="PackedScene" uid="uid://8jkesanu4hrn" path="res://behaviours/tracker.tscn" id="10_bm07a"] +[ext_resource type="PackedScene" uid="uid://b3gydtrenbw3n" path="res://entities/skull.tscn" id="6_5k7gy"] +[ext_resource type="PackedScene" uid="uid://b04xhv32ypi42" path="res://entities/monocle.tscn" id="7_lahut"] +[ext_resource type="PackedScene" uid="uid://8ejgwtkpaa44" path="res://entities/top_hat.tscn" id="8_atoon"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -816,9 +814,6 @@ sources/0 = SubResource("TileSetAtlasSource_058kb") [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_htttx"] -[sub_resource type="CircleShape2D" id="CircleShape2D_h5qsh"] -radius = 48.0 - [node name="MainGame" type="Node2D" groups=["game"]] script = ExtResource("1_wiglu") @@ -829,7 +824,7 @@ unique_name_in_owner = true scale = Vector2(2, 2) tile_set = SubResource("TileSet_g2dkm") format = 2 -layer_0/tile_data = PackedInt32Array(720915, 262144, 4, 655379, 0, 8, 589843, 262144, 3, 524307, 0, 8, 458771, 0, 8, 393235, 262144, 3, 327699, 0, 8, 262163, 262144, 2, 196627, 0, 7, 131091, 262144, 3, 65555, 0, 10, 19, 0, 8, -65517, 0, 7, -131053, 262144, 3, -196589, 0, 10, -262125, 262144, 2, -327661, 0, 8, -393197, 262144, 2, -458733, 262144, 2, -524269, 0, 7, -589805, 0, 7, -655341, 0, 10, -720877, 262144, 3, 720914, 131072, 6, 655378, 131072, 2, 589842, 196608, 3, 524306, 196608, 2, 458770, 131072, 3, 393234, 196608, 3, 327698, 196608, 3, 262162, 131072, 3, 196626, 131072, 3, 131090, 131072, 3, 65554, 131072, 2, 18, 196608, 2, -65518, 131072, 3, -131054, 196608, 2, -196590, 131072, 2, -262126, 196608, 3, -327662, 131072, 2, -393198, 196608, 3, -458734, 131072, 3, -524270, 196608, 2, -589806, 131072, 3, -655342, 131072, 2, -720878, 131072, 3, 720913, 131072, 6, 655377, 131072, 2, 589841, 196608, 3, 524305, 196608, 2, 458769, 196608, 3, 393233, 131072, 2, 327697, 131072, 2, 262161, 131072, 3, 196625, 196608, 3, 131089, 131072, 3, 65553, 196608, 2, 17, 131072, 2, -65519, 196608, 2, -131055, 131072, 3, -196591, 131072, 2, -262127, 131072, 3, -327663, 196608, 3, -393199, 196608, 2, -458735, 131072, 3, -524271, 196608, 2, -589807, 131072, 2, -655343, 196608, 2, -720879, 131072, 2, 720912, 196608, 4, 655376, 131072, 2, 589840, 131072, 3, 524304, 196608, 3, 458768, 131072, 3, 393232, 196608, 2, 327696, 131072, 2, 262160, 196608, 2, 196624, 131072, 2, 131088, 196608, 3, 65552, 131072, 3, 16, 131072, 3, -65520, 196608, 2, -131056, 196608, 3, -196592, 131072, 2, -262128, 131072, 2, -327664, 131072, 2, -393200, 131072, 2, -458736, 196608, 2, -524272, 131072, 2, -589808, 196608, 2, -655344, 131072, 3, -720880, 131072, 3, 720911, 131072, 6, 655375, 196608, 2, 589839, 131072, 3, 524303, 196608, 3, 458767, 196608, 3, 393231, 131072, 3, 327695, 196608, 2, 262159, 196608, 3, 196623, 131072, 2, 131087, 131072, 3, 65551, 196608, 2, 15, 196608, 3, -65521, 131072, 3, -131057, 131072, 2, -196593, 131072, 2, -262129, 131072, 3, -327665, 196608, 3, -393201, 196608, 2, -458737, 196608, 2, -524273, 196608, 3, -589809, 196608, 3, -655345, 196608, 2, -720881, 196608, 3, 720910, 131072, 6, 655374, 131072, 2, 589838, 131072, 3, 524302, 196608, 3, 458766, 131072, 3, 393230, 196608, 2, 327694, 196608, 2, 262158, 131072, 2, 196622, 196608, 2, 131086, 196608, 3, 65550, 131072, 2, 14, 131072, 3, -65522, 196608, 3, -131058, 196608, 3, -196594, 131072, 3, -262130, 196608, 3, -327666, 131072, 3, -393202, 196608, 3, -458738, 131072, 3, -524274, 196608, 3, -589810, 196608, 2, -655346, 196608, 2, -720882, 131072, 2, 720909, 262144, 6, 655373, 131072, 2, 589837, 196608, 3, 524301, 196608, 3, 458765, 196608, 3, 393229, 131072, 2, 327693, 196608, 2, 262157, 131072, 2, 196621, 196608, 3, 131085, 131072, 2, 65549, 131072, 3, 13, 196608, 3, -65523, 131072, 2, -131059, 196608, 2, -196595, 131072, 2, -262131, 196608, 3, -327667, 196608, 3, -393203, 131072, 3, -458739, 196608, 2, -524275, 131072, 2, -589811, 196608, 3, -655347, 131072, 3, -720883, 196608, 2, 720908, 196608, 6, 655372, 196608, 3, 589836, 196608, 2, 524300, 131072, 2, 458764, 196608, 2, 393228, 131072, 2, 327692, 131072, 3, 262156, 131072, 3, 196620, 131072, 3, 131084, 131072, 2, 65548, 196608, 2, 12, 196608, 3, -65524, 131072, 2, -131060, 196608, 2, -196596, 196608, 2, -262132, 131072, 3, -327668, 196608, 2, -393204, 131072, 3, -458740, 196608, 2, -524276, 131072, 2, -589812, 196608, 2, -655348, 131072, 3, -720884, 131072, 2, 720907, 131072, 4, 655371, 196608, 3, 589835, 131072, 3, 524299, 131072, 3, 458763, 196608, 2, 393227, 131072, 2, 327691, 131072, 2, 262155, 196608, 3, 196619, 131072, 2, 131083, 131072, 3, 65547, 131072, 3, 11, 196608, 2, -65525, 131072, 3, -131061, 131072, 3, -196597, 131072, 3, -262133, 196608, 3, -327669, 131072, 2, -393205, 196608, 2, -458741, 196608, 3, -524277, 131072, 3, -589813, 131072, 3, -655349, 131072, 2, -720885, 196608, 2, 720906, 262144, 6, 655370, 196608, 3, 589834, 131072, 3, 524298, 131072, 3, 458762, 131072, 2, 393226, 196608, 2, 327690, 196608, 2, 262154, 196608, 2, 196618, 131072, 3, 131082, 196608, 2, 65546, 196608, 2, 10, 131072, 2, -65526, 131072, 3, -131062, 196608, 3, -196598, 196608, 2, -262134, 131072, 2, -327670, 196608, 3, -393206, 196608, 2, -458742, 131072, 3, -524278, 131072, 3, -589814, 196608, 2, -655350, 131072, 2, -720886, 196608, 2, 720905, 65536, 6, 655369, 196608, 3, 589833, 196608, 3, 524297, 196608, 3, 458761, 196608, 3, 393225, 196608, 3, 327689, 196608, 3, 262153, 131072, 3, 196617, 131072, 3, 131081, 196608, 2, 65545, 131072, 3, 9, 131072, 3, -65527, 131072, 2, -131063, 131072, 2, -196599, 196608, 2, -262135, 131072, 2, -327671, 196608, 2, -393207, 131072, 3, -458743, 131072, 2, -524279, 131072, 2, -589815, 131072, 3, -655351, 196608, 2, -720887, 196608, 2, 720904, 196608, 4, 655368, 196608, 2, 589832, 131072, 3, 524296, 131072, 3, 458760, 196608, 2, 393224, 196608, 3, 327688, 131072, 2, 262152, 131072, 3, 196616, 196608, 3, 131080, 196608, 3, 65544, 196608, 2, 8, 196608, 2, -65528, 131072, 2, -131064, 131072, 3, -196600, 196608, 3, -262136, 196608, 2, -327672, 196608, 2, -393208, 196608, 2, -458744, 196608, 2, -524280, 131072, 3, -589816, 196608, 2, -655352, 196608, 3, -720888, 196608, 2, 720903, 131072, 4, 655367, 196608, 3, 589831, 196608, 2, 524295, 196608, 3, 458759, 196608, 3, 393223, 196608, 3, 327687, 196608, 3, 262151, 196608, 3, 196615, 196608, 3, 131079, 131072, 2, 65543, 131072, 2, 7, 196608, 3, -65529, 196608, 3, -131065, 131072, 3, -196601, 196608, 3, -262137, 196608, 3, -327673, 131072, 2, -393209, 196608, 3, -458745, 196608, 2, -524281, 131072, 3, -589817, 131072, 3, -655353, 131072, 3, -720889, 196608, 2, 720902, 262144, 6, 655366, 131072, 3, 589830, 131072, 3, 524294, 196608, 2, 458758, 131072, 3, 393222, 131072, 3, 327686, 196608, 3, 262150, 196608, 3, 196614, 196608, 2, 131078, 196608, 3, 65542, 131072, 2, 6, 131072, 3, -65530, 131072, 2, -131066, 131072, 3, -196602, 196608, 2, -262138, 131072, 3, -327674, 196608, 3, -393210, 131072, 3, -458746, 131072, 2, -524282, 196608, 3, -589818, 131072, 2, -655354, 131072, 2, -720890, 131072, 3, 720901, 131072, 6, 655365, 131072, 2, 589829, 131072, 2, 524293, 131072, 3, 458757, 131072, 2, 393221, 131072, 2, 327685, 131072, 3, 262149, 131072, 3, 196613, 196608, 2, 131077, 131072, 3, 65541, 196608, 2, 5, 131072, 3, -65531, 131072, 2, -131067, 196608, 3, -196603, 131072, 3, -262139, 196608, 2, -327675, 196608, 2, -393211, 131072, 3, -458747, 131072, 3, -524283, 131072, 2, -589819, 131072, 2, -655355, 131072, 2, -720891, 131072, 2, 720900, 131072, 6, 655364, 196608, 2, 589828, 131072, 3, 524292, 131072, 3, 458756, 196608, 2, 393220, 131072, 2, 327684, 131072, 2, 262148, 196608, 2, 196612, 131072, 3, 131076, 131072, 3, 65540, 196608, 2, 4, 196608, 3, -65532, 131072, 3, -131068, 131072, 2, -196604, 196608, 3, -262140, 131072, 2, -327676, 196608, 2, -393212, 131072, 3, -458748, 196608, 2, -524284, 131072, 2, -589820, 196608, 3, -655356, 196608, 2, -720892, 196608, 2, 720899, 131072, 6, 655363, 196608, 2, 589827, 196608, 2, 524291, 131072, 2, 458755, 131072, 2, 393219, 131072, 3, 327683, 196608, 3, 262147, 196608, 3, 196611, 196608, 2, 131075, 131072, 3, 65539, 196608, 3, 3, 196608, 3, -65533, 131072, 2, -131069, 196608, 2, -196605, 196608, 3, -262141, 131072, 2, -327677, 196608, 3, -393213, 131072, 2, -458749, 196608, 3, -524285, 196608, 2, -589821, 131072, 3, -655357, 131072, 3, -720893, 196608, 2, 720898, 196608, 4, 655362, 196608, 2, 589826, 196608, 3, 524290, 196608, 3, 458754, 196608, 2, 393218, 131072, 3, 327682, 131072, 3, 262146, 196608, 3, 196610, 131072, 2, 131074, 131072, 3, 65538, 131072, 2, 2, 131072, 2, -65534, 196608, 2, -131070, 196608, 2, -196606, 131072, 3, -262142, 131072, 2, -327678, 131072, 3, -393214, 196608, 3, -458750, 196608, 3, -524286, 131072, 3, -589822, 196608, 2, -655358, 131072, 3, -720894, 196608, 2, 720897, 196608, 4, 655361, 131072, 3, 589825, 131072, 2, 524289, 131072, 3, 458753, 196608, 2, 393217, 131072, 3, 327681, 196608, 2, 262145, 131072, 3, 196609, 196608, 2, 131073, 196608, 3, 65537, 196608, 3, 1, 196608, 2, -65535, 131072, 2, -131071, 196608, 3, -196607, 131072, 2, -262143, 131072, 3, -327679, 196608, 2, -393215, 131072, 2, -458751, 196608, 2, -524287, 131072, 2, -589823, 196608, 3, -655359, 131072, 2, -720895, 131072, 2, 720896, 131072, 4, 655360, 131072, 2, 589824, 196608, 3, 524288, 196608, 2, 458752, 131072, 2, 393216, 196608, 3, 327680, 196608, 3, 262144, 131072, 2, 196608, 131072, 2, 131072, 131072, 2, 65536, 196608, 2, 0, 196608, 3, -65536, 196608, 3, -131072, 131072, 2, -196608, 131072, 3, -262144, 196608, 3, -327680, 196608, 2, -393216, 196608, 2, -458752, 131072, 3, -524288, 131072, 2, -589824, 131072, 2, -655360, 131072, 3, -720896, 131072, 2, 786431, 196608, 4, 720895, 196608, 2, 655359, 131072, 2, 589823, 131072, 2, 524287, 131072, 3, 458751, 196608, 3, 393215, 196608, 2, 327679, 196608, 2, 262143, 131072, 2, 196607, 196608, 2, 131071, 196608, 2, 65535, 196608, 2, -1, 131072, 3, -65537, 196608, 2, -131073, 196608, 3, -196609, 196608, 2, -262145, 196608, 3, -327681, 196608, 2, -393217, 196608, 2, -458753, 131072, 2, -524289, 196608, 3, -589825, 196608, 2, -655361, 131072, 3, 786430, 131072, 6, 720894, 196608, 3, 655358, 196608, 2, 589822, 131072, 2, 524286, 196608, 3, 458750, 196608, 3, 393214, 131072, 2, 327678, 131072, 3, 262142, 131072, 2, 196606, 131072, 2, 131070, 131072, 2, 65534, 131072, 3, -2, 196608, 3, -65538, 131072, 3, -131074, 131072, 3, -196610, 131072, 3, -262146, 196608, 3, -327682, 131072, 2, -393218, 196608, 2, -458754, 131072, 2, -524290, 131072, 2, -589826, 131072, 2, -655362, 131072, 2, 786429, 131072, 4, 720893, 131072, 3, 655357, 131072, 2, 589821, 131072, 3, 524285, 196608, 3, 458749, 131072, 3, 393213, 131072, 2, 327677, 196608, 3, 262141, 196608, 2, 196605, 196608, 2, 131069, 196608, 3, 65533, 131072, 2, -3, 131072, 2, -65539, 131072, 2, -131075, 131072, 2, -196611, 196608, 2, -262147, 131072, 3, -327683, 131072, 3, -393219, 131072, 3, -458755, 196608, 3, -524291, 196608, 3, -589827, 196608, 2, -655363, 196608, 2, 786428, 65536, 6, 720892, 131072, 2, 655356, 196608, 2, 589820, 131072, 2, 524284, 131072, 3, 458748, 196608, 2, 393212, 196608, 2, 327676, 131072, 2, 262140, 196608, 3, 196604, 196608, 2, 131068, 196608, 2, 65532, 131072, 3, -4, 196608, 2, -65540, 196608, 3, -131076, 196608, 2, -196612, 196608, 2, -262148, 131072, 2, -327684, 131072, 3, -393220, 131072, 3, -458756, 131072, 2, -524292, 196608, 3, -589828, 196608, 2, -655364, 131072, 2, 786427, 131072, 6, 720891, 196608, 3, 655355, 196608, 3, 589819, 196608, 3, 524283, 131072, 3, 458747, 196608, 2, 393211, 196608, 2, 327675, 196608, 2, 262139, 131072, 3, 196603, 131072, 2, 131067, 196608, 3, 65531, 131072, 3, -5, 196608, 3, -65541, 196608, 3, -131077, 196608, 3, -196613, 131072, 2, -262149, 196608, 3, -327685, 196608, 2, -393221, 131072, 2, -458757, 131072, 2, -524293, 131072, 3, -589829, 196608, 3, -655365, 196608, 2, 786426, 262144, 6, 720890, 131072, 3, 655354, 131072, 3, 589818, 196608, 2, 524282, 196608, 3, 458746, 196608, 2, 393210, 196608, 3, 327674, 131072, 2, 262138, 196608, 2, 196602, 131072, 2, 131066, 131072, 3, 65530, 196608, 3, -6, 131072, 3, -65542, 196608, 3, -131078, 196608, 2, -196614, 196608, 2, -262150, 196608, 3, -327686, 131072, 3, -393222, 131072, 3, -458758, 196608, 3, -524294, 196608, 3, -589830, 196608, 2, -655366, 196608, 2, 786425, 131072, 6, 720889, 196608, 2, 655353, 131072, 2, 589817, 196608, 2, 524281, 196608, 2, 458745, 196608, 2, 393209, 131072, 2, 327673, 131072, 3, 262137, 131072, 3, 196601, 131072, 2, 131065, 196608, 2, 65529, 131072, 2, -7, 196608, 2, -65543, 131072, 3, -131079, 131072, 2, -196615, 196608, 3, -262151, 196608, 3, -327687, 131072, 3, -393223, 131072, 2, -458759, 131072, 2, -524295, 131072, 2, -589831, 131072, 3, -655367, 131072, 3, 786424, 262144, 6, 720888, 131072, 3, 655352, 131072, 3, 589816, 196608, 3, 524280, 196608, 2, 458744, 196608, 3, 393208, 196608, 2, 327672, 196608, 3, 262136, 196608, 3, 196600, 196608, 2, 131064, 196608, 3, 65528, 131072, 3, -8, 131072, 2, -65544, 196608, 2, -131080, 196608, 2, -196616, 196608, 2, -262152, 196608, 2, -327688, 196608, 2, -393224, 196608, 2, -458760, 196608, 2, -524296, 196608, 3, -589832, 131072, 2, -655368, 131072, 3, 786423, 262144, 6, 720887, 196608, 2, 655351, 196608, 3, 589815, 131072, 2, 524279, 131072, 3, 458743, 131072, 3, 393207, 131072, 2, 327671, 196608, 3, 262135, 131072, 2, 196599, 196608, 2, 131063, 131072, 3, 65527, 131072, 2, -9, 131072, 3, -65545, 196608, 2, -131081, 131072, 3, -196617, 131072, 2, -262153, 131072, 3, -327689, 131072, 3, -393225, 131072, 3, -458761, 196608, 2, -524297, 131072, 2, -589833, 196608, 3, -655369, 196608, 3, 786422, 131072, 6, 720886, 131072, 2, 655350, 131072, 2, 589814, 131072, 3, 524278, 327680, 11, 458742, 65536, 3, 393206, 327680, 10, 327670, 327680, 10, 262134, 327680, 10, 196598, 327680, 6, 131062, 131072, 2, 65526, 131072, 3, -10, 196608, 3, -65546, 196608, 2, -131082, 131072, 2, -196618, 131072, 2, -262154, 131072, 3, -327690, 131072, 3, -393226, 131072, 2, -458762, 131072, 2, -524298, 196608, 2, -589834, 196608, 3, -655370, 131072, 3, 786421, 262144, 6, 720885, 131072, 2, 655349, 196608, 3, 589813, 196608, 3, 524277, 196608, 11, 458741, 65536, 8, 393205, 196608, 8, 327669, 65536, 0, 262133, 65536, 7, 196597, 131072, 4, 131061, 196608, 3, 65525, 131072, 3, -11, 196608, 2, -65547, 131072, 3, -131083, 196608, 2, -196619, 196608, 2, -262155, 196608, 2, -327691, 131072, 3, -393227, 131072, 2, -458763, 131072, 2, -524299, 131072, 3, -589835, 196608, 3, -655371, 196608, 3, 786420, 262144, 6, 720884, 131072, 3, 655348, 131072, 3, 589812, 196608, 2, 524276, 196608, 1, 458740, 327680, 4, 393204, 131072, 0, 327668, 262144, 9, 262132, 131072, 10, 196596, 196608, 4, 131060, 131072, 2, 65524, 131072, 2, -12, 131072, 2, -65548, 131072, 3, -131084, 131072, 3, -196620, 131072, 2, -262156, 131072, 2, -327692, 131072, 3, -393228, 196608, 3, -458764, 131072, 3, -524300, 131072, 3, -589836, 131072, 2, -655372, 196608, 3, 786419, 196608, 6, 720883, 196608, 2, 655347, 131072, 3, 589811, 131072, 3, 524275, 196608, 11, 458739, 262144, 8, 393203, 65536, 5, 327667, 131072, 7, 262131, 0, 0, 196595, 131072, 4, 131059, 131072, 3, 65523, 131072, 3, -13, 131072, 2, -65549, 196608, 2, -131085, 131072, 2, -196621, 131072, 3, -262157, 131072, 3, -327693, 196608, 3, -393229, 131072, 2, -458765, 131072, 2, -524301, 196608, 2, -589837, 196608, 2, -655373, 196608, 2, 786418, 131072, 6, 720882, 196608, 2, 655346, 196608, 3, 589810, 196608, 3, 524274, 262144, 11, 458738, 0, 1, 393202, 327680, 4, 327666, 196608, 5, 262130, 65536, 7, 196594, 262144, 6, 131058, 196608, 3, 65522, 196608, 2, -14, 196608, 3, -65550, 131072, 2, -131086, 196608, 2, -196622, 131072, 2, -262158, 131072, 2, -327694, 196608, 3, -393230, 131072, 2, -458766, 196608, 3, -524302, 196608, 3, -589838, 196608, 3, -655374, 196608, 3, 786417, 65536, 6, 720881, 196608, 2, 655345, 131072, 3, 589809, 131072, 3, 524273, 0, 11, 458737, 0, 8, 393201, 0, 9, 327665, 0, 9, 262129, 262144, 2, 196593, 0, 6, 131057, 131072, 3, 65521, 196608, 2, -15, 131072, 2, -65551, 131072, 2, -131087, 131072, 3, -196623, 196608, 2, -262159, 196608, 2, -327695, 196608, 3, -393231, 196608, 3, -458767, 196608, 2, -524303, 131072, 3, -589839, 196608, 3, -655375, 131072, 2, 786416, 131072, 4, 720880, 131072, 2, 655344, 196608, 2, 589808, 196608, 2, 524272, 196608, 2, 458736, 196608, 3, 393200, 196608, 2, 327664, 131072, 3, 262128, 196608, 3, 196592, 196608, 2, 131056, 131072, 2, 65520, 131072, 3, -16, 131072, 3, -65552, 196608, 3, -131088, 196608, 3, -196624, 196608, 3, -262160, 196608, 3, -327696, 196608, 3, -393232, 131072, 2, -458768, 196608, 3, -524304, 196608, 3, -589840, 131072, 3, -655376, 131072, 3, 786415, 196608, 4, 720879, 196608, 2, 655343, 131072, 3, 589807, 196608, 2, 524271, 196608, 3, 458735, 196608, 2, 393199, 131072, 3, 327663, 131072, 3, 262127, 196608, 2, 196591, 131072, 2, 131055, 196608, 3, 65519, 196608, 2, -17, 196608, 3, -65553, 196608, 3, -131089, 196608, 2, -196625, 131072, 2, -262161, 196608, 3, -327697, 131072, 2, -393233, 196608, 3, -458769, 131072, 2, -524305, 196608, 3, -589841, 131072, 3, -655377, 131072, 2, 786414, 131072, 4, 720878, 196608, 2, 655342, 196608, 2, 589806, 131072, 2, 524270, 131072, 2, 458734, 196608, 2, 393198, 196608, 2, 327662, 131072, 2, 262126, 196608, 2, 196590, 196608, 2, 131054, 131072, 3, 65518, 196608, 3, -18, 196608, 2, -65554, 196608, 3, -131090, 131072, 2, -196626, 196608, 3, -262162, 131072, 3, -327698, 131072, 3, -393234, 131072, 3, -458770, 196608, 3, -524306, 196608, 2, -589842, 196608, 3, -655378, 196608, 2, 786413, 196608, 4, 720877, 196608, 2, 655341, 196608, 3, 589805, 131072, 3, 524269, 131072, 2, 458733, 196608, 2, 393197, 131072, 2, 327661, 131072, 2, 262125, 131072, 2, 196589, 131072, 3, 131053, 131072, 2, 65517, 196608, 2, -19, 196608, 2, -65555, 196608, 3, -131091, 131072, 3, -196627, 131072, 2, -262163, 196608, 3, -327699, 131072, 3, -393235, 196608, 3, -458771, 196608, 2, -524307, 196608, 3, -589843, 131072, 2, -655379, 196608, 3, 786412, 65536, 4, 720876, 327680, 7, 655340, 65536, 2, 589804, 327680, 10, 524268, 65536, 3, 458732, 327680, 10, 393196, 327680, 7, 327660, 327680, 8, 262124, 65536, 2, 196588, 65536, 3, 131052, 327680, 8, 65516, 327680, 8, -20, 65536, 2, -65556, 327680, 10, -131092, 327680, 8, -196628, 327680, 7, -262164, 65536, 2, -327700, 65536, 2, -393236, 327680, 10, -458772, 65536, 2, -524308, 65536, 3, -589844, 65536, 2, -655380, 327680, 7, -786413, 262144, 1, -786414, 262144, 11, -786415, 65536, 11, -786416, 65536, 11, -786417, 131072, 11, -786418, 196608, 11, -786419, 131072, 11, -786420, 131072, 1, -786421, 65536, 11, -786422, 196608, 11, -786423, 131072, 1, -786424, 65536, 11, -786425, 131072, 11, -786426, 131072, 1, -786427, 262144, 11, -786428, 262144, 11, -786429, 65536, 11, -786430, 262144, 11, -786431, 131072, 11, -786432, 262144, 11, -720897, 131072, 1, -720898, 196608, 1, -720899, 262144, 11, -720900, 131072, 1, -720901, 196608, 1, -720902, 262144, 11, -720903, 196608, 11, -720904, 262144, 11, -720905, 196608, 1, -720906, 196608, 1, -720907, 131072, 11, -720908, 196608, 1, -720909, 262144, 11, -720910, 131072, 11, -720911, 196608, 1, -720912, 131072, 1, -720913, 131072, 1, -720914, 131072, 11, -720915, 196608, 11, -720916, 65536, 1) +layer_0/tile_data = PackedInt32Array(720915, 196608, 9, 655379, 65536, 10, 589843, 131072, 8, 524307, 0, 5, 458771, 196608, 10, 393235, 131072, 0, 327699, 327680, 5, 262163, 327680, 5, 196627, 65536, 8, 131091, 65536, 0, 65555, 196608, 7, 19, 262144, 9, -65517, 65536, 9, -131053, 262144, 7, -196589, 65536, 5, -262125, 131072, 8, -327661, 196608, 5, -393197, 131072, 7, -458733, 327680, 1, -524269, 327680, 0, -589805, 327680, 4, -655341, 0, 4, -720877, 262144, 5, 720914, 196608, 0, 655378, 131072, 10, 589842, 327680, 5, 524306, 327680, 2, 458770, 196608, 8, 393234, 327680, 3, 327698, 65536, 0, 262162, 327680, 3, 196626, 65536, 7, 131090, 65536, 0, 65554, 262144, 9, 18, 262144, 8, -65518, 0, 0, -131054, 65536, 8, -196590, 65536, 10, -262126, 196608, 9, -327662, 65536, 7, -393198, 262144, 8, -458734, 262144, 10, -524270, 65536, 10, -589806, 65536, 10, -655342, 327680, 4, -720878, 327680, 5, 720913, 196608, 8, 655377, 196608, 9, 589841, 262144, 0, 524305, 131072, 0, 458769, 327680, 0, 393233, 196608, 8, 327697, 262144, 0, 262161, 327680, 4, 196625, 0, 3, 131089, 327680, 2, 65553, 196608, 0, 17, 262144, 8, -65519, 196608, 8, -131055, 196608, 5, -196591, 327680, 1, -262127, 196608, 9, -327663, 131072, 0, -393199, 196608, 10, -458735, 196608, 9, -524271, 327680, 3, -589807, 262144, 7, -655343, 196608, 10, -720879, 65536, 7, 720912, 65536, 0, 655376, 65536, 0, 589840, 65536, 10, 524304, 262144, 7, 458768, 262144, 0, 393232, 262144, 8, 327696, 0, 2, 262160, 327680, 4, 196624, 65536, 5, 131088, 196608, 7, 65552, 327680, 3, 16, 327680, 0, -65520, 262144, 9, -131056, 327680, 4, -196592, 65536, 5, -262128, 262144, 8, -327664, 196608, 9, -393200, 327680, 1, -458736, 196608, 0, -524272, 196608, 5, -589808, 0, 3, -655344, 196608, 9, -720880, 196608, 10, 720911, 65536, 10, 655375, 262144, 9, 589839, 327680, 0, 524303, 196608, 5, 458767, 327680, 3, 393231, 262144, 5, 327695, 327680, 5, 262159, 0, 2, 196623, 196608, 10, 131087, 65536, 7, 65551, 131072, 0, 15, 262144, 5, -65521, 65536, 5, -131057, 0, 1, -196593, 131072, 8, -262129, 131072, 9, -327665, 327680, 2, -393201, 131072, 7, -458737, 131072, 10, -524273, 262144, 7, -589809, 131072, 7, -655345, 0, 5, -720881, 65536, 0, 720910, 196608, 8, 655374, 131072, 10, 589838, 327680, 5, 524302, 65536, 7, 458766, 65536, 0, 393230, 327680, 0, 327694, 196608, 0, 262158, 65536, 8, 196622, 131072, 7, 131086, 65536, 9, 65550, 131072, 10, 14, 0, 3, -65522, 262144, 9, -131058, 327680, 4, -196594, 65536, 8, -262130, 196608, 5, -327666, 131072, 9, -393202, 262144, 9, -458738, 196608, 10, -524274, 196608, 10, -589810, 131072, 0, -655346, 0, 4, -720882, 65536, 7, 720909, 65536, 5, 655373, 131072, 0, 589837, 0, 0, 524301, 327680, 0, 458765, 65536, 0, 393229, 0, 1, 327693, 262144, 5, 262157, 262144, 5, 196621, 65536, 10, 131085, 65536, 9, 65549, 196608, 7, 13, 262144, 0, -65523, 0, 1, -131059, 262144, 7, -196595, 0, 3, -262131, 65536, 8, -327667, 196608, 8, -393203, 196608, 0, -458739, 262144, 7, -524275, 327680, 0, -589811, 327680, 0, -655347, 65536, 8, -720883, 262144, 9, 720908, 327680, 3, 655372, 196608, 0, 589836, 131072, 7, 524300, 327680, 1, 458764, 327680, 5, 393228, 327680, 1, 327692, 196608, 8, 262156, 65536, 5, 196620, 65536, 8, 131084, 196608, 9, 65548, 65536, 7, 12, 327680, 2, -65524, 0, 3, -131060, 262144, 10, -196596, 262144, 8, -262132, 65536, 0, -327668, 65536, 9, -393204, 262144, 7, -458740, 65536, 8, -524276, 65536, 5, -589812, 327680, 0, -655348, 131072, 8, -720884, 196608, 8, 720907, 327680, 2, 655371, 196608, 8, 589835, 65536, 0, 524299, 131072, 0, 458763, 327680, 1, 393227, 65536, 9, 327691, 65536, 9, 262155, 65536, 0, 196619, 262144, 5, 131083, 327680, 1, 65547, 131072, 10, 11, 131072, 7, -65525, 196608, 10, -131061, 0, 1, -196597, 262144, 8, -262133, 196608, 8, -327669, 262144, 7, -393205, 262144, 8, -458741, 196608, 7, -524277, 196608, 7, -589813, 196608, 10, -655349, 0, 3, -720885, 131072, 10, 720906, 196608, 10, 655370, 196608, 0, 589834, 196608, 10, 524298, 327680, 3, 458762, 196608, 10, 393226, 131072, 9, 327690, 131072, 8, 262154, 196608, 9, 196618, 327680, 4, 131082, 196608, 8, 65546, 131072, 5, 10, 65536, 5, -65526, 327680, 3, -131062, 0, 3, -196598, 262144, 5, -262134, 327680, 3, -327670, 0, 2, -393206, 0, 4, -458742, 65536, 5, -524278, 196608, 10, -589814, 327680, 1, -655350, 262144, 0, -720886, 196608, 5, 720905, 131072, 5, 655369, 131072, 0, 589833, 0, 3, 524297, 327680, 0, 458761, 131072, 7, 393225, 327680, 4, 327689, 262144, 9, 262153, 262144, 10, 196617, 65536, 10, 131081, 0, 3, 65545, 65536, 10, 9, 327680, 5, -65527, 131072, 7, -131063, 262144, 9, -196599, 327680, 2, -262135, 327680, 0, -327671, 0, 4, -393207, 262144, 5, -458743, 0, 3, -524279, 65536, 0, -589815, 65536, 0, -655351, 196608, 5, -720887, 131072, 7, 720904, 0, 3, 655368, 0, 2, 589832, 131072, 9, 524296, 327680, 4, 458760, 131072, 9, 393224, 327680, 0, 327688, 327680, 0, 262152, 262144, 8, 196616, 0, 0, 131080, 0, 1, 65544, 65536, 0, 8, 0, 1, -65528, 262144, 0, -131064, 65536, 9, -196600, 65536, 7, -262136, 131072, 5, -327672, 131072, 10, -393208, 0, 1, -458744, 65536, 5, -524280, 327680, 5, -589816, 131072, 8, -655352, 0, 0, -720888, 262144, 9, 720903, 196608, 10, 655367, 196608, 0, 589831, 0, 3, 524295, 327680, 3, 458759, 131072, 5, 393223, 262144, 8, 327687, 65536, 5, 262151, 0, 0, 196615, 131072, 0, 131079, 65536, 7, 65543, 262144, 7, 7, 327680, 0, -65529, 327680, 5, -131065, 65536, 0, -196601, 65536, 7, -262137, 196608, 0, -327673, 327680, 1, -393209, 0, 4, -458745, 0, 0, -524281, 131072, 8, -589817, 327680, 4, -655353, 0, 5, -720889, 196608, 10, 720902, 65536, 0, 655366, 0, 5, 589830, 0, 4, 524294, 0, 4, 458758, 131072, 8, 393222, 196608, 0, 327686, 196608, 0, 262150, 327680, 3, 196614, 196608, 9, 131078, 131072, 9, 65542, 327680, 3, 6, 0, 2, -65530, 0, 0, -131066, 131072, 5, -196602, 0, 1, -262138, 327680, 2, -327674, 131072, 5, -393210, 131072, 8, -458746, 262144, 5, -524282, 327680, 0, -589818, 65536, 10, -655354, 196608, 7, -720890, 262144, 8, 720901, 262144, 9, 655365, 0, 2, 589829, 65536, 9, 524293, 0, 2, 458757, 262144, 8, 393221, 327680, 5, 327685, 196608, 0, 262149, 65536, 10, 196613, 327680, 2, 131077, 0, 4, 65541, 131072, 5, 5, 327680, 1, -65531, 131072, 5, -131067, 131072, 9, -196603, 262144, 7, -262139, 65536, 8, -327675, 196608, 0, -393211, 65536, 10, -458747, 65536, 8, -524283, 196608, 9, -589819, 327680, 2, -655355, 0, 4, -720891, 131072, 9, 720900, 131072, 0, 655364, 262144, 0, 589828, 131072, 10, 524292, 0, 1, 458756, 327680, 0, 393220, 0, 1, 327684, 65536, 0, 262148, 262144, 10, 196612, 262144, 10, 131076, 131072, 8, 65540, 0, 4, 4, 65536, 7, -65532, 262144, 5, -131068, 196608, 0, -196604, 262144, 8, -262140, 0, 1, -327676, 131072, 10, -393212, 131072, 7, -458748, 0, 1, -524284, 0, 4, -589820, 0, 1, -655356, 65536, 5, -720892, 0, 0, 720899, 327680, 0, 655363, 327680, 1, 589827, 262144, 10, 524291, 196608, 8, 458755, 327680, 3, 393219, 262144, 0, 327683, 262144, 8, 262147, 262144, 7, 196611, 131072, 0, 131075, 262144, 7, 65539, 327680, 2, 3, 65536, 0, -65533, 131072, 0, -131069, 196608, 7, -196605, 196608, 9, -262141, 65536, 9, -327677, 262144, 7, -393213, 262144, 10, -458749, 196608, 5, -524285, 327680, 3, -589821, 131072, 7, -655357, 196608, 8, -720893, 65536, 10, 720898, 65536, 10, 655362, 65536, 7, 589826, 131072, 8, 524290, 196608, 8, 458754, 196608, 10, 393218, 65536, 8, 327682, 327680, 2, 262146, 0, 5, 196610, 196608, 5, 131074, 262144, 4, 65538, 0, 9, 2, 262144, 3, -65534, 262144, 3, -131070, 262144, 3, -196606, 262144, 1, -262142, 262144, 9, -327678, 262144, 5, -393214, 196608, 9, -458750, 327680, 5, -524286, 327680, 5, -589822, 196608, 8, -655358, 327680, 2, -720894, 131072, 9, 720897, 262144, 7, 655361, 196608, 10, 589825, 262144, 7, 524289, 65536, 8, 458753, 262144, 9, 393217, 65536, 8, 327681, 262144, 9, 262145, 131072, 5, 196609, 196608, 7, 131073, 65536, 6, 65537, 196608, 2, 1, 196608, 3, -65535, 131072, 3, -131071, 196608, 3, -196607, 131072, 11, -262143, 0, 5, -327679, 131072, 10, -393215, 196608, 8, -458751, 327680, 5, -524287, 0, 2, -589823, 196608, 9, -655359, 327680, 0, -720895, 65536, 10, 720896, 0, 4, 655360, 262144, 8, 589824, 327680, 4, 524288, 131072, 0, 458752, 262144, 0, 393216, 0, 1, 327680, 0, 1, 262144, 196608, 9, 196608, 0, 2, 131072, 196608, 6, 65536, 196608, 2, 0, 131072, 3, -65536, 131072, 2, -131072, 196608, 2, -196608, 196608, 11, -262144, 0, 3, -327680, 0, 0, -393216, 65536, 0, -458752, 196608, 9, -524288, 196608, 0, -589824, 196608, 0, -655360, 327680, 2, -720896, 65536, 7, 786431, 0, 3, 720895, 65536, 7, 655359, 0, 4, 589823, 196608, 7, 524287, 196608, 7, 458751, 65536, 9, 393215, 327680, 4, 327679, 65536, 9, 262143, 65536, 8, 196607, 196608, 4, 131071, 131072, 2, 65535, 196608, 3, -1, 131072, 3, -65537, 196608, 2, -131073, 131072, 11, -196609, 262144, 7, -262145, 0, 1, -327681, 65536, 8, -393217, 327680, 1, -458753, 65536, 8, -524289, 131072, 8, -589825, 131072, 9, -655361, 327680, 0, 786430, 65536, 7, 720894, 327680, 4, 655358, 0, 0, 589822, 0, 2, 524286, 262144, 5, 458750, 131072, 0, 393214, 0, 0, 327678, 0, 5, 262142, 196608, 0, 196606, 262144, 6, 131070, 196608, 2, 65534, 196608, 3, -2, 196608, 3, -65538, 131072, 2, -131074, 196608, 1, -196610, 0, 2, -262146, 327680, 5, -327682, 327680, 4, -393218, 131072, 9, -458754, 65536, 9, -524290, 0, 4, -589826, 131072, 5, -655362, 65536, 5, 786429, 196608, 7, 720893, 65536, 9, 655357, 196608, 7, 589821, 327680, 3, 524285, 65536, 10, 458749, 327680, 4, 393213, 262144, 7, 327677, 0, 3, 262141, 196608, 8, 196605, 65536, 4, 131069, 327680, 7, 65533, 65536, 2, -3, 65536, 3, -65539, 327680, 9, -131075, 65536, 1, -196611, 262144, 10, -262147, 196608, 8, -327683, 65536, 7, -393219, 262144, 5, -458755, 262144, 7, -524291, 196608, 5, -589827, 65536, 7, -655363, 196608, 7, 786428, 131072, 5, 720892, 131072, 0, 655356, 196608, 9, 589820, 0, 1, 524284, 65536, 10, 458748, 0, 5, 393212, 262144, 5, 327676, 262144, 5, 262140, 131072, 0, 196604, 0, 3, 131068, 196608, 0, 65532, 327680, 3, -4, 0, 1, -65540, 0, 5, -131076, 327680, 0, -196612, 196608, 9, -262148, 0, 4, -327684, 196608, 9, -393220, 0, 5, -458756, 327680, 2, -524292, 65536, 0, -589828, 0, 5, -655364, 327680, 3, 786427, 196608, 10, 720891, 262144, 5, 655355, 65536, 0, 589819, 131072, 9, 524283, 262144, 0, 458747, 0, 4, 393211, 131072, 0, 327675, 131072, 5, 262139, 327680, 2, 196603, 131072, 7, 131067, 0, 1, 65531, 327680, 3, -5, 65536, 0, -65541, 0, 2, -131077, 196608, 5, -196613, 327680, 1, -262149, 0, 0, -327685, 327680, 5, -393221, 65536, 0, -458757, 327680, 5, -524293, 327680, 1, -589829, 65536, 5, -655365, 262144, 8, 786426, 327680, 3, 720890, 327680, 4, 655354, 65536, 0, 589818, 327680, 5, 524282, 196608, 5, 458746, 262144, 5, 393210, 0, 3, 327674, 196608, 9, 262138, 65536, 0, 196602, 131072, 10, 131066, 0, 1, 65530, 196608, 9, -6, 0, 3, -65542, 0, 4, -131078, 196608, 5, -196614, 65536, 0, -262150, 262144, 5, -327686, 0, 3, -393222, 0, 3, -458758, 196608, 8, -524294, 0, 4, -589830, 262144, 10, -655366, 196608, 0, 786425, 196608, 7, 720889, 262144, 0, 655353, 196608, 0, 589817, 262144, 9, 524281, 0, 1, 458745, 262144, 8, 393209, 327680, 5, 327673, 327680, 0, 262137, 196608, 8, 196601, 131072, 9, 131065, 196608, 8, 65529, 131072, 7, -7, 327680, 0, -65543, 327680, 0, -131079, 0, 1, -196615, 196608, 8, -262151, 65536, 9, -327687, 196608, 5, -393223, 0, 5, -458759, 262144, 10, -524295, 65536, 8, -589831, 65536, 9, -655367, 0, 5, 786424, 196608, 8, 720888, 0, 0, 655352, 262144, 9, 589816, 327680, 4, 524280, 0, 4, 458744, 196608, 9, 393208, 327680, 2, 327672, 0, 2, 262136, 65536, 0, 196600, 0, 1, 131064, 0, 0, 65528, 131072, 0, -8, 0, 0, -65544, 131072, 9, -131080, 131072, 8, -196616, 131072, 0, -262152, 196608, 5, -327688, 131072, 10, -393224, 0, 0, -458760, 0, 5, -524296, 65536, 7, -589832, 131072, 5, -655368, 262144, 7, 786423, 196608, 8, 720887, 327680, 2, 655351, 196608, 9, 589815, 196608, 5, 524279, 131072, 10, 458743, 262144, 8, 393207, 196608, 10, 327671, 65536, 0, 262135, 262144, 10, 196599, 196608, 9, 131063, 131072, 9, 65527, 131072, 5, -9, 131072, 8, -65545, 262144, 9, -131081, 131072, 8, -196617, 65536, 5, -262153, 262144, 8, -327689, 0, 5, -393225, 327680, 3, -458761, 65536, 9, -524297, 327680, 1, -589833, 0, 4, -655369, 0, 1, 786422, 65536, 0, 720886, 196608, 10, 655350, 262144, 5, 589814, 196608, 10, 524278, 262144, 10, 458742, 131072, 5, 393206, 0, 4, 327670, 262144, 7, 262134, 65536, 8, 196598, 327680, 4, 131062, 327680, 3, 65526, 327680, 4, -10, 196608, 8, -65546, 131072, 8, -131082, 131072, 10, -196618, 262144, 5, -262154, 327680, 2, -327690, 131072, 7, -393226, 65536, 5, -458762, 327680, 0, -524298, 131072, 10, -589834, 327680, 0, -655370, 196608, 7, 786421, 196608, 8, 720885, 196608, 7, 655349, 327680, 0, 589813, 196608, 7, 524277, 0, 3, 458741, 327680, 3, 393205, 0, 5, 327669, 131072, 10, 262133, 262144, 9, 196597, 262144, 7, 131061, 65536, 0, 65525, 131072, 7, -11, 0, 4, -65547, 65536, 5, -131083, 131072, 5, -196619, 0, 4, -262155, 327680, 5, -327691, 131072, 0, -393227, 0, 3, -458763, 327680, 1, -524299, 0, 2, -589835, 262144, 10, -655371, 262144, 7, 786420, 65536, 8, 720884, 131072, 8, 655348, 0, 1, 589812, 131072, 10, 524276, 327680, 4, 458740, 0, 0, 393204, 65536, 10, 327668, 131072, 7, 262132, 0, 4, 196596, 327680, 5, 131060, 0, 0, 65524, 0, 0, -12, 131072, 5, -65548, 327680, 1, -131084, 65536, 0, -196620, 196608, 0, -262156, 65536, 10, -327692, 65536, 8, -393228, 65536, 10, -458764, 196608, 8, -524300, 262144, 10, -589836, 0, 5, -655372, 327680, 2, 786419, 262144, 7, 720883, 65536, 9, 655347, 196608, 8, 589811, 196608, 5, 524275, 131072, 9, 458739, 327680, 4, 393203, 0, 0, 327667, 65536, 9, 262131, 327680, 1, 196595, 65536, 5, 131059, 131072, 9, 65523, 196608, 7, -13, 262144, 9, -65549, 196608, 8, -131085, 196608, 8, -196621, 65536, 8, -262157, 262144, 5, -327693, 196608, 9, -393229, 131072, 7, -458765, 262144, 7, -524301, 327680, 3, -589837, 196608, 7, -655373, 196608, 0, 786418, 131072, 5, 720882, 327680, 3, 655346, 327680, 1, 589810, 327680, 0, 524274, 0, 0, 458738, 196608, 10, 393202, 262144, 10, 327666, 327680, 3, 262130, 65536, 9, 196594, 0, 5, 131058, 327680, 1, 65522, 327680, 5, -14, 0, 4, -65550, 65536, 9, -131086, 327680, 5, -196622, 65536, 5, -262158, 131072, 8, -327694, 65536, 5, -393230, 327680, 5, -458766, 262144, 10, -524302, 196608, 5, -589838, 131072, 0, -655374, 196608, 0, 786417, 262144, 8, 720881, 327680, 2, 655345, 327680, 4, 589809, 262144, 0, 524273, 262144, 9, 458737, 196608, 7, 393201, 262144, 5, 327665, 0, 1, 262129, 65536, 10, 196593, 0, 5, 131057, 65536, 9, 65521, 196608, 5, -15, 131072, 7, -65551, 262144, 0, -131087, 65536, 5, -196623, 65536, 8, -262159, 327680, 4, -327695, 196608, 0, -393231, 131072, 7, -458767, 262144, 9, -524303, 65536, 7, -589839, 262144, 8, -655375, 262144, 9, 786416, 65536, 0, 720880, 196608, 8, 655344, 0, 0, 589808, 131072, 7, 524272, 196608, 9, 458736, 0, 3, 393200, 327680, 1, 327664, 327680, 4, 262128, 131072, 9, 196592, 131072, 10, 131056, 262144, 0, 65520, 131072, 5, -16, 65536, 7, -65552, 327680, 4, -131088, 0, 4, -196624, 262144, 10, -262160, 327680, 0, -327696, 196608, 0, -393232, 65536, 8, -458768, 262144, 0, -524304, 196608, 9, -589840, 196608, 5, -655376, 0, 3, 786415, 262144, 0, 720879, 0, 2, 655343, 196608, 8, 589807, 65536, 5, 524271, 262144, 5, 458735, 327680, 1, 393199, 0, 2, 327663, 65536, 10, 262127, 196608, 5, 196591, 262144, 7, 131055, 0, 3, 65519, 262144, 5, -17, 0, 1, -65553, 262144, 10, -131089, 65536, 10, -196625, 196608, 5, -262161, 131072, 0, -327697, 327680, 5, -393233, 65536, 0, -458769, 65536, 5, -524305, 262144, 8, -589841, 196608, 0, -655377, 327680, 5, 786414, 0, 0, 720878, 131072, 0, 655342, 131072, 10, 589806, 65536, 7, 524270, 65536, 5, 458734, 0, 2, 393198, 131072, 7, 327662, 131072, 10, 262126, 196608, 0, 196590, 196608, 8, 131054, 65536, 8, 65518, 327680, 2, -18, 65536, 0, -65554, 196608, 0, -131090, 327680, 3, -196626, 196608, 0, -262162, 131072, 8, -327698, 262144, 5, -393234, 327680, 5, -458770, 262144, 5, -524306, 131072, 0, -589842, 327680, 0, -655378, 262144, 5, 786413, 262144, 5, 720877, 65536, 0, 655341, 196608, 0, 589805, 196608, 10, 524269, 196608, 9, 458733, 262144, 9, 393197, 0, 4, 327661, 196608, 5, 262125, 196608, 0, 196589, 65536, 0, 131053, 0, 2, 65517, 196608, 9, -19, 262144, 5, -65555, 131072, 5, -131091, 327680, 2, -196627, 327680, 4, -262163, 131072, 8, -327699, 65536, 9, -393235, 0, 4, -458771, 0, 4, -524307, 0, 4, -589843, 327680, 3, -655379, 196608, 9, 786412, 65536, 7, 720876, 0, 3, 655340, 65536, 10, 589804, 0, 4, 524268, 0, 4, 458732, 262144, 9, 393196, 131072, 5, 327660, 327680, 1, 262124, 262144, 7, 196588, 65536, 9, 131052, 262144, 10, 65516, 0, 5, -20, 327680, 0, -65556, 327680, 0, -131092, 65536, 9, -196628, 196608, 7, -262164, 262144, 9, -327700, 0, 2, -393236, 196608, 8, -458772, 262144, 9, -524308, 262144, 7, -589844, 262144, 5, -655380, 196608, 8, -786413, 65536, 8, -786414, 131072, 0, -786415, 327680, 5, -786416, 327680, 2, -786417, 65536, 0, -786418, 65536, 8, -786419, 327680, 0, -786420, 0, 3, -786421, 327680, 5, -786422, 65536, 9, -786423, 65536, 7, -786424, 0, 3, -786425, 262144, 5, -786426, 196608, 8, -786427, 65536, 10, -786428, 131072, 8, -786429, 0, 1, -786430, 262144, 5, -786431, 65536, 10, -786432, 327680, 4, -720897, 262144, 8, -720898, 327680, 1, -720899, 196608, 9, -720900, 65536, 5, -720901, 262144, 9, -720902, 327680, 5, -720903, 196608, 0, -720904, 327680, 3, -720905, 327680, 2, -720906, 262144, 10, -720907, 262144, 10, -720908, 0, 2, -720909, 65536, 10, -720910, 262144, 7, -720911, 0, 2, -720912, 327680, 1, -720913, 0, 0, -720914, 131072, 9, -720915, 262144, 8, -720916, 65536, 0) [node name="GameCamera" parent="." instance=ExtResource("2_db5xs")] @@ -838,9 +833,6 @@ unique_name_in_owner = true [node name="Cursor" parent="." instance=ExtResource("5_g504x")] -[node name="Imp" parent="." instance=ExtResource("7_7od2n")] -position = Vector2(102, -21) - [node name="Walls" type="Node2D" parent="."] [node name="BottomBoundary" type="StaticBody2D" parent="Walls"] @@ -878,21 +870,11 @@ collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"] shape = SubResource("WorldBoundaryShape2D_htttx") -[node name="Spawner" parent="." node_paths=PackedStringArray("blocking_tracker") instance=ExtResource("7_kqc55")] -position = Vector2(-386, 162) -scene = ExtResource("6_j2kdp") -blocking_tracker = NodePath("Tracker") +[node name="Skull" parent="." instance=ExtResource("6_5k7gy")] +position = Vector2(2, 3) -[node name="TimerStddev" parent="Spawner" instance=ExtResource("9_8875b")] -autostart = true -mean_secs = 6.0 -min_secs = 3.0 -max_secs = 9.0 +[node name="Monocle" parent="." instance=ExtResource("7_lahut")] +position = Vector2(-56, 56) -[node name="Tracker" parent="Spawner" instance=ExtResource("10_bm07a")] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Spawner/Tracker"] -shape = SubResource("CircleShape2D_h5qsh") -debug_color = Color(0, 1, 0, 0.152941) - -[connection signal="timeout" from="Spawner/TimerStddev" to="Spawner" method="spawn"] +[node name="TopHat" parent="." instance=ExtResource("8_atoon")] +position = Vector2(56, -50) From 3a3340a18c962c135f43d65b5ff74030d1999b74 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 00:14:29 +0200 Subject: [PATCH 76/83] Add drag and drop sound to `Skull` --- NOTICE.md | 2 +- entities/{drop.wav => fall.wav} | 0 entities/{drop.wav.import => fall.wav.import} | 6 +++--- entities/skull.tscn | 12 +++++++++++- temp/bones.wav => entities/skull_drag.wav | 0 .../skull_drag.wav.import | 6 +++--- 6 files changed, 18 insertions(+), 8 deletions(-) rename entities/{drop.wav => fall.wav} (100%) rename entities/{drop.wav.import => fall.wav.import} (57%) rename temp/bones.wav => entities/skull_drag.wav (100%) rename temp/bones.wav.import => entities/skull_drag.wav.import (55%) diff --git a/NOTICE.md b/NOTICE.md index 7af921e..0ec74e5 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -13,7 +13,7 @@ This project uses the following external assets: | `./temp/puff.wav` | https://freesound.org/people/JustInvoke/sounds/446124/ | Attribution 4 | | `./temp/place.wav` | https://freesound.org/people/Planman/sounds/208111/ | CC0 | | `./temp/gore.wav` | https://freesound.org/people/MinecraftGamerLR/sounds/728695/ | Attribution 4 | -| `./temp/bones.wav` | https://freesound.org/people/cliftonmcarlson/sounds/392883/ | CC0 | +| `./entities/skull_pickup.wav` | https://freesound.org/people/cliftonmcarlson/sounds/392883/ | CC0 | | `./temp/metallic_whistle.wav` | https://freesound.org/people/furbyguy/sounds/365643/| Attribution 3| | `./temp/upgradeselect.wav` | https://freesound.org/people/TechspiredMinds/sounds/729216/| Attribution 4| | `./temp/upgrade.wav` | https://freesound.org/people/colorsCrimsonTears/sounds/607409/ | CC0 | diff --git a/entities/drop.wav b/entities/fall.wav similarity index 100% rename from entities/drop.wav rename to entities/fall.wav diff --git a/entities/drop.wav.import b/entities/fall.wav.import similarity index 57% rename from entities/drop.wav.import rename to entities/fall.wav.import index 08d956e..7d0b77e 100644 --- a/entities/drop.wav.import +++ b/entities/fall.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://buxgivpkh8dyl" -path="res://.godot/imported/drop.wav-e321e3ff0b5883beef3e60642ca137ca.sample" +path="res://.godot/imported/fall.wav-db08e68086e6fbfdfcb891d3b1804e1e.sample" [deps] -source_file="res://entities/drop.wav" -dest_files=["res://.godot/imported/drop.wav-e321e3ff0b5883beef3e60642ca137ca.sample"] +source_file="res://entities/fall.wav" +dest_files=["res://.godot/imported/fall.wav-db08e68086e6fbfdfcb891d3b1804e1e.sample"] [params] diff --git a/entities/skull.tscn b/entities/skull.tscn index 318604b..8cdf288 100644 --- a/entities/skull.tscn +++ b/entities/skull.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=7 format=3 uid="uid://b3gydtrenbw3n"] +[gd_scene load_steps=9 format=3 uid="uid://b3gydtrenbw3n"] [ext_resource type="Script" path="res://entities/skull.gd" id="1_7g8bu"] [ext_resource type="Texture2D" uid="uid://dwvvwjdexdywh" path="res://entities/skull.png" id="1_v6qk3"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="2_h0icd"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_83m1a"] +[ext_resource type="AudioStream" uid="uid://dq3xf4i2wpt50" path="res://entities/skull_drag.wav" id="5_duqrf"] +[ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/fall.wav" id="6_b7mxf"] [sub_resource type="CircleShape2D" id="CircleShape2D_ypibs"] radius = 12.0 @@ -32,12 +34,20 @@ collision_layer = 32 shape = SubResource("CircleShape2D_1c7gd") debug_color = Color(1, 1, 1, 0) +[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag/Draggable"] +stream = ExtResource("5_duqrf") + [node name="FallTimer" type="Timer" parent="MovementDrag"] wait_time = 0.5 one_shot = true +[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag/FallTimer"] +stream = ExtResource("6_b7mxf") + [connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] [connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] +[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag/Draggable/DragSound" method="play" unbinds=1] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] [connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] +[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag/FallTimer/FallSound" method="play"] diff --git a/temp/bones.wav b/entities/skull_drag.wav similarity index 100% rename from temp/bones.wav rename to entities/skull_drag.wav diff --git a/temp/bones.wav.import b/entities/skull_drag.wav.import similarity index 55% rename from temp/bones.wav.import rename to entities/skull_drag.wav.import index 8ba7e5d..cdd80ac 100644 --- a/temp/bones.wav.import +++ b/entities/skull_drag.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://dq3xf4i2wpt50" -path="res://.godot/imported/bones.wav-53a2d1735511ef1f1bf2921348b332aa.sample" +path="res://.godot/imported/skull_drag.wav-b4fa618d3799af68752c0db13a8d9e22.sample" [deps] -source_file="res://temp/bones.wav" -dest_files=["res://.godot/imported/bones.wav-53a2d1735511ef1f1bf2921348b332aa.sample"] +source_file="res://entities/skull_drag.wav" +dest_files=["res://.godot/imported/skull_drag.wav-b4fa618d3799af68752c0db13a8d9e22.sample"] [params] From c4775d327b563795c9773df19bd2dbe5c3e1286b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 00:56:35 +0200 Subject: [PATCH 77/83] Update physics and add some sounds --- NOTICE.md | 2 +- behaviours/move_physics.gd | 17 ++++++++++++----- entities/fall.ogg | 3 +++ entities/fall.ogg.import | 19 +++++++++++++++++++ entities/fall.wav | 3 --- entities/fall.wav.import | 24 ------------------------ entities/monocle.gd | 10 ++++++++++ entities/monocle.tscn | 22 +++++++++++++--------- entities/skull.gd | 10 ++++++++++ entities/skull.tscn | 26 +++++++++++--------------- entities/top_hat.gd | 10 ++++++++++ entities/top_hat.tscn | 21 +++++++++++++-------- scenes/game/cursor.tscn | 1 + 13 files changed, 103 insertions(+), 65 deletions(-) create mode 100644 entities/fall.ogg create mode 100644 entities/fall.ogg.import delete mode 100644 entities/fall.wav delete mode 100644 entities/fall.wav.import diff --git a/NOTICE.md b/NOTICE.md index 0ec74e5..a71ac59 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -10,7 +10,7 @@ This project uses the following external assets: | `./temp/click&pop.wav` | https://freesound.org/people/GammaGool/sounds/730488/ | CC0 | | `./temp/pop.wav` | https://freesound.org/people/NovaSoundTechnology/sounds/727104/ | CC0 | | `./temp/mouth_pop.wav` | https://freesound.org/people/igaopuromalte/sounds/725453/ | Attribution 4 | -| `./temp/puff.wav` | https://freesound.org/people/JustInvoke/sounds/446124/ | Attribution 4 | +| `./entities/fall.ogg` | https://freesound.org/people/JustInvoke/sounds/446124/ | Attribution 4 | | `./temp/place.wav` | https://freesound.org/people/Planman/sounds/208111/ | CC0 | | `./temp/gore.wav` | https://freesound.org/people/MinecraftGamerLR/sounds/728695/ | Attribution 4 | | `./entities/skull_pickup.wav` | https://freesound.org/people/cliftonmcarlson/sounds/392883/ | CC0 | diff --git a/behaviours/move_physics.gd b/behaviours/move_physics.gd index 7e51e39..bb8524a 100644 --- a/behaviours/move_physics.gd +++ b/behaviours/move_physics.gd @@ -7,15 +7,16 @@ signal dropped signal fallen -@export var acceleration = 650.0 -@export var linear_damp = 18.0 +@export var acceleration = 1250.0 +@export var drag_damp = 0.4 +@export var drop_damp = 0.05 +@export var drop_epsilon = 16.0 var cursor: Cursor = null +var falling: bool = false var velocity := Vector2.ZERO -@onready var ticks_per_second = ProjectSettings.get_setting("physics/common/physics_ticks_per_second") - func drag(value: Cursor) -> void: cursor = value @@ -23,10 +24,12 @@ func drag(value: Cursor) -> void: func drop() -> void: cursor = null + falling = true dropped.emit() func fall() -> void: velocity = Vector2.ZERO + falling = false fallen.emit() @@ -35,5 +38,9 @@ func _physics_process(delta: float) -> void: if cursor: var gap = cursor.global_position - global_position velocity += gap * delta * acceleration - velocity *= 1.0 - linear_damp / ticks_per_second + velocity *= 1.0 - drag_damp + else: + velocity *= 1.0 - drop_damp + if falling and velocity.length() < drop_epsilon: + fall() move.emit(velocity * delta) diff --git a/entities/fall.ogg b/entities/fall.ogg new file mode 100644 index 0000000..d0e149b --- /dev/null +++ b/entities/fall.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ceb2d1acdd2f606bc90bc5b578deec7f8987cc20a23b9e990c515be1dcc4f70 +size 10708 diff --git a/entities/fall.ogg.import b/entities/fall.ogg.import new file mode 100644 index 0000000..6caf55e --- /dev/null +++ b/entities/fall.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://cwsg776c11xfc" +path="res://.godot/imported/fall.ogg-ba2036bd4382e626c27cc3d1d5eb69f1.oggvorbisstr" + +[deps] + +source_file="res://entities/fall.ogg" +dest_files=["res://.godot/imported/fall.ogg-ba2036bd4382e626c27cc3d1d5eb69f1.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/entities/fall.wav b/entities/fall.wav deleted file mode 100644 index 2dbb33c..0000000 --- a/entities/fall.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:39d8e006f4e8c678841a95097425c2452545a19946f40fdf917ce3601baa0d48 -size 359148 diff --git a/entities/fall.wav.import b/entities/fall.wav.import deleted file mode 100644 index 7d0b77e..0000000 --- a/entities/fall.wav.import +++ /dev/null @@ -1,24 +0,0 @@ -[remap] - -importer="wav" -type="AudioStreamWAV" -uid="uid://buxgivpkh8dyl" -path="res://.godot/imported/fall.wav-db08e68086e6fbfdfcb891d3b1804e1e.sample" - -[deps] - -source_file="res://entities/fall.wav" -dest_files=["res://.godot/imported/fall.wav-db08e68086e6fbfdfcb891d3b1804e1e.sample"] - -[params] - -force/8_bit=false -force/mono=false -force/max_rate=false -force/max_rate_hz=44100 -edit/trim=false -edit/normalize=false -edit/loop_mode=0 -edit/loop_begin=0 -edit/loop_end=-1 -compress/mode=0 diff --git a/entities/monocle.gd b/entities/monocle.gd index f129c22..c7d507f 100644 --- a/entities/monocle.gd +++ b/entities/monocle.gd @@ -4,3 +4,13 @@ class_name Monocle func _on_move(movement: Vector2) -> void: move_and_collide(movement) + +func _on_dragged(_cursor: Cursor) -> void: + collision_layer = 16 + collision_mask = 18 + z_index = 1 + +func _on_fallen() -> void: + collision_layer = 8 + collision_mask = 14 + z_index = 0 diff --git a/entities/monocle.tscn b/entities/monocle.tscn index 89c27db..3de9b9d 100644 --- a/entities/monocle.tscn +++ b/entities/monocle.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://b04xhv32ypi42"] +[gd_scene load_steps=8 format=3 uid="uid://b04xhv32ypi42"] [ext_resource type="Script" path="res://entities/monocle.gd" id="1_ehpfj"] [ext_resource type="Texture2D" uid="uid://d3tb6ypb36v8e" path="res://entities/monocle.png" id="1_omrit"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="2_jgnsw"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_e0ni5"] +[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="5_grwug"] [sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] radius = 12.0 @@ -12,8 +13,9 @@ radius = 12.0 radius = 24.0 [node name="Monocle" type="CharacterBody2D"] -collision_layer = 32 -collision_mask = 38 +collision_layer = 8 +collision_mask = 14 +motion_mode = 1 script = ExtResource("1_ehpfj") [node name="Sprite" type="Sprite2D" parent="."] @@ -26,18 +28,20 @@ shape = SubResource("CircleShape2D_o7chm") [node name="MovementDrag" parent="." instance=ExtResource("2_jgnsw")] [node name="Draggable" parent="MovementDrag" instance=ExtResource("3_e0ni5")] -collision_layer = 32 [node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] shape = SubResource("CircleShape2D_juisb") debug_color = Color(1, 1, 1, 0) -[node name="FallTimer" type="Timer" parent="MovementDrag"] -wait_time = 0.5 -one_shot = true +[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] -[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] +[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("5_grwug") + +[connection signal="dragged" from="MovementDrag" to="." method="_on_dragged"] +[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1] +[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"] +[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"] [connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] -[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] diff --git a/entities/skull.gd b/entities/skull.gd index 2f6a16a..9fcbdc6 100644 --- a/entities/skull.gd +++ b/entities/skull.gd @@ -4,3 +4,13 @@ class_name Skull func _on_move(movement: Vector2) -> void: move_and_collide(movement) + +func _on_dragged(_cursor: Cursor) -> void: + collision_layer = 16 + collision_mask = 18 + z_index = 1 + +func _on_fallen() -> void: + collision_layer = 8 + collision_mask = 14 + z_index = 0 diff --git a/entities/skull.tscn b/entities/skull.tscn index 8cdf288..d879aea 100644 --- a/entities/skull.tscn +++ b/entities/skull.tscn @@ -5,7 +5,7 @@ [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="2_h0icd"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_83m1a"] [ext_resource type="AudioStream" uid="uid://dq3xf4i2wpt50" path="res://entities/skull_drag.wav" id="5_duqrf"] -[ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/fall.wav" id="6_b7mxf"] +[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="6_7yx26"] [sub_resource type="CircleShape2D" id="CircleShape2D_ypibs"] radius = 12.0 @@ -14,8 +14,9 @@ radius = 12.0 radius = 24.0 [node name="Skull" type="CharacterBody2D"] -collision_layer = 32 -collision_mask = 38 +collision_layer = 8 +collision_mask = 14 +motion_mode = 1 script = ExtResource("1_7g8bu") [node name="Sprite" type="Sprite2D" parent="."] @@ -28,26 +29,21 @@ shape = SubResource("CircleShape2D_ypibs") [node name="MovementDrag" parent="." instance=ExtResource("3_83m1a")] [node name="Draggable" parent="MovementDrag" instance=ExtResource("2_h0icd")] -collision_layer = 32 [node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] shape = SubResource("CircleShape2D_1c7gd") debug_color = Color(1, 1, 1, 0) -[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag/Draggable"] +[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] stream = ExtResource("5_duqrf") -[node name="FallTimer" type="Timer" parent="MovementDrag"] -wait_time = 0.5 -one_shot = true +[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("6_7yx26") -[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag/FallTimer"] -stream = ExtResource("6_b7mxf") - -[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] +[connection signal="dragged" from="MovementDrag" to="." method="_on_dragged"] +[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1] +[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"] +[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"] [connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] -[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag/Draggable/DragSound" method="play" unbinds=1] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] -[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] -[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag/FallTimer/FallSound" method="play"] diff --git a/entities/top_hat.gd b/entities/top_hat.gd index 407bacc..1c66e29 100644 --- a/entities/top_hat.gd +++ b/entities/top_hat.gd @@ -4,3 +4,13 @@ class_name TopHat func _on_move(movement: Vector2) -> void: move_and_collide(movement) + +func _on_dragged(_cursor: Cursor) -> void: + collision_layer = 16 + collision_mask = 18 + z_index = 1 + +func _on_fallen() -> void: + collision_layer = 8 + collision_mask = 14 + z_index = 0 diff --git a/entities/top_hat.tscn b/entities/top_hat.tscn index 03a626e..30601a8 100644 --- a/entities/top_hat.tscn +++ b/entities/top_hat.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://8ejgwtkpaa44"] +[gd_scene load_steps=8 format=3 uid="uid://8ejgwtkpaa44"] [ext_resource type="Script" path="res://entities/top_hat.gd" id="1_0eh11"] [ext_resource type="Texture2D" uid="uid://deqvgvf66grr4" path="res://entities/top_hat.png" id="1_gbqic"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_gy414"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="4_fcvjo"] +[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="6_6tpnh"] [sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] radius = 12.0 @@ -12,8 +13,9 @@ radius = 12.0 radius = 24.0 [node name="TopHat" type="CharacterBody2D"] -collision_layer = 32 -collision_mask = 38 +collision_layer = 8 +collision_mask = 14 +motion_mode = 1 script = ExtResource("1_0eh11") [node name="Sprite" type="Sprite2D" parent="."] @@ -32,12 +34,15 @@ collision_layer = 32 shape = SubResource("CircleShape2D_juisb") debug_color = Color(1, 1, 1, 0) -[node name="FallTimer" type="Timer" parent="MovementDrag"] -wait_time = 0.5 -one_shot = true +[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] -[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] +[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("6_6tpnh") + +[connection signal="dragged" from="MovementDrag" to="." method="_on_dragged"] +[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1] +[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"] +[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"] [connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] -[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"] diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 53c56f9..a85fb27 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -6,6 +6,7 @@ radius = 4.0 [node name="Cursor" type="Area2D" groups=["cursor"]] +z_index = 100 collision_layer = 64 collision_mask = 40 script = ExtResource("1_1og6v") From dbbc2f21509f59481a5220dfb108567943ea0516 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 00:59:27 +0200 Subject: [PATCH 78/83] Fix `Imp`'s physics --- entities/imp.tscn | 2 -- 1 file changed, 2 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index d097666..9945124 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -90,8 +90,6 @@ debug_color = Color(1, 0.498039, 0, 0) 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")] From a12b46e64c41324e97a5cda35a84673a9d6f6c77 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 01:00:14 +0200 Subject: [PATCH 79/83] Get rid of `FallTimer`s --- entities/imp.tscn | 6 ------ entities/sheep.tscn | 6 ------ 2 files changed, 12 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index 9945124..70e2a7a 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -101,10 +101,6 @@ alternative_priority = 50 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"]) @@ -126,7 +122,6 @@ debug_color = Color(1, 0, 0, 0) [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"] @@ -134,5 +129,4 @@ debug_color = Color(1, 0, 0, 0) [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"] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 285e785..e9c22d9 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -176,10 +176,6 @@ scale = Vector2(3, 3) shape = SubResource("CircleShape2D_c5tcn") debug_color = Color(1, 1, 1, 0) -[node name="FallTimer" type="Timer" parent="MovementDrag"] -wait_time = 0.5 -one_shot = true - [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"] @@ -206,7 +202,6 @@ one_shot = true [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="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="move_enabled" from="MovementDrag" to="MovementWander" method="clear_direction"] @@ -215,4 +210,3 @@ one_shot = true [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"] From 267682d28c29f25a36d5de18e43ebb40ab7099ee Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 01:05:21 +0200 Subject: [PATCH 80/83] Tweak physics again a bit --- entities/imp.gd | 5 ++--- entities/imp.tscn | 16 +++++++++++++--- entities/monocle.tscn | 2 +- entities/sheep.gd | 5 ++--- entities/sheep.tscn | 16 +++++++++++++--- entities/skull.tscn | 2 +- entities/top_hat.tscn | 2 +- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/entities/imp.gd b/entities/imp.gd index b269e7d..b5fb24e 100644 --- a/entities/imp.gd +++ b/entities/imp.gd @@ -13,14 +13,13 @@ func _on_move(movement: Vector2): func _on_eater_eaten(edible: Edible) -> void: edible.get_parent().queue_free() - -func _on_draggable_dragged(_cursor: Cursor) -> void: +func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 collision_mask = 18 z_index = 1 eater.collision_mask = 16 -func _on_draggable_dropped() -> void: +func _on_fallen() -> void: collision_layer = 8 collision_mask = 14 z_index = 0 diff --git a/entities/imp.tscn b/entities/imp.tscn index 70e2a7a..299010d 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://4d3ksr3171x4"] +[gd_scene load_steps=23 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"] @@ -16,6 +16,8 @@ [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"] +[ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="16_0nbhd"] +[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="17_lib0h"] [sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"] radius = 32.0 @@ -101,6 +103,12 @@ alternative_priority = 50 shape = SubResource("CircleShape2D_50iad") debug_color = Color(1, 1, 1, 0) +[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("16_0nbhd") + +[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("17_lib0h") + [node name="Eater" parent="." instance=ExtResource("14_w2h8x")] acceptable_diets = Array[StringName]([&"Meat"]) @@ -121,12 +129,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="." method="_on_dragged"] [connection signal="dragged" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_alternative" unbinds=1] +[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1] +[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"] [connection signal="fallen" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_default"] +[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"] [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="eaten" from="Eater" to="." method="_on_eater_eaten"] diff --git a/entities/monocle.tscn b/entities/monocle.tscn index 3de9b9d..d430b42 100644 --- a/entities/monocle.tscn +++ b/entities/monocle.tscn @@ -10,7 +10,7 @@ radius = 12.0 [sub_resource type="CircleShape2D" id="CircleShape2D_juisb"] -radius = 24.0 +radius = 12.0 [node name="Monocle" type="CharacterBody2D"] collision_layer = 8 diff --git a/entities/sheep.gd b/entities/sheep.gd index 68aa731..e28982c 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -13,13 +13,12 @@ func _on_move(movement: Vector2) -> void: move_and_collide(movement) sprite.handle_move(movement) - -func _on_draggable_dragged(_cursor: Cursor) -> void: +func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 collision_mask = 18 z_index = 1 -func _on_draggable_dropped() -> void: +func _on_fallen() -> void: collision_layer = 8 collision_mask = 14 z_index = 0 diff --git a/entities/sheep.tscn b/entities/sheep.tscn index e9c22d9..b07e995 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=24 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"] @@ -15,6 +15,8 @@ [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="14_0b1hs"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="14_3wojv"] [ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] +[ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="16_nswfl"] +[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="17_8kst2"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] radius = 8.0 @@ -176,6 +178,12 @@ scale = Vector2(3, 3) shape = SubResource("CircleShape2D_c5tcn") debug_color = Color(1, 1, 1, 0) +[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("16_nswfl") + +[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("17_8kst2") + [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"] @@ -201,12 +209,14 @@ debug_color = Color(1, 1, 1, 0) [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="MovementDrag" to="." method="_on_dragged"] [connection signal="dragged" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_alternative" unbinds=1] +[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1] +[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"] [connection signal="fallen" from="MovementDrag" to="MovementDrag/DragPriority" method="priority_default"] +[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"] [connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="move_enabled" from="MovementDrag" to="MovementWander" method="clear_direction"] [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"] diff --git a/entities/skull.tscn b/entities/skull.tscn index d879aea..e7d68a9 100644 --- a/entities/skull.tscn +++ b/entities/skull.tscn @@ -11,7 +11,7 @@ radius = 12.0 [sub_resource type="CircleShape2D" id="CircleShape2D_1c7gd"] -radius = 24.0 +radius = 12.0 [node name="Skull" type="CharacterBody2D"] collision_layer = 8 diff --git a/entities/top_hat.tscn b/entities/top_hat.tscn index 30601a8..05bd86f 100644 --- a/entities/top_hat.tscn +++ b/entities/top_hat.tscn @@ -10,7 +10,7 @@ radius = 12.0 [sub_resource type="CircleShape2D" id="CircleShape2D_juisb"] -radius = 24.0 +radius = 12.0 [node name="TopHat" type="CharacterBody2D"] collision_layer = 8 From e1bcfcb82883369fbf15cb1f776105afb99a7806 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 01:11:22 +0200 Subject: [PATCH 81/83] Create a `MainGame` with everything in it --- scenes/game/main_game.tscn | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index e1c11ea..18bbdd9 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=14 format=3 uid="uid://cxj5aud02f40j"] [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"] @@ -8,6 +8,8 @@ [ext_resource type="PackedScene" uid="uid://b3gydtrenbw3n" path="res://entities/skull.tscn" id="6_5k7gy"] [ext_resource type="PackedScene" uid="uid://b04xhv32ypi42" path="res://entities/monocle.tscn" id="7_lahut"] [ext_resource type="PackedScene" uid="uid://8ejgwtkpaa44" path="res://entities/top_hat.tscn" id="8_atoon"] +[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="9_qrqqu"] +[ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="10_yw228"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -828,9 +830,6 @@ layer_0/tile_data = PackedInt32Array(720915, 196608, 9, 655379, 65536, 10, 58984 [node name="GameCamera" parent="." instance=ExtResource("2_db5xs")] -[node name="DefaultSpawnParent" type="Node2D" parent="."] -unique_name_in_owner = true - [node name="Cursor" parent="." instance=ExtResource("5_g504x")] [node name="Walls" type="Node2D" parent="."] @@ -870,6 +869,9 @@ collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"] shape = SubResource("WorldBoundaryShape2D_htttx") +[node name="DefaultSpawnParent" type="Node2D" parent="."] +unique_name_in_owner = true + [node name="Skull" parent="." instance=ExtResource("6_5k7gy")] position = Vector2(2, 3) @@ -878,3 +880,27 @@ position = Vector2(-56, 56) [node name="TopHat" parent="." instance=ExtResource("8_atoon")] position = Vector2(56, -50) + +[node name="Sheep" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-310, 166) + +[node name="Imp" parent="." instance=ExtResource("10_yw228")] +position = Vector2(393, -137) + +[node name="Sheep2" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-415, 202) + +[node name="Sheep3" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-386, 112) + +[node name="Sheep4" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-314, 261) + +[node name="Sheep5" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-211, 241) + +[node name="Sheep6" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-491, 137) + +[node name="Sheep7" parent="." instance=ExtResource("9_qrqqu")] +position = Vector2(-177, 154) From c48273bd6e5e666534ba9d1d32360765c1ac7b1c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 01:21:19 +0200 Subject: [PATCH 82/83] Add a couple more sounds --- NOTICE.md | 6 ++--- entities/imp.tscn | 11 ++++++--- temp/tank.wav => entities/imp_drag.wav | 0 .../imp_drag.wav.import | 6 ++--- entities/imp_eat.ogg | 3 +++ entities/imp_eat.ogg.import | 19 +++++++++++++++ entities/monocle.tscn | 4 +++- temp/pop.wav => entities/monocle_drag.wav | 0 .../monocle_drag.wav.import | 6 ++--- temp/gore.wav | 3 --- temp/gore.wav.import | 24 ------------------- 11 files changed, 42 insertions(+), 40 deletions(-) rename temp/tank.wav => entities/imp_drag.wav (100%) rename temp/tank.wav.import => entities/imp_drag.wav.import (56%) create mode 100644 entities/imp_eat.ogg create mode 100644 entities/imp_eat.ogg.import rename temp/pop.wav => entities/monocle_drag.wav (100%) rename temp/pop.wav.import => entities/monocle_drag.wav.import (55%) delete mode 100644 temp/gore.wav delete mode 100644 temp/gore.wav.import diff --git a/NOTICE.md b/NOTICE.md index a71ac59..73872be 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -8,11 +8,11 @@ This project uses the following external assets: | `./temp/tollbell.mp3` | https://freesound.org/people/sdroliasnick/sounds/731270/ | CC0 | | `./entities/sheep_drag.wav` | https://freesound.org/people/michaelperfect/sounds/710298/ | CC0 | | `./temp/click&pop.wav` | https://freesound.org/people/GammaGool/sounds/730488/ | CC0 | -| `./temp/pop.wav` | https://freesound.org/people/NovaSoundTechnology/sounds/727104/ | CC0 | +| `./entities/monocle_drag.wav` | https://freesound.org/people/NovaSoundTechnology/sounds/727104/ | CC0 | | `./temp/mouth_pop.wav` | https://freesound.org/people/igaopuromalte/sounds/725453/ | Attribution 4 | | `./entities/fall.ogg` | https://freesound.org/people/JustInvoke/sounds/446124/ | Attribution 4 | | `./temp/place.wav` | https://freesound.org/people/Planman/sounds/208111/ | CC0 | -| `./temp/gore.wav` | https://freesound.org/people/MinecraftGamerLR/sounds/728695/ | Attribution 4 | +| `./entities/imp_eat.ogg` | https://freesound.org/people/MinecraftGamerLR/sounds/728695/ | Attribution 4 | | `./entities/skull_pickup.wav` | https://freesound.org/people/cliftonmcarlson/sounds/392883/ | CC0 | | `./temp/metallic_whistle.wav` | https://freesound.org/people/furbyguy/sounds/365643/| Attribution 3| | `./temp/upgradeselect.wav` | https://freesound.org/people/TechspiredMinds/sounds/729216/| Attribution 4| @@ -22,7 +22,7 @@ This project uses the following external assets: | `./temp/arcade_cancel.flac` | https://freesound.org/people/plasterbrain/sounds/464912/ | CC0 | | `./temp/cancel.wav` | https://freesound.org/people/Kagateni/sounds/571510/ | CC0 | | `./temp/monster_bite.wav` | https://freesound.org/people/OGsoundFX/sounds/423010/ | Attribution 4 | -| `./temp/tank.wav` | https://freesound.org/people/JarredGibb/sounds/217273/ | CC0 | +| `./entities/imp_drag.wav` | https://freesound.org/people/JarredGibb/sounds/217273/ | CC0 | | `./temp/demon_dying.wav` | https://freesound.org/people/THE_bizniss/sounds/37823/ | Attribution 3 | | `./entities/coin.ogg` | https://freesound.org/people/forrisday/sounds/214509/ | Attribution 4 | | `./behaviours/*.svg` | https://fontawesome.com/ | CC-BY 4.0 | diff --git a/entities/imp.tscn b/entities/imp.tscn index 299010d..e58fc3e 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=3 uid="uid://4d3ksr3171x4"] +[gd_scene load_steps=24 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"] @@ -16,8 +16,9 @@ [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"] -[ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="16_0nbhd"] +[ext_resource type="AudioStream" uid="uid://d0feiq5s6fnux" path="res://entities/imp_drag.wav" id="16_0frai"] [ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="17_lib0h"] +[ext_resource type="AudioStream" uid="uid://c1yuksnjdd6g2" path="res://entities/imp_eat.ogg" id="19_7la6c"] [sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"] radius = 32.0 @@ -104,7 +105,7 @@ shape = SubResource("CircleShape2D_50iad") debug_color = Color(1, 1, 1, 0) [node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] -stream = ExtResource("16_0nbhd") +stream = ExtResource("16_0frai") [node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] stream = ExtResource("17_lib0h") @@ -116,6 +117,9 @@ acceptable_diets = Array[StringName]([&"Meat"]) shape = SubResource("CircleShape2D_qhk1q") debug_color = Color(1, 0, 0, 0) +[node name="EatSound" type="AudioStreamPlayer2D" parent="Eater"] +stream = ExtResource("19_7la6c") + [connection signal="timeout" from="GoldSpawner/TimerStddev" to="GoldSpawner" method="spawn"] [connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"] [connection signal="changed_direction" from="MovementWander" to="MovementWander/WanderPriority" method="priority_conditional"] @@ -140,3 +144,4 @@ debug_color = Color(1, 0, 0, 0) [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] [connection signal="eaten" from="Eater" to="." method="_on_eater_eaten"] +[connection signal="eaten" from="Eater" to="Eater/EatSound" method="play" unbinds=1] diff --git a/temp/tank.wav b/entities/imp_drag.wav similarity index 100% rename from temp/tank.wav rename to entities/imp_drag.wav diff --git a/temp/tank.wav.import b/entities/imp_drag.wav.import similarity index 56% rename from temp/tank.wav.import rename to entities/imp_drag.wav.import index 824282a..8b66524 100644 --- a/temp/tank.wav.import +++ b/entities/imp_drag.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://d0feiq5s6fnux" -path="res://.godot/imported/tank.wav-76da0daecf3b365c21fcd97289993799.sample" +path="res://.godot/imported/imp_drag.wav-e4ed42c6f5f4ccfe6d180bc00d8af7df.sample" [deps] -source_file="res://temp/tank.wav" -dest_files=["res://.godot/imported/tank.wav-76da0daecf3b365c21fcd97289993799.sample"] +source_file="res://entities/imp_drag.wav" +dest_files=["res://.godot/imported/imp_drag.wav-e4ed42c6f5f4ccfe6d180bc00d8af7df.sample"] [params] diff --git a/entities/imp_eat.ogg b/entities/imp_eat.ogg new file mode 100644 index 0000000..63f7d70 --- /dev/null +++ b/entities/imp_eat.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7804f60b616a01fa2dc07371af00f1b15f726bd0fcb5be456b39c39b81497ea3 +size 16127 diff --git a/entities/imp_eat.ogg.import b/entities/imp_eat.ogg.import new file mode 100644 index 0000000..362c0af --- /dev/null +++ b/entities/imp_eat.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://c1yuksnjdd6g2" +path="res://.godot/imported/imp_eat.ogg-8244e5ac229d57fa0fbf148a2e9862db.oggvorbisstr" + +[deps] + +source_file="res://entities/imp_eat.ogg" +dest_files=["res://.godot/imported/imp_eat.ogg-8244e5ac229d57fa0fbf148a2e9862db.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/entities/monocle.tscn b/entities/monocle.tscn index d430b42..8eb8379 100644 --- a/entities/monocle.tscn +++ b/entities/monocle.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=8 format=3 uid="uid://b04xhv32ypi42"] +[gd_scene load_steps=9 format=3 uid="uid://b04xhv32ypi42"] [ext_resource type="Script" path="res://entities/monocle.gd" id="1_ehpfj"] [ext_resource type="Texture2D" uid="uid://d3tb6ypb36v8e" path="res://entities/monocle.png" id="1_omrit"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="2_jgnsw"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_e0ni5"] +[ext_resource type="AudioStream" uid="uid://dgd1ldpffk6ql" path="res://entities/monocle_drag.wav" id="5_bs8m7"] [ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="5_grwug"] [sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] @@ -34,6 +35,7 @@ shape = SubResource("CircleShape2D_juisb") debug_color = Color(1, 1, 1, 0) [node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"] +stream = ExtResource("5_bs8m7") [node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"] stream = ExtResource("5_grwug") diff --git a/temp/pop.wav b/entities/monocle_drag.wav similarity index 100% rename from temp/pop.wav rename to entities/monocle_drag.wav diff --git a/temp/pop.wav.import b/entities/monocle_drag.wav.import similarity index 55% rename from temp/pop.wav.import rename to entities/monocle_drag.wav.import index 82ce6ca..6e59e39 100644 --- a/temp/pop.wav.import +++ b/entities/monocle_drag.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://dgd1ldpffk6ql" -path="res://.godot/imported/pop.wav-5c8ab1a460889e6b7e24366eae5d4a3a.sample" +path="res://.godot/imported/monocle_drag.wav-d899e772e1792f41cd5a6ddac30bd2f6.sample" [deps] -source_file="res://temp/pop.wav" -dest_files=["res://.godot/imported/pop.wav-5c8ab1a460889e6b7e24366eae5d4a3a.sample"] +source_file="res://entities/monocle_drag.wav" +dest_files=["res://.godot/imported/monocle_drag.wav-d899e772e1792f41cd5a6ddac30bd2f6.sample"] [params] diff --git a/temp/gore.wav b/temp/gore.wav deleted file mode 100644 index 681e56b..0000000 --- a/temp/gore.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:263e85a80630a5123045cdfed923a51248471fdf07f558383e2dff5b709cbd82 -size 966522 diff --git a/temp/gore.wav.import b/temp/gore.wav.import deleted file mode 100644 index 59719b5..0000000 --- a/temp/gore.wav.import +++ /dev/null @@ -1,24 +0,0 @@ -[remap] - -importer="wav" -type="AudioStreamWAV" -uid="uid://dlp0oo8tbp3w1" -path="res://.godot/imported/gore.wav-c74757bf12b5b41aaaf2eb9a0f1110a0.sample" - -[deps] - -source_file="res://temp/gore.wav" -dest_files=["res://.godot/imported/gore.wav-c74757bf12b5b41aaaf2eb9a0f1110a0.sample"] - -[params] - -force/8_bit=false -force/mono=false -force/max_rate=false -force/max_rate_hz=44100 -edit/trim=false -edit/normalize=false -edit/loop_mode=0 -edit/loop_begin=0 -edit/loop_end=-1 -compress/mode=0 From c325d9970f531bf5556c46a609615d1e21c95b5c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Apr 2024 01:21:50 +0200 Subject: [PATCH 83/83] Delete the now-unused `CursorMagnet` --- scenes/game/cursor_magnet.gd | 54 ------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 scenes/game/cursor_magnet.gd diff --git a/scenes/game/cursor_magnet.gd b/scenes/game/cursor_magnet.gd deleted file mode 100644 index 1f71ec9..0000000 --- a/scenes/game/cursor_magnet.gd +++ /dev/null @@ -1,54 +0,0 @@ -extends Area2D -class_name CursorMagnet - - -signal dragged(node: Draggable) -signal dropped(node: Draggable) - - -func find_closest_target() -> Draggable: - var bodies = get_overlapping_bodies() - var min_distance: float = INF - var to_drag: Node = null - for body in bodies: - for target in body.find_children("Draggable", "Draggable", false, false): - var distance = position.distance_to(target.position) - if distance < min_distance: - min_distance = distance - to_drag = target - return to_drag - - -var dragging: Draggable = null - -func drag(): - var target = find_closest_target() - if target: - dragging = target - target.drag() - dragged.emit(target) - -func drop(): - if dragging: - var target = dragging - dragging = null - target.drop() - dropped.emit(target) - - -func _input(event: InputEvent) -> void: - if event is InputEventMouseButton: - if event.button_index == MOUSE_BUTTON_LEFT: - if event.pressed: - drag() - else: - drop() - -func _on_dragged(node: Draggable) -> void: - Log.p(self, "Dragged: %s" % node) - -func _on_dropped(node: Draggable) -> void: - Log.p(self, "Dropped: %s" % node) - -func _on_move(movement: Vector2) -> void: - position += movement