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: if not input_active:
return 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"): if Input.is_action_just_pressed("view_zoom"):
# tween.remove_all() # tween.remove_all()
@ -165,7 +165,7 @@ func _process(delta):
if not input_active: if not input_active:
return 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: if view_zoom_direction and view_zoom < view_zoom_target:
view_zoom = min(view_zoom_target, view_zoom + delta * 4) view_zoom = min(view_zoom_target, view_zoom + delta * 4)

View File

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