feat(multiplayer): ENet networking + player/world sync + lobby menu + chat

Add dedicated server / host / client modes via NetworkManager autoload,
PlayerSyncComponent (20 Hz unreliable RPC), WorldSyncComponent (authoritative
block break/place), ChatManager (F2), LobbyMenu scene, updated MainMenu
with Solo/Heberger/Rejoindre/Quitter buttons. Port changed to 7777
(9999 occupied by sntlkeyssrvr on this machine). Mobs disabled in multi
(spawn solo only). Solo mode untouched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Floppyrj45
2026-04-19 17:48:48 +02:00
parent 9546fcd96b
commit 5db858527e
15 changed files with 748 additions and 48 deletions

View File

@@ -3,6 +3,10 @@ extends Control
@onready var _options_popup: Window = $OptionsPopup
@onready var _music_slider: HSlider = $OptionsPopup/VBox/MusicSlider
@onready var _sfx_slider: HSlider = $OptionsPopup/VBox/SFXSlider
@onready var _host_port_popup: Window = $HostPortPopup
@onready var _host_port_input: LineEdit = $HostPortPopup/VBox/PortInput
@onready var _host_status: Label = $HostPortPopup/VBox/StatusLabel
func _ready() -> void:
AudioManager.play_music("underwater_theme.mp3")
@@ -10,9 +14,30 @@ func _ready() -> void:
func _on_dive_pressed() -> void:
NetworkManager.current_mode = NetworkManager.Mode.SOLO
get_tree().change_scene_to_file("res://scenes/Main.tscn")
func _on_host_pressed() -> void:
_host_status.text = ""
_host_port_input.text = str(NetworkManager.DEFAULT_PORT)
_host_port_popup.popup_centered()
func _on_host_confirm_pressed() -> void:
var port: int = int(_host_port_input.text.strip_edges())
_host_port_popup.hide()
if NetworkManager.start_host(port):
get_tree().change_scene_to_file("res://scenes/Main.tscn")
else:
_host_status.text = "Erreur demarrage serveur"
_host_port_popup.popup_centered()
func _on_join_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/LobbyMenu.tscn")
func _on_options_pressed() -> void:
_options_popup.popup_centered()