feat: implement networked match HUD with real-time scoreboard and killfeed systems

This commit is contained in:
DottsGit
2026-06-06 13:49:12 -04:00
parent aefed46daf
commit 168bd8f1ce
11 changed files with 501 additions and 13 deletions
+38
View File
@@ -242,6 +242,37 @@ func take_damage(amount: float, _hit_pos: Vector3, _source: Node3D = null, impul
if health <= 0.0:
health = 0.0
die(impulse)
if get_node_or_null("/root/NetworkManager") and multiplayer.has_multiplayer_peer():
var victim_id = multiplayer.get_unique_id() if is_multiplayer_authority() else int(str(name))
var killer_id = 0
var weapon_name = "Killed"
if _source and _source is Node:
if _source.has_method("get_multiplayer_authority"):
killer_id = _source.get_multiplayer_authority()
elif "owner_player" in _source and _source.owner_player:
killer_id = int(str(_source.owner_player.name))
elif _source is PlayerMovementController:
killer_id = int(str(_source.name))
if _source.has_method("get_weapon_name"):
weapon_name = _source.get_weapon_name()
get_node("/root/NetworkManager").register_kill.rpc(victim_id, killer_id, weapon_name, "")
func get_weapon_name() -> String:
if camera:
var wman = camera.get_node_or_null("WeaponManager")
if wman:
var slot = wman.get("active_slot")
if slot != null and wman.weapons.has(slot):
var w = wman.weapons[slot]
if w and w.has_method("get_weapon_name"):
return w.get_weapon_name()
elif w:
# Format "res://weapons/assault_rifle.tscn" -> "Assault Rifle"
var p = w.scene_file_path.get_file().get_basename()
return p.capitalize()
return "Killed"
func _ensure_machine() -> MovementStateMachine:
if is_instance_valid(_machine):
@@ -381,6 +412,13 @@ func _setup_hud() -> void:
var vbox = VBoxContainer.new()
margin.add_child(vbox)
# Add Match HUD overlay
if is_multiplayer_authority():
var match_hud_scene = load("res://ui/match_hud.tscn")
if match_hud_scene:
var match_hud = match_hud_scene.instantiate()
add_child(match_hud)
# Shield Bar (Top)
var shield_box = VBoxContainer.new()
var s_title = Label.new()