Co-op pass: host-disconnect handling, spectate, late-join wave sync
- Clients now handle the host closing the arena: bank winnings if still alive (retire), reset the HUD, and return to the camp menu instead of being stranded in a dead world - Death in co-op offers Spectate when a teammate is still fighting: closes the results overlay and watches the run; the escape menu gains a "Back to Camp" option for dead spectators to leave later - Late joiners receive the current wave number on connect so their HUD doesn't sit on "Prepare..." until the next wave starts
This commit is contained in:
@@ -80,6 +80,15 @@ func _ready():
|
||||
|
||||
_add_spacer(vbox, 16)
|
||||
|
||||
# Spectate option - only when a teammate is still fighting
|
||||
if _teammates_still_alive():
|
||||
var spectate_button = Button.new()
|
||||
spectate_button.text = "Spectate"
|
||||
spectate_button.custom_minimum_size = Vector2(0, 44)
|
||||
spectate_button.pressed.connect(_on_spectate_pressed)
|
||||
vbox.add_child(spectate_button)
|
||||
_add_spacer(vbox, 6)
|
||||
|
||||
# Return button
|
||||
var return_button = Button.new()
|
||||
return_button.text = "Return to Camp"
|
||||
@@ -90,6 +99,25 @@ func _ready():
|
||||
# Make sure the mouse is usable on the overlay
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
## Any other living player in the arena?
|
||||
func _teammates_still_alive() -> bool:
|
||||
if multiplayer.multiplayer_peer == null:
|
||||
return false
|
||||
var level = get_tree().get_current_scene()
|
||||
if not level or not level.has_node("PlayersContainer"):
|
||||
return false
|
||||
var my_id = multiplayer.get_unique_id()
|
||||
for p in level.get_node("PlayersContainer").get_children():
|
||||
if p is Character and not p.is_dead and str(p.name).to_int() != my_id:
|
||||
return true
|
||||
return false
|
||||
|
||||
## Close the overlay and watch the run play out (escape menu can leave later).
|
||||
## For the host this also keeps the server alive for everyone else.
|
||||
func _on_spectate_pressed():
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
queue_free()
|
||||
|
||||
func _add_header(parent: Control, text: String):
|
||||
var label = Label.new()
|
||||
label.text = text
|
||||
|
||||
Reference in New Issue
Block a user