From d725b79f4e40e17a688d90f32e98a82a5e00350b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 18:46:09 +0200 Subject: [PATCH] Prevent spawning during a purchase --- game/game.gd | 3 +++ spawner/spawner.gd | 2 ++ 2 files changed, 5 insertions(+) diff --git a/game/game.gd b/game/game.gd index 6465c77..7d03387 100644 --- a/game/game.gd +++ b/game/game.gd @@ -41,6 +41,7 @@ func _on_purchase_begin(what: PurchasableItem): store_collector_panel.show() ghost.process_mode = Node.PROCESS_MODE_INHERIT ghost.show() + time_spawner_timer.stop() func _handle_purchase_success(what: PurchasableItem): what.complete_purchase() @@ -52,6 +53,7 @@ func _on_purchase_cancel(what: PurchasableItem): store_collector_panel.hide() ghost.process_mode = Node.PROCESS_MODE_DISABLED ghost.hide() + time_spawner_timer.start() func _on_purchase_success(what: PurchasableItem): print("[Game] Succedeed purchase of ", what.name, " costing ", what.item_cost_goal, "x ", what.item_cost_type) @@ -60,6 +62,7 @@ func _on_purchase_success(what: PurchasableItem): store_collector_panel.hide() ghost.process_mode = Node.PROCESS_MODE_DISABLED ghost.hide() + time_spawner_timer.start() func _on_store_collector_collected(_body: RigidBody2D): update_counter_text() diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 9a2ca0a..08aba7a 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -52,6 +52,8 @@ func _do_spawn(): var overlapping_bodies = get_overlapping_bodies() if len(overlapping_bodies) > overlapping_body_count_limit: return + if scene == null: + return var instantiated = scene.instantiate() instantiated.global_position = global_position + _select_spawn_position() instantiated.rotation_degrees = _select_spawn_rotation()