add emit_player_key_change on ready and add extra checks for empty _current_key
This commit is contained in:
parent
7966e2073c
commit
c5c0f50aad
@ -96,13 +96,13 @@ static func sort_func(a: GameKey, b: GameKey) -> bool:
|
||||
|
||||
#region builtins
|
||||
func _ready() -> void:
|
||||
_adjacency_light.visible = false
|
||||
_keyboard.layout_size_changed.connect(_on_keyboard_layout_size_changed)
|
||||
_keyboard.keys_requested.connect(_on_keyboard_keys_requested)
|
||||
_keyboard.is_configuring_changed.connect(_on_keyboard_is_configuring_changed)
|
||||
_keyboard.player_key_changed.connect(_on_keyboard_player_key_changed)
|
||||
_keyboard.player_finished_move.connect(_on_keyboard_player_finished_move)
|
||||
_set_labels()
|
||||
_adjacency_light.visible = false
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
||||
@ -26,6 +26,7 @@ func _ready() -> void:
|
||||
_current_key = _keyboard.request_key_by_keycode(_starting_keycode)
|
||||
if _current_key:
|
||||
global_transform = _current_key.player_pos_marker.global_transform
|
||||
_keyboard.emit_player_key_change(_current_key)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@ -100,7 +101,11 @@ func _finish_move(_interrupted: bool) -> void:
|
||||
|
||||
#region event handlers
|
||||
func _on_keyboard_key_press_changed(game_key: GameKey, event: InputEventKey) -> void:
|
||||
if event.is_pressed() and KeyAdjacency.is_adjacent(_current_key, game_key):
|
||||
if (
|
||||
event.is_pressed()
|
||||
and _current_key
|
||||
and KeyAdjacency.is_adjacent(_current_key, game_key)
|
||||
):
|
||||
_move(game_key)
|
||||
|
||||
#endregion
|
||||
|
||||
Loading…
Reference in New Issue
Block a user