Fix: disable ESCGame inputs until signal room_ready is emitted (#582)

* Fix: disable ESCGame inputs until signal room_ready is emitted
* fix: add a new function to use in _input() to check for inputs

* Apply suggestions from code review
Co-authored-by: balloonpopper <5151242+balloonpopper@users.noreply.github.com>
Co-authored-by: Duncan Brown <duncan@prometheussoftware.ca>
This commit is contained in:
Julian Murgia
2022-04-30 20:10:14 +02:00
committed by GitHub
parent 0414833c6d
commit 8a58aa7efc
4 changed files with 32 additions and 5 deletions

View File

@@ -38,6 +38,11 @@ export(NodePath) var ui_parent_control_node
# A reference to the node handling tooltips
var tooltip_node: Object
# Boolean indicating whether the game scene is ready to accept inputs
# from the player. This enables using escoria.is_ready_for_inputs() in _input()
# function of game.gd script.
var room_ready_for_inputs: bool = false
# Function called when ESCGame enters the scene tree.
func _enter_tree():
@@ -51,6 +56,12 @@ func _enter_tree():
self,
"_on_action_finished"
)
escoria.main.connect(
"room_ready",
self,
"_on_room_ready"
)
# Function called when ESCGame exits the scene tree.
@@ -447,3 +458,8 @@ func escoria_show_ui():
"esc_game.gd#escoria_show_ui",
["UI parent Control node not defined!"]
)
# Manage signal room_deady from main.gd.
func _on_room_ready():
room_ready_for_inputs = true