From bd7e67e6b0a503b7ed9d4a15abcd55148f807ab8 Mon Sep 17 00:00:00 2001 From: teatov Date: Mon, 21 Oct 2024 23:13:49 +1000 Subject: [PATCH] fix gathering state mess --- project.godot | 4 ++++ scripts/units/components/gathering.gd | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/project.godot b/project.godot index 8ed8754..d4238e1 100644 --- a/project.godot +++ b/project.godot @@ -50,6 +50,10 @@ window/stretch/aspect="expand" mouse_cursor/custom_image="res://assets/textures/gui/cursor.png" mouse_cursor/custom_image_hotspot=Vector2(32, 32) +[editor] + +movie_writer/movie_file="E:/Projects/Games/tli/build/recording.avi" + [filesystem] import/fbx2gltf/enabled=false diff --git a/scripts/units/components/gathering.gd b/scripts/units/components/gathering.gd index 81eda89..3f1d470 100644 --- a/scripts/units/components/gathering.gd +++ b/scripts/units/components/gathering.gd @@ -149,6 +149,10 @@ func _pick_up() -> void: _unit.animation_playback.travel("plop_down") await get_tree().create_timer(_pickup_interval).timeout + + if state == State.STOP: + return + var nearest := _find_nearest(_nearby_items.values()) if _carrying_items.size() == _max_carrying or nearest == null: _go_deposit() @@ -158,7 +162,6 @@ func _pick_up() -> void: func _deposit() -> void: - await get_tree().create_timer(0.5).timeout while _carrying_items.size() > 0: if state != State.DEPOSITING: return @@ -182,6 +185,9 @@ func _deposit() -> void: _unit.anthill.deposit_honeydew(1) await get_tree().create_timer(_drop_interval).timeout + if state == State.STOP: + return + var nearest := _find_nearest(_nearby_items.values()) if nearest == null: state = State.WAITING_FOR_NEW_ITEMS