From 13567e5dd36ede41c4e9eb87a393054d5e02eea8 Mon Sep 17 00:00:00 2001 From: JonShard Date: Sat, 25 Jul 2026 20:48:36 +0200 Subject: [PATCH] Add global key events to close game --- Stations/table.gd | 30 +++++--- Stations/table.tscn | 3 +- global_key_events.gd | 20 +++++ global_key_events.gd.uid | 1 + openxr_action_map.tres | 154 +-------------------------------------- project.godot | 18 ++++- recipes.yaml.uid | 1 - 7 files changed, 60 insertions(+), 167 deletions(-) create mode 100644 global_key_events.gd create mode 100644 global_key_events.gd.uid delete mode 100644 recipes.yaml.uid diff --git a/Stations/table.gd b/Stations/table.gd index 7d39d1d..827b586 100644 --- a/Stations/table.gd +++ b/Stations/table.gd @@ -1,3 +1,4 @@ +class_name Table extends StaticBody3D const GAME_MANAGER = preload("res://GameManager.gd") @@ -100,6 +101,25 @@ func place_order() -> void: _unsatisfied_orders.append(GAME_MANAGER.get_random_meal()) +func satisfyAllOrders() -> void: + print("Table: satisfyAllOrders()") + _unsatisfied_orders.clear() + clearAllPlates() + _setState(TableState.EMPTY) + + +func clearAllPlates() -> void: + print("Table: clearAllPlates()") + for snap_zone_node in snap_zones: + var held_object = snap_zone_node.picked_up_object + if not held_object: + continue + + var plate = _get_plate_from_item(held_object) + if plate: + plate.container.clear() + plate.is_dirty = true + ## Server-only state transition: sets the new state's timer and assigns ## _state (whose setter refreshes the display on every peer). func _setState(newState: TableState) -> void: @@ -176,13 +196,5 @@ func _process(delta: float) -> void: label_3d.text = lbl_gameover TableState.EATING: - for snap_zone_node in snap_zones: - var held_object = snap_zone_node.picked_up_object - if not held_object: - continue - - var plate = _get_plate_from_item(held_object) - if plate: - plate.container.clear() - plate.is_dirty = true + clearAllPlates() _setState(TableState.EMPTY) diff --git a/Stations/table.tscn b/Stations/table.tscn index f410db3..c69c862 100644 --- a/Stations/table.tscn +++ b/Stations/table.tscn @@ -167,6 +167,5 @@ pixel_size = 0.003 billboard = 2 text = "20.1s" -[node name="Sync" type="MultiplayerSynchronizer" parent="."] -root_path = NodePath("..") +[node name="Sync" type="MultiplayerSynchronizer" parent="." unique_id=2000411505] replication_config = SubResource("SceneReplicationConfig_np_table") diff --git a/global_key_events.gd b/global_key_events.gd new file mode 100644 index 0000000..077089c --- /dev/null +++ b/global_key_events.gd @@ -0,0 +1,20 @@ +extends Node + +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("quit_game"): + get_tree().quit() + if event.is_action_pressed("satisfy_table_orders"): + satisfy_table_orders() + + +# Finds any node of class/type Table and calls satisfyAllOrders() +func satisfy_table_orders() -> void: + # Searches all nodes in the current running scene matching the class "Table" + var table_nodes = get_tree().root.find_children("*", "Table", true, false) + + for node in table_nodes: + if node.has_method("satisfyAllOrders"): + node.satisfyAllOrders() + + + diff --git a/global_key_events.gd.uid b/global_key_events.gd.uid new file mode 100644 index 0000000..1cf5d45 --- /dev/null +++ b/global_key_events.gd.uid @@ -0,0 +1 @@ +uid://c60unagog5oi1 diff --git a/openxr_action_map.tres b/openxr_action_map.tres index ad32196..ac2bf41 100644 --- a/openxr_action_map.tres +++ b/openxr_action_map.tres @@ -248,158 +248,6 @@ binding_path = "/user/hand/right/output/haptic" interaction_profile_path = "/interaction_profiles/khr/generic_controller" bindings = [SubResource("OpenXRIPBinding_r3qn1"), SubResource("OpenXRIPBinding_n01b8"), SubResource("OpenXRIPBinding_pjtev"), SubResource("OpenXRIPBinding_nqyri"), SubResource("OpenXRIPBinding_86uui"), SubResource("OpenXRIPBinding_nrtxc"), SubResource("OpenXRIPBinding_qovyo"), SubResource("OpenXRIPBinding_d6uso"), SubResource("OpenXRIPBinding_hvi7v"), SubResource("OpenXRIPBinding_7dxun"), SubResource("OpenXRIPBinding_rp8ih"), SubResource("OpenXRIPBinding_0uca0"), SubResource("OpenXRIPBinding_rjtq8"), SubResource("OpenXRIPBinding_lce2q"), SubResource("OpenXRIPBinding_ckeh6"), SubResource("OpenXRIPBinding_538mi"), SubResource("OpenXRIPBinding_548p5"), SubResource("OpenXRIPBinding_6o0wr"), SubResource("OpenXRIPBinding_fsghu"), SubResource("OpenXRIPBinding_88umk"), SubResource("OpenXRIPBinding_4uneg"), SubResource("OpenXRIPBinding_67o31"), SubResource("OpenXRIPBinding_lf1a1"), SubResource("OpenXRIPBinding_x1adc"), SubResource("OpenXRIPBinding_j1vtv"), SubResource("OpenXRIPBinding_tud50")] -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_unnrh"] -action = SubResource("OpenXRAction_oi0ij") -binding_path = "/user/hand/left/input/aim/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_3wafl"] -action = SubResource("OpenXRAction_oi0ij") -binding_path = "/user/hand/right/input/aim/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_tjb53"] -action = SubResource("OpenXRAction_m08eo") -binding_path = "/user/hand/left/input/aim/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_lcg2b"] -action = SubResource("OpenXRAction_m08eo") -binding_path = "/user/hand/right/input/aim/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_sp6l2"] -action = SubResource("OpenXRAction_c4j1d") -binding_path = "/user/hand/left/input/grip/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_xj6ir"] -action = SubResource("OpenXRAction_c4j1d") -binding_path = "/user/hand/right/input/grip/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_igmf3"] -action = SubResource("OpenXRAction_sopde") -binding_path = "/user/hand/left/input/grip_surface/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_inw5v"] -action = SubResource("OpenXRAction_sopde") -binding_path = "/user/hand/right/input/grip_surface/pose" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_iy2wq"] -action = SubResource("OpenXRAction_3p2as") -binding_path = "/user/hand/left/input/system/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_plu03"] -action = SubResource("OpenXRAction_3p2as") -binding_path = "/user/hand/right/input/system/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_dad45"] -action = SubResource("OpenXRAction_iphn4") -binding_path = "/user/hand/left/input/menu/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_m5e8q"] -action = SubResource("OpenXRAction_wdehm") -binding_path = "/user/hand/left/input/x/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_5t7jh"] -action = SubResource("OpenXRAction_wdehm") -binding_path = "/user/hand/right/input/a/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_chplt"] -action = SubResource("OpenXRAction_clfly") -binding_path = "/user/hand/left/input/x/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_obxrh"] -action = SubResource("OpenXRAction_clfly") -binding_path = "/user/hand/right/input/a/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_on7oi"] -action = SubResource("OpenXRAction_e1frq") -binding_path = "/user/hand/left/input/y/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_ege4h"] -action = SubResource("OpenXRAction_e1frq") -binding_path = "/user/hand/right/input/b/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_h7ix0"] -action = SubResource("OpenXRAction_l7aq8") -binding_path = "/user/hand/left/input/y/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_8qanm"] -action = SubResource("OpenXRAction_l7aq8") -binding_path = "/user/hand/right/input/b/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_3senm"] -action = SubResource("OpenXRAction_6ivru") -binding_path = "/user/hand/left/input/trigger/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_7ca55"] -action = SubResource("OpenXRAction_6ivru") -binding_path = "/user/hand/right/input/trigger/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_ih1l2"] -action = SubResource("OpenXRAction_vfhwq") -binding_path = "/user/hand/left/input/trigger/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_ipewn"] -action = SubResource("OpenXRAction_vfhwq") -binding_path = "/user/hand/right/input/trigger/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_5ngl7"] -action = SubResource("OpenXRAction_5w03k") -binding_path = "/user/hand/left/input/trigger/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_klygg"] -action = SubResource("OpenXRAction_5w03k") -binding_path = "/user/hand/right/input/trigger/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_4p63k"] -action = SubResource("OpenXRAction_typ1r") -binding_path = "/user/hand/left/input/squeeze/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_6vi2m"] -action = SubResource("OpenXRAction_typ1r") -binding_path = "/user/hand/right/input/squeeze/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_888d1"] -action = SubResource("OpenXRAction_clvbf") -binding_path = "/user/hand/left/input/squeeze/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_246v5"] -action = SubResource("OpenXRAction_clvbf") -binding_path = "/user/hand/right/input/squeeze/value" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_xj73r"] -action = SubResource("OpenXRAction_3k6la") -binding_path = "/user/hand/left/input/thumbstick" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_sugej"] -action = SubResource("OpenXRAction_3k6la") -binding_path = "/user/hand/right/input/thumbstick" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_fp7u7"] -action = SubResource("OpenXRAction_i8esw") -binding_path = "/user/hand/left/input/thumbstick/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_gvgeq"] -action = SubResource("OpenXRAction_i8esw") -binding_path = "/user/hand/right/input/thumbstick/click" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_i0s8c"] -action = SubResource("OpenXRAction_um1hv") -binding_path = "/user/hand/left/input/thumbstick/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_ynetq"] -action = SubResource("OpenXRAction_um1hv") -binding_path = "/user/hand/right/input/thumbstick/touch" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_p8bcx"] -action = SubResource("OpenXRAction_sow2k") -binding_path = "/user/hand/left/output/haptic" - -[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_jkemj"] -action = SubResource("OpenXRAction_sow2k") -binding_path = "/user/hand/right/output/haptic" - -[sub_resource type="OpenXRInteractionProfile" id="OpenXRInteractionProfile_d3nfp"] -interaction_profile_path = "/interaction_profiles/bytedance/pico4_controller" -bindings = [SubResource("OpenXRIPBinding_unnrh"), SubResource("OpenXRIPBinding_3wafl"), SubResource("OpenXRIPBinding_tjb53"), SubResource("OpenXRIPBinding_lcg2b"), SubResource("OpenXRIPBinding_sp6l2"), SubResource("OpenXRIPBinding_xj6ir"), SubResource("OpenXRIPBinding_igmf3"), SubResource("OpenXRIPBinding_inw5v"), SubResource("OpenXRIPBinding_iy2wq"), SubResource("OpenXRIPBinding_plu03"), SubResource("OpenXRIPBinding_dad45"), SubResource("OpenXRIPBinding_m5e8q"), SubResource("OpenXRIPBinding_5t7jh"), SubResource("OpenXRIPBinding_chplt"), SubResource("OpenXRIPBinding_obxrh"), SubResource("OpenXRIPBinding_on7oi"), SubResource("OpenXRIPBinding_ege4h"), SubResource("OpenXRIPBinding_h7ix0"), SubResource("OpenXRIPBinding_8qanm"), SubResource("OpenXRIPBinding_3senm"), SubResource("OpenXRIPBinding_7ca55"), SubResource("OpenXRIPBinding_ih1l2"), SubResource("OpenXRIPBinding_ipewn"), SubResource("OpenXRIPBinding_5ngl7"), SubResource("OpenXRIPBinding_klygg"), SubResource("OpenXRIPBinding_4p63k"), SubResource("OpenXRIPBinding_6vi2m"), SubResource("OpenXRIPBinding_888d1"), SubResource("OpenXRIPBinding_246v5"), SubResource("OpenXRIPBinding_xj73r"), SubResource("OpenXRIPBinding_sugej"), SubResource("OpenXRIPBinding_fp7u7"), SubResource("OpenXRIPBinding_gvgeq"), SubResource("OpenXRIPBinding_i0s8c"), SubResource("OpenXRIPBinding_ynetq"), SubResource("OpenXRIPBinding_p8bcx"), SubResource("OpenXRIPBinding_jkemj")] - [sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_jyu76"] action = SubResource("OpenXRAction_oi0ij") binding_path = "/user/hand/left/input/aim/pose" @@ -470,4 +318,4 @@ bindings = [SubResource("OpenXRIPBinding_jyu76"), SubResource("OpenXRIPBinding_a [resource] action_sets = [SubResource("OpenXRActionSet_ngwcy")] -interaction_profiles = [SubResource("OpenXRInteractionProfile_akdt0"), SubResource("OpenXRInteractionProfile_d3nfp"), SubResource("OpenXRInteractionProfile_m1cgb")] +interaction_profiles = [SubResource("OpenXRInteractionProfile_akdt0"), SubResource("OpenXRInteractionProfile_m1cgb")] diff --git a/project.godot b/project.godot index eec2178..407a20a 100644 --- a/project.godot +++ b/project.godot @@ -20,11 +20,12 @@ config/icon="res://icon.svg" XRToolsUserSettings="*uid://bqgb8i74tm0t" XRToolsRumbleManager="*uid://by853dk86g1qw" NetworkManager="*res://Net/network_manager.gd" +GlobalKeyEvents="*uid://c60unagog5oi1" [display] -window/size/viewport_width=1920 -window/size/viewport_height=1080 +window/size/viewport_width=1800 +window/size/viewport_height=650 window/stretch/mode="canvas_items" window/stretch/aspect="expand" @@ -41,6 +42,19 @@ import/blender/enabled=false platalbe_item="Meals, sides, augments for meals" station="Hobs, Counters ..." +[input] + +quit_game={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +satisfy_table_orders={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} + [layer_names] 3d_physics/layer_1="Static World" diff --git a/recipes.yaml.uid b/recipes.yaml.uid deleted file mode 100644 index d264c0c..0000000 --- a/recipes.yaml.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dqqu56yetl8ok