replace with multiplayer-coop files

This commit is contained in:
2026-01-08 16:47:52 +01:00
parent 1725c615ce
commit 22c7025ac4
1230 changed files with 20555 additions and 17232 deletions

View File

@@ -0,0 +1,102 @@
extends CanvasLayer
# Debug Overlay - Shows network and player information
var debug_label: Label
var info_label: Label
var network_manager
var visible_debug = false
func _ready():
network_manager = get_node_or_null("/root/NetworkManager")
# Create debug label (toggleable)
debug_label = Label.new()
debug_label.name = "DebugLabel"
debug_label.position = Vector2(10, 10)
debug_label.add_theme_color_override("font_color", Color.YELLOW)
add_child(debug_label)
debug_label.visible = false
# Create info label (always visible in top right)
info_label = Label.new()
info_label.name = "InfoLabel"
info_label.add_theme_color_override("font_color", Color.WHITE)
info_label.add_theme_font_size_override("font_size", 20)
info_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
add_child(info_label)
# Position in top right
info_label.anchor_left = 1.0
info_label.anchor_right = 1.0
info_label.offset_left = -200
info_label.offset_right = -10
info_label.offset_top = 10
info_label.offset_bottom = 100
func _process(_delta):
# Toggle debug with F3
if Input.is_action_just_pressed("ui_cancel"):
visible_debug = !visible_debug
debug_label.visible = visible_debug
if visible_debug:
_update_debug_info()
# Always update info label
_update_info_label()
func _update_info_label():
var info = []
if multiplayer.has_multiplayer_peer():
# Show role
if multiplayer.is_server():
info.append("HOST")
else:
info.append("CLIENT")
# Show peer ID
info.append("ID: %d" % multiplayer.get_unique_id())
else:
info.append("OFFLINE")
# Show local player position
var game_world = get_node_or_null("../GameWorld")
if not game_world:
game_world = get_node_or_null("/root/Main/GameWorld")
if game_world:
var player_manager = game_world.get_node_or_null("PlayerManager")
if player_manager:
var local_players = player_manager.get_local_players()
if local_players.size() > 0:
var player = local_players[0]
info.append("Pos: (%.1f, %.1f)" % [player.global_position.x, player.global_position.y])
info_label.text = "\n".join(info)
func _update_debug_info():
var info = []
# Network info
if multiplayer.has_multiplayer_peer():
info.append("Network: Connected")
info.append("Peer ID: %d" % multiplayer.get_unique_id())
info.append("Is Server: %s" % multiplayer.is_server())
if network_manager:
info.append("Connected Peers: %d" % network_manager.players_info.size())
else:
info.append("Network: Offline")
# Player info
if network_manager:
info.append("\nPlayers:")
for peer_id in network_manager.players_info.keys():
var player_info = network_manager.players_info[peer_id]
info.append(" Peer %d: %d local players" % [peer_id, player_info.local_player_count])
# Performance
info.append("\nFPS: %d" % Engine.get_frames_per_second())
debug_label.text = "\n".join(info)