Mainmenu loads when host leaves
This commit is contained in:
parent
b8e42872f7
commit
017150b4bf
4 changed files with 18 additions and 2 deletions
|
@ -79,6 +79,9 @@ func _unhandled_input(event):
|
|||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
func _physics_process(delta):
|
||||
if Global.kickAllPlayers:
|
||||
Global.kickAllPlayers = false
|
||||
rpc("kick_all_players")
|
||||
if not Global.playerDisable:
|
||||
if is_multiplayer_authority():
|
||||
# This variable gets set my the death scene, so we know the player needs to be respawned
|
||||
|
@ -238,3 +241,9 @@ func spawn_cotton():
|
|||
$CPUParticles3D.emitting = true
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
$CPUParticles3D.emitting = false
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func kick_all_players():
|
||||
Global.playingGame = false
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
get_tree().change_scene_to_file("res://scenes/mainmenu-background.tscn")
|
||||
|
|
|
@ -50,6 +50,7 @@ var addedMenuScene = false # Used for teddy.gd, fixes multiple menu bug
|
|||
var tutorialCompleted = false # Used in the save file, to know if a play should go to tutorial first
|
||||
var playerDisable = false # Can be used to disable the player
|
||||
var playerDeathHealth = 100 # Can be changed by death.gd
|
||||
var kickAllPlayers = false # Can be set to true to kick all players in-game
|
||||
|
||||
func _process(delta):
|
||||
spawn_locations()
|
||||
|
@ -118,6 +119,7 @@ func reset_variables_hard():
|
|||
addedMenuScene = false
|
||||
playerDisable = false
|
||||
playerDeathHealth = 100
|
||||
kickAllPlayers = false
|
||||
|
||||
func save_data():
|
||||
SettingsFile.save_data()
|
||||
|
|
|
@ -110,3 +110,4 @@ func _on_light_button_pressed():
|
|||
|
||||
func _on_issues_button_pressed():
|
||||
OS.shell_open("https://git.techwizz-emu.com/the_adventures_of_teddy/public_issues/issues")
|
||||
|
||||
|
|
|
@ -10,8 +10,12 @@ func _process(delta):
|
|||
|
||||
|
||||
func _on_yes_button_pressed():
|
||||
Networking.peer.close()
|
||||
if Global.goScene == "res://scenes/mainmenu-background.tscn":
|
||||
if Global.teddyAuthorityID == 1:
|
||||
Global.kickAllPlayers = true
|
||||
Global.playingGame = false
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
Networking.peer.close()
|
||||
get_tree().change_scene_to_file(Global.goScene)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue