1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-21 23:34:18 +00:00

Prevent spawning during a purchase

This commit is contained in:
Steffo 2023-10-02 18:46:09 +02:00
parent 233627ad71
commit d725b79f4e
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 5 additions and 0 deletions

View file

@ -41,6 +41,7 @@ func _on_purchase_begin(what: PurchasableItem):
store_collector_panel.show() store_collector_panel.show()
ghost.process_mode = Node.PROCESS_MODE_INHERIT ghost.process_mode = Node.PROCESS_MODE_INHERIT
ghost.show() ghost.show()
time_spawner_timer.stop()
func _handle_purchase_success(what: PurchasableItem): func _handle_purchase_success(what: PurchasableItem):
what.complete_purchase() what.complete_purchase()
@ -52,6 +53,7 @@ func _on_purchase_cancel(what: PurchasableItem):
store_collector_panel.hide() store_collector_panel.hide()
ghost.process_mode = Node.PROCESS_MODE_DISABLED ghost.process_mode = Node.PROCESS_MODE_DISABLED
ghost.hide() ghost.hide()
time_spawner_timer.start()
func _on_purchase_success(what: PurchasableItem): func _on_purchase_success(what: PurchasableItem):
print("[Game] Succedeed purchase of ", what.name, " costing ", what.item_cost_goal, "x ", what.item_cost_type) 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() store_collector_panel.hide()
ghost.process_mode = Node.PROCESS_MODE_DISABLED ghost.process_mode = Node.PROCESS_MODE_DISABLED
ghost.hide() ghost.hide()
time_spawner_timer.start()
func _on_store_collector_collected(_body: RigidBody2D): func _on_store_collector_collected(_body: RigidBody2D):
update_counter_text() update_counter_text()

View file

@ -52,6 +52,8 @@ func _do_spawn():
var overlapping_bodies = get_overlapping_bodies() var overlapping_bodies = get_overlapping_bodies()
if len(overlapping_bodies) > overlapping_body_count_limit: if len(overlapping_bodies) > overlapping_body_count_limit:
return return
if scene == null:
return
var instantiated = scene.instantiate() var instantiated = scene.instantiate()
instantiated.global_position = global_position + _select_spawn_position() instantiated.global_position = global_position + _select_spawn_position()
instantiated.rotation_degrees = _select_spawn_rotation() instantiated.rotation_degrees = _select_spawn_rotation()