Fix error overflowing
This commit is contained in:
@ -106,7 +106,7 @@ func _notification(what):
|
||||
NOTIFICATION_WM_WINDOW_FOCUS_IN:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
NOTIFICATION_EXIT_TREE:
|
||||
print("PlayerController %s exited tree" % multiplayer.get_unique_id())
|
||||
print("PlayerController exited tree")
|
||||
NOTIFICATION_ENTER_TREE:
|
||||
print("PlayerController %s entered tree" % multiplayer.get_unique_id())
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ func close_connection():
|
||||
multiplayer.multiplayer_peer = null
|
||||
print("Connection closed.")
|
||||
_disconnect_signals()
|
||||
GameManager.reset_game_state()
|
||||
|
||||
func setup_connections():
|
||||
if not multiplayer.peer_connected.is_connected(on_peer_connected):
|
||||
@ -85,3 +86,4 @@ func on_connected_to_server() -> void:
|
||||
func on_server_disconnected() -> void:
|
||||
print("Disconnected from server.")
|
||||
get_tree().change_scene_to_file("res://main.tscn")
|
||||
GameManager.reset_game_state()
|
||||
|
||||
@ -27,7 +27,13 @@ func _ready():
|
||||
return
|
||||
|
||||
func _process(_delta):
|
||||
if find_available_spawner():
|
||||
if not multiplayer.multiplayer_peer: return
|
||||
if not multiplayer.is_server(): return
|
||||
|
||||
# Safety check: don't try to spawn if the system isn't ready or is deleted
|
||||
if not is_instance_valid(current_star_system): return
|
||||
|
||||
if not waiting_players.is_empty() and find_available_spawner():
|
||||
_try_spawn_waiting_player()
|
||||
|
||||
|
||||
@ -150,3 +156,13 @@ func _get_orbital_body_ancestor(node: Node) -> OrbitalBody3D:
|
||||
return current
|
||||
current = current.get_parent()
|
||||
return null
|
||||
|
||||
func reset_game_state():
|
||||
current_star_system = null
|
||||
registered_spawners.clear()
|
||||
waiting_players.clear()
|
||||
player_pawns.clear()
|
||||
player_controllers.clear()
|
||||
|
||||
# Reset any other state variables
|
||||
print("GameManager state cleared.")
|
||||
|
||||
Reference in New Issue
Block a user