Respawn delay 5 seconds

remotes/1705377932733043820/tmp_refs/heads/unbroken
unfa 2021-09-11 15:23:02 +02:00
parent 55fe11328a
commit a580e2ef7c
2 changed files with 40 additions and 24 deletions

View File

@ -131,7 +131,7 @@ func _input(event) -> void:
if not input_active:
return
assert(is_network_authority() == true, "input_active is true, even though the node is not network_authority")
#assert(is_network_authority() == true, "input_active is true, even though the node is not network_authority")
if Input.is_action_just_pressed("view_zoom"):
# tween.remove_all()
@ -165,7 +165,7 @@ func _process(delta):
if not input_active:
return
assert(is_network_authority() == true, "input_active is true, even though the node is not network_authority")
#assert(is_network_authority() == true, "input_active is true, even though the node is not network_authority")
if view_zoom_direction and view_zoom < view_zoom_target:
view_zoom = min(view_zoom_target, view_zoom + delta * 4)

View File

@ -72,13 +72,30 @@ class PlayerInfo:
self.score = info['score']
#func generate():
var uptime = 0 # seconds
const respawn_delay = 5 # seconds
var spawn_queue = {}
func _process(delta):
uptime += delta
$Label.text = "player_list: \n"
for i in player_list.players.keys():
if player_list.players[i]:
$Label.text += str(i) + " = " + str(player_list.get(i).serialize()) + "\n"
else:
$Label.text += str(i) + " = ???"
# poll respawn queue
$Label.text += "\n\nspawn_queue: \n"
$Label.text += str(spawn_queue)
for i in spawn_queue.keys():
if spawn_queue[i] <= uptime:
var is_local = true if i == get_tree().multiplayer.get_network_unique_id() else false
create_player(i, is_local, true)
spawn_queue.erase(i)
class PlayerList:
var players = {}
@ -111,23 +128,25 @@ class PlayerList:
var focus = GameFocus.MENU :
set(new_focus):
match new_focus:
0:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
gui.show()
if local_player:
local_player.input_active = false
1:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
gui.hide()
if local_player:
local_player.input_active = true
2:
if local_player:
local_player.input_active = false
3:
if local_player:
local_player.input_active = true
if local_player != null:
assert(local_player != null, "local_player is not null but it is null, WTF?!")
match new_focus:
0:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
gui.show()
if local_player:
local_player.input_active = false
1:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
gui.hide()
if local_player:
local_player.input_active = true
2:
if local_player:
local_player.input_active = false
3:
if local_player:
local_player.input_active = true
focus = new_focus
@ -195,11 +214,8 @@ func push_local_player_info(): #
assert(player_node != null, "Attempting to delete a player node that does not exist")
player_node.name = str(player_node.name) + "_dead" # avoids name collision when instancing another player scene
player_node.queue_free()
#player.queue_free()
var is_local = true if pid == local_player.get_network_authority() else false
create_player(pid, is_local, true)
spawn_queue[pid] = uptime + respawn_delay
func create_player(pid: int, is_local:= false, respawn:= false) -> void:
var new_player