fix bug
This commit is contained in:
@@ -23,6 +23,7 @@ func _ready() -> void:
|
||||
NetworkManager.player_left.connect(_on_player_left)
|
||||
NetworkManager.session_started.connect(_on_session_started)
|
||||
NetworkManager.connection_failed.connect(_on_connection_failed)
|
||||
NetworkManager.session_ended.connect(_on_session_ended)
|
||||
_menu.host_pressed.connect(_on_menu_host)
|
||||
_menu.join_pressed.connect(_on_menu_join)
|
||||
_menu.solo_pressed.connect(_on_menu_solo)
|
||||
@@ -66,6 +67,9 @@ func _on_session_started(is_server: bool) -> void:
|
||||
if not is_server:
|
||||
# Connected to a host as a client.
|
||||
_menu.hide_menu()
|
||||
# Stations are server-authoritative: clients must not run snap zones, or
|
||||
# they create divergent local copies of snapped items.
|
||||
_disable_client_snap_zones()
|
||||
|
||||
|
||||
func _on_connection_failed() -> void:
|
||||
@@ -74,6 +78,19 @@ func _on_connection_failed() -> void:
|
||||
_menu.show_menu()
|
||||
|
||||
|
||||
# The client lost the server (or left): reload the scene to return to a clean
|
||||
# main-menu state.
|
||||
func _on_session_ended() -> void:
|
||||
get_tree().reload_current_scene.call_deferred()
|
||||
|
||||
|
||||
func _disable_client_snap_zones() -> void:
|
||||
for station in get_tree().get_nodes_in_group("station"):
|
||||
var zone = station.get_node_or_null("XRToolsSnapZone")
|
||||
if zone:
|
||||
zone.enabled = false
|
||||
|
||||
|
||||
# --- Player / item spawning ------------------------------------------------
|
||||
|
||||
func _on_player_joined(peer_id: int) -> void:
|
||||
|
||||
Reference in New Issue
Block a user