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

107
scenes/LobbyMenu.tscn Normal file
View File

@@ -0,0 +1,107 @@
[gd_scene load_steps=3 format=3 uid="uid://dauphincraft_lobby"]
[ext_resource type="Script" path="res://scripts/net/LobbyMenu.gd" id="1_lobbyscript"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_btn"]
bg_color = Color(0.05, 0.15, 0.3, 0.75)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.3, 0.8, 1.0, 1.0)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
[node name="LobbyMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("1_lobbyscript")
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
color = Color(0.02, 0.08, 0.18, 1.0)
[node name="Panel" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -200.0
offset_top = -200.0
offset_right = 200.0
offset_bottom = 200.0
alignment = 1
[node name="Title" type="Label" parent="Panel"]
layout_mode = 2
text = "REJOINDRE"
horizontal_alignment = 1
theme_override_font_sizes/font_size = 48
theme_override_colors/font_color = Color(0.7, 0.95, 1.0, 1.0)
[node name="Spacer1" type="Control" parent="Panel"]
layout_mode = 2
custom_minimum_size = Vector2(0, 20)
[node name="VBox" type="VBoxContainer" parent="Panel"]
layout_mode = 2
[node name="IPLabel" type="Label" parent="Panel/VBox"]
text = "Adresse IP du serveur"
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.7, 0.9, 1.0, 1.0)
[node name="IPInput" type="LineEdit" parent="Panel/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(400, 48)
placeholder_text = "127.0.0.1"
theme_override_font_sizes/font_size = 20
[node name="Spacer2" type="Control" parent="Panel/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(0, 10)
[node name="PortLabel" type="Label" parent="Panel/VBox"]
text = "Port"
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.7, 0.9, 1.0, 1.0)
[node name="PortInput" type="LineEdit" parent="Panel/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(400, 48)
placeholder_text = "9999"
theme_override_font_sizes/font_size = 20
[node name="Spacer3" type="Control" parent="Panel/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(0, 10)
[node name="StatusLabel" type="Label" parent="Panel/VBox"]
layout_mode = 2
theme_override_font_sizes/font_size = 16
theme_override_colors/font_color = Color(1.0, 0.8, 0.3, 1.0)
[node name="ConnectBtn" type="Button" parent="Panel/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(400, 56)
text = "Se connecter"
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")
[node name="BackBtn" type="Button" parent="Panel/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(400, 56)
text = "Retour"
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")

View File

@@ -36,9 +36,9 @@ anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -200.0
offset_top = -160.0
offset_top = -220.0
offset_right = 200.0
offset_bottom = 160.0
offset_bottom = 220.0
alignment = 1
[node name="Title" type="Label" parent="CenterContainer"]
@@ -53,36 +53,52 @@ theme_override_constants/shadow_offset_y = 3
[node name="Subtitle" type="Label" parent="CenterContainer"]
layout_mode = 2
text = "Un monde voxel sous l'océan"
text = "Un monde voxel sous l'ocean"
horizontal_alignment = 1
theme_override_font_sizes/font_size = 22
theme_override_colors/font_color = Color(0.5, 0.75, 0.9, 0.85)
[node name="Spacer" type="Control" parent="CenterContainer"]
layout_mode = 2
custom_minimum_size = Vector2(0, 30)
custom_minimum_size = Vector2(0, 20)
[node name="DiveButton" type="Button" parent="CenterContainer"]
layout_mode = 2
custom_minimum_size = Vector2(300, 56)
text = "Plonger"
theme_override_font_sizes/font_size = 26
custom_minimum_size = Vector2(300, 52)
text = "Solo"
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")
[node name="HostButton" type="Button" parent="CenterContainer"]
layout_mode = 2
custom_minimum_size = Vector2(300, 52)
text = "Heberger"
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")
[node name="JoinButton" type="Button" parent="CenterContainer"]
layout_mode = 2
custom_minimum_size = Vector2(300, 52)
text = "Rejoindre"
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")
[node name="OptionsButton" type="Button" parent="CenterContainer"]
layout_mode = 2
custom_minimum_size = Vector2(300, 56)
custom_minimum_size = Vector2(300, 52)
text = "Options"
theme_override_font_sizes/font_size = 26
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")
[node name="QuitButton" type="Button" parent="CenterContainer"]
layout_mode = 2
custom_minimum_size = Vector2(300, 56)
custom_minimum_size = Vector2(300, 52)
text = "Quitter"
theme_override_font_sizes/font_size = 26
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.8, 0.97, 1.0, 1.0)
theme_override_styles/normal = SubResource("StyleBoxFlat_btn")
@@ -134,8 +150,42 @@ max_value = 1.0
step = 0.01
value = 0.8
[node name="HostPortPopup" type="Window" parent="."]
title = "Heberger une partie"
size = Vector2i(360, 200)
visible = false
[node name="VBox" type="VBoxContainer" parent="HostPortPopup"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 20.0
offset_top = 20.0
offset_right = -20.0
offset_bottom = -20.0
[node name="PortLabel" type="Label" parent="HostPortPopup/VBox"]
text = "Port (defaut 9999)"
[node name="PortInput" type="LineEdit" parent="HostPortPopup/VBox"]
layout_mode = 2
text = "9999"
theme_override_font_sizes/font_size = 18
[node name="StatusLabel" type="Label" parent="HostPortPopup/VBox"]
theme_override_colors/font_color = Color(1.0, 0.4, 0.4, 1.0)
[node name="ConfirmBtn" type="Button" parent="HostPortPopup/VBox"]
layout_mode = 2
text = "Lancer le serveur"
theme_override_font_sizes/font_size = 18
[connection signal="pressed" from="CenterContainer/DiveButton" to="." method="_on_dive_pressed"]
[connection signal="pressed" from="CenterContainer/HostButton" to="." method="_on_host_pressed"]
[connection signal="pressed" from="CenterContainer/JoinButton" to="." method="_on_join_pressed"]
[connection signal="pressed" from="CenterContainer/OptionsButton" to="." method="_on_options_pressed"]
[connection signal="pressed" from="CenterContainer/QuitButton" to="." method="_on_quit_pressed"]
[connection signal="value_changed" from="OptionsPopup/VBox/MusicSlider" to="." method="_on_music_slider_value_changed"]
[connection signal="value_changed" from="OptionsPopup/VBox/SFXSlider" to="." method="_on_sfx_slider_value_changed"]
[connection signal="pressed" from="HostPortPopup/VBox/ConfirmBtn" to="." method="_on_host_confirm_pressed"]